Browse Source

debitWorkOrderCost method created

combat-2
MagicBot 8 months ago
parent
commit
70e6756651
  1. 31
      src/engine/gameManager/ForgeManager.java

31
src/engine/gameManager/ForgeManager.java

@ -123,6 +123,23 @@ public enum ForgeManager implements Runnable {
// Deduct gold cost from building // Deduct gold cost from building
debitWorkOrderCost(workOrder);
// Create in-memory items and add to collections
forgeWorkOrderBatch(workOrder);
// Submit workOrder for next completion cycle
forge.add(workOrder);
Logger.info(workOrder.toString());
return validation_result;
}
public static boolean debitWorkOrderCost(WorkOrder workOrder) {
int strongbox = workOrder.vendor.building.getStrongboxValue(); int strongbox = workOrder.vendor.building.getStrongboxValue();
int overflow = strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD); int overflow = strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD);
@ -133,24 +150,16 @@ public enum ForgeManager implements Runnable {
City city = workOrder.vendor.building.getCity(); City city = workOrder.vendor.building.getCity();
if (city == null) if (city == null)
return 1; return false;
Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; Warehouse warehouse = workOrder.vendor.building.getCity().warehouse;
if (warehouse == null) if (warehouse == null)
return 1; return false;
workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.compute(key, (k, v) -> warehouse.resources.get(key) - value)); workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.compute(key, (k, v) -> warehouse.resources.get(key) - value));
} }
return true;
// Create in-memory items and add to collections
forgeWorkOrderBatch(workOrder);
Logger.info(workOrder.toString());
forge.add(workOrder);
return validation_result;
} }
public static long calcRollingDuration(WorkOrder workOrder) { public static long calcRollingDuration(WorkOrder workOrder) {

Loading…
Cancel
Save