From 7c4f7f391ba861726a500ea070dd27bd30470a2d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 15:54:25 -0400 Subject: [PATCH] Method to calculate warehosue overflow. --- src/engine/objects/Warehouse.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 0f30940d..2b0576ad 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -640,4 +640,16 @@ public class Warehouse { return warehouse.locked.contains(resourceType); } + public static HashMap calcOverflow(Warehouse warehouse, HashMap cost_map) { + + HashMap overflowMap = new HashMap<>(); + + for (mbEnums.ResourceType resourceType : cost_map.keySet()) { + int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType); + if (debit < 0) + overflowMap.put(resourceType, debit); + } + + return overflowMap; + } } \ No newline at end of file