diff --git a/src/engine/db/handlers/dbEffectsBaseHandler.java b/src/engine/db/handlers/dbEffectsBaseHandler.java index cdfd76e0..587b6b6b 100644 --- a/src/engine/db/handlers/dbEffectsBaseHandler.java +++ b/src/engine/db/handlers/dbEffectsBaseHandler.java @@ -20,7 +20,6 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.HashSet; public class dbEffectsBaseHandler extends dbHandlerBase { @@ -29,26 +28,6 @@ public class dbEffectsBaseHandler extends dbHandlerBase { } - public static ArrayList getAllEffectsBase() { - - ArrayList effectList = new ArrayList<>(); - - try (Connection connection = DbManager.getConnection(); - PreparedStatement prepareStatement = connection.prepareStatement("SELECT * FROM static_power_effectbase ORDER BY `IDString` DESC")) { - - ResultSet rs = prepareStatement.executeQuery(); - - while (rs.next()) { - EffectsBase effectBase = new EffectsBase(rs); - effectList.add(effectBase); - } - } catch (SQLException e) { - Logger.error(e.toString()); - } - - return effectList; - } - public static void cacheAllEffectModifiers() { String IDString; @@ -86,7 +65,7 @@ public class dbEffectsBaseHandler extends dbHandlerBase { } - private static AbstractEffectModifier getCombinedModifiers(AbstractEffectModifier abstractEffectModifier, ResultSet rs, EffectsBase effectBase, mbEnums.ModType modifier) throws SQLException { + public static AbstractEffectModifier getCombinedModifiers(AbstractEffectModifier abstractEffectModifier, ResultSet rs, EffectsBase effectBase, mbEnums.ModType modifier) throws SQLException { switch (modifier) { case AdjustAboveDmgCap: abstractEffectModifier = new AdjustAboveDmgCapEffectModifier(rs); @@ -284,7 +263,7 @@ public class dbEffectsBaseHandler extends dbHandlerBase { abstractEffectModifier = new ValueEffectModifier(rs); if (effectBase != null) { ValueEffectModifier valueEffect = (ValueEffectModifier) abstractEffectModifier; - effectBase.setValue(valueEffect.minMod); + effectBase.value = valueEffect.minMod; } break; case WeaponProc: diff --git a/src/engine/db/handlers/dbPowerHandler.java b/src/engine/db/handlers/dbPowerHandler.java index 5a007924..65665818 100644 --- a/src/engine/db/handlers/dbPowerHandler.java +++ b/src/engine/db/handlers/dbPowerHandler.java @@ -27,32 +27,6 @@ public class dbPowerHandler extends dbHandlerBase { this.localClass = Mob.class; this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName()); } - - public static void addAllSourceTypes() { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_sourcetype")) { - - ResultSet rs = preparedStatement.executeQuery(); - String IDString, source; - - while (rs.next()) { - IDString = rs.getString("IDString"); - int token = DbManager.hasher.SBStringHash(IDString); - - source = rs.getString("source").replace("-", "").trim(); - mbEnums.EffectSourceType effectSourceType = mbEnums.EffectSourceType.GetEffectSourceType(source); - - if (EffectsBase.effectSourceTypeMap.containsKey(token) == false) - EffectsBase.effectSourceTypeMap.put(token, new HashSet<>()); - - EffectsBase.effectSourceTypeMap.get(token).add(effectSourceType); - } - } catch (Exception e) { - Logger.error(e); - } - } - public static void addAllAnimationOverrides() { try (Connection connection = DbManager.getConnection(); diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index a98dfc60..33abfd68 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -127,8 +127,15 @@ public enum PowersManager { PowersManager.effectsBaseByIDString.put(effectBase.getIDString(), effectBase); } - // Add Fail Conditions + // Add Fail Conditions **Replace with parsed values from cfg file** EffectsBase.getFailConditions(PowersManager.effectsBaseByIDString); + + // Add Modifiers to Effects **Replace with parsed values from cfg file** + dbEffectsBaseHandler.cacheAllEffectModifiers(); + + // Add Source Types to Effects **Replace with parsed values from cfg file** + //dbPowerHandler.addAllSourceTypes(); + dbPowerHandler.addAllAnimationOverrides(); } // This pre-loads all powers and effects @@ -140,9 +147,7 @@ public enum PowersManager { InitializeEffects(); - // Add Source Types to Effects - dbPowerHandler.addAllSourceTypes(); - dbPowerHandler.addAllAnimationOverrides(); + // Add PowerActions AbstractPowerAction.getAllPowerActions(PowersManager.powerActionsByIDString, PowersManager.powerActionsByID, PowersManager.effectsBaseByIDString); diff --git a/src/engine/objects/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index 12d867f9..f7834856 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -375,7 +375,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject { if (eff == null) { continue; } - if (eff.containsSource(source) && trains >= eff.getTrains()) { + if (eff.getEffectsBase().effectSources.contains(source) && trains >= eff.getTrains()) { if (removeAll) { //remove all effects of source type if (eff.cancel()) { diff --git a/src/engine/objects/Effect.java b/src/engine/objects/Effect.java index 22165e4b..4804dd50 100644 --- a/src/engine/objects/Effect.java +++ b/src/engine/objects/Effect.java @@ -433,12 +433,6 @@ public class Effect { return duration; } - public boolean containsSource(EffectSourceType source) { - if (this.eb != null) - return this.eb.containsSource(source); - return false; - } - public JobContainer getJobContainer() { return this.jc; } diff --git a/src/engine/powers/EffectsBase.java b/src/engine/powers/EffectsBase.java index ed1f3ce7..18d9cf6e 100644 --- a/src/engine/powers/EffectsBase.java +++ b/src/engine/powers/EffectsBase.java @@ -28,29 +28,24 @@ import engine.objects.AbstractCharacter; import engine.objects.AbstractWorldObject; import engine.objects.Effect; import engine.objects.PlayerCharacter; -import engine.powers.effectmodifiers.AbstractEffectModifier; +import engine.powers.effectmodifiers.*; import engine.server.MBServerStatics; import engine.util.Hasher; import engine.wpak.data.EffectEntry; +import engine.wpak.data.EffectModifier; import org.pmw.tinylog.Logger; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; public class EffectsBase { - public static HashMap> effectSourceTypeMap = new HashMap<>(); public static HashMap> modifiersMap = new HashMap<>(); - public static HashMap>> OldEffectsMap = new HashMap<>(); - public static HashMap>> NewEffectsMap = new HashMap<>(); - public static HashMap>> ChangedEffectsMap = new HashMap<>(); - public static HashMap> EffectFailConditions = new HashMap<>(); public static HashMap> EffectDamageTypes = new HashMap<>(); public static HashSet DefaultModifiers = new HashSet<>(); private static ConcurrentHashMap itemEffectsByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); @@ -82,10 +77,16 @@ public class EffectsBase { private boolean isPrefix = false; //used by items private boolean isSuffix = false; //used by items private String name = ""; - private float value = 0; + public float value = 0; private ConcurrentHashMap resourceCosts = new ConcurrentHashMap<>(); private ConcurrentHashMap sourceTypes = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); + //loaded values from parser + public HashSet effectSources = new HashSet<>(); + public HashSet effectModifiers = new HashSet<>(); + public HashSet effectFailCondition = new HashSet<>(); + public HashSet effectDamageType = new HashSet<>(); + /** * No Table ID Constructor */ @@ -118,6 +119,19 @@ public class EffectsBase { this.isPrefix = true; else if (this.IDString.startsWith("SUF-")) this.isSuffix = true; + + //load effect modifiers + this.effectModifiers = new HashSet<>(entry.mods); + + //load sources + for(String source : entry.sources) + this.effectSources.add(EffectSourceType.GetEffectSourceType(source)); + + //load fail conditions + for(String condition : entry.conditions.keySet()) + this.effectFailCondition.add(PowerFailCondition.valueOf(condition)); + + //TODO load damage types and slopes from conditions } public EffectsBase(EffectsBase copyEffect, int newToken, String IDString) { @@ -223,11 +237,7 @@ public class EffectsBase { continue; } - if (EffectsBase.EffectFailConditions.get(IDString) == null) { - EffectsBase.EffectFailConditions.put(IDString, new HashSet<>()); - } - EffectsBase.EffectFailConditions.get(IDString).add(failCondition); EffectsBase eb = effects.get(IDString); switch (failCondition) { @@ -359,10 +369,6 @@ public class EffectsBase { this.token = token; } - public ConcurrentHashMap getSourceTypes() { - return this.sourceTypes; - } - public HashSet getModifiers() { if (EffectsBase.modifiersMap.containsKey(this.IDString) == false) @@ -371,22 +377,6 @@ public class EffectsBase { return EffectsBase.modifiersMap.get(this.IDString); } - public boolean isItemEffect() { - return this.isItemEffect; - } - - public boolean isSpireEffect() { - return this.isSpireEffect; - } - - public boolean ignoreMod() { - return this.ignoreNoMod; - } - - public boolean dontSave() { - return this.dontSave; - } - public boolean isPrefix() { return this.isPrefix; } @@ -668,13 +658,6 @@ public class EffectsBase { } } - public boolean containsSource(EffectSourceType sourceType) { - if (EffectsBase.effectSourceTypeMap.containsKey(this.token) == false) - return false; - return EffectsBase.effectSourceTypeMap.get(this.token).contains(sourceType); - - } - public boolean cancelOnAttack() { return this.cancelOnAttack; } @@ -742,12 +725,4 @@ public class EffectsBase { this.name = name; } - public float getValue() { - return value; - } - - public void setValue(float Value) { - this.value = Value; - } - } diff --git a/src/engine/wpak/data/EffectEntry.java b/src/engine/wpak/data/EffectEntry.java index ac027f23..09475f34 100644 --- a/src/engine/wpak/data/EffectEntry.java +++ b/src/engine/wpak/data/EffectEntry.java @@ -8,6 +8,8 @@ package engine.wpak.data; +import engine.powers.effectmodifiers.AbstractEffectModifier; + import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet;