From 4e05c2ab748aed03d0289e68f1b6b30221197517 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 13:38:35 -0400 Subject: [PATCH] Warehouse debit work --- src/engine/gameManager/ForgeManager.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 55952874..d0dd2781 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -127,8 +127,7 @@ public enum ForgeManager implements Runnable { // Single item configuration - if (workOrder.multiple_slot_request == false && - workOrder.total_to_produce == 0) + if (!workOrder.multiple_slot_request && workOrder.total_to_produce == 0) workOrder.total_to_produce = 1; workOrder.total_to_produce *= workOrder.slots_used; @@ -386,21 +385,19 @@ public enum ForgeManager implements Runnable { int strongbox = workOrder.vendor.building.getStrongboxValue(); - if (workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) > strongbox) { + if (workOrder.vendor.building.getCity() == null) + return false; - if (workOrder.vendor.building.getCity() == null) - return false; + Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; - Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; + if (warehouse == null) + return false; - if (warehouse == null) - return false; + // Deduct total cost from warehouse - // Deduct total cost from warehouse + workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.put(key, warehouse.resources.get(key) - value)); + DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); - workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.put(key, warehouse.resources.get(key) - value)); - DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); - } return true; } }