Exemple #1
0
 /**
  * @inheritdoc
  */
 protected function initGameGearsForGroup(Group $group)
 {
     // this is AvA, create one game for each player vs each other player
     $players = $group->getPlayers();
     $players = $players instanceof Collection ? $players->toArray() : $players;
     $gameGears = array();
     while (count($players) > 1) {
         $player = array_shift($players);
         $gameGears = array_merge($gameGears, $this->createGameGears($group, $player, $players));
     }
     return $gameGears;
 }
Exemple #2
0
 /**
  * @param Group  $group
  * @param Player $player1
  * @param Player $player2
  *
  * @return GameGearsInterface
  */
 public function create(Group $group, Player $player1, Player $player2)
 {
     $roundSetup = $group->getRound()->getSetup();
     $gameMode = $roundSetup->getGameMode();
     $game = $group->getGameByContestants($player1, $player2);
     if (null === $game) {
         $game = new Game($group, $player1, $player2);
         $this->entityManager->persist($game);
     }
     if (in_array($gameMode->getMode(), GameGearsSimple::getSupportedModes())) {
         $gears = new GameGearsSimple($game);
     } else {
         throw new \InvalidArgumentException('can not create game-gears for ' . $gameMode->getMode());
     }
     $gears->setLegGearsFactory($this->legGearsFactory);
     $gears->setLogger($this->logger);
     $this->eventDispatcher->addSubscriber($gears);
     $this->entityManager->flush();
     return $gears;
 }
 /**
  * check if the provided group completes the associated round and proceed accordingly
  *
  * @param Group $group
  * @param EventDispatcherInterface $dispatcher
  */
 protected function handleGroupCompletesRound(Group $group, EventDispatcherInterface $dispatcher)
 {
     $round = $group->getRound();
     if ($round->isClosed()) {
         $this->log('handleGroupCompletesRound, ROUND COMPLETE!');
         $roundCompletedEvent = new RoundEvent();
         $roundCompletedEvent->setRound($round);
         $dispatcher->dispatch(EngineEvents::ROUND_COMPLETED, $roundCompletedEvent);
     }
 }