Ejemplo n.º 1
0
  /**
   * 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();
    }
  }
Ejemplo n.º 2
0
 /**
  * produces game values
  *
  * @throws IOException exception
  */
 public static void produce() throws IOException {
   for (Player p : Configurations.getPlayers()) {
     for (MapTiles tile : p.getOwned()) {
       for (int i = 0; i < tile.getMules().length && p.getEnergy() > 0; i++) {
         if (tile.getMules()[i]) {
           if (i == 0) {
             p.setFood(p.getFood() + tile.getFood());
             p.setEnergy(p.getEnergy() - 1);
           } else if (i == 1) {
             p.setEnergy(p.getEnergy() + tile.getEnergy());
             p.setEnergy(p.getEnergy() - 1);
           } else {
             p.setSmithore(p.getSmithore() + tile.getOre());
             p.setEnergy(p.getEnergy() - 1);
           }
         }
       }
     }
   }
   // Save.save();
 }