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; }
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; } }
public boolean canUpgrade(Base b) { if (getWood() >= b.getWoodRequire() && getIron() >= b.getIronRequire()) { return true; } return false; }