Browse Source

Parsing conditions

feature-config-parsing2
MagicBot 3 months ago
parent
commit
f8b9c97730
  1. 3
      src/engine/ConfigParsing/EffectEntry/EffectEntry.java
  2. 11
      src/engine/ConfigParsing/EffectsParser.java

3
src/engine/ConfigParsing/EffectEntry/EffectEntry.java

@ -1,6 +1,7 @@
package engine.ConfigParsing.EffectEntry; package engine.ConfigParsing.EffectEntry;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
public class EffectEntry { public class EffectEntry {
@ -9,5 +10,5 @@ public class EffectEntry {
public int icon; public int icon;
public HashSet<String> sources = new HashSet<>(); public HashSet<String> sources = new HashSet<>();
public ArrayList<EffectModifier> mods = new ArrayList<>(); public ArrayList<EffectModifier> mods = new ArrayList<>();
public HashSet<String> conditions = new HashSet<>(); public HashMap<String, Float> conditions = new HashMap<>();
} }

11
src/engine/ConfigParsing/EffectsParser.java

@ -28,6 +28,7 @@ public class EffectsParser {
public static HashMap<String, EffectEntry> effect_data = new HashMap<>(); public static HashMap<String, EffectEntry> effect_data = new HashMap<>();
private static final Pattern EFFECT_REGEX = Pattern.compile("(?<=EFFECTBEGIN)(.+?)(?=EFFECTEND)", Pattern.DOTALL); private static final Pattern EFFECT_REGEX = Pattern.compile("(?<=EFFECTBEGIN)(.+?)(?=EFFECTEND)", Pattern.DOTALL);
private static final Pattern SOURCE_REGEX = Pattern.compile("(?<=SOURCEBEGIN)(.+?)(?=SOURCEEND)", Pattern.DOTALL); private static final Pattern SOURCE_REGEX = Pattern.compile("(?<=SOURCEBEGIN)(.+?)(?=SOURCEEND)", Pattern.DOTALL);
private static final Pattern CONDITIONS_REGEX = Pattern.compile("(?<=CONDITIONBEGIN)(.+?)(?=CONDITIONEND)", Pattern.DOTALL);
private static final Pattern MODS_REGEX = Pattern.compile("(?<=MODSBEGIN)(.+?)(?=MODSEND)", Pattern.DOTALL); private static final Pattern MODS_REGEX = Pattern.compile("(?<=MODSBEGIN)(.+?)(?=MODSEND)", Pattern.DOTALL);
private static final Pattern STRSPLIT_REGEX = Pattern.compile("([^\"]\\S*|\"[^\"]*\")\\s*"); private static final Pattern STRSPLIT_REGEX = Pattern.compile("([^\"]\\S*|\"[^\"]*\")\\s*");
@ -107,6 +108,16 @@ public class EffectsParser {
effectEntry.mods.add(effectModifier); effectEntry.mods.add(effectModifier);
} }
// Parse Conditions
matcher = CONDITIONS_REGEX.matcher(effectData);
while (matcher.find()) {
String[] condition = matcher.group().split(" ");
effectEntry.conditions.put(condition[0].trim(), Float.parseFloat(condition[1]));
}
return effectEntry; return effectEntry;
} }

Loading…
Cancel
Save