Browse Source

Method to calculate warehosue overflow.

combat-2
MagicBot 7 months ago
parent
commit
98c0712dea
  1. 4
      src/engine/objects/Warehouse.java

4
src/engine/objects/Warehouse.java

@ -642,10 +642,14 @@ public class Warehouse {
public static HashMap<mbEnums.ResourceType, Integer> calcOverflow(Warehouse warehouse, HashMap<mbEnums.ResourceType, Integer> cost_map) { public static HashMap<mbEnums.ResourceType, Integer> calcOverflow(Warehouse warehouse, HashMap<mbEnums.ResourceType, Integer> cost_map) {
// Method returns a map of resourceType that a transaction overdrafts.
HashMap<mbEnums.ResourceType, Integer> overflowMap = new HashMap<>(); HashMap<mbEnums.ResourceType, Integer> overflowMap = new HashMap<>();
for (mbEnums.ResourceType resourceType : cost_map.keySet()) { for (mbEnums.ResourceType resourceType : cost_map.keySet()) {
int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType); int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType);
if (debit < 0) if (debit < 0)
overflowMap.put(resourceType, debit); overflowMap.put(resourceType, debit);
} }

Loading…
Cancel
Save