|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TutorialHelper |
|
5
|
|
|
* |
|
6
|
|
|
* @author Jacky Casas |
|
7
|
|
|
* @copyright Asylamba |
|
8
|
|
|
* |
|
9
|
|
|
* @package Zeus |
|
10
|
|
|
* @update 25.04.14 |
|
11
|
|
|
*/ |
|
12
|
|
|
namespace Asylamba\Modules\Zeus\Helper; |
|
13
|
|
|
|
|
14
|
|
|
use Asylamba\Classes\Library\Session\SessionWrapper; |
|
15
|
|
|
|
|
16
|
|
|
use Asylamba\Classes\Entity\EntityManager; |
|
17
|
|
|
use Asylamba\Modules\Zeus\Manager\PlayerManager; |
|
18
|
|
|
use Asylamba\Modules\Athena\Manager\OrbitalBaseManager; |
|
19
|
|
|
use Asylamba\Modules\Athena\Manager\BuildingQueueManager; |
|
20
|
|
|
use Asylamba\Modules\Promethee\Manager\TechnologyQueueManager; |
|
21
|
|
|
use Asylamba\Modules\Promethee\Manager\TechnologyManager; |
|
22
|
|
|
|
|
23
|
|
|
class TutorialHelper { |
|
24
|
|
|
/** @var EntityManager **/ |
|
25
|
|
|
protected $entityManager; |
|
26
|
|
|
/** @var PlayerManager **/ |
|
27
|
|
|
protected $playerManager; |
|
28
|
|
|
/** @var OrbitalBaseManager **/ |
|
29
|
|
|
protected $orbitalBaseManager; |
|
30
|
|
|
/** @var BuildingQueueManager **/ |
|
31
|
|
|
protected $buildingQueueManager; |
|
32
|
|
|
/** @var TechnologyQueueManager **/ |
|
33
|
|
|
protected $technologyQueueManager; |
|
34
|
|
|
/** @var TechnologyManager **/ |
|
35
|
|
|
protected $technologyManager; |
|
36
|
|
|
/** @var SessionWrapper **/ |
|
37
|
|
|
protected $session; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param EntityManager $entityManager |
|
41
|
|
|
* @param PlayerManager $playerManager |
|
42
|
|
|
* @param OrbitalBaseManager $orbitalBaseManager |
|
43
|
|
|
* @param BuildingQueueManager $buildingQueueManager |
|
44
|
|
|
* @param TechnologyQueueManager $technologyQueueManager |
|
45
|
|
|
* @param TechnologyManager $technologyManager |
|
46
|
|
|
* @param SessionWrapper $session |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __construct( |
|
49
|
|
|
EntityManager $entityManager, |
|
50
|
|
|
PlayerManager $playerManager, |
|
51
|
|
|
OrbitalBaseManager $orbitalBaseManager, |
|
52
|
|
|
BuildingQueueManager $buildingQueueManager, |
|
53
|
|
|
TechnologyQueueManager $technologyQueueManager, |
|
54
|
|
|
TechnologyManager $technologyManager, |
|
55
|
|
|
SessionWrapper $session |
|
56
|
|
|
) |
|
57
|
|
|
{ |
|
|
|
|
|
|
58
|
|
|
$this->entityManager = $entityManager; |
|
59
|
|
|
$this->playerManager = $playerManager; |
|
60
|
|
|
$this->orbitalBaseManager = $orbitalBaseManager; |
|
61
|
|
|
$this->buildingQueueManager = $buildingQueueManager; |
|
62
|
|
|
$this->technologyQueueManager = $technologyQueueManager; |
|
63
|
|
|
$this->technologyManager = $technologyManager; |
|
64
|
|
|
$this->session = $session; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function checkTutorial() { |
|
68
|
|
|
# PAS UTILISEE POUR L'INSTANT (le sera quand il y aura une étape passive dans le tutoriel) |
|
69
|
|
|
$player = $this->session->get('playerId'); |
|
|
|
|
|
|
70
|
|
|
$stepTutorial = $this->session->get('playerInfo')->get('stepTutorial'); |
|
71
|
|
|
$stepDone = $this->session->get('playerInfo')->get('stepDone'); |
|
72
|
|
|
|
|
73
|
|
|
if ($stepTutorial > 0) { |
|
74
|
|
|
if ($stepDone == FALSE) { |
|
75
|
|
|
# check if current step is done |
|
76
|
|
|
|
|
77
|
|
|
# hint : checker seulement les actions passives |
|
78
|
|
|
switch ($stepTutorial) { |
|
79
|
|
|
case 1: |
|
80
|
|
|
$asdf = 'asdf'; |
|
|
|
|
|
|
81
|
|
|
break; |
|
82
|
|
|
case 2: |
|
83
|
|
|
$jlk = 'jkl'; |
|
|
|
|
|
|
84
|
|
|
break; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function setStepDone() { |
|
91
|
|
|
$player = $this->playerManager->get($this->session->get('playerId')); |
|
92
|
|
|
|
|
93
|
|
|
$player->stepDone = TRUE; |
|
94
|
|
|
|
|
95
|
|
|
$this->session->get('playerInfo')->add('stepDone', TRUE); |
|
96
|
|
|
|
|
97
|
|
|
$this->entityManager->flush($player); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function clearStepDone() { |
|
101
|
|
|
$player = $this->playerManager->get($this->session->get('playerId')); |
|
102
|
|
|
|
|
103
|
|
|
$player->stepDone = FALSE; |
|
104
|
|
|
|
|
105
|
|
|
$this->session->get('playerInfo')->add('stepDone', FALSE); |
|
106
|
|
|
|
|
107
|
|
|
$this->entityManager->flush($player); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function isNextBuildingStepAlreadyDone($playerId, $buildingId, $level) { |
|
111
|
|
|
$nextStepAlreadyDone = FALSE; |
|
112
|
|
|
|
|
113
|
|
|
$playerBases = $this->orbitalBaseManager->getPlayerBases($playerId); |
|
114
|
|
|
foreach ($playerBases as $orbitalBase) { |
|
115
|
|
|
if ($orbitalBase->getBuildingLevel($buildingId) >= $level) { |
|
116
|
|
|
$nextStepAlreadyDone = TRUE; |
|
117
|
|
|
break; |
|
118
|
|
|
} else { |
|
119
|
|
|
# verify in the queue |
|
120
|
|
|
$buildingQueues = $this->buildingQueueManager->getBaseQueues($orbitalBase->rPlace); |
|
121
|
|
|
foreach ($buildingQueues as $buildingQueue) { |
|
122
|
|
|
if ($buildingQueue->buildingNumber == $buildingId AND $buildingQueue->targetLevel >= $level) { |
|
|
|
|
|
|
123
|
|
|
$nextStepAlreadyDone = TRUE; |
|
124
|
|
|
break; |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
return $nextStepAlreadyDone; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function isNextTechnoStepAlreadyDone($playerId, $technoId, $level = 1) { |
|
133
|
|
|
$technology = $this->technologyManager->getPlayerTechnology($playerId); |
|
134
|
|
|
if ($technology->getTechnology($technoId) >= $level) { |
|
135
|
|
|
return true; |
|
136
|
|
|
} |
|
137
|
|
|
// verify in the queue |
|
138
|
|
|
if (($this->technologyQueueManager->getPlayerTechnologyQueue($playerId, $technoId)) !== null) { |
|
139
|
|
|
return true; |
|
140
|
|
|
} |
|
141
|
|
|
return false; |
|
142
|
|
|
} |
|
143
|
|
|
} |