Browse Source

EffectBase sources and fail conditions static maps removed

feature-config-usage
FatBoy-DOTC 3 months ago
parent
commit
c01c69db83
  1. 25
      src/engine/db/handlers/dbEffectsBaseHandler.java
  2. 26
      src/engine/db/handlers/dbPowerHandler.java
  3. 13
      src/engine/gameManager/PowersManager.java
  4. 2
      src/engine/objects/AbstractWorldObject.java
  5. 6
      src/engine/objects/Effect.java
  6. 69
      src/engine/powers/EffectsBase.java
  7. 2
      src/engine/wpak/data/EffectEntry.java

25
src/engine/db/handlers/dbEffectsBaseHandler.java

@ -20,7 +20,6 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
public class dbEffectsBaseHandler extends dbHandlerBase { public class dbEffectsBaseHandler extends dbHandlerBase {
@ -29,26 +28,6 @@ public class dbEffectsBaseHandler extends dbHandlerBase {
} }
public static ArrayList<EffectsBase> getAllEffectsBase() {
ArrayList<EffectsBase> 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() { public static void cacheAllEffectModifiers() {
String IDString; 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) { switch (modifier) {
case AdjustAboveDmgCap: case AdjustAboveDmgCap:
abstractEffectModifier = new AdjustAboveDmgCapEffectModifier(rs); abstractEffectModifier = new AdjustAboveDmgCapEffectModifier(rs);
@ -284,7 +263,7 @@ public class dbEffectsBaseHandler extends dbHandlerBase {
abstractEffectModifier = new ValueEffectModifier(rs); abstractEffectModifier = new ValueEffectModifier(rs);
if (effectBase != null) { if (effectBase != null) {
ValueEffectModifier valueEffect = (ValueEffectModifier) abstractEffectModifier; ValueEffectModifier valueEffect = (ValueEffectModifier) abstractEffectModifier;
effectBase.setValue(valueEffect.minMod); effectBase.value = valueEffect.minMod;
} }
break; break;
case WeaponProc: case WeaponProc:

26
src/engine/db/handlers/dbPowerHandler.java

@ -27,32 +27,6 @@ public class dbPowerHandler extends dbHandlerBase {
this.localClass = Mob.class; this.localClass = Mob.class;
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName()); 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() { public static void addAllAnimationOverrides() {
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();

13
src/engine/gameManager/PowersManager.java

@ -127,8 +127,15 @@ public enum PowersManager {
PowersManager.effectsBaseByIDString.put(effectBase.getIDString(), effectBase); PowersManager.effectsBaseByIDString.put(effectBase.getIDString(), effectBase);
} }
// Add Fail Conditions // Add Fail Conditions **Replace with parsed values from cfg file**
EffectsBase.getFailConditions(PowersManager.effectsBaseByIDString); 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 // This pre-loads all powers and effects
@ -140,9 +147,7 @@ public enum PowersManager {
InitializeEffects(); InitializeEffects();
// Add Source Types to Effects
dbPowerHandler.addAllSourceTypes();
dbPowerHandler.addAllAnimationOverrides();
// Add PowerActions // Add PowerActions
AbstractPowerAction.getAllPowerActions(PowersManager.powerActionsByIDString, PowersManager.powerActionsByID, PowersManager.effectsBaseByIDString); AbstractPowerAction.getAllPowerActions(PowersManager.powerActionsByIDString, PowersManager.powerActionsByID, PowersManager.effectsBaseByIDString);

2
src/engine/objects/AbstractWorldObject.java

@ -375,7 +375,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
if (eff == null) { if (eff == null) {
continue; continue;
} }
if (eff.containsSource(source) && trains >= eff.getTrains()) { if (eff.getEffectsBase().effectSources.contains(source) && trains >= eff.getTrains()) {
if (removeAll) { if (removeAll) {
//remove all effects of source type //remove all effects of source type
if (eff.cancel()) { if (eff.cancel()) {

6
src/engine/objects/Effect.java

@ -433,12 +433,6 @@ public class Effect {
return duration; return duration;
} }
public boolean containsSource(EffectSourceType source) {
if (this.eb != null)
return this.eb.containsSource(source);
return false;
}
public JobContainer getJobContainer() { public JobContainer getJobContainer() {
return this.jc; return this.jc;
} }

69
src/engine/powers/EffectsBase.java

@ -28,29 +28,24 @@ import engine.objects.AbstractCharacter;
import engine.objects.AbstractWorldObject; import engine.objects.AbstractWorldObject;
import engine.objects.Effect; import engine.objects.Effect;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
import engine.powers.effectmodifiers.AbstractEffectModifier; import engine.powers.effectmodifiers.*;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import engine.util.Hasher; import engine.util.Hasher;
import engine.wpak.data.EffectEntry; import engine.wpak.data.EffectEntry;
import engine.wpak.data.EffectModifier;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class EffectsBase { public class EffectsBase {
public static HashMap<Integer, HashSet<EffectSourceType>> effectSourceTypeMap = new HashMap<>();
public static HashMap<String, HashSet<AbstractEffectModifier>> modifiersMap = new HashMap<>(); public static HashMap<String, HashSet<AbstractEffectModifier>> modifiersMap = new HashMap<>();
public static HashMap<String, HashMap<String, ArrayList<String>>> OldEffectsMap = new HashMap<>();
public static HashMap<String, HashMap<String, ArrayList<String>>> NewEffectsMap = new HashMap<>();
public static HashMap<String, HashMap<String, ArrayList<String>>> ChangedEffectsMap = new HashMap<>();
public static HashMap<String, HashSet<PowerFailCondition>> EffectFailConditions = new HashMap<>();
public static HashMap<Integer, HashSet<mbEnums.DamageType>> EffectDamageTypes = new HashMap<>(); public static HashMap<Integer, HashSet<mbEnums.DamageType>> EffectDamageTypes = new HashMap<>();
public static HashSet<AbstractEffectModifier> DefaultModifiers = new HashSet<>(); public static HashSet<AbstractEffectModifier> DefaultModifiers = new HashSet<>();
private static ConcurrentHashMap<String, String> itemEffectsByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private static ConcurrentHashMap<String, String> 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 isPrefix = false; //used by items
private boolean isSuffix = false; //used by items private boolean isSuffix = false; //used by items
private String name = ""; private String name = "";
private float value = 0; public float value = 0;
private ConcurrentHashMap<mbEnums.ResourceType, Integer> resourceCosts = new ConcurrentHashMap<>(); private ConcurrentHashMap<mbEnums.ResourceType, Integer> resourceCosts = new ConcurrentHashMap<>();
private ConcurrentHashMap<String, Boolean> sourceTypes = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private ConcurrentHashMap<String, Boolean> sourceTypes = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
//loaded values from parser
public HashSet<EffectSourceType> effectSources = new HashSet<>();
public HashSet<EffectModifier> effectModifiers = new HashSet<>();
public HashSet<PowerFailCondition> effectFailCondition = new HashSet<>();
public HashSet<mbEnums.DamageType> effectDamageType = new HashSet<>();
/** /**
* No Table ID Constructor * No Table ID Constructor
*/ */
@ -118,6 +119,19 @@ public class EffectsBase {
this.isPrefix = true; this.isPrefix = true;
else if (this.IDString.startsWith("SUF-")) else if (this.IDString.startsWith("SUF-"))
this.isSuffix = true; 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) { public EffectsBase(EffectsBase copyEffect, int newToken, String IDString) {
@ -223,11 +237,7 @@ public class EffectsBase {
continue; continue;
} }
if (EffectsBase.EffectFailConditions.get(IDString) == null) {
EffectsBase.EffectFailConditions.put(IDString, new HashSet<>());
}
EffectsBase.EffectFailConditions.get(IDString).add(failCondition);
EffectsBase eb = effects.get(IDString); EffectsBase eb = effects.get(IDString);
switch (failCondition) { switch (failCondition) {
@ -359,10 +369,6 @@ public class EffectsBase {
this.token = token; this.token = token;
} }
public ConcurrentHashMap<String, Boolean> getSourceTypes() {
return this.sourceTypes;
}
public HashSet<AbstractEffectModifier> getModifiers() { public HashSet<AbstractEffectModifier> getModifiers() {
if (EffectsBase.modifiersMap.containsKey(this.IDString) == false) if (EffectsBase.modifiersMap.containsKey(this.IDString) == false)
@ -371,22 +377,6 @@ public class EffectsBase {
return EffectsBase.modifiersMap.get(this.IDString); 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() { public boolean isPrefix() {
return this.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() { public boolean cancelOnAttack() {
return this.cancelOnAttack; return this.cancelOnAttack;
} }
@ -742,12 +725,4 @@ public class EffectsBase {
this.name = name; this.name = name;
} }
public float getValue() {
return value;
}
public void setValue(float Value) {
this.value = Value;
}
} }

2
src/engine/wpak/data/EffectEntry.java

@ -8,6 +8,8 @@
package engine.wpak.data; package engine.wpak.data;
import engine.powers.effectmodifiers.AbstractEffectModifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;

Loading…
Cancel
Save