From 70e6756651d9cdda7bd2b7f2c671b3b09bca3a9e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 13:01:21 -0400 Subject: [PATCH] debitWorkOrderCost method created --- src/engine/gameManager/ForgeManager.java | 31 +++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ecd90360..989b5cab 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -123,6 +123,23 @@ public enum ForgeManager implements Runnable { // 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 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(); if (city == null) - return 1; + return false; Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; 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)); } - - // Create in-memory items and add to collections - - forgeWorkOrderBatch(workOrder); - - Logger.info(workOrder.toString()); - forge.add(workOrder); - - return validation_result; + return true; } public static long calcRollingDuration(WorkOrder workOrder) {