|
|
|
@ -40,7 +40,7 @@ public enum ForgeManager implements Runnable {
@@ -40,7 +40,7 @@ public enum ForgeManager implements Runnable {
|
|
|
|
|
FORGE_MANAGER; |
|
|
|
|
|
|
|
|
|
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<Item, WorkOrder> itemWorkOrderLookup = new ConcurrentHashMap<>(); |
|
|
|
|
|
|
|
|
@ -131,7 +131,7 @@ public enum ForgeManager implements Runnable {
@@ -131,7 +131,7 @@ public enum ForgeManager implements Runnable {
|
|
|
|
|
try { |
|
|
|
|
// Configure this production run.
|
|
|
|
|
|
|
|
|
|
workOrder.workOrderID = wordOrderCounter.incrementAndGet(); |
|
|
|
|
workOrder.workOrderID = workOrderCounter.incrementAndGet(); |
|
|
|
|
workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); |
|
|
|
|
workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; |
|
|
|
|
workOrder.slots_used = calcAvailableSlots(workOrder); |
|
|
|
@ -151,16 +151,17 @@ public enum ForgeManager implements Runnable {
@@ -151,16 +151,17 @@ public enum ForgeManager implements Runnable {
|
|
|
|
|
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)); |
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
// Create new batch of virtual items
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
forge.add(workOrder); |
|
|
|
|