From 058887ff4d11aea6ffd41896c9bbcebcf0e5c9de Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 17:16:12 -0400 Subject: [PATCH] Locked resources are always unavailable. --- src/engine/gameManager/ForgeManager.java | 20 ++++++++++++++++++++ src/engine/objects/Warehouse.java | 18 ------------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 2a78868f..207de0cb 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -14,6 +14,7 @@ import engine.net.client.msg.ErrorPopupMsg; import engine.objects.Item; import engine.objects.ItemTemplate; import engine.objects.PlayerCharacter; +import engine.objects.Warehouse; import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; @@ -30,6 +31,25 @@ public enum ForgeManager implements Runnable { public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); public static HashMap oven = new HashMap(); + public static HashMap calcWarehouseOverflow(Warehouse warehouse, HashMap cost_map) { + + // Method returns a map of resourceType that a transaction overdrafts. + + HashMap overflowMap = new HashMap<>(); + + for (mbEnums.ResourceType resourceType : cost_map.keySet()) { + + int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType); + + // Locked resources are always unavailable + + if (debit < 0 || warehouse.locked.contains(resourceType)) + overflowMap.put(resourceType, debit); + } + + return overflowMap; + } + @Override public void run() { diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 0bcdce7c..4891701e 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -635,22 +635,4 @@ public class Warehouse { return warehouse.locked.contains(resourceType); } - public static HashMap calcOverflow(Warehouse warehouse, HashMap cost_map) { - - // Method returns a map of resourceType that a transaction overdrafts. - - HashMap overflowMap = new HashMap<>(); - - for (mbEnums.ResourceType resourceType : cost_map.keySet()) { - - int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType); - - // Locked resources are always unavailable - - if (debit < 0 || warehouse.locked.contains(resourceType)) - overflowMap.put(resourceType, debit); - } - - return overflowMap; - } } \ No newline at end of file