Browse Source

Workorder and Forgemanger classes created

combat-2
MagicBot 7 months ago
parent
commit
39e06994d9
  1. 67
      src/engine/gameManager/ForgeManager.java
  2. 52
      src/engine/loot/WorkOrder.java

67
src/engine/gameManager/ForgeManager.java

@ -0,0 +1,67 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.gameManager;
import engine.loot.WorkOrder;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.atomic.AtomicInteger;
public enum ForgeManager implements Runnable {
FORGE_MANAGER;
private final BlockingQueue<WorkOrder> workQueue = new DelayQueue();
public static final AtomicInteger workOrder = new AtomicInteger(0);
@Override
public void run() {
while (true) {
try {
WorkOrder workOrder = workQueue.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();
}
}
}
}

52
src/engine/loot/WorkOrder.java

@ -0,0 +1,52 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.loot;
import engine.gameManager.ForgeManager;
import engine.objects.NPC;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
import static java.lang.Math.toIntExact;
public class WorkOrder implements Delayed {
public int workOrder;
public NPC vendor;
public int slotCount;
public int itemCount;
public int itemBase;
public String itemName;
public int prefixToken;
public int suffixToken;
public boolean isRandom;
public long completionTime;
public boolean runCompleted;
public WorkOrder() {
this.workOrder = ForgeManager.workOrder.incrementAndGet();
this.completionTime = System.currentTimeMillis() + 10000;
}
@Override
public long getDelay(TimeUnit unit) {
long timeRemaining = completionTime - System.currentTimeMillis();
return unit.convert(timeRemaining, TimeUnit.MILLISECONDS);
}
@Override
public int compareTo(@NotNull Delayed o) {
return toIntExact(this.completionTime - ((WorkOrder) o).completionTime);
}
}
Loading…
Cancel
Save