示例#1
0
  // @ requires message != null;
  @Override
  public void tradeFailed(String message) {
    hand.addAll(playedTiles);

    --tilesToTrade;
    playedTiles = new ArrayList<Tile>(hand);
    Collections.shuffle(playedTiles);
    while (playedTiles.size() > tilesToTrade) {
      playedTiles.remove(0);
    }

    hand.removeAll(playedTiles);
    try {
      game.tradeTiles(this, playedTiles);
    } catch (MoveOrderException e) {
      e.printStackTrace();
    }
  }
示例#2
0
 /** Asks the player to determine their next move using their behaviour. */
 @Override
 public void determineMove() {
   tilesToTrade = 6;
   Move move = behaviour.determineMove(game.getBoard(), getHand());
   if (move.getTiles().size() > 0) {
     playedTiles = move.getTiles();
     try {
       game.doMove(this, move);
     } catch (InvalidMoveException e) {
       e.printStackTrace();
     } catch (MoveOrderException e) {
       e.printStackTrace();
     }
   } else {
     playedTiles = new ArrayList<Tile>(hand);
     hand.clear();
     try {
       game.tradeTiles(this, playedTiles);
     } catch (MoveOrderException e) {
       e.printStackTrace();
     }
   }
 }