From 98c0712dea4ac9bd14809a5fdba33358f2f3e571 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 15:55:57 -0400 Subject: [PATCH] Method to calculate warehosue overflow. --- src/engine/objects/Warehouse.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 2b0576ad..bbb1900f 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -642,10 +642,14 @@ public class Warehouse { 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); + if (debit < 0) overflowMap.put(resourceType, debit); }