コード例 #1
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);
 }
コード例 #2
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);
  }
コード例 #3
0
  @Override
  public void start(Stage primaryStage) {
    System.out.println("GUI.start()");
    EnumPolicy.load();
    EnumRegion.loadIcons();
    // TODO: THIS WILL BE REMOVED WHEN PHASE HANDLING IS FULLY IMPLEMENTED
    MapController.setCurrentController(GamePhaseMapController.class);
    this.primaryStage = primaryStage;
    primaryStage.setTitle("Starvation Evasion");

    // fills a list of all the product types

    // primaryStage.setMaxHeight(maxHeight);
    // primaryStage.setMinHeight(maxHeight);
    primaryStage.setResizable(true);

    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();

    primaryStage.setX(bounds.getMinX());
    primaryStage.setY(bounds.getMinY());
    primaryStage.setWidth(bounds.getWidth());
    primaryStage.setHeight(bounds.getHeight());

    boxHeight = primaryStage.getWidth() / DraftLayout.ROWS;
    boxWidth = primaryStage.getWidth() / DraftLayout.COLS;

    // instantiate helper classes
    imageGetter = new ImageGetter();
    popupManager = new PopupManager(this);
    graphManager = new GraphManager(this);

    // instantiate the DraftLayout
    draftLayout = new DraftLayout(this);
    votingLayout = new VotingLayout(this);
    // make a scene for displaying the game
    gameScene = new Scene(draftLayout);
    currentRoot = draftLayout;
    primaryStage.setScene(gameScene);

    primaryStage.show();

    primaryStage.setOnCloseRequest(
        arg0 -> {
          if (client != null) client.shutdown();
          Platform.exit();
        });

    initGame();
  }
コード例 #4
0
 public GUI(Client client, LocalDataContainer localDataContainer) {
   super();
   this.client = client;
   this.localDataContainer = localDataContainer;
   assignedRegion = client.getRegion();
 }
コード例 #5
0
 public GameState getServerGameState() {
   if (client != null) return client.getServerState();
   else return null;
 }
コード例 #6
0
 @Override
 public void stop() {
   if (client != null) client.shutdown();
 }