コード例 #1
0
  @Override
  public void update() {
    if (MasterController.getSingleton().hasGameBegun()
        && ModelFacade.whatStateMightItBe() == Status.Discarding
        && !ModelFacade.getUserPlayer().hasDiscarded()) {
      Player user = ModelFacade.getUserPlayer();

      updateDiscardView();

      if (user.needsToDiscard()) {
        showModal();
      }
    }
  }
コード例 #2
0
  @Override
  public void discard() {

    DiscardCards command = new DiscardCards(ModelFacade.getUserPlayerInfo().getIndex(), theList);

    try {
      MasterController.getSingleton().discardCards(command);
      ModelFacade.getUserPlayer().setDiscarded(true);
    } catch (ServerException e) {
      System.err.println(e.getReason());
    }

    closeModal();
  }
コード例 #3
0
  public void updateDiscardView() {
    Player user = ModelFacade.getUserPlayer();

    int numToDiscard = user.getResources().getTotal() / 2;

    getDiscardView().setDiscardButtonEnabled(numToDiscard == theList.getTotal());
    getDiscardView().setStateMessage("Discard " + theList.getTotal() + "/" + numToDiscard);

    for (ResourceType type : ResourceType.values()) {
      int amount = user.getResourceAmount(type);
      int value = theList.getResource(type);

      getDiscardView().setResourceDiscardAmount(type, value);
      getDiscardView().setResourceMaxAmount(type, amount);

      getDiscardView()
          .setResourceAmountChangeEnabled(
              type, value < amount && numToDiscard > theList.getTotal(), value != 0);
    }
  }