Browse Source

Comment cleanup

combat-2
MagicBot 7 months ago
parent
commit
9dd2e1d5e5
  1. 31
      src/engine/gameManager/ForgeManager.java

31
src/engine/gameManager/ForgeManager.java

@ -141,13 +141,12 @@ 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 cost from forge // Debit gold and resource costs
// and / or warehouse
if (!debitWorkOrderCost(workOrder)) if (!debitWorkOrderCost(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 in-memory items and add to collections // Create new batch of virtual items
forgeWorkOrderBatch(workOrder); forgeWorkOrderBatch(workOrder);
@ -193,7 +192,7 @@ public enum ForgeManager implements Runnable {
int availableSlots = workOrder.vendor.getRank(); int availableSlots = workOrder.vendor.getRank();
// Subtract slots currently being used by npc workOrders // Subtract slots currently assigned to npc workOrders
for (WorkOrder npcWorkOrder : ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor)) for (WorkOrder npcWorkOrder : ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor))
availableSlots = availableSlots - npcWorkOrder.cooking.size(); availableSlots = availableSlots - npcWorkOrder.cooking.size();
@ -208,7 +207,7 @@ public enum ForgeManager implements Runnable {
public static HashMap<mbEnums.ResourceType, Integer> calcProductionCost(WorkOrder workOrder) { public static HashMap<mbEnums.ResourceType, Integer> calcProductionCost(WorkOrder workOrder) {
// Calculate the production cost for a single run of this workOrder // Calculate production cost for a single run of this workOrder
HashMap<mbEnums.ResourceType, Integer> production_cost = new HashMap<>(); HashMap<mbEnums.ResourceType, Integer> production_cost = new HashMap<>();
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID);
@ -235,7 +234,7 @@ public enum ForgeManager implements Runnable {
public static Item forgeItem(WorkOrder workOrder) { public static Item forgeItem(WorkOrder workOrder) {
// Create new item from specified template // Create new virtual item from specified template
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID);
Item forgedItem = new Item(workOrder.templateID); Item forgedItem = new Item(workOrder.templateID);
@ -246,12 +245,12 @@ public enum ForgeManager implements Runnable {
forgedItem.containerType = mbEnums.ItemContainerType.FORGE; forgedItem.containerType = mbEnums.ItemContainerType.FORGE;
forgedItem.ownerID = workOrder.vendor.getObjectUUID(); forgedItem.ownerID = workOrder.vendor.getObjectUUID();
// The UpgradeDate for the item is serialized for the // item.upgradeDate is serialized (ItemProductionMsg)
// vendor forge window // for vendor forge window completion time.
forgedItem.setDateToUpgrade(workOrder.completionTime); forgedItem.setDateToUpgrade(workOrder.completionTime);
// Give prefix and suffix to this item if random rolled // Assign a prefix and suffix to this item if random rolled
if (workOrder.prefixToken == 0) if (workOrder.prefixToken == 0)
forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable); forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable);
@ -263,7 +262,7 @@ public enum ForgeManager implements Runnable {
else else
forgedItem.suffixToken = workOrder.suffixToken; forgedItem.suffixToken = workOrder.suffixToken;
// Forged random rolled items are unidentified until completed // Random rolled items are unidentified until completed
if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0)
forgedItem.flags.remove(mbEnums.ItemFlags.Identified); forgedItem.flags.remove(mbEnums.ItemFlags.Identified);
@ -315,15 +314,17 @@ public enum ForgeManager implements Runnable {
toRemove.add(virutalItem); toRemove.add(virutalItem);
} }
// Remove the virtual item from all collections
for (Item virtualItem : toRemove) { for (Item virtualItem : toRemove) {
// Remove the virtual items from the forge window // Remove virtual items from the forge window
ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true);
DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false);
// Remove virtual item from all collections
workOrder.cooking.remove(virtualItem); workOrder.cooking.remove(virtualItem);
itemWorkOrderLookup.remove(virtualItem); itemWorkOrderLookup.remove(virtualItem);
DbManager.removeFromCache(virtualItem); DbManager.removeFromCache(virtualItem);
@ -332,7 +333,7 @@ public enum ForgeManager implements Runnable {
public static void forgeWorkOrderBatch(WorkOrder workOrder) { public static void forgeWorkOrderBatch(WorkOrder workOrder) {
// New completion time for this batch // Completion time for this batch is in the future
workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration;
@ -347,7 +348,7 @@ public enum ForgeManager implements Runnable {
workOrder.total_produced = workOrder.total_produced + 1; workOrder.total_produced = workOrder.total_produced + 1;
} }
// Save updated status to disk // Save updated state to disk
DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder);
@ -355,6 +356,8 @@ public enum ForgeManager implements Runnable {
public static int calcRandomMod(NPC vendor, mbEnums.ItemModType itemModType, int modTable) { public static int calcRandomMod(NPC vendor, mbEnums.ItemModType itemModType, int modTable) {
// Random prefix or suffix token based on item.template.modtable
int modifier = 0; int modifier = 0;
ModTypeTableEntry modTypeTableEntry = null; ModTypeTableEntry modTypeTableEntry = null;
ModTableEntry modTableEntry = null; ModTableEntry modTableEntry = null;

Loading…
Cancel
Save