Ejemplo n.º 1
0
  private boolean handleCommodityArea(Player player, List<Integer> c) {
    if (player.getPawnLeft() < 1 || c.size() == 7) {
      return false;
    }

    if (nPlayers == 2) {
      if (getOtherThan(c, player.getId()) > 0) {
        return false;
      }
      c.add(player.getId());
      player.putPawn();
      return true;
    } else if (nPlayers == 3) {
      if (getOtherThan(c, player.getId()) > 1) {
        return false;
      }
      c.add(player.getId());
      player.putPawn();
      return true;
    } else {
      c.add(player.getId());
      player.putPawn();
      return true;
    }
  }
Ejemplo n.º 2
0
 public boolean putPawn(Player player, int areaId) {
   switch (areaId) {
     case TouchAreas.FOOD_ID:
       if (player.getPawnLeft() > 1) {
         foodArea.add(player.getId());
         player.putPawn();
         return true;
       } else {
         return false;
       }
     case TouchAreas.WOOD_ID:
       return handleCommodityArea(player, woodArea);
     case TouchAreas.COPPER_ID:
       handleCommodityArea(player, copperArea);
     case TouchAreas.GOLD_ID:
       handleCommodityArea(player, goldArea);
     case TouchAreas.HUT_ID:
       if (hutArea == -1 && player.getPawnLeft() > 2) {
         hutArea = player.getId();
         player.putPawn();
         player.putPawn();
         return true;
       } else {
         return false;
       }
     case TouchAreas.FARM_ID:
       if (farmArea == -1 && player.getPawnLeft() > 1) {
         farmArea = player.getId();
         player.putPawn();
         return true;
       } else {
         return false;
       }
     case TouchAreas.FACTORY_ID:
       if (factoryArea == -1 && player.getPawnLeft() > 1) {
         factoryArea = player.getId();
         player.putPawn();
         return true;
       } else {
         return false;
       }
     case TouchAreas.BUILDING_1_ID:
       if (buildingAreas[0] == -1 && player.getPawnLeft() > 1) {
         buildingAreas[0] = player.getId();
         player.putPawn();
         return true;
       } else {
         return false;
       }
     case TouchAreas.BUILDING_2_ID:
       if (buildingAreas[1] == -1 && player.getPawnLeft() > 1) {
         buildingAreas[1] = player.getId();
         player.putPawn();
         return true;
       } else {
         return false;
       }
     case TouchAreas.BUILDING_3_ID:
       if (buildingAreas[2] == -1 && player.getPawnLeft() > 1) {
         buildingAreas[2] = player.getId();
         player.putPawn();
         return true;
       } else {
         return false;
       }
     case TouchAreas.BUILDING_4_ID:
       if (buildingAreas[3] == -1 && player.getPawnLeft() > 1) {
         buildingAreas[3] = player.getId();
         player.putPawn();
         return true;
       } else {
         return false;
       }
     case TouchAreas.CIVILIZATION_1_ID:
       if (civilisationAreas[0] == -1 && player.getPawnLeft() > 1) {
         civilisationAreas[0] = player.getId();
         player.putPawn();
         return true;
       } else {
         return false;
       }
     case TouchAreas.CIVILIZATION_2_ID:
       if (civilisationAreas[1] == -1 && player.getPawnLeft() > 1) {
         civilisationAreas[1] = player.getId();
         player.putPawn();
         return true;
       } else {
         return false;
       }
     case TouchAreas.CIVILIZATION_3_ID:
       if (civilisationAreas[2] == -1 && player.getPawnLeft() > 1) {
         civilisationAreas[2] = player.getId();
         player.putPawn();
         return true;
       } else {
         return false;
       }
     case TouchAreas.CIVILIZATION_4_ID:
       if (civilisationAreas[3] == -1 && player.getPawnLeft() > 1) {
         civilisationAreas[3] = player.getId();
         player.putPawn();
         return true;
       } else {
         return false;
       }
     default:
       return false;
   }
 }