From 9850b54981a1baa28229e09e9808330fc53e3a16 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 09:22:50 -0400 Subject: [PATCH] Comment cleanup --- src/engine/db/handlers/dbWarehouseHandler.java | 2 +- src/engine/gameManager/ForgeManager.java | 11 ++++++----- src/engine/loot/WorkOrder.java | 14 +++++++++++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index c58cb10e..31fb4a10 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -210,7 +210,7 @@ public class dbWarehouseHandler extends dbHandlerBase { // Submit the new workOrders to the ForgeManager for (WorkOrder workOrder : submitList) { - workOrder.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet(); + workOrder.workOrderID = ForgeManager.workOrderCounter.incrementAndGet(); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); // If workorder is not yet complete process it diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index c957ef1d..f91aec6f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -40,7 +40,7 @@ public enum ForgeManager implements Runnable { FORGE_MANAGER; public static final BlockingQueue forge = new DelayQueue<>(); - public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); + public static final AtomicInteger workOrderCounter = new AtomicInteger(0); public static final ConcurrentHashMap> vendorWorkOrderLookup = new ConcurrentHashMap<>(); public static final ConcurrentHashMap itemWorkOrderLookup = new ConcurrentHashMap<>(); @@ -131,7 +131,7 @@ public enum ForgeManager implements Runnable { try { // Configure this production run. - workOrder.workOrderID = wordOrderCounter.incrementAndGet(); + workOrder.workOrderID = workOrderCounter.incrementAndGet(); workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrder.slots_used = calcAvailableSlots(workOrder); @@ -151,16 +151,17 @@ 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)); - // Debit gold and resource costs + // Withdraw gold and resource costs - if (!WorkOrder.debitWorkOrderCost(workOrder)) + if (!WorkOrder.withdrawWorkOrderCost(workOrder)) return 58; //58: The formula is beyond the means of this facility // Create new batch of virtual items forgeWorkOrderBatch(workOrder); - // Submit workOrder for next completion cycle + // Enqueue workOrder for next completion cycle + // and assign it to the 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 e2d4feb2..d1e534a9 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -31,6 +31,15 @@ import java.util.concurrent.TimeUnit; public class WorkOrder implements Delayed { + // MB Dev notes: + // Class defines a Forge rolling request made through a + // vendor and then passed to the ForgeManager singleton + // for completion. + // + // A workOrder once created will last until all items are + // either completed or junked. They are persisted in the + // table dyn_workorders. + public int workOrderID; public NPC vendor; public int slots_used; @@ -133,6 +142,9 @@ public class WorkOrder implements Delayed { public static int validate(WorkOrder workOrder) { + // Validate that a workOrder can be completed by both + // the vendor and the forge. + int validation_result = 0; ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); @@ -158,7 +170,7 @@ public class WorkOrder implements Delayed { return validation_result; } - public static boolean debitWorkOrderCost(WorkOrder workOrder) { + public static boolean withdrawWorkOrderCost(WorkOrder workOrder) { if (workOrder.vendor.building.getCity() == null) return false;