Browse Source

Warehouse loading work.

combat-2
MagicBot 8 months ago
parent
commit
5db5a26037
  1. 10
      src/engine/objects/Warehouse.java

10
src/engine/objects/Warehouse.java

@ -30,14 +30,14 @@ import java.util.concurrent.ConcurrentHashMap; @@ -30,14 +30,14 @@ import java.util.concurrent.ConcurrentHashMap;
public class Warehouse {
public EnumSet<Enum.ResourceType> locked = EnumSet.noneOf(Enum.ResourceType.class);
public int buildingUID;
public Building building;
public City city;
public ArrayList<Transaction> transactions = new ArrayList<>();
public ConcurrentHashMap<Enum.ResourceType, Integer> resources = new ConcurrentHashMap<>();
public Warehouse(Building building) {
this.buildingUID = building.objectUUID;
this.building = building;
this.city = building.getCity();
// New empty warehouse
@ -604,16 +604,16 @@ public class Warehouse { @@ -604,16 +604,16 @@ public class Warehouse {
}
public static void loadAllTransactions(Warehouse warehouse) {
warehouse.transactions = DbManager.WarehouseQueries.GET_TRANSACTIONS_FOR_WAREHOUSE(warehouse.buildingUID);
warehouse.transactions = DbManager.WarehouseQueries.GET_TRANSACTIONS_FOR_WAREHOUSE(warehouse.building.getObjectUUID());
}
public static void AddTransactionToWarehouse(Warehouse warehouse, Enum.GameObjectType targetType, int targetUUID, Enum.TransactionType transactionType, Enum.ResourceType resource, int amount) {
if (!DbManager.WarehouseQueries.CREATE_TRANSACTION(warehouse.buildingUID, targetType, targetUUID, transactionType, resource, amount, DateTime.now()))
if (!DbManager.WarehouseQueries.CREATE_TRANSACTION(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, DateTime.now()))
return;
Transaction transaction = new Transaction(warehouse.buildingUID, targetType, targetUUID, transactionType, resource, amount, DateTime.now());
Transaction transaction = new Transaction(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, DateTime.now());
warehouse.transactions.add(transaction);
}

Loading…
Cancel
Save