From 3a514dc771cb3a807f19206ef013b714f470c9d0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 10:03:37 -0400 Subject: [PATCH] comment cleanup --- src/engine/gameManager/ForgeManager.java | 12 ++++++------ src/engine/loot/WorkOrder.java | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 41328ca2..711e3468 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -128,8 +128,8 @@ public enum ForgeManager implements Runnable { int validation_result = WorkOrder.validate(workOrder); - // The return code is used by the ItemProductionMsgHandler as a - // popup error message for the player. + // The return code is used by the caller (ItemProductionMsgHandler) + // for display of a popup error message to the player. if (validation_result != 0) return validation_result; @@ -149,7 +149,7 @@ public enum ForgeManager implements Runnable { if (!workOrder.multiple_slot_request && workOrder.total_to_produce == 0) workOrder.total_to_produce = 1; - // Set total cost for this production run + // Set total cost for production run workOrder.total_to_produce *= workOrder.slots_used; @@ -157,7 +157,7 @@ public enum ForgeManager implements Runnable { workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.put(key, value * workOrder.total_to_produce)); - // Withdraw gold and resource costs + // Withdraw gold and resource costs. Availability has previously been validated. if (!WorkOrder.withdrawWorkOrderCost(workOrder)) return 58; //58: The formula is beyond the means of this facility @@ -166,8 +166,8 @@ public enum ForgeManager implements Runnable { forgeWorkOrderBatch(workOrder); - // Enqueue workOrder for next completion cycle - // and assign it to the vendor + // Enqueue workOrder in the .forge and then + // add the workOrder to it's vendor vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); forge.add(workOrder); diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 955a4e65..9b12f22e 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -56,6 +56,9 @@ public class WorkOrder implements Delayed { public long completionTime; public boolean runCompleted = false; public boolean runCanceled = false; + + // This collection is serialized to the vendor rolling window in ManageNPCMsg. + public ConcurrentHashMap.KeySetView cooking = ConcurrentHashMap.newKeySet(); public WorkOrder() { @@ -64,6 +67,9 @@ public class WorkOrder implements Delayed { public WorkOrder(JSONObject jsonWorkOrder) { + // This constructor is used to load workOrders from disk + // during bootstrap. (dyn_workorders) + this.workOrderID = jsonWorkOrder.getInt("workOrderID"); this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor")); this.slots_used = jsonWorkOrder.getInt("slots_used"); @@ -191,6 +197,8 @@ public class WorkOrder implements Delayed { public static JSONObject toJson(WorkOrder workOrder) { + // Workorders are persisted in JSON format. + JSONObject jsonWorkOrder = new JSONObject(); jsonWorkOrder.put("workOrderID", workOrder.workOrderID);