@@ 53-120 (lines=68) @@ | ||
50 | return $this->getMissionGameMapper()->findBy(array('mission'=>$mission)); |
|
51 | } |
|
52 | ||
53 | public function checkMissionCondition($game, $winner, $prediction, $entry) |
|
54 | { |
|
55 | $missionGame = $this->findMissionGameByGame($game); |
|
56 | if (empty($missionGame)) { |
|
57 | return false; |
|
58 | } |
|
59 | ||
60 | if ($missionGame->getMission()->getActive() === false) { |
|
61 | return false; |
|
62 | } |
|
63 | ||
64 | $nextMissionGame = $this->getMissionGameMapper()->getNextGame( |
|
65 | $missionGame->getMission(), |
|
66 | $missionGame->getPosition() |
|
67 | ); |
|
68 | ||
69 | if (empty($nextMissionGame)) { |
|
70 | return false; |
|
71 | } |
|
72 | ||
73 | $missionGameConditions = $this->findMissionGameConditionByMissionGame($nextMissionGame); |
|
74 | ||
75 | if (empty($missionGameConditions)) { |
|
76 | return false; |
|
77 | } |
|
78 | ||
79 | foreach ($missionGameConditions as $missionGameCondition) { |
|
80 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::NONE) { |
|
81 | continue; |
|
82 | } |
|
83 | ||
84 | // On passe au suivant si on a gagné |
|
85 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::VICTORY) { |
|
86 | if (!($winner || $prediction)) { |
|
87 | return false; |
|
88 | } |
|
89 | } |
|
90 | ||
91 | // On passe au suivant si on a perdu |
|
92 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::DEFEAT) { |
|
93 | if ($winner || $prediction) { |
|
94 | return false; |
|
95 | } |
|
96 | } |
|
97 | ||
98 | // On passe au suivant si on a perdu |
|
99 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::GREATER) { |
|
100 | if (!$entry) { |
|
101 | return false; |
|
102 | } |
|
103 | if (!($entry->getPoints() > $missionGameCondition->getValue())) { |
|
104 | return false; |
|
105 | } |
|
106 | } |
|
107 | ||
108 | // On passe au suivant si on a perdu |
|
109 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::LESS) { |
|
110 | if (!$entry) { |
|
111 | return false; |
|
112 | } |
|
113 | if (!($entry->getPoints() < $missionGameCondition->getValue())) { |
|
114 | return false; |
|
115 | } |
|
116 | } |
|
117 | } |
|
118 | ||
119 | return $nextMissionGame->getGame(); |
|
120 | } |
|
121 | ||
122 | public function getGameEntity() |
|
123 | { |
@@ 130-197 (lines=68) @@ | ||
127 | } |
|
128 | ||
129 | ||
130 | public function checkCondition($game, $winner, $prediction, $entry) |
|
131 | { |
|
132 | $missionGame = $this->findMissionGameByGame($game); |
|
133 | if (empty($missionGame)) { |
|
134 | return false; |
|
135 | } |
|
136 | ||
137 | if ($missionGame->getMission()->getActive() === false) { |
|
138 | return false; |
|
139 | } |
|
140 | ||
141 | $nextMissionGame = $this->getMissionGameMapper()->getNextGame( |
|
142 | $missionGame->getMission(), |
|
143 | $missionGame->getPosition() |
|
144 | ); |
|
145 | ||
146 | if (empty($nextMissionGame)) { |
|
147 | return false; |
|
148 | } |
|
149 | ||
150 | $missionGameConditions = $this->findMissionGameConditionByMissionGame($nextMissionGame); |
|
151 | ||
152 | if (empty($missionGameConditions)) { |
|
153 | return false; |
|
154 | } |
|
155 | ||
156 | foreach ($missionGameConditions as $missionGameCondition) { |
|
157 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::NONE) { |
|
158 | continue; |
|
159 | } |
|
160 | ||
161 | // On passe au suivant si on a gagné |
|
162 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::VICTORY) { |
|
163 | if (!($winner || $prediction)) { |
|
164 | return false; |
|
165 | } |
|
166 | } |
|
167 | ||
168 | // On passe au suivant si on a perdu |
|
169 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::DEFEAT) { |
|
170 | if ($winner || $prediction) { |
|
171 | return false; |
|
172 | } |
|
173 | } |
|
174 | ||
175 | // On passe au suivant si on a perdu |
|
176 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::GREATER) { |
|
177 | if (!$entry) { |
|
178 | return false; |
|
179 | } |
|
180 | if (!($entry->getPoints() > $missionGameCondition->getValue())) { |
|
181 | return false; |
|
182 | } |
|
183 | } |
|
184 | ||
185 | // On passe au suivant si on a perdu |
|
186 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::LESS) { |
|
187 | if (!$entry) { |
|
188 | return false; |
|
189 | } |
|
190 | if (!($entry->getPoints() < $missionGameCondition->getValue())) { |
|
191 | return false; |
|
192 | } |
|
193 | } |
|
194 | } |
|
195 | ||
196 | return $nextMissionGame->getGame(); |
|
197 | } |
|
198 | ||
199 | /** |
|
200 | * findMissionGameByMission : Permet de recuperer les missionsGame à partir d'une mission |