public function start(Game $game) { $game->start(); if ($game->getInvited()->getIsAi()) { return array(); } $messages = array(); $messages[] = ucfirst($game->getCreator()->getColor()) . ' creates the game'; $messages[] = ucfirst($game->getInvited()->getColor()) . ' joins the game'; if ($game->hasClock()) { $messages[] = 'Clock: ' . $game->getClock()->getName(); } if ($game->getIsRated()) { $messages[] = 'This game is rated'; } return $messages; }
public function detectCheater(Game $game) { if ($game->getTurns() != $this->turns && $game->getTurns() != $this->turns + 1) { return false; } if ($game->getInvited()->getIsAi()) { return false; } // Detect client using internal AI $similarGames = $this->gameRepository->findSimilar($game, new DateTime('-5 minutes')); foreach ($similarGames as $similarGame) { if ($similarGame->getInvited()->getIsAi()) { return $game->getPlayer($similarGame->getInvited()->getColor()); } } return false; }