From 911698a7e371119c729db9a36c3ac6ac3f3c0a18 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 15:11:56 -0400 Subject: [PATCH] Method moved to WorkOrder --- src/engine/gameManager/ForgeManager.java | 2 +- src/engine/gameManager/ItemManager.java | 28 ----------------------- src/engine/loot/WorkOrder.java | 29 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b21a5eb7..edc3c1c0 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -98,7 +98,7 @@ public enum ForgeManager implements Runnable { // Make sure vendor can roll the formulae, warehouse can // afford this wordOrder and other related checks. - int validation_result = ItemManager.validate(workOrder); + int validation_result = WorkOrder.validate(workOrder); // The return code is used by the submitter as a // popup error message for the player. diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index c9634ad8..76bd7f0f 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -1,6 +1,5 @@ package engine.gameManager; -import engine.loot.WorkOrder; import engine.mbEnums; import engine.objects.*; import engine.powers.EffectsBase; @@ -229,33 +228,6 @@ public enum ItemManager { return true; } - public static int validate(WorkOrder workOrder) { - - int validation_result = 0; - - ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); - - if (workOrder.vendor.getBuilding() == null) - return 58; //58: The formula is beyond the means of this facility - - if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) - return 30; //30: That person cannot carry that item - - if (!workOrder.vendor.getItemModTable().contains((template.modTable))) - return 59; //59: This hireling does not have this formula - - if (!Warehouse.calcCostOverrun(workOrder).isEmpty()) - return 10; //18: You can't really afford that - - // Forge must be protected in order to access warehouse. - - if (ForgeManager.calcProductionCost(workOrder).size() > 1) - if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) - return 193; //193: Production denied: This building must be protected to gain access to warehouse - - return validation_result; - } - public static void applyItemEffects(Item forgedItem) { if (forgedItem.prefixToken != 0) { diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index fc4e8a33..815bf3d7 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -11,7 +11,9 @@ package engine.loot; import engine.gameManager.ForgeManager; import engine.mbEnums; import engine.objects.Item; +import engine.objects.ItemTemplate; import engine.objects.NPC; +import engine.objects.Warehouse; import org.json.JSONArray; import org.json.JSONObject; @@ -127,6 +129,33 @@ public class WorkOrder implements Delayed { return jsonWorkOrder; } + public static int validate(WorkOrder workOrder) { + + int validation_result = 0; + + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + + if (workOrder.vendor.getBuilding() == null) + return 58; //58: The formula is beyond the means of this facility + + if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) + return 30; //30: That person cannot carry that item + + if (!workOrder.vendor.getItemModTable().contains((template.modTable))) + return 59; //59: This hireling does not have this formula + + if (!Warehouse.calcCostOverrun(workOrder).isEmpty()) + return 10; //18: You can't really afford that + + // Forge must be protected in order to access warehouse. + + if (ForgeManager.calcProductionCost(workOrder).size() > 1) + if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) + return 193; //193: Production denied: This building must be protected to gain access to warehouse + + return validation_result; + } + @Override public long getDelay(TimeUnit unit) {