diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index adcd6b9d..39d2c064 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -25,6 +25,7 @@ import org.pmw.tinylog.Logger; import java.sql.SQLException; import java.util.ArrayList; import java.util.EnumSet; +import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; public class Warehouse { @@ -68,6 +69,20 @@ public class Warehouse { } + public static HashMap calculateWarehouseOverdraft(Warehouse warehouse, HashMap costMap) { + HashMap overdraft = new HashMap<>(); + + for (Enum.ResourceType resourceType : costMap.keySet()) { + + int cost = costMap.get(resourceType); + + if (cost > warehouse.resources.get(resourceType)) + overdraft.put(resourceType, cost - warehouse.resources.get(resourceType)); + } + + return overdraft; + } + public static void warehouseDeposit(MerchantMsg msg, PlayerCharacter player, NPC npc) { Building warehouseBuilding;