/** * @inheritDoc */ public function getLeaderBoard() { $leaderBoard = new BasicLeaderBoard(); foreach ($this->getRound()->getGroups() as $group) { foreach ($group->getPlayers() as $player) { $leaderBoard->update($group->getNumber(), $player, 0); } } return $leaderBoard; }
/** * @inheritDoc */ public function getLeaderBoard() { $leaderBoard = new BasicLeaderBoard(); foreach ($this->getGameGearsGrouped() as $groupNumber => $gamesGears) { foreach ($gamesGears as $gameGears) { /** @var GameGearsInterface $gameGears */ $game = $gameGears->getGame(); $player1 = $game->getPlayer1(); $player2 = $game->getPlayer2(); $winner = $game->getWinner(); $player1entry = $leaderBoard->update($groupNumber, $player1, $winner == $player1 ? 1 : 0); $player2entry = $leaderBoard->update($groupNumber, $player2, $winner == $player2 ? 1 : 0); if (!$game->isClosed()) { $player1entry->setFinal(false); $player2entry->setFinal(false); } } } return $leaderBoard; }
protected function createEvenFilledLeaderBoard($groups, $playersPerGroup) { $board = new BasicLeaderBoard(); $playerReflection = new \ReflectionClass('Fda\\PlayerBundle\\Entity\\Player'); $idAccessor = $playerReflection->getProperty('id'); $idAccessor->setAccessible(true); for ($group = 0; $group < $groups; ++$group) { for ($player = 0; $player < $playersPerGroup; ++$player) { $newPlayer = new Player(); $idAccessor->setValue($newPlayer, $group + 1 . ($player + 1)); $board->update($group, $newPlayer, ($group + 1) * ($player + 1)); } } return $board; }