Browse Source

comment cleanup

combat-2
MagicBot 8 months ago
parent
commit
3a514dc771
  1. 12
      src/engine/gameManager/ForgeManager.java
  2. 8
      src/engine/loot/WorkOrder.java

12
src/engine/gameManager/ForgeManager.java

@ -128,8 +128,8 @@ public enum ForgeManager implements Runnable {
int validation_result = WorkOrder.validate(workOrder); int validation_result = WorkOrder.validate(workOrder);
// The return code is used by the ItemProductionMsgHandler as a // The return code is used by the caller (ItemProductionMsgHandler)
// popup error message for the player. // for display of a popup error message to the player.
if (validation_result != 0) if (validation_result != 0)
return validation_result; return validation_result;
@ -149,7 +149,7 @@ public enum ForgeManager implements Runnable {
if (!workOrder.multiple_slot_request && workOrder.total_to_produce == 0) if (!workOrder.multiple_slot_request && workOrder.total_to_produce == 0)
workOrder.total_to_produce = 1; workOrder.total_to_produce = 1;
// Set total cost for this production run // Set total cost for production run
workOrder.total_to_produce *= workOrder.slots_used; workOrder.total_to_produce *= workOrder.slots_used;
@ -157,7 +157,7 @@ public enum ForgeManager implements Runnable {
workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.putAll(workOrder.production_cost);
workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.put(key, value * workOrder.total_to_produce)); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.put(key, value * workOrder.total_to_produce));
// Withdraw gold and resource costs // Withdraw gold and resource costs. Availability has previously been validated.
if (!WorkOrder.withdrawWorkOrderCost(workOrder)) if (!WorkOrder.withdrawWorkOrderCost(workOrder))
return 58; //58: The formula is beyond the means of this facility return 58; //58: The formula is beyond the means of this facility
@ -166,8 +166,8 @@ public enum ForgeManager implements Runnable {
forgeWorkOrderBatch(workOrder); forgeWorkOrderBatch(workOrder);
// Enqueue workOrder for next completion cycle // Enqueue workOrder in the .forge and then
// and assign it to the vendor // add the workOrder to it's vendor
vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder);
forge.add(workOrder); forge.add(workOrder);

8
src/engine/loot/WorkOrder.java

@ -56,6 +56,9 @@ public class WorkOrder implements Delayed {
public long completionTime; public long completionTime;
public boolean runCompleted = false; public boolean runCompleted = false;
public boolean runCanceled = false; public boolean runCanceled = false;
// This collection is serialized to the vendor rolling window in ManageNPCMsg.
public ConcurrentHashMap.KeySetView<Item, Boolean> cooking = ConcurrentHashMap.newKeySet(); public ConcurrentHashMap.KeySetView<Item, Boolean> cooking = ConcurrentHashMap.newKeySet();
public WorkOrder() { public WorkOrder() {
@ -64,6 +67,9 @@ public class WorkOrder implements Delayed {
public WorkOrder(JSONObject jsonWorkOrder) { public WorkOrder(JSONObject jsonWorkOrder) {
// This constructor is used to load workOrders from disk
// during bootstrap. (dyn_workorders)
this.workOrderID = jsonWorkOrder.getInt("workOrderID"); this.workOrderID = jsonWorkOrder.getInt("workOrderID");
this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor")); this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor"));
this.slots_used = jsonWorkOrder.getInt("slots_used"); this.slots_used = jsonWorkOrder.getInt("slots_used");
@ -191,6 +197,8 @@ public class WorkOrder implements Delayed {
public static JSONObject toJson(WorkOrder workOrder) { public static JSONObject toJson(WorkOrder workOrder) {
// Workorders are persisted in JSON format.
JSONObject jsonWorkOrder = new JSONObject(); JSONObject jsonWorkOrder = new JSONObject();
jsonWorkOrder.put("workOrderID", workOrder.workOrderID); jsonWorkOrder.put("workOrderID", workOrder.workOrderID);

Loading…
Cancel
Save