예제 #1
0
파일: Util.java 프로젝트: zbolmb/MULE
  /**
   * claims tiles for players
   *
   * @param x double
   * @param y double
   * @param tile MapTiles
   * @throws IOException exception
   */
  public static void claimTile(double x, double y, MapTiles tile) throws IOException {
    if (Configurations.getRound() == 0 && Configurations.getCurPlayer().getMoney() < 300) {
      return;
    }
    if (!(tile instanceof TownTile) && tile.getOwner().equals("None")) {
      Player cp = Configurations.getCurPlayer();
      if (cp.getOwned().size() <= 0) {
        int rx = (int) (x / 100) * 100;
        int ry = (int) (y / 100) * 100;
        cp.setStartX(rx + 0.5 * MapTiles.getW());
        cp.setStartY(ry + 0.5 * MapTiles.getH());
        cp.setPlayerIcon(new Circle(cp.getStartX(), cp.getStartY(), 10, cp.getColor()));
        Configurations.getGameMapController().add(cp.getPlayerIcon());
      }
      cp.getOwned().add(tile);
      tile.setOwner(cp.getName());
      if (Configurations.getRound() == 0) {
        cp.setMoney(cp.getMoney() - 300);
      }
      Rectangle[] sq = Util.drawSelectionSq(x, y, cp.getColor());

      for (Rectangle r : sq) {
        Configurations.getGameMapController().add(r);
      }
      incrementTurn();
    }
  }
예제 #2
0
파일: Util.java 프로젝트: zbolmb/MULE
  /**
   * 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();
  }
예제 #3
0
파일: Util.java 프로젝트: zbolmb/MULE
 /**
  * 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();
   }
 }
예제 #4
0
파일: Util.java 프로젝트: zbolmb/MULE
 /**
  * increments turn
  *
  * @throws IOException exception
  */
 public static void incrementTurn() throws IOException {
   if (Configurations.getRound() == 0) {
     buyTurnIncre();
   } else {
     movePhaseTurnIncre();
   }
 }