Browse Source

Comment cleanup

combat-2
MagicBot 7 months ago
parent
commit
9850b54981
  1. 2
      src/engine/db/handlers/dbWarehouseHandler.java
  2. 11
      src/engine/gameManager/ForgeManager.java
  3. 14
      src/engine/loot/WorkOrder.java

2
src/engine/db/handlers/dbWarehouseHandler.java

@ -210,7 +210,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
// Submit the new workOrders to the ForgeManager // Submit the new workOrders to the ForgeManager
for (WorkOrder workOrder : submitList) { for (WorkOrder workOrder : submitList) {
workOrder.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet(); workOrder.workOrderID = ForgeManager.workOrderCounter.incrementAndGet();
ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder);
// If workorder is not yet complete process it // If workorder is not yet complete process it

11
src/engine/gameManager/ForgeManager.java

@ -40,7 +40,7 @@ public enum ForgeManager implements Runnable {
FORGE_MANAGER; FORGE_MANAGER;
public static final BlockingQueue<WorkOrder> forge = new DelayQueue<>(); public static final BlockingQueue<WorkOrder> forge = new DelayQueue<>();
public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); public static final AtomicInteger workOrderCounter = new AtomicInteger(0);
public static final ConcurrentHashMap<NPC, ConcurrentHashMap.KeySetView<WorkOrder, Boolean>> vendorWorkOrderLookup = new ConcurrentHashMap<>(); public static final ConcurrentHashMap<NPC, ConcurrentHashMap.KeySetView<WorkOrder, Boolean>> vendorWorkOrderLookup = new ConcurrentHashMap<>();
public static final ConcurrentHashMap<Item, WorkOrder> itemWorkOrderLookup = new ConcurrentHashMap<>(); public static final ConcurrentHashMap<Item, WorkOrder> itemWorkOrderLookup = new ConcurrentHashMap<>();
@ -131,7 +131,7 @@ public enum ForgeManager implements Runnable {
try { try {
// Configure this production run. // Configure this production run.
workOrder.workOrderID = wordOrderCounter.incrementAndGet(); workOrder.workOrderID = workOrderCounter.incrementAndGet();
workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder);
workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration;
workOrder.slots_used = calcAvailableSlots(workOrder); workOrder.slots_used = calcAvailableSlots(workOrder);
@ -151,16 +151,17 @@ 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));
// Debit gold and resource costs // Withdraw gold and resource costs
if (!WorkOrder.debitWorkOrderCost(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
// Create new batch of virtual items // Create new batch of virtual items
forgeWorkOrderBatch(workOrder); forgeWorkOrderBatch(workOrder);
// Submit workOrder for next completion cycle // Enqueue workOrder for next completion cycle
// and assign it to the vendor
vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder);
forge.add(workOrder); forge.add(workOrder);

14
src/engine/loot/WorkOrder.java

@ -31,6 +31,15 @@ import java.util.concurrent.TimeUnit;
public class WorkOrder implements Delayed { public class WorkOrder implements Delayed {
// MB Dev notes:
// Class defines a Forge rolling request made through a
// vendor and then passed to the ForgeManager singleton
// for completion.
//
// A workOrder once created will last until all items are
// either completed or junked. They are persisted in the
// table dyn_workorders.
public int workOrderID; public int workOrderID;
public NPC vendor; public NPC vendor;
public int slots_used; public int slots_used;
@ -133,6 +142,9 @@ public class WorkOrder implements Delayed {
public static int validate(WorkOrder workOrder) { public static int validate(WorkOrder workOrder) {
// Validate that a workOrder can be completed by both
// the vendor and the forge.
int validation_result = 0; int validation_result = 0;
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID);
@ -158,7 +170,7 @@ public class WorkOrder implements Delayed {
return validation_result; return validation_result;
} }
public static boolean debitWorkOrderCost(WorkOrder workOrder) { public static boolean withdrawWorkOrderCost(WorkOrder workOrder) {
if (workOrder.vendor.building.getCity() == null) if (workOrder.vendor.building.getCity() == null)
return false; return false;

Loading…
Cancel
Save