Browse Source

Persisting effects in complete item

combat-2
MagicBot 8 months ago
parent
commit
98d03620bc
  1. 28
      src/engine/gameManager/ForgeManager.java
  2. 25
      src/engine/gameManager/ItemManager.java
  3. 8
      src/engine/net/client/handlers/ItemProductionMsgHandler.java

28
src/engine/gameManager/ForgeManager.java

@ -101,7 +101,7 @@ public enum ForgeManager implements Runnable {
public static int submit(WorkOrder workOrder) { public static int submit(WorkOrder workOrder) {
int validation_result = ForgeManager.validate(workOrder); int validation_result = ItemManager.validate(workOrder);
if (validation_result != 0) if (validation_result != 0)
return validation_result; return validation_result;
@ -154,30 +154,6 @@ public enum ForgeManager implements Runnable {
return validation_result; return validation_result;
} }
public static int validate(WorkOrder workOrder) {
int validation_result = 0;
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID);
if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt))
return 30; //30: That person cannot carry that item
if (!workOrder.vendor.getItemModTable().contains((template.modTable)))
return 59; //59: This hireling does not have this formula
if (!Warehouse.calcCostOverrun(workOrder).isEmpty())
return 10; //18: You can't really afford that
// Forge must be protected in order to access warehouse.
if (calcProductionCost(workOrder).size() > 1)
if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED))
return 193; //193: Production denied: This building must be protected to gain access to warehouse
return validation_result;
}
public static long calcRollingDuration(WorkOrder workOrder) { public static long calcRollingDuration(WorkOrder workOrder) {
float rollingDuration; float rollingDuration;
@ -284,7 +260,7 @@ public enum ForgeManager implements Runnable {
return forgedItem; return forgedItem;
} }
private static void applyItemEffects(Item forgedItem) { public static void applyItemEffects(Item forgedItem) {
if (forgedItem.prefixToken != 0) { if (forgedItem.prefixToken != 0) {
EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken); EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken);

25
src/engine/gameManager/ItemManager.java

@ -1,5 +1,6 @@
package engine.gameManager; package engine.gameManager;
import engine.loot.WorkOrder;
import engine.mbEnums; import engine.mbEnums;
import engine.objects.*; import engine.objects.*;
import engine.powers.poweractions.AbstractPowerAction; import engine.powers.poweractions.AbstractPowerAction;
@ -235,4 +236,28 @@ public enum ItemManager {
abstractPowerAction.applyEffectForItem(item, 0); abstractPowerAction.applyEffectForItem(item, 0);
item.getEffectNames().add(powerAction); item.getEffectNames().add(powerAction);
} }
public static int validate(WorkOrder workOrder) {
int validation_result = 0;
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID);
if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt))
return 30; //30: That person cannot carry that item
if (!workOrder.vendor.getItemModTable().contains((template.modTable)))
return 59; //59: This hireling does not have this formula
if (!Warehouse.calcCostOverrun(workOrder).isEmpty())
return 10; //18: You can't really afford that
// Forge must be protected in order to access warehouse.
if (ForgeManager.calcProductionCost(workOrder).size() > 1)
if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED))
return 193; //193: Production denied: This building must be protected to gain access to warehouse
return validation_result;
}
} }

8
src/engine/net/client/handlers/ItemProductionMsgHandler.java

@ -153,6 +153,14 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
// Persist item and add to vendor inventory // Persist item and add to vendor inventory
Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem);
// Apply Item effects for Prefix and Suffix tokens
completedItem.prefixToken = virtualItem.prefixToken;
completedItem.suffixToken = virtualItem.suffixToken;
ForgeManager.applyItemEffects(completedItem);
vendor.charItemManager.addItemToInventory(completedItem); vendor.charItemManager.addItemToInventory(completedItem);
ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true);

Loading…
Cancel
Save