forge items each cycle

This commit is contained in:
2024-04-13 08:51:02 -04:00
parent 980dee2e14
commit ec80146117
2 changed files with 14 additions and 20 deletions
+13 -19
View File
@@ -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);
}
}
}
@@ -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() {