Beispiel #1
0
 private void checkLost(Game gameByGameId) {
   for (Player player : gameByGameId.getPlayers()) {
     if (player.getColonies().size() == 0) {
       gameByGameId.setLoserPlayerId(player.getPlayerId());
     }
   }
 }
Beispiel #2
0
  @Override
  public void endTurn(Integer playerID) {
    Player player = playerRepository.getPlayerByPlayerId(playerID);
    Game game = player.getGame();
    if (!player.isTurnEnded()) {
      int commandPoints = player.getCommandPoints();
      player.setCommandPoints(commandPoints + COMMANDPOINTS_PER_TURN);
      player.setTurnEnded(true);

      boolean allTurnsEnded = true;
      List<Player> players = game.getPlayers();
      for (Player p : players) {
        if (!p.isTurnEnded()) {
          allTurnsEnded = false;
        }
      }
      if (allTurnsEnded) {
        for (Player p : players) {
          p.setTurnEnded(false);
        }
      }
    } else {
      throw new SpaceCrackNotAcceptableException("Turn is already ended");
    }
    gameSynchronizer.updateGame(game);
  }
Beispiel #3
0
 @Override
 public void acceptGameInvite(int gameId) {
   Game game = getGameByGameId(gameId);
   for (Player p : game.getPlayers()) {
     p.setRequestAccepted(true);
   }
   gameSynchronizer.updateGame(game);
 }
Beispiel #4
0
 @Override
 public Player getActivePlayer(User user, Game game) {
   for (Player p : user.getProfile().getPlayers()) {
     for (Player gamePlayer : game.getPlayers()) {
       if (gamePlayer.getPlayerId() == p.getPlayerId()) {
         return gamePlayer;
       }
     }
   }
   throw new SpaceCrackUnexpectedException("This user isn't playing this game");
 }