コード例 #1
0
ファイル: Board.java プロジェクト: franckyy/jeux
  /**
   * The process of a turn for one player. Will move their token(unless in jail). Pay any rent/ get
   * any cards automatically and then gives them options to buy/sell mortgage/unmortgage and check
   * on their statistics in the game.
   *
   * @param currentPlayer
   */
  public void turn(Player player) {
    menus.clear();
    menus.add(new DefaultMenu(player, this));
    actionInfo = "";
    currentPlayer = player;

    String playerName = currentPlayer.name();

    if (!currentPlayer.inJail()) {
      int roll = dice.rollDice();

      movePlayer(roll, currentPlayer);
      currentTile = Locations[playerPositions.get(currentPlayer)];
      currentPlayer.setCurrentPosition(currentTile);

      // 			prints relevant
      //			 information if it
      //			 is a property(e.g
      //			 owner, cost)

      actionInfo = currentTile.autoAction(currentPlayer);
    } else {

      currentTile = Locations[playerPositions.get(currentPlayer)];
      currentTile.autoAction(currentPlayer);
      return;
    }
  }
コード例 #2
0
ファイル: Board.java プロジェクト: franckyy/jeux
 /**
  * Moves player on the board, the number of spaces of the current dice roll.
  *
  * @param roll
  * @param currentPlayer
  */
 private void movePlayer(int roll, Player currentPlayer) {
   if (!playerPositions.containsKey(currentPlayer)) { // Player isn't on the
     // board yet!
     playerPositions.put(currentPlayer, roll);
   } else {
     int oldPosition = playerPositions.get(currentPlayer);
     int newPosition = (oldPosition + roll) % 40; // ensure player stays
     // within the 40
     // tiles.
     if (newPosition < oldPosition) {
       currentPlayer.add(200);
     }
     playerPositions.put(currentPlayer, newPosition);
   }
 }