From 5505d7bc613305b0a7660cc562533464dedad9ed Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 12:12:40 -0400 Subject: [PATCH] Items are persisted and moved to vendor inventory --- src/engine/gameManager/ForgeManager.java | 38 ++++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 8f93dd2e..8fb7340e 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -74,15 +74,10 @@ public enum ForgeManager implements Runnable { if (workOrder.runCompleted == true) continue; - ; // Persist items that were currently cooking - for (Item workOrderItem : workOrder.cooking) { - // ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.TAKE, true); - // DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - - } + persistItems(workOrder); // Create new set in memory items @@ -295,6 +290,37 @@ public enum ForgeManager implements Runnable { return forgedItem; } + public static void persistItems(WorkOrder workOrder) { + + ArrayList toRemove = new ArrayList<>(); + Item completed_item; + + for (Item workOrderItem : workOrder.cooking) { + + toRemove.add(workOrderItem); + workOrderItem.containerType = mbEnums.ItemContainerType.INVENTORY; + completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); + + workOrder.vendor.charItemManager.addItemToInventory(completed_item); + + // Remove the fake negativeID item from all collections. + // set the items as 'completed' + + for (Item memoryItem : toRemove) { + + workOrder.cooking.remove(memoryItem); + inMemoryItemLookup.remove(memoryItem.objectUUID); + vendorItemLookup.get(workOrder.vendor).remove(memoryItem); + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + } + + } + + } public static void forgeItems(WorkOrder workOrder) { for (int i = 0; i < workOrder.slots_used; ++i) {