| @@ 21-31 (lines=11) @@ | ||
| 18 | ||
| 19 | if ($this->game->getOccurrenceType()=='datetime') { |
|
| 20 | $entry = $this->getGameService()->play($this->game, $this->user); |
|
| 21 | if (!$entry) { |
|
| 22 | // the user has already taken part of this game and the participation limit has been reached |
|
| 23 | $this->flashMessenger()->addMessage('Vous avez déjà participé'); |
|
| 24 | ||
| 25 | return $this->redirect()->toUrl( |
|
| 26 | $this->frontendUrl()->fromRoute( |
|
| 27 | 'instantwin/result', |
|
| 28 | array('id' => $this->game->getIdentifier()) |
|
| 29 | ) |
|
| 30 | ); |
|
| 31 | } |
|
| 32 | ||
| 33 | // update the winner attribute in entry. |
|
| 34 | $occurrence = $this->getGameService()->IsInstantWinner($this->game, $this->user); |
|
| @@ 91-99 (lines=9) @@ | ||
| 88 | { |
|
| 89 | $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
|
| 90 | ||
| 91 | if (!$lastEntry) { |
|
| 92 | return $this->redirect()->toUrl( |
|
| 93 | $this->frontendUrl()->fromRoute( |
|
| 94 | 'instantwin', |
|
| 95 | array('id' => $this->game->getIdentifier(), ), |
|
| 96 | array('force_canonical' => true) |
|
| 97 | ) |
|
| 98 | ); |
|
| 99 | } |
|
| 100 | $winner = $lastEntry->getWinner(); |
|
| 101 | $occurrence = null; |
|
| 102 | ||
| @@ 20-30 (lines=11) @@ | ||
| 17 | } |
|
| 18 | ||
| 19 | $entry = $this->getGameService()->play($this->game, $this->user); |
|
| 20 | if (!$entry) { |
|
| 21 | // the user has already taken part of this game and the participation limit has been reached |
|
| 22 | $this->flashMessenger()->addMessage('Vous avez déjà participé'); |
|
| 23 | ||
| 24 | return $this->redirect()->toUrl( |
|
| 25 | $this->frontendUrl()->fromRoute( |
|
| 26 | 'lottery/result', |
|
| 27 | array('id' => $this->game->getIdentifier()) |
|
| 28 | ) |
|
| 29 | ); |
|
| 30 | } |
|
| 31 | ||
| 32 | // Every entry is eligible to draw |
|
| 33 | $entry->setDrawable(true); |
|
| @@ 58-66 (lines=9) @@ | ||
| 55 | $socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl); |
|
| 56 | ||
| 57 | $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
|
| 58 | if (!$lastEntry) { |
|
| 59 | return $this->redirect()->toUrl( |
|
| 60 | $this->frontendUrl()->fromRoute( |
|
| 61 | 'lottery', |
|
| 62 | array('id' => $this->game->getIdentifier()), |
|
| 63 | array('force_canonical' => true) |
|
| 64 | ) |
|
| 65 | ); |
|
| 66 | } |
|
| 67 | ||
| 68 | $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form'); |
|
| 69 | $form->setAttribute('method', 'post'); |
|
| @@ 156-164 (lines=9) @@ | ||
| 153 | { |
|
| 154 | $entry = $this->getGameService()->findLastActiveEntry($this->game, $this->user); |
|
| 155 | ||
| 156 | if (!$entry) { |
|
| 157 | // the user has already taken part of this game and the participation limit has been reached |
|
| 158 | return $this->redirect()->toUrl( |
|
| 159 | $this->frontendUrl()->fromRoute( |
|
| 160 | 'postvote/'.$this->game->nextStep('preview'), |
|
| 161 | array('id' => $this->game->getIdentifier()) |
|
| 162 | ) |
|
| 163 | ); |
|
| 164 | } |
|
| 165 | ||
| 166 | // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
|
| 167 | $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0)); |
|
| @@ 228-235 (lines=8) @@ | ||
| 225 | // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
|
| 226 | $post = $this->getGameService()->getPostVotePostMapper()->findById($postId); |
|
| 227 | ||
| 228 | if (! $post || $post->getStatus() === 9) { |
|
| 229 | return $this->redirect()->toUrl( |
|
| 230 | $this->frontendUrl()->fromRoute( |
|
| 231 | 'postvote', |
|
| 232 | array('id' => $this->game->getIdentifier()) |
|
| 233 | ) |
|
| 234 | ); |
|
| 235 | } |
|
| 236 | ||
| 237 | $formModeration = new Form(); |
|
| 238 | $formModeration->setAttribute('method', 'post'); |
|
| @@ 169-176 (lines=8) @@ | ||
| 166 | // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
|
| 167 | $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0)); |
|
| 168 | ||
| 169 | if (! $post) { |
|
| 170 | return $this->redirect()->toUrl( |
|
| 171 | $this->frontendUrl()->fromRoute( |
|
| 172 | 'postvote', |
|
| 173 | array('id' => $this->game->getIdentifier()) |
|
| 174 | ) |
|
| 175 | ); |
|
| 176 | } |
|
| 177 | ||
| 178 | if ($this->getRequest()->isPost()) { |
|
| 179 | $post = $this->getGameService()->confirmPost($this->game, $this->user); |
|
| @@ 333-340 (lines=8) @@ | ||
| 330 | // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
|
| 331 | $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntry)); |
|
| 332 | ||
| 333 | if (! $post) { |
|
| 334 | return $this->redirect()->toUrl( |
|
| 335 | $this->frontendUrl()->fromRoute( |
|
| 336 | 'postvote', |
|
| 337 | array('id' => $this->game->getIdentifier()) |
|
| 338 | ) |
|
| 339 | ); |
|
| 340 | } |
|
| 341 | ||
| 342 | $view = $this->forward()->dispatch( |
|
| 343 | 'playgroundgame_'.$this->game->getClassType(), |
|
| @@ 27-37 (lines=11) @@ | ||
| 24 | } |
|
| 25 | ||
| 26 | $entry = $this->getGameService()->play($this->game, $this->user); |
|
| 27 | if (!$entry) { |
|
| 28 | // the user has already taken part of this game and the participation limit has been reached |
|
| 29 | $this->flashMessenger()->addMessage('Vous avez déjà participé!'); |
|
| 30 | ||
| 31 | return $this->redirect()->toUrl( |
|
| 32 | $this->frontendUrl()->fromRoute( |
|
| 33 | $this->game->getClassType() . '/result', |
|
| 34 | array('id' => $this->game->getIdentifier()) |
|
| 35 | ) |
|
| 36 | ); |
|
| 37 | } |
|
| 38 | ||
| 39 | $reply = $this->getGameService()->getQuizReplyMapper()->getLastGameReply($entry); |
|
| 40 | $userAnswers = array(); |
|
| @@ 208-216 (lines=9) @@ | ||
| 205 | $socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl); |
|
| 206 | ||
| 207 | $lastEntry = $this->getGameService()->findLastEntry($this->game, $this->user); |
|
| 208 | if (!$lastEntry) { |
|
| 209 | return $this->redirect()->toUrl( |
|
| 210 | $this->frontendUrl()->fromRoute( |
|
| 211 | 'quiz', |
|
| 212 | array('id' => $this->game->getIdentifier()), |
|
| 213 | array('force_canonical' => true) |
|
| 214 | ) |
|
| 215 | ); |
|
| 216 | } |
|
| 217 | ||
| 218 | // je compte les bonnes réponses et le ratio |
|
| 219 | $maxCorrectAnswers = $this->game->getMaxCorrectAnswers(); |
|
| @@ 41-51 (lines=11) @@ | ||
| 38 | { |
|
| 39 | $subGameIdentifier = $this->getEvent()->getRouteMatch()->getParam('gameId'); |
|
| 40 | $entry = $this->getGameService()->play($this->game, $this->user); |
|
| 41 | if (!$entry) { |
|
| 42 | // the user has already taken part of this game and the participation limit has been reached |
|
| 43 | $this->flashMessenger()->addMessage('You have already played'); |
|
| 44 | ||
| 45 | return $this->redirect()->toUrl( |
|
| 46 | $this->frontendUrl()->fromRoute( |
|
| 47 | 'mission/result', |
|
| 48 | array('id' => $this->game->getIdentifier()) |
|
| 49 | ) |
|
| 50 | ); |
|
| 51 | } |
|
| 52 | ||
| 53 | if (!$subGameIdentifier) { |
|
| 54 | $subGame = $this->game->getNextPlayableGame($entry); |
|
| @@ 59-69 (lines=11) @@ | ||
| 56 | $subGame = $this->getGameService()->checkGame($subGameIdentifier); |
|
| 57 | } |
|
| 58 | ||
| 59 | if (!$this->game->isPlayable($subGame, $entry)) { |
|
| 60 | // this subgame is not playable |
|
| 61 | $this->flashMessenger()->addMessage('No game found'); |
|
| 62 | ||
| 63 | return $this->redirect()->toUrl( |
|
| 64 | $this->frontendUrl()->fromRoute( |
|
| 65 | 'mission', |
|
| 66 | array('id' => $this->game->getIdentifier()) |
|
| 67 | ) |
|
| 68 | ); |
|
| 69 | } |
|
| 70 | ||
| 71 | $session = new Container('facebook'); |
|
| 72 | // Redirect to fan gate if the game require to 'like' the page before playing |
|
| @@ 342-355 (lines=14) @@ | ||
| 339 | ||
| 340 | if ($key < $keyplay || ($keyStep && !$keyplayStep && $key <= $keyplay)) { |
|
| 341 | $entry = $this->getGameService()->play($this->game, $this->user); |
|
| 342 | if (!$entry) { |
|
| 343 | // the user has already taken part of this game and the participation limit has been reached |
|
| 344 | $this->flashMessenger()->addMessage('Vous avez déjà participé'); |
|
| 345 | ||
| 346 | return $this->redirect()->toUrl( |
|
| 347 | $this->frontendUrl()->fromRoute( |
|
| 348 | $this->game->getClassType().'/result', |
|
| 349 | array( |
|
| 350 | 'id' => $this->game->getIdentifier(), |
|
| 351 | ||
| 352 | ) |
|
| 353 | ) |
|
| 354 | ); |
|
| 355 | } |
|
| 356 | } else { |
|
| 357 | // I'm looking for an entry without anonymousIdentifier (the active entry in fact). |
|
| 358 | $entry = $this->getGameService()->findLastEntry($this->game, $this->user); |
|
| @@ 563-570 (lines=8) @@ | ||
| 560 | // Has the user finished the game ? |
|
| 561 | $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
|
| 562 | ||
| 563 | if ($lastEntry === null) { |
|
| 564 | return $this->redirect()->toUrl( |
|
| 565 | $this->frontendUrl()->fromRoute( |
|
| 566 | $this->game->getClassType(), |
|
| 567 | array('id' => $this->game->getIdentifier()) |
|
| 568 | ) |
|
| 569 | ); |
|
| 570 | } |
|
| 571 | } |
|
| 572 | ||
| 573 | $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form'); |
|