Browse Source

Method to load workorders on bootstrap

combat-2
MagicBot 8 months ago
parent
commit
73e30062ea
  1. 14
      src/engine/db/handlers/dbWarehouseHandler.java
  2. 10
      src/engine/loot/WorkOrder.java

14
src/engine/db/handlers/dbWarehouseHandler.java

@ -10,6 +10,7 @@
package engine.db.handlers; package engine.db.handlers;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.ForgeManager;
import engine.loot.WorkOrder; import engine.loot.WorkOrder;
import engine.mbEnums; import engine.mbEnums;
import engine.mbEnums.GameObjectType; import engine.mbEnums.GameObjectType;
@ -201,12 +202,23 @@ public class dbWarehouseHandler extends dbHandlerBase {
Logger.error(e); Logger.error(e);
} }
// Delete the old records // Process workOrder records
for (WorkOrder workOrder : submitList) for (WorkOrder workOrder : submitList)
DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); 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 // Pass the new workOrders to the ForgeManager
} }
} }

10
src/engine/loot/WorkOrder.java

@ -11,6 +11,7 @@ package engine.loot;
import engine.mbEnums; import engine.mbEnums;
import engine.objects.Item; import engine.objects.Item;
import engine.objects.NPC; import engine.objects.NPC;
import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.time.Duration; import java.time.Duration;
@ -79,6 +80,15 @@ public class WorkOrder implements Delayed {
int value = productionTotalCostMap.getInt(key); int value = productionTotalCostMap.getInt(key);
this.production_cost_total.put(resourceType, value); 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) { public static JSONObject toJson(WorkOrder workOrder) {

Loading…
Cancel
Save