|
|
@ -17,7 +17,6 @@ import engine.net.client.msg.ItemProductionMsg; |
|
|
|
import engine.objects.*; |
|
|
|
import engine.objects.*; |
|
|
|
import engine.powers.EffectsBase; |
|
|
|
import engine.powers.EffectsBase; |
|
|
|
import engine.powers.poweractions.AbstractPowerAction; |
|
|
|
import engine.powers.poweractions.AbstractPowerAction; |
|
|
|
import engine.server.MBServerStatics; |
|
|
|
|
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -58,38 +57,18 @@ public enum ForgeManager implements Runnable { |
|
|
|
if (Objects.requireNonNull(workOrder).runCanceled || workOrder.runCompleted) |
|
|
|
if (Objects.requireNonNull(workOrder).runCanceled || workOrder.runCompleted) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
// Persist current items that are currently cooking for this
|
|
|
|
Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); |
|
|
|
// workOrder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<Item> toRemove = new ArrayList<>(); |
|
|
|
|
|
|
|
Item completed_item = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Item cooked_item : workOrder.cooking) { |
|
|
|
|
|
|
|
toRemove.add(cooked_item); |
|
|
|
|
|
|
|
cooked_item.containerType = mbEnums.ItemContainerType.INVENTORY; |
|
|
|
|
|
|
|
completed_item = DbManager.ItemQueries.PERSIST(cooked_item); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workOrder.vendor.charItemManager.addItemToInventory(completed_item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Remove the fake negativeID item from all collections.
|
|
|
|
|
|
|
|
// set the items as 'completed'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Item memoryItem : toRemove) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update vendor windows
|
|
|
|
// Complete this workOrder. Persist items currently in memory
|
|
|
|
|
|
|
|
// and set the items as completed.
|
|
|
|
|
|
|
|
|
|
|
|
ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.COMPLETE, true); |
|
|
|
if (workOrder.total_produced >= workOrder.total_to_produce) { |
|
|
|
DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, MBServerStatics.STRUCTURE_LOAD_RANGE, false, false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workOrder.cooking.remove(memoryItem); |
|
|
|
for (Item workOrderItem : workOrder.cooking) { |
|
|
|
inMemoryItemLookup.remove(memoryItem.objectUUID); |
|
|
|
workOrderItem.setDateToUpgrade(0); |
|
|
|
vendorItemLookup.get(workOrder.vendor).remove(memoryItem); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
Logger.info("workOrder has completed: " + workOrder.workOrderID); |
|
|
|
workOrder.runCompleted = true; |
|
|
|
workOrder.runCompleted = true; |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -319,7 +298,6 @@ public enum ForgeManager implements Runnable { |
|
|
|
inMemoryItemLookup.put(forged_item.objectUUID, forged_item); |
|
|
|
inMemoryItemLookup.put(forged_item.objectUUID, forged_item); |
|
|
|
vendorItemLookup.computeIfAbsent(workOrder.vendor, k -> new ArrayList<>()); |
|
|
|
vendorItemLookup.computeIfAbsent(workOrder.vendor, k -> new ArrayList<>()); |
|
|
|
vendorItemLookup.get(workOrder.vendor).add(forged_item); |
|
|
|
vendorItemLookup.get(workOrder.vendor).add(forged_item); |
|
|
|
vendorItemLookup.get(workOrder.vendor).add(forged_item); |
|
|
|
|
|
|
|
vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); |
|
|
|
vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); |
|
|
|
|
|
|
|
|
|
|
|
// Update NPC window
|
|
|
|
// Update NPC window
|
|
|
|