From f0c6584818c9c0466cf4fe6de75d664d8ef0f061 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 21 Aug 2024 12:35:01 -0400 Subject: [PATCH] pojo created for ConditionEntry --- src/engine/wpak/EffectsParser.java | 22 +++++++++++++++++----- src/engine/wpak/data/ConditionEntry.java | 21 +++++++++++++++++++++ src/engine/wpak/data/EffectEntry.java | 3 +-- 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 src/engine/wpak/data/ConditionEntry.java diff --git a/src/engine/wpak/EffectsParser.java b/src/engine/wpak/EffectsParser.java index ee4490bf..90bc11c9 100644 --- a/src/engine/wpak/EffectsParser.java +++ b/src/engine/wpak/EffectsParser.java @@ -10,6 +10,7 @@ package engine.wpak; import engine.gameManager.ConfigManager; import engine.mbEnums; +import engine.wpak.data.ConditionEntry; import engine.wpak.data.EffectEntry; import engine.wpak.data.EffectModifier; import org.pmw.tinylog.Logger; @@ -17,8 +18,7 @@ import org.pmw.tinylog.Logger; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -125,11 +125,23 @@ public class EffectsParser { matcher = CONDITIONS_REGEX.matcher(effectData); while (matcher.find()) { - String[] conditions = matcher.group().trim().split("\n"); + List conditions = new ArrayList<>(Arrays.asList(matcher.group().trim().split("\n"))); for (String condition : conditions) { - String[] parameters = condition.trim().split("\\s+"); - effectEntry.conditions.put(parameters[0], Float.parseFloat(parameters[1])); + List parameters = new ArrayList<>(Arrays.asList(condition.trim().split("\\s+"))); + Iterator iterator = parameters.iterator(); + + ConditionEntry conditionEntry = new ConditionEntry(); + conditionEntry.condition = iterator.next(); + conditionEntry.arg = Integer.parseInt(iterator.next()); + + if (iterator.hasNext()) + conditionEntry.curveType = mbEnums.CompoundCurveType.valueOf(iterator.next()); + + while (iterator.hasNext()) + conditionEntry.damageTypes.add(mbEnums.DamageType.valueOf(iterator.next())); + + effectEntry.conditions.add(conditionEntry); } } diff --git a/src/engine/wpak/data/ConditionEntry.java b/src/engine/wpak/data/ConditionEntry.java new file mode 100644 index 00000000..0c3eda2c --- /dev/null +++ b/src/engine/wpak/data/ConditionEntry.java @@ -0,0 +1,21 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2024 +// www.magicbane.com +// +package engine.wpak.data; + +import engine.mbEnums; + +import java.util.EnumSet; + +public class ConditionEntry { + public String condition; + public int arg; + public mbEnums.CompoundCurveType curveType; + public EnumSet damageTypes = EnumSet.noneOf(mbEnums.DamageType.class); + +} diff --git a/src/engine/wpak/data/EffectEntry.java b/src/engine/wpak/data/EffectEntry.java index ac027f23..9961faad 100644 --- a/src/engine/wpak/data/EffectEntry.java +++ b/src/engine/wpak/data/EffectEntry.java @@ -9,7 +9,6 @@ package engine.wpak.data; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; public class EffectEntry { @@ -18,7 +17,7 @@ public class EffectEntry { public int icon; public HashSet sources = new HashSet<>(); public ArrayList mods = new ArrayList<>(); - public HashMap conditions = new HashMap<>(); + public ArrayList conditions = new ArrayList<>(); public boolean isItemEffect; public boolean isSpireEffect;