diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ee7993e8..66599457 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -11,7 +11,9 @@ package engine.gameManager; import engine.loot.WorkOrder; import engine.mbEnums; import engine.objects.Item; +import engine.objects.ItemTemplate; import engine.objects.PlayerCharacter; +import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; import java.util.HashMap; @@ -89,9 +91,15 @@ public enum ForgeManager implements Runnable { workOrder.workOrderID = wordOrderCounter.incrementAndGet(); workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrder.slotCount = calcAvailableSlots(workOrder); - workOrder.production_cost = calcProductionCost(workOrder); workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); + // Cost to execute this workOrder + + workOrder.production_cost = calcProductionCost(workOrder); + + for (mbEnums.ResourceType resourceType : workOrder.production_cost.keySet()) + workOrder.production_cost.compute(resourceType, (k, resourceValue) -> resourceValue * workOrder.total_to_produce); + // Single item rolls are total_to_produce of 0; if (workOrder.slotCount > 0 && workOrder.total_to_produce == 0) @@ -149,7 +157,28 @@ public enum ForgeManager implements Runnable { } public static HashMap calcProductionCost(WorkOrder workOrder) { + HashMap production_cost = new HashMap<>(); + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + + // Add gold and resource costs from template + + production_cost.put(mbEnums.ResourceType.GOLD, template.item_value); + production_cost.putAll(template.item_resource_cost); + + // Calculate cost of prefix and suffix + + if (workOrder.prefixToken != 0) { + EffectsBase prefix = PowersManager.getEffectByToken(workOrder.prefixToken); + EffectsBase prefixValue = PowersManager.getEffectByIDString(prefix.getIDString() + 'A'); + production_cost.putAll(prefixValue.getResourcesForEffect()); + } + + if (workOrder.suffixToken != 0) { + EffectsBase suffix = PowersManager.getEffectByToken(workOrder.suffixToken); + EffectsBase suffixValue = PowersManager.getEffectByIDString(suffix.getIDString() + 'A'); + production_cost.putAll(suffixValue.getResourcesForEffect()); + } return production_cost; } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 87ca5455..dd4b20ab 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -28,6 +28,7 @@ public class WorkOrder implements Delayed { public int total_to_produce; public int total_produced; public HashMap production_cost = new HashMap<>(); + public HashMap production_cost_total = new HashMap<>(); public int templateID; public String itemName; public int prefixToken;