|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|