Example #1
0
 /**
  * moves / increments turn based off of players priority queue
  *
  * @throws IOException exception
  */
 private static void movePhaseTurnIncre() throws IOException {
   if (playerOrder.isEmpty()) {
     for (Player p : Configurations.getPlayers()) {
       playerOrder.add(p);
     }
     Configurations.setRound(Configurations.getRound() + 1);
     if (Configurations.getPhase() == 1) {
       produce();
     }
   }
   Configurations.setCurPlayer(playerOrder.remove());
   if (Configurations.getPhase() != 0) {
     if (Math.random() < .27) {
       Configurations.getCurPlayer().setMessage(applyRandomEvent());
       Configurations.getGameScreenController()
           .updateText(Configurations.getCurPlayer().getMessage());
     } else {
       Configurations.getCurPlayer().setMessage("");
       Configurations.getGameScreenController()
           .updateText(Configurations.getCurPlayer().getMessage());
     }
   } else {
     Configurations.getGameScreenController().updateText();
   }
 }
Example #2
0
  /**
   * gives turns for buying to players
   *
   * @throws IOException exception
   */
  private static void buyTurnIncre() throws IOException {
    if (playerOrder.isEmpty()) {
      for (Player p : Configurations.getPlayers()) {
        if (p.getMoney() > 300 && !p.isPassed()) {
          playerOrder.add(p);
        }
      }
      if (playerOrder.isEmpty()) {
        Configurations.setRound(Configurations.getRound() + 1);

        // Applying random event to player 1 during initial game start
        Configurations.getCurPlayer().setMessage(applyRandomEvent());
        Configurations.getGameScreenController()
            .updateText(Configurations.getCurPlayer().getMessage());
        Configurations.getLoopService().start();
        movePhaseTurnIncre();
        return;
      }
    }
    Configurations.setCurPlayer(playerOrder.remove());
    if (Configurations.getCurPlayer().isPassed()) {
      buyTurnIncre();
    }
    Configurations.getGameScreenController().updateText();
  }