/** * @param Game $game * @return Pgn */ private function buildPgnForSaver(Game $game) : Pgn { $headers = ['Event' => 'Game #' . $game->getId(), 'Site' => $this->container->getParameter('app_core_site_host'), 'White' => $game->getUserWhite(), 'Black' => $game->getUserBlack(), 'Result' => $game->getResultWhite() == 0.5 ? '1/2-1/2' : $game->getResultWhite() . '-' . $game->getResultBlack(), 'Date' => $game->getTimeLastMove()->format('Y.m.d')]; if ($game->getTournamentGame()) { $headers['Event'] = $game->getTournamentGame()->getTournament()->getName(); $headers['Round'] = $game->getTournamentGame()->getRound(); } return (new Pgn())->setPgnString($game->getPgn())->setHeaders($headers); }
/** * @param User $user * @param Game $game */ private function changeUserLastMove(User $user, Game $game) { if ($user->getLastMove() < $game->getTimeLastMove()) { $user->setLastMove($game->getTimeLastMove()); } }