From e60a7a5ac01dbd277ab5cbe28ce649eed3ad6e2a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 19 Aug 2024 21:11:53 -0400 Subject: [PATCH] PowerActionEntry parsing work. --- src/engine/wpak/PowerActionParser.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/engine/wpak/PowerActionParser.java b/src/engine/wpak/PowerActionParser.java index faf44bab..b6704a6f 100644 --- a/src/engine/wpak/PowerActionParser.java +++ b/src/engine/wpak/PowerActionParser.java @@ -9,6 +9,7 @@ package engine.wpak; import engine.gameManager.ConfigManager; +import engine.wpak.data.EffectDescription; import engine.wpak.data.PowerActionEntry; import java.io.IOException; @@ -54,6 +55,8 @@ public class PowerActionParser { private static PowerActionEntry parsePowerActionEntry(String powerActionData) { PowerActionEntry powerActionEntry = new PowerActionEntry(); + EffectDescription effectDescription; + // Remove all lines that contain a # and leading/trailing blank lines powerActionData = powerActionData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "").trim(); @@ -62,9 +65,9 @@ public class PowerActionParser { // Parse effect entry header - Iterator iterator = Arrays.stream(lineData).iterator(); + Iterator entryIterator = Arrays.stream(lineData).iterator(); - String headerLine = iterator.next().toString(); + String headerLine = entryIterator.next(); ArrayList headerData = new ArrayList<>(); Matcher matcher = STRSPLIT_REGEX.matcher(headerLine.trim()); @@ -72,6 +75,17 @@ public class PowerActionParser { while (matcher.find()) headerData.add(matcher.group().trim()); + Iterator headerIterator = headerData.iterator(); + + powerActionEntry.action_id = headerIterator.next(); + powerActionEntry.action_type = headerIterator.next(); + + while (headerIterator.hasNext()) { + effectDescription = new EffectDescription(); + effectDescription.effect_id = headerIterator.next(); + effectDescription.level = Integer.parseInt(headerIterator.next()); + } + return powerActionEntry; } }