Exemplo n.º 1
0
 /**
  * @param User $user
  * @param Game $game
  */
 public function defineUserMoveAndOpponentForGame(User $user, Game $game)
 {
     $game->setUserMove($game->getUserToMove() == $user);
     switch (true) {
         case $game->getUserWhite() == $user:
             $game->setOpponent($game->getUserBlack());
             break;
         case $game->getUserBlack() == $user:
             $game->setOpponent($game->getUserWhite());
             break;
         default:
             throw new GameHandlerException("Unknown user {$user->getLogin()} for game {$game->getId()}");
     }
 }