Beispiel #1
0
  /**
   * Handles the trade from a Client.
   *
   * @param params is a String array containing the blocks to trade
   */
  public void doMoveTrade(String[] params) {
    List<Block> tradeBlocks = new ArrayList<>();

    for (String block : params) {
      tradeBlocks.add(new Block(Integer.parseInt(block)));
    }

    try {
      game.doMoveTrade(tradeBlocks);
    } catch (TradeFirstTurnException e) {
      sendError(IProtocol.Error.TRADE_FIRST_TURN.ordinal() + " You cannot trade on the first turn");
      game.sendPlayerTurn();
    } catch (TilesUnownedException e) {
      sendError(
          IProtocol.Error.MOVE_TILES_UNOWNED.ordinal() + " Player tried to place unowned tile");
      game.sendPlayerTurn();
    } catch (EmptyBagException e) {
      sendError(
          IProtocol.Error.DECK_EMPTY.ordinal() + " The bag does not contain this many blocks");
      game.sendPlayerTurn();
    }
  }