Method moved to WorkOrder

This commit is contained in:
2024-04-23 15:11:56 -04:00
parent 4fa646ce94
commit 911698a7e3
3 changed files with 30 additions and 29 deletions
+29
View File
@@ -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) {