Browse Source

Locked resources are always unavailable.

combat-2
MagicBot 8 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;
import engine.objects.Item; import engine.objects.Item;
import engine.objects.ItemTemplate; import engine.objects.ItemTemplate;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
import engine.objects.Warehouse;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -30,6 +31,25 @@ public enum ForgeManager implements Runnable {
public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0);
public static HashMap<Item, WorkOrder> oven = new HashMap<Item, WorkOrder>(); 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 @Override
public void run() { public void run() {

18
src/engine/objects/Warehouse.java

@ -635,22 +635,4 @@ public class Warehouse {
return warehouse.locked.contains(resourceType); 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