From ec80146117630c704194781a26ca851aded0a927 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 08:51:02 -0400 Subject: [PATCH] forge items each cycle --- src/engine/gameManager/ForgeManager.java | 32 ++++++++----------- .../handlers/ItemProductionMsgHandler.java | 2 +- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index c7030fe4..40c3c85f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -34,7 +34,6 @@ public enum ForgeManager implements Runnable { while (true) { try { - WorkOrder workOrder = workOrders.take(); // Completed or canceled work orders are not re-enqueued @@ -42,36 +41,29 @@ public enum ForgeManager implements Runnable { if (workOrder.runCanceled || workOrder.runCompleted) continue; - // Create negative ID items to add to collections - - for (int i = 0; i < workOrder.slots_used; ++i) { - - // Create workOrder items; one for each slot - // assigned to this workOrder. - - // if Prefix and suffix are null random roll item - // otherwise roll what was asked for - - workOrder.total_produced = workOrder.total_produced + 1; - } + // Create in memory items to add to collections + forgeItems(workOrder); Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); + if (workOrder.total_produced >= workOrder.total_to_produce) { Logger.info("workOrder has completed: " + workOrder.workOrderID); + // Persist current items that are cooking + // after removing the negative id item from all collections. + + // Add new item to the vendors inventory + workOrder.runCompleted = true; workOrder.vendor.workOrders.remove(workOrder); continue; } - // Persist current items that are cooking - // after removing the negative id item from all collections. - // Add new item to the vendors inventory - - // Resubmit workOrder + // enQueue this workOrder again; back into the oven + // until all items for this workOrder are completed. workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrders.add(workOrder); @@ -263,6 +255,7 @@ public enum ForgeManager implements Runnable { forgedItem.objectUUID = MobLoot.lastNegativeID.getAndDecrement(); forgedItem.containerType = mbEnums.ItemContainerType.FORGE; forgedItem.ownerID = workOrder.vendor.getObjectUUID(); + forgedItem.setDateToUpgrade(workOrder.completionTime); // Forged items are unidentified until completed @@ -277,10 +270,11 @@ public enum ForgeManager implements Runnable { Item forged_item = forgeItem(workOrder); ForgeManager.oven.put(forged_item, workOrder); + workOrder.cooking.add(forged_item); workOrder.total_produced = workOrder.total_produced + 1; - Logger.info("Forged item: " + forged_item.objectUUID + " of template " + forged_item.templateID); + Logger.info("Forging item: " + forged_item.objectUUID + " of template " + forged_item.templateID); } } } diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 16df9139..832ca23e 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -9,7 +9,6 @@ package engine.net.client.handlers; - import engine.exception.MsgSendException; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; @@ -34,6 +33,7 @@ import java.util.HashMap; * @Summary: Processes application protocol message which modifies * hireling inventory through rolling, junking or depositing. */ + public class ItemProductionMsgHandler extends AbstractClientMsgHandler { public ItemProductionMsgHandler() {