Browse Source

pojo created for ConditionEntry

feature-config-parsing2
MagicBot 3 months ago
parent
commit
f0c6584818
  1. 22
      src/engine/wpak/EffectsParser.java
  2. 21
      src/engine/wpak/data/ConditionEntry.java
  3. 3
      src/engine/wpak/data/EffectEntry.java

22
src/engine/wpak/EffectsParser.java

@ -10,6 +10,7 @@ package engine.wpak; @@ -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; @@ -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 { @@ -125,11 +125,23 @@ public class EffectsParser {
matcher = CONDITIONS_REGEX.matcher(effectData);
while (matcher.find()) {
String[] conditions = matcher.group().trim().split("\n");
List<String> 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<String> parameters = new ArrayList<>(Arrays.asList(condition.trim().split("\\s+")));
Iterator<String> 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);
}
}

21
src/engine/wpak/data/ConditionEntry.java

@ -0,0 +1,21 @@ @@ -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<mbEnums.DamageType> damageTypes = EnumSet.noneOf(mbEnums.DamageType.class);
}

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

@ -9,7 +9,6 @@ @@ -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 { @@ -18,7 +17,7 @@ public class EffectEntry {
public int icon;
public HashSet<String> sources = new HashSet<>();
public ArrayList<EffectModifier> mods = new ArrayList<>();
public HashMap<String, Float> conditions = new HashMap<>();
public ArrayList<ConditionEntry> conditions = new ArrayList<>();
public boolean isItemEffect;
public boolean isSpireEffect;

Loading…
Cancel
Save