コード例 #1
0
      @Override
      public void update(GameManager manager) {
        if (manager.isChoicePlayed) {
          if (manager.choicePlayed != null) {
            for (Player player : manager.players.values()) {
              player.playChoice(manager.choicePlayed);
            }
          }

          manager.isChoicePlayed = false;
          manager.choicePlayed = null;
          manager.unreadyAll();

          if (manager.isGameOver) {
            manager.state = GameManagerState.WAIT_TO_REVEAL_ENDGAME;
          } else {
            manager.state = GameManagerState.WAIT_FOR_PLAYER_READY;
          }
        }
      }
コード例 #2
0
      @Override
      public void update(GameManager manager) {
        if (manager.allPlayersReady()) {
          GameInfo gameInformation = manager.game.advanceAndGetState();

          // We can only wait for a choice to be played if there is a choice
          manager.isChoicePlayed = gameInformation.getChoices().isEmpty();

          // Unready the current player for the next state
          Player currentPlayer = manager.players.get(gameInformation.getPlayerColor());

          // Send the game information to everyone
          for (Player player : manager.players.values()) {
            player.updateGameInfo(gameInformation, currentPlayer == player);
          }

          manager.unreadyPlayer(currentPlayer);

          manager.state = GameManagerState.WAIT_TO_REVEAL_DICE;
        }
      }