Browse Source

Overdraft method written

combat-2
MagicBot 8 months ago
parent
commit
0c0f0aa54d
  1. 15
      src/engine/objects/Warehouse.java

15
src/engine/objects/Warehouse.java

@ -25,6 +25,7 @@ import org.pmw.tinylog.Logger; @@ -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 { @@ -68,6 +69,20 @@ public class Warehouse {
}
public static HashMap<Enum.ResourceType, Integer> calculateWarehouseOverdraft(Warehouse warehouse, HashMap<Enum.ResourceType, Integer> costMap) {
HashMap<Enum.ResourceType, Integer> 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;

Loading…
Cancel
Save