Esempio n. 1
0
 @Override
 public void playYearOfPlentyCard(ResourceType resource1, ResourceType resource2) {
   if (clientFacade.canPlayDevCard(DevCardType.YEAR_OF_PLENTY)) {
     clientFacade.yearOfPlenty(
         clientFacade.convertResourceType(resource1), clientFacade.convertResourceType(resource2));
   }
 }
Esempio n. 2
0
 @Override
 public void playMonopolyCard(ResourceType resource) {
   if (clientFacade.canPlayDevCard(DevCardType.MONOPOLY)) {
     clientFacade.monopoly(
         clientFacade.convertResourceType(resource), clientFacade.getPlayerIndex());
   }
 }
Esempio n. 3
0
  @Override
  public void startPlayCard() {
    getPlayCardView().reset();
    DevCardList playerDevCards = clientFacade.getPlayerDevCards();

    // Set Number of each card
    getPlayCardView().setCardAmount(DevCardType.MONOPOLY, playerDevCards.getMonopoly());
    getPlayCardView().setCardAmount(DevCardType.MONUMENT, playerDevCards.getMonument());
    getPlayCardView().setCardAmount(DevCardType.ROAD_BUILD, playerDevCards.getRoadBuilding());
    getPlayCardView().setCardAmount(DevCardType.SOLDIER, playerDevCards.getSoldier());
    getPlayCardView().setCardAmount(DevCardType.YEAR_OF_PLENTY, playerDevCards.getYearOfPlenty());

    DevCardList playerOldDevCards = clientFacade.getPlayerOldDevCards();

    // Set enabled or disabled
    int currentTurn = clientFacade.getTurnTracker().getCurrentTurn();
    boolean isPlayerTurn = (currentTurn == clientFacade.getPlayerIndex());
    boolean playing = clientFacade.getTurnTracker().getStatus().equals("Playing");
    boolean playedDevCard = clientFacade.getPlayer().isPlayedDevCard();

    if (isPlayerTurn && playing && !playedDevCard) {
      if (playerOldDevCards.getMonopoly() < 1) {
        getPlayCardView().setCardEnabled(DevCardType.MONOPOLY, false);
      } else {
        getPlayCardView().setCardEnabled(DevCardType.MONOPOLY, true);
      }

      if (playerOldDevCards.getRoadBuilding() < 1) {
        getPlayCardView().setCardEnabled(DevCardType.ROAD_BUILD, false);
      } else {
        getPlayCardView().setCardEnabled(DevCardType.ROAD_BUILD, true);
      }

      if (playerOldDevCards.getSoldier() < 1) {
        getPlayCardView().setCardEnabled(DevCardType.SOLDIER, false);
      } else {
        getPlayCardView().setCardEnabled(DevCardType.SOLDIER, true);
      }

      if (playerOldDevCards.getYearOfPlenty() < 1) {
        getPlayCardView().setCardEnabled(DevCardType.YEAR_OF_PLENTY, false);
      } else {
        getPlayCardView().setCardEnabled(DevCardType.YEAR_OF_PLENTY, true);
      }

      //			if(playerDevCards.getMonument() < 1){
      //				getPlayCardView().setCardEnabled(DevCardType.MONUMENT, false);
      //			}
      //			else if(clientFacade.canPlayDevCard(DevCardType.MONUMENT)){
      //				getPlayCardView().setCardEnabled(DevCardType.MONUMENT, true);
      //			}
    } else {
      getPlayCardView().setCardEnabled(DevCardType.MONOPOLY, false);
      getPlayCardView().setCardEnabled(DevCardType.ROAD_BUILD, false);
      getPlayCardView().setCardEnabled(DevCardType.SOLDIER, false);
      getPlayCardView().setCardEnabled(DevCardType.YEAR_OF_PLENTY, false);
    }

    if (isPlayerTurn && playing) {
      if (clientFacade.canPlayDevCard(DevCardType.MONUMENT) && (playerDevCards.getMonument() > 0)) {
        getPlayCardView().setCardEnabled(DevCardType.MONUMENT, true);
      } else {
        getPlayCardView().setCardEnabled(DevCardType.MONUMENT, false);
      }
    } else {
      getPlayCardView().setCardEnabled(DevCardType.MONUMENT, false);
    }

    getPlayCardView().showModal();
  }
Esempio n. 4
0
 @Override
 public void playSoldierCard() {
   if (clientFacade.canPlayDevCard(DevCardType.SOLDIER)) {
     soldierAction.execute();
   }
 }