示例#1
0
 public List<DiceValue> getDiceValues() {
   values.clear();
   for (Dice d : dice) {
     values.add(d.getValue());
   }
   return Collections.unmodifiableList(values);
 }
示例#2
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;
    }
  }
示例#3
0
  public int playRound(Player player, DiceValue pick, int bet) {
    if (player == null) throw new IllegalArgumentException("Player cannot be null.");
    if (pick == null) throw new IllegalArgumentException("Pick cannot be negative.");
    if (bet < 0) throw new IllegalArgumentException("Bet cannot be negative.");

    int matches = 0;
    for (Dice d : dice) {
      d.roll();
      if (d.getValue().equals(pick)) {
        matches += 1;
      }
    }

    int winnings = matches * bet;

    if (matches > 0) {
      player.receiveWinnings(winnings);
    } else {
      player.takeBet(bet);
    }
    return winnings;
  }
示例#4
0
 public void rollDice() {
   moves = dice.nextRandom();
 }
示例#5
0
 public int getDiceRoll() {
   return dice.nextRandom();
 }