Exemplo n.º 1
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);
  }
Exemplo n.º 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();
    }
  }
Exemplo n.º 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);
 }