Browse Source

New workorder constructor

combat-2
MagicBot 8 months ago
parent
commit
89c3eb4d47
  1. 33
      src/engine/loot/WorkOrder.java

33
src/engine/loot/WorkOrder.java

@ -8,6 +8,7 @@
package engine.loot; package engine.loot;
import engine.gameManager.ForgeManager;
import engine.mbEnums; import engine.mbEnums;
import engine.objects.Item; import engine.objects.Item;
import engine.objects.NPC; import engine.objects.NPC;
@ -47,8 +48,38 @@ public class WorkOrder implements Delayed {
} }
public WorkOrder(String json) { public WorkOrder(JSONObject jsonWorkOrder) {
this.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet();
this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor"));
this.slots_used = jsonWorkOrder.getInt("slots_used");
this.total_to_produce = jsonWorkOrder.getInt("total_to_produce");
this.total_produced = jsonWorkOrder.getInt("total_produced");
this.multiple_slot_request = jsonWorkOrder.getBoolean("multiple_slot_request");
this.templateID = jsonWorkOrder.getInt("templateID");
this.item_name_override = jsonWorkOrder.getString("item_name_override");
this.prefixToken = jsonWorkOrder.getInt("prefixToken");
this.suffixToken = jsonWorkOrder.getInt("suffixToken");
this.slots_used = jsonWorkOrder.getInt("slots_used");
this.rollingDuration = jsonWorkOrder.getLong("rollingDuration");
this.completionTime = jsonWorkOrder.getLong("completionTime");
this.runCompleted = jsonWorkOrder.getBoolean("runCompleted");
JSONObject productionCostMap = jsonWorkOrder.getJSONObject("production_cost");
for (String key : productionCostMap.keySet()) {
mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf(key);
int value = productionCostMap.getInt(key);
this.production_cost.put(resourceType, value);
}
JSONObject productionTotalCostMap = jsonWorkOrder.getJSONObject("production_cost");
for (String key : productionTotalCostMap.keySet()) {
mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf(key);
int value = productionTotalCostMap.getInt(key);
this.production_cost_total.put(resourceType, value);
}
} }
public static JSONObject toJson(WorkOrder workOrder) { public static JSONObject toJson(WorkOrder workOrder) {

Loading…
Cancel
Save