Browse Source

Locked resources are always unavailable.

combat-2
MagicBot 9 months ago
parent
commit
058887ff4d
  1. 20
      src/engine/gameManager/ForgeManager.java
  2. 18
      src/engine/objects/Warehouse.java

20
src/engine/gameManager/ForgeManager.java

@ -14,6 +14,7 @@ import engine.net.client.msg.ErrorPopupMsg; @@ -14,6 +14,7 @@ import engine.net.client.msg.ErrorPopupMsg;
import engine.objects.Item;
import engine.objects.ItemTemplate;
import engine.objects.PlayerCharacter;
import engine.objects.Warehouse;
import engine.powers.EffectsBase;
import org.pmw.tinylog.Logger;
@ -30,6 +31,25 @@ public enum ForgeManager implements Runnable { @@ -30,6 +31,25 @@ public enum ForgeManager implements Runnable {
public static final AtomicInteger wordOrderCounter = new AtomicInteger(0);
public static HashMap<Item, WorkOrder> oven = new HashMap<Item, WorkOrder>();
public static HashMap<mbEnums.ResourceType, Integer> calcWarehouseOverflow(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<>();
for (mbEnums.ResourceType resourceType : cost_map.keySet()) {
int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType);
// Locked resources are always unavailable
if (debit < 0 || warehouse.locked.contains(resourceType))
overflowMap.put(resourceType, debit);
}
return overflowMap;
}
@Override
public void run() {

18
src/engine/objects/Warehouse.java

@ -635,22 +635,4 @@ public class Warehouse { @@ -635,22 +635,4 @@ public class Warehouse {
return warehouse.locked.contains(resourceType);
}
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<>();
for (mbEnums.ResourceType resourceType : cost_map.keySet()) {
int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType);
// Locked resources are always unavailable
if (debit < 0 || warehouse.locked.contains(resourceType))
overflowMap.put(resourceType, debit);
}
return overflowMap;
}
}
Loading…
Cancel
Save