示例#1
0
 public boolean canBuild(Base b, ArrayList<Base> baseList) {
   for (Base each : baseList) {
     if (each instanceof Farm && b instanceof Farm) return false;
     if (each instanceof Ironworks && b instanceof Ironworks) return false;
     if (each instanceof Logger && b instanceof Logger) return false;
     if (each instanceof Warehouse && b instanceof Warehouse) return false;
   }
   if (getFarm() >= b.getFarmPer()) {
     return canUpgrade(b);
   }
   return false;
 }
示例#2
0
  private void updateBaseStat(ArrayList<Base> baseList) {
    farm = 0;

    boolean hasFarm = false;
    for (Base base : baseList) {
      if (base.isDestroy()) continue;
      if (base instanceof Farm) {
        hasFarm = true;
        maximumFarm = ((Farm) base).getGiveFarm() + defaultFarm;
      }
      if (base instanceof Warehouse) {
        maximumWood = ((Warehouse) base).getMaximumWood() + defaultWood;
        maximumIron = ((Warehouse) base).getMaximumIron() + defaultIron;
      }
      farm += base.getFarmPer();
    }

    if (!hasFarm) {
      maximumFarm = defaultFarm;
    }
  }
示例#3
0
 public boolean canUpgrade(Base b) {
   if (getWood() >= b.getWoodRequire() && getIron() >= b.getIronRequire()) {
     return true;
   }
   return false;
 }