Usage of EffectsParser
This commit is contained in:
@@ -170,9 +170,9 @@ public enum ConfigManager {
|
||||
|
||||
Logger.info("Loading WPAK data");
|
||||
|
||||
EffectsParser.parseWpakFile();
|
||||
PowersParser.parseWpakFile();
|
||||
PowerActionParser.parseWpakFile();
|
||||
//EffectsParser.parseWpakFile();
|
||||
//PowersParser.parseWpakFile();
|
||||
//PowerActionParser.parseWpakFile();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@ import engine.objects.*;
|
||||
import engine.powers.*;
|
||||
import engine.powers.poweractions.AbstractPowerAction;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.wpak.EffectsParser;
|
||||
import engine.wpak.PowerActionParser;
|
||||
import engine.wpak.PowersParser;
|
||||
import engine.wpak.data.EffectEntry;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -112,23 +116,29 @@ public enum PowersManager {
|
||||
return powerEntries;
|
||||
}
|
||||
|
||||
// This pre-loads all powers and effects
|
||||
public static void InitializePowers() {
|
||||
|
||||
public static void InitializeEffects(){
|
||||
// Add EffectsBase
|
||||
ArrayList<EffectsBase> ebList = dbEffectsBaseHandler.getAllEffectsBase();
|
||||
|
||||
for (EffectsBase eb : ebList) {
|
||||
PowersManager.effectsBaseByToken.put(eb.getToken(), eb);
|
||||
PowersManager.effectsBaseByIDString.put(eb.getIDString(), eb);
|
||||
ArrayList<EffectsBase> effectList = new ArrayList<>();
|
||||
|
||||
for (EffectEntry entry : EffectsParser.effect_data.values()) {
|
||||
EffectsBase effectBase = new EffectsBase(entry);
|
||||
effectList.add(effectBase);
|
||||
PowersManager.effectsBaseByToken.put(effectBase.getToken(), effectBase);
|
||||
PowersManager.effectsBaseByIDString.put(effectBase.getIDString(), effectBase);
|
||||
}
|
||||
|
||||
// Add Fail Conditions
|
||||
EffectsBase.getFailConditions(PowersManager.effectsBaseByIDString);
|
||||
}
|
||||
|
||||
// Add Modifiers to Effects
|
||||
dbEffectsBaseHandler.cacheAllEffectModifiers();
|
||||
// This pre-loads all powers and effects
|
||||
public static void InitializePowers() {
|
||||
|
||||
EffectsParser.parseWpakFile();
|
||||
PowersParser.parseWpakFile();
|
||||
PowerActionParser.parseWpakFile();
|
||||
|
||||
InitializeEffects();
|
||||
|
||||
// Add Source Types to Effects
|
||||
dbPowerHandler.addAllSourceTypes();
|
||||
|
||||
@@ -30,6 +30,8 @@ import engine.objects.Effect;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.util.Hasher;
|
||||
import engine.wpak.data.EffectEntry;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -62,7 +64,7 @@ public class EffectsBase {
|
||||
// flags
|
||||
private boolean isItemEffect;
|
||||
private boolean isSpireEffect;
|
||||
private boolean ignoreMod;
|
||||
private boolean ignoreNoMod;
|
||||
private boolean dontSave;
|
||||
private boolean cancelOnAttack = false;
|
||||
private boolean cancelOnAttackSwing = false;
|
||||
@@ -91,6 +93,33 @@ public class EffectsBase {
|
||||
|
||||
}
|
||||
|
||||
//EffectEntry constructor
|
||||
public EffectsBase(EffectEntry entry) {
|
||||
this.IDString = entry.effect_id;
|
||||
this.name = entry.effect_name;
|
||||
this.token = Hasher.SBStringHash(entry.effect_name);
|
||||
|
||||
//override tokens for some effects like Safemode that use the Action Token instead of the effect Token,
|
||||
switch (this.IDString) {
|
||||
case "INVIS-D":
|
||||
this.token = -1661751254;
|
||||
break;
|
||||
case "SafeMode":
|
||||
this.token = -1661750486;
|
||||
break;
|
||||
|
||||
}
|
||||
this.isItemEffect = entry.isItemEffect;
|
||||
this.isSpireEffect = entry.isSpireEffect;
|
||||
this.ignoreNoMod = entry.ignoreNoMod;
|
||||
this.dontSave = entry.dontSave;
|
||||
|
||||
if (this.IDString.startsWith("PRE-"))
|
||||
this.isPrefix = true;
|
||||
else if (this.IDString.startsWith("SUF-"))
|
||||
this.isSuffix = true;
|
||||
}
|
||||
|
||||
public EffectsBase(EffectsBase copyEffect, int newToken, String IDString) {
|
||||
|
||||
UUID = NewID++;
|
||||
@@ -102,7 +131,7 @@ public class EffectsBase {
|
||||
int flags = 0;
|
||||
this.isItemEffect = ((flags & 1) != 0) ? true : false;
|
||||
this.isSpireEffect = ((flags & 2) != 0) ? true : false;
|
||||
this.ignoreMod = ((flags & 4) != 0) ? true : false;
|
||||
this.ignoreNoMod = ((flags & 4) != 0) ? true : false;
|
||||
this.dontSave = ((flags & 8) != 0) ? true : false;
|
||||
|
||||
if (this.IDString.startsWith("PRE-"))
|
||||
@@ -117,7 +146,7 @@ public class EffectsBase {
|
||||
this.amountRamp = copyEffect.amountRamp;
|
||||
this.isItemEffect = copyEffect.isItemEffect;
|
||||
this.isSpireEffect = copyEffect.isSpireEffect;
|
||||
this.ignoreMod = copyEffect.ignoreMod;
|
||||
this.ignoreNoMod = copyEffect.ignoreNoMod;
|
||||
this.dontSave = copyEffect.dontSave;
|
||||
this.cancelOnAttack = copyEffect.cancelOnAttack;
|
||||
this.cancelOnAttackSwing = copyEffect.cancelOnAttackSwing;
|
||||
@@ -163,7 +192,7 @@ public class EffectsBase {
|
||||
int flags = rs.getInt("flags");
|
||||
this.isItemEffect = ((flags & 1) != 0) ? true : false;
|
||||
this.isSpireEffect = ((flags & 2) != 0) ? true : false;
|
||||
this.ignoreMod = ((flags & 4) != 0) ? true : false;
|
||||
this.ignoreNoMod = ((flags & 4) != 0) ? true : false;
|
||||
this.dontSave = ((flags & 8) != 0) ? true : false;
|
||||
|
||||
if (this.IDString.startsWith("PRE-"))
|
||||
@@ -351,7 +380,7 @@ public class EffectsBase {
|
||||
}
|
||||
|
||||
public boolean ignoreMod() {
|
||||
return this.ignoreMod;
|
||||
return this.ignoreNoMod;
|
||||
}
|
||||
|
||||
public boolean dontSave() {
|
||||
|
||||
@@ -61,6 +61,11 @@ public class EffectsParser {
|
||||
EffectEntry effectEntry = new EffectEntry();
|
||||
|
||||
// Remove all lines that contain a # and leading/trailing blank lines
|
||||
effectEntry.isItemEffect = effectData.contains("IsItemEffect");
|
||||
effectEntry.isSpireEffect = effectData.contains("IsSpireEffect");
|
||||
effectEntry.ignoreNoMod = effectData.contains("IgnoreNoMod");
|
||||
effectEntry.dontSave = effectData.contains("DontSave");
|
||||
|
||||
|
||||
effectData = effectData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "");
|
||||
effectData = effectData.trim();
|
||||
|
||||
@@ -19,4 +19,9 @@ public class EffectEntry {
|
||||
public HashSet<String> sources = new HashSet<>();
|
||||
public ArrayList<EffectModifier> mods = new ArrayList<>();
|
||||
public HashMap<String, Float> conditions = new HashMap<>();
|
||||
|
||||
public boolean isItemEffect;
|
||||
public boolean isSpireEffect;
|
||||
public boolean ignoreNoMod;
|
||||
public boolean dontSave;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user