From f8b9c97730c8776c76ae386a94e3ddc3885e0b86 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 12 Aug 2024 11:01:27 -0400 Subject: [PATCH] Parsing conditions --- src/engine/ConfigParsing/EffectEntry/EffectEntry.java | 3 ++- src/engine/ConfigParsing/EffectsParser.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/engine/ConfigParsing/EffectEntry/EffectEntry.java b/src/engine/ConfigParsing/EffectEntry/EffectEntry.java index 429f8c2a..0a74a792 100644 --- a/src/engine/ConfigParsing/EffectEntry/EffectEntry.java +++ b/src/engine/ConfigParsing/EffectEntry/EffectEntry.java @@ -1,6 +1,7 @@ package engine.ConfigParsing.EffectEntry; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; public class EffectEntry { @@ -9,5 +10,5 @@ public class EffectEntry { public int icon; public HashSet sources = new HashSet<>(); public ArrayList mods = new ArrayList<>(); - public HashSet conditions = new HashSet<>(); + public HashMap conditions = new HashMap<>(); } diff --git a/src/engine/ConfigParsing/EffectsParser.java b/src/engine/ConfigParsing/EffectsParser.java index 28c84961..2f576fae 100644 --- a/src/engine/ConfigParsing/EffectsParser.java +++ b/src/engine/ConfigParsing/EffectsParser.java @@ -28,6 +28,7 @@ public class EffectsParser { public static HashMap effect_data = new HashMap<>(); 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 CONDITIONS_REGEX = Pattern.compile("(?<=CONDITIONBEGIN)(.+?)(?=CONDITIONEND)", Pattern.DOTALL); private static final Pattern MODS_REGEX = Pattern.compile("(?<=MODSBEGIN)(.+?)(?=MODSEND)", Pattern.DOTALL); private static final Pattern STRSPLIT_REGEX = Pattern.compile("([^\"]\\S*|\"[^\"]*\")\\s*"); @@ -107,6 +108,16 @@ public class EffectsParser { 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; }