コード例 #1
0
ファイル: SwissService.php プロジェクト: StasPiv/playzone
 /**
  * @param TournamentPlayer $tournamentPlayer
  * @return string
  */
 private function getPlayerInfo(TournamentPlayer $tournamentPlayer) : string
 {
     return $tournamentPlayer->getPlayer()->getLogin() . " (" . $tournamentPlayer->getPlayer()->getId() . ")" . " " . $this->container->get("jms_serializer")->serialize($tournamentPlayer, "json");
 }
コード例 #2
0
 /**
  * @param Tournament $tournament
  * @param int $round
  * @param TournamentPlayer $firstPlayer
  * @param TournamentPlayer $secondPlayer
  * @return TournamentGame
  */
 public function createTournamentGame(Tournament $tournament, int $round, TournamentPlayer $firstPlayer, TournamentPlayer $secondPlayer) : TournamentGame
 {
     if ($firstPlayer->getId() === 0 || $secondPlayer->getId() === 0) {
         throw new TournamentGameShouldBeSkippedException();
     }
     $game = $this->container->get("core.handler.game")->createEntity();
     switch (true) {
         case $firstPlayer->getRequiredColor() == GameColor::BLACK || $secondPlayer->getRequiredColor() == GameColor::WHITE:
             $game->setUserWhite($secondPlayer->getPlayer())->setUserBlack($firstPlayer->getPlayer());
             $whiteTournamentPlayer = $secondPlayer;
             $blackTournamentPlayer = $firstPlayer;
             break;
         default:
             $game->setUserWhite($firstPlayer->getPlayer())->setUserBlack($secondPlayer->getPlayer());
             $whiteTournamentPlayer = $firstPlayer;
             $blackTournamentPlayer = $secondPlayer;
     }
     $game->setUserToMove($game->getUserWhite());
     $game->setTimeWhite($tournament->getGameParams()->getTimeBase())->setTimeBlack($tournament->getGameParams()->getTimeBase())->setRatingWhite($whiteTournamentPlayer->getPlayer()->getRating())->setRatingBlack($blackTournamentPlayer->getPlayer()->getRating());
     $game->setGameParams($tournament->getGameParams());
     $this->container->get("core.handler.game")->changeGameStatus($game, GameStatus::PLAY);
     $tournamentGame = new TournamentGame();
     $tournamentGame->setGame($game)->setTournament($tournament)->setRound($round)->setPlayerWhite($whiteTournamentPlayer)->setPlayerBlack($blackTournamentPlayer);
     return $tournamentGame;
 }