From 73e30062ea550b50084ac8323133a7220b1bd2a1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 16:02:22 -0400 Subject: [PATCH] Method to load workorders on bootstrap --- src/engine/db/handlers/dbWarehouseHandler.java | 14 +++++++++++++- src/engine/loot/WorkOrder.java | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 49ec1e8b..f353a046 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -10,6 +10,7 @@ package engine.db.handlers; import engine.gameManager.DbManager; +import engine.gameManager.ForgeManager; import engine.loot.WorkOrder; import engine.mbEnums; import engine.mbEnums.GameObjectType; @@ -201,12 +202,23 @@ public class dbWarehouseHandler extends dbHandlerBase { Logger.error(e); } - // Delete the old records + // Process workOrder records for (WorkOrder workOrder : submitList) DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); + for (WorkOrder workOrder : submitList) { + + // WorkOrder needs a new ID + + workOrder.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet(); + + // Reconstruct cooking items + + + } // Pass the new workOrders to the ForgeManager + } } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index f1fc288f..59eec45f 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -11,6 +11,7 @@ package engine.loot; import engine.mbEnums; import engine.objects.Item; import engine.objects.NPC; +import org.json.JSONArray; import org.json.JSONObject; import java.time.Duration; @@ -79,6 +80,15 @@ public class WorkOrder implements Delayed { int value = productionTotalCostMap.getInt(key); this.production_cost_total.put(resourceType, value); } + + // Reconstruct cooking items + + JSONArray tokenList = jsonWorkOrder.getJSONArray("cookingTokens"); + + for (Object o : tokenList) { + int prefix = tokenList.getInt(0); + int suffix = tokenList.getInt(1); + } } public static JSONObject toJson(WorkOrder workOrder) {