コード例 #1
0
      @Override
      public void update(GameManager manager) {
        if (manager.allPlayersReady()) {
          for (Player player : manager.players.values()) {
            player.revealDice();
          }

          manager.state = GameManagerState.WAIT_FOR_CHOICE_TO_PLAY;
        }
      }
コード例 #2
0
      @Override
      public void update(GameManager manager) {
        if (manager.allPlayersReady()) {
          for (Player players : manager.players.values()) {
            players.reset();
          }

          manager.newGame();
          manager.state = GameManagerState.WAIT_FOR_PLAYER_READY;
        }
      }
コード例 #3
0
      @Override
      public void update(GameManager manager) {
        if (manager.allPlayersReady()) {
          for (Player players : manager.players.values()) {
            players.endGame(manager.endGameInfo);
          }

          manager.unreadyAll();
          manager.state = GameManagerState.WAIT_FOR_PLAY_AGAIN;
        }
      }
コード例 #4
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;
          }
        }
      }
コード例 #5
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;
        }
      }