|
|
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
|
|
// Magicbane Emulator Project © 2013 - 2022
|
|
|
|
// www.magicbane.com
|
|
|
|
|
|
|
|
package engine.gameManager;
|
|
|
|
|
|
|
|
import engine.loot.WorkOrder;
|
|
|
|
import engine.objects.PlayerCharacter;
|
|
|
|
|
|
|
|
import java.util.concurrent.BlockingQueue;
|
|
|
|
import java.util.concurrent.DelayQueue;
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
|
|
public enum ForgeManager implements Runnable {
|
|
|
|
|
|
|
|
FORGE_MANAGER;
|
|
|
|
|
|
|
|
private static final BlockingQueue<WorkOrder> workOrders = new DelayQueue();
|
|
|
|
public static final AtomicInteger wordOrderCounter = new AtomicInteger(0);
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
WorkOrder workOrder = workOrders.take();
|
|
|
|
|
|
|
|
// Fulfill workOrder
|
|
|
|
|
|
|
|
for (int i = 0; i < workOrder.slotCount; ++i) {
|
|
|
|
|
|
|
|
// Create workOrder items; one for each slot
|
|
|
|
// assigned to this workOrder.
|
|
|
|
|
|
|
|
// if Prefix and suffix are null random roll item
|
|
|
|
// otherwise roll what was asked for
|
|
|
|
|
|
|
|
workOrder.itemCount = workOrder.itemCount - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (workOrder.itemCount == 0) {
|
|
|
|
|
|
|
|
workOrder.runCompleted = true;
|
|
|
|
|
|
|
|
// Remove this workOrder from any slots on vendor
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resubmit workOrder
|
|
|
|
|
|
|
|
workOrder.completionTime = System.currentTimeMillis() + 10000;
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void submit(WorkOrder workOrder) {
|
|
|
|
workOrder.workOrderID = wordOrderCounter.incrementAndGet();
|
|
|
|
workOrder.completionTime = System.currentTimeMillis() + 10000;
|
|
|
|
workOrders.add(workOrder);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean validate(PlayerCharacter playerCharacter, WorkOrder workOrder) {
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|