| @@ 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'); |
|
| @@ 182-190 (lines=9) @@ | ||
| 179 | $socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl); |
|
| 180 | ||
| 181 | $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
|
| 182 | if (!$lastEntry) { |
|
| 183 | return $this->redirect()->toUrl( |
|
| 184 | $this->frontendUrl()->fromRoute( |
|
| 185 | 'quiz', |
|
| 186 | array('id' => $this->game->getIdentifier()), |
|
| 187 | array('force_canonical' => true) |
|
| 188 | ) |
|
| 189 | ); |
|
| 190 | } |
|
| 191 | ||
| 192 | // je compte les bonnes réponses et le ratio |
|
| 193 | $maxCorrectAnswers = $this->game->getMaxCorrectAnswers(); |
|
| @@ 166-174 (lines=9) @@ | ||
| 163 | { |
|
| 164 | $entry = $this->getGameService()->findLastActiveEntry($this->game, $this->user); |
|
| 165 | ||
| 166 | if (!$entry) { |
|
| 167 | // the user has already taken part of this game and the participation limit has been reached |
|
| 168 | return $this->redirect()->toUrl( |
|
| 169 | $this->frontendUrl()->fromRoute( |
|
| 170 | 'postvote/'.$this->game->nextStep('preview'), |
|
| 171 | array('id' => $this->game->getIdentifier()) |
|
| 172 | ) |
|
| 173 | ); |
|
| 174 | } |
|
| 175 | ||
| 176 | // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
|
| 177 | $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0)); |
|
| @@ 238-245 (lines=8) @@ | ||
| 235 | // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
|
| 236 | $post = $this->getGameService()->getPostVotePostMapper()->findById($postId); |
|
| 237 | ||
| 238 | if (! $post || $post->getStatus() === 9) { |
|
| 239 | return $this->redirect()->toUrl( |
|
| 240 | $this->frontendUrl()->fromRoute( |
|
| 241 | 'postvote', |
|
| 242 | array('id' => $this->game->getIdentifier()) |
|
| 243 | ) |
|
| 244 | ); |
|
| 245 | } |
|
| 246 | ||
| 247 | $formModeration = new Form(); |
|
| 248 | $formModeration->setAttribute('method', 'post'); |
|
| @@ 47-57 (lines=11) @@ | ||
| 44 | { |
|
| 45 | $subGameIdentifier = $this->getEvent()->getRouteMatch()->getParam('gameId'); |
|
| 46 | $entry = $this->getGameService()->play($this->game, $this->user); |
|
| 47 | if (!$entry) { |
|
| 48 | // the user has already taken part of this game and the participation limit has been reached |
|
| 49 | $this->flashMessenger()->addMessage('You have already played'); |
|
| 50 | ||
| 51 | return $this->redirect()->toUrl( |
|
| 52 | $this->frontendUrl()->fromRoute( |
|
| 53 | 'mission/result', |
|
| 54 | array('id' => $this->game->getIdentifier()) |
|
| 55 | ) |
|
| 56 | ); |
|
| 57 | } |
|
| 58 | ||
| 59 | if (!$subGameIdentifier) { |
|
| 60 | $subGame = $this->game->getNextPlayableGame($entry); |
|
| @@ 65-75 (lines=11) @@ | ||
| 62 | $subGame = $this->getGameService()->checkGame($subGameIdentifier); |
|
| 63 | } |
|
| 64 | ||
| 65 | if (!$this->game->isPlayable($subGame, $entry)) { |
|
| 66 | // this subgame is not playable |
|
| 67 | $this->flashMessenger()->addMessage('No game found'); |
|
| 68 | ||
| 69 | return $this->redirect()->toUrl( |
|
| 70 | $this->frontendUrl()->fromRoute( |
|
| 71 | 'mission', |
|
| 72 | array('id' => $this->game->getIdentifier()) |
|
| 73 | ) |
|
| 74 | ); |
|
| 75 | } |
|
| 76 | ||
| 77 | $socialLinkUrl = $this->frontendUrl()->fromRoute( |
|
| 78 | 'mission', |
|
| @@ 537-544 (lines=8) @@ | ||
| 534 | // Has the user finished the game ? |
|
| 535 | $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
|
| 536 | ||
| 537 | if ($lastEntry === null) { |
|
| 538 | return $this->redirect()->toUrl( |
|
| 539 | $this->frontendUrl()->fromRoute( |
|
| 540 | $this->game->getClassType(), |
|
| 541 | array('id' => $this->game->getIdentifier()) |
|
| 542 | ) |
|
| 543 | ); |
|
| 544 | } |
|
| 545 | } |
|
| 546 | ||
| 547 | $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form'); |
|