From 9dd2e1d5e58189cf1adf559a6809c40450c89012 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 08:41:23 -0400 Subject: [PATCH] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 31 +++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index c13a21ff..958685e1 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -141,13 +141,12 @@ 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 cost from forge - // and / or warehouse + // Debit gold and resource costs if (!debitWorkOrderCost(workOrder)) return 58; //58: The formula is beyond the means of this facility - // Create in-memory items and add to collections + // Create new batch of virtual items forgeWorkOrderBatch(workOrder); @@ -193,7 +192,7 @@ public enum ForgeManager implements Runnable { int availableSlots = workOrder.vendor.getRank(); - // Subtract slots currently being used by npc workOrders + // Subtract slots currently assigned to npc workOrders for (WorkOrder npcWorkOrder : ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor)) availableSlots = availableSlots - npcWorkOrder.cooking.size(); @@ -208,7 +207,7 @@ public enum ForgeManager implements Runnable { public static HashMap calcProductionCost(WorkOrder workOrder) { - // Calculate the production cost for a single run of this workOrder + // Calculate production cost for a single run of this workOrder HashMap production_cost = new HashMap<>(); ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); @@ -235,7 +234,7 @@ public enum ForgeManager implements Runnable { public static Item forgeItem(WorkOrder workOrder) { - // Create new item from specified template + // Create new virtual item from specified template ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); Item forgedItem = new Item(workOrder.templateID); @@ -246,12 +245,12 @@ public enum ForgeManager implements Runnable { forgedItem.containerType = mbEnums.ItemContainerType.FORGE; forgedItem.ownerID = workOrder.vendor.getObjectUUID(); - // The UpgradeDate for the item is serialized for the - // vendor forge window + // item.upgradeDate is serialized (ItemProductionMsg) + // for vendor forge window completion time. forgedItem.setDateToUpgrade(workOrder.completionTime); - // Give prefix and suffix to this item if random rolled + // Assign a prefix and suffix to this item if random rolled if (workOrder.prefixToken == 0) forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable); @@ -263,7 +262,7 @@ public enum ForgeManager implements Runnable { else forgedItem.suffixToken = workOrder.suffixToken; - // Forged random rolled items are unidentified until completed + // Random rolled items are unidentified until completed if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) forgedItem.flags.remove(mbEnums.ItemFlags.Identified); @@ -315,15 +314,17 @@ public enum ForgeManager implements Runnable { toRemove.add(virutalItem); } - // Remove the virtual item from all collections + for (Item virtualItem : toRemove) { - // Remove the virtual items from the forge window + // Remove virtual items from the forge window ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + // Remove virtual item from all collections + workOrder.cooking.remove(virtualItem); itemWorkOrderLookup.remove(virtualItem); DbManager.removeFromCache(virtualItem); @@ -332,7 +333,7 @@ public enum ForgeManager implements Runnable { public static void forgeWorkOrderBatch(WorkOrder workOrder) { - // New completion time for this batch + // Completion time for this batch is in the future workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; @@ -347,7 +348,7 @@ public enum ForgeManager implements Runnable { workOrder.total_produced = workOrder.total_produced + 1; } - // Save updated status to disk + // Save updated state to disk DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); @@ -355,6 +356,8 @@ public enum ForgeManager implements Runnable { public static int calcRandomMod(NPC vendor, mbEnums.ItemModType itemModType, int modTable) { + // Random prefix or suffix token based on item.template.modtable + int modifier = 0; ModTypeTableEntry modTypeTableEntry = null; ModTableEntry modTableEntry = null;