コード例 #1
0
 /** resets hand and buttons */
 public void resetDraftingPhase() {
   needHand = true;
   cardsInHand.clear();
   cardsInHand = null;
   // draftLayout.getHand().newTurn();
   draftLayout.getActionButtons().resetActionButtons();
 }
コード例 #2
0
  /** Method which switches the which phase of the game is being displayed on the GUI */
  public void switchScenes() {
    if (currentRoot == draftLayout) {
      primaryStage.getScene().setRoot(votingLayout);
      currentRoot = votingLayout;
      draftingPhase = false;
      // votingLayout.onResize();
      chatNode = votingLayout.getChatNode();
      tickerReel = votingLayout.getTickerReel();

    } else {
      primaryStage.getScene().setRoot(draftLayout);
      currentRoot = draftLayout;
      draftingPhase = true;
      draftLayout.getHand().onResize();
      chatNode = draftLayout.getChatNode();
      tickerReel = draftLayout.getTickerReel();
    }
  }
コード例 #3
0
 /** basic initializing of things that only need to be called once */
 public void initGame() {
   chatNode = draftLayout.getChatNode();
   tickerReel = draftLayout.getTickerReel();
   if (client != null) {
     cardsInHand = client.getHand();
     assignedRegion = client.getRegion();
   }
   if (testing) {
     CardDeck cardDeck = new CardDeck(EnumRegion.USA_MOUNTAIN);
     EnumPolicy[] deck = cardDeck.drawCards();
     draftLayout.getHand().setPolicies(deck);
     System.out.println(Arrays.deepToString(deck));
   }
   if (cardsInHand != null) {
     getDraftLayout()
         .getHand()
         .setPolicies(cardsInHand.toArray(new EnumPolicy[cardsInHand.size()]));
   }
   System.out.println(assignedRegion);
   getDraftLayout().getSummaryBar().setRegion(assignedRegion);
 }
コード例 #4
0
  private void initTimer() {
    java.util.Timer timer = new java.util.Timer();
    ChatNode chatNodeDraft = draftLayout.getChatNode();
    ChatNode chatNodeVote = votingLayout.getChatNode();
    ChatManager chatManager = client.getChatManager();
    HandNode hand = getDraftLayout().getHand();
    TimerTask timerTask =
        new TimerTask() {
          boolean flag = false;

          @Override
          public void run() {
            Platform.runLater(
                () -> {
                  chatNodeDraft.setChatMessages(chatManager.getChat());
                  chatNodeVote.setChatMessages(chatManager.getChat());
                  if (needsHand() && client.getHand() != null && !client.getHand().isEmpty()) {

                    setCardsInHand(client.getHand());
                    cardsInHand = client.getHand();
                    hand.setPolicies(client.getHand().toArray(new EnumPolicy[cardsInHand.size()]));
                    System.out.println(
                        "please work "
                            + Arrays.toString(hand.getPolicies())
                            + Platform.isFxApplicationThread());
                  }
                  if (getDraftLayout().getHand().getPolicies() != null) {
                    chatNodeDraft.setHand(getDraftLayout().getHand().getPolicies());
                    chatNodeVote.setHand(getDraftLayout().getHand().getPolicies());
                  }
                  if (isDraftingPhase() && client.getServerState().equals(GameState.VOTING)) {
                    resetDraftingPhase();
                    switchScenes();
                  }
                  if (!isDraftingPhase()
                      && (client.getServerState().equals(GameState.DRAFTING)
                          || client.getServerState().equals(GameState.DRAWING))) {
                    resetVotingPhase();
                    switchScenes();
                  }
                  // if (client.getVotingCards() != null &&
                  // !getVotingLayout().hasReceivedCards())
                  // getVotingLayout().updateCardSpaces(client.getVotingCards());

                });
          }
        };

    timer.schedule(timerTask, 100, 1000);
  }
コード例 #5
0
 public void updateState() {
   draftLayout.update();
 }