From b0f8c758e53c6a7f2e577fb92735f651593d642e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 11 Mar 2024 11:29:41 -0400 Subject: [PATCH] Refactor baked in stats --- src/engine/objects/Item.java | 9 +-------- src/engine/objects/ItemBase.java | 8 -------- src/engine/objects/MobEquipment.java | 10 +++------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 15323491..34b54ab7 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -30,7 +30,6 @@ import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantLock; @@ -270,7 +269,7 @@ public class Item extends AbstractWorldObject { writer.putInt(36); //Magical, blue name else writer.putInt(40); //Magical, unidentified - else if (item.getItemBase().getBakedInStats().size() > 0) + else if (item.template.item_user_power_action.size() > 0) writer.putInt(36); //Magical, blue name else writer.putInt(4); //Non-Magical, grey name @@ -1064,12 +1063,6 @@ public class Item extends AbstractWorldObject { this.magicValue = this.template.item_value + calcMagicValue(); } - public HashMap getBakedInStats() { - if (this.getItemBase() != null) - return this.getItemBase().getBakedInStats(); - return null; - } - public void clearEnchantments() { //Clear permanent enchantment out of database diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index b19207c0..7b089306 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -44,9 +44,6 @@ public class ItemBase { private final String mastery; private final engine.Enum.SourceType damageType; private boolean isConsumable; - - // Item stat modifiers - private final HashMap bakedInStats = new HashMap<>(); private final HashMap usedStats = new HashMap<>(); private final boolean isStrBased; private ArrayList animations = new ArrayList<>(); @@ -166,11 +163,6 @@ public class ItemBase { return ID > 7000099 && ID < 7000281; } - //returns powers tokens baked in to item - public HashMap getBakedInStats() { - return this.bakedInStats; - } - //returns power tokens granted when using item, such as scrolls and potions public HashMap getUsedStats() { return this.usedStats; diff --git a/src/engine/objects/MobEquipment.java b/src/engine/objects/MobEquipment.java index 098e206c..ebd9811f 100644 --- a/src/engine/objects/MobEquipment.java +++ b/src/engine/objects/MobEquipment.java @@ -229,17 +229,13 @@ public class MobEquipment extends AbstractGameObject { if (itemBase != null) - for (Integer token : itemBase.getBakedInStats().keySet()) { + for (String effectID : this.template.item_user_power_action.keySet()) { - EffectsBase effect = PowersManager.getEffectByToken(token); + AbstractPowerAction apa = PowersManager.getPowerActionByIDString(effectID); - AbstractPowerAction apa = PowersManager.getPowerActionByIDString(effect.getIDString()); if (apa.getEffectsBase() != null) - if (apa.getEffectsBase().getValue() > 0) { - //System.out.println(apa.getEffectsBase().getValue()); + if (apa.getEffectsBase().getValue() > 0) value += apa.getEffectsBase().getValue(); - } - if (apa.getEffectsBase2() != null) value += apa.getEffectsBase2().getValue();