|
|
@ -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); |
|
|
|