New rolling duration method moved to manager singleton.
This commit is contained in:
@@ -23,7 +23,10 @@ import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.DelayQueue;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public enum ForgeManager implements Runnable {
|
||||
@@ -146,7 +149,7 @@ public enum ForgeManager implements Runnable {
|
||||
|
||||
try {
|
||||
workOrder.workOrderID = workOrderCounter.incrementAndGet();
|
||||
workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder);
|
||||
workOrder.rollingDuration = NPCManager.calcRollingDuration(workOrder.vendor, workOrder.templateID);
|
||||
workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration;
|
||||
workOrder.slots_used.set(calcAvailableSlots(workOrder));
|
||||
|
||||
@@ -197,24 +200,6 @@ public enum ForgeManager implements Runnable {
|
||||
return validation_result;
|
||||
}
|
||||
|
||||
public static long calcRollingDuration(WorkOrder workOrder) {
|
||||
|
||||
float rollingDuration;
|
||||
|
||||
rollingDuration = workOrder.vendor.getBuilding().getRank() * -5L + 40;
|
||||
rollingDuration = TimeUnit.MINUTES.toMillis((long) rollingDuration);
|
||||
rollingDuration *= Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue());
|
||||
|
||||
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID);
|
||||
|
||||
// Bane circle special case
|
||||
|
||||
if (template.item_bane_rank > 0)
|
||||
rollingDuration = (long) template.item_bane_rank * 60 * 60 * 3 * 1000 * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue());
|
||||
|
||||
return (long) rollingDuration;
|
||||
}
|
||||
|
||||
public static int calcAvailableSlots(WorkOrder workOrder) {
|
||||
|
||||
// Slots available in a forge are based on the npc rank
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static engine.math.FastMath.acos;
|
||||
|
||||
@@ -530,4 +531,25 @@ public enum NPCManager {
|
||||
|
||||
return itemList;
|
||||
}
|
||||
|
||||
public static long calcRollingDuration(NPC vendor, int templateID) {
|
||||
|
||||
ItemTemplate template = ItemTemplate.templates.get(templateID);
|
||||
float rollingDuration;
|
||||
|
||||
if (template == null)
|
||||
return 0;
|
||||
|
||||
if (template.item_bane_rank > 0)
|
||||
return (long) (template.item_bane_rank * 60 * 60 * 3 * 1000 * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()));
|
||||
|
||||
if (vendor.building == null)
|
||||
return 600;
|
||||
|
||||
rollingDuration = vendor.getBuilding().getRank() * -5L + 40;
|
||||
rollingDuration = TimeUnit.MINUTES.toMillis((long) rollingDuration);
|
||||
rollingDuration *= Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue());
|
||||
|
||||
return (long) rollingDuration;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ package engine.net.client.msg;
|
||||
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.ForgeManager;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.loot.WorkOrder;
|
||||
import engine.mbEnums;
|
||||
import engine.mbEnums.GameObjectType;
|
||||
@@ -259,6 +260,7 @@ public class ItemProductionMsg extends ClientNetMsg {
|
||||
writer.putInt(toRoll.getValue());
|
||||
|
||||
NPC vendor = NPC.getFromCache(this.npcUUID);
|
||||
|
||||
if (vendor != null) {
|
||||
if (toRoll.isComplete()) {
|
||||
writer.putInt(0);
|
||||
@@ -268,7 +270,7 @@ public class ItemProductionMsg extends ClientNetMsg {
|
||||
|
||||
timeLeft /= 1000;
|
||||
writer.putInt((int) timeLeft);
|
||||
writer.putInt(vendor.getRollingTimeInSeconds(toRoll.templateID));
|
||||
writer.putInt((int) (NPCManager.calcRollingDuration(vendor, toRoll.templateID) * .001));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -450,7 +450,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
|
||||
timeLife /= 1000;
|
||||
writer.putInt((int) timeLife);
|
||||
writer.putInt(npc.getRollingTimeInSeconds(item.templateID));
|
||||
writer.putInt((int) (NPCManager.calcRollingDuration(npc, item.templateID) * .001));
|
||||
writer.putInt(1);
|
||||
|
||||
if (item.isComplete())
|
||||
|
||||
@@ -1014,28 +1014,6 @@ public class NPC extends AbstractCharacter {
|
||||
return filteredItemList;
|
||||
}
|
||||
|
||||
public int getRollingTimeInSeconds(int itemID) {
|
||||
|
||||
ItemTemplate ib = ItemTemplate.templates.get(itemID);
|
||||
|
||||
if (ib == null)
|
||||
return 0;
|
||||
|
||||
if (ItemTemplate.templates.get(itemID).item_type == ItemType.SCROLL)
|
||||
return this.getRank() * 60 * 60 * 3;
|
||||
|
||||
float time;
|
||||
|
||||
if (this.building == null)
|
||||
return 600;
|
||||
|
||||
float rank = this.building.getRank() - 1;
|
||||
float rate = (float) (2.5 * rank);
|
||||
time = (20 - rate);
|
||||
time *= 60;
|
||||
return (int) time;
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
|
||||
Building building;
|
||||
|
||||
Reference in New Issue
Block a user