From 218de2bb70aed1bd97d2b2680832a9ccee1b8bf4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 17 Aug 2024 15:13:32 -0400 Subject: [PATCH] Support for multiple power enrties. --- src/engine/wpak/PowerData.java | 2 +- src/engine/wpak/PowerEntry.java | 2 +- src/engine/wpak/PowersParser.java | 64 ++++++++++++++++++------------- 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/src/engine/wpak/PowerData.java b/src/engine/wpak/PowerData.java index e325485c..1e8e686f 100644 --- a/src/engine/wpak/PowerData.java +++ b/src/engine/wpak/PowerData.java @@ -9,7 +9,7 @@ package engine.wpak; public class PowerData { - public String power; public String power_type; public int icon; + public String powerBase; } diff --git a/src/engine/wpak/PowerEntry.java b/src/engine/wpak/PowerEntry.java index 0077b6e9..1729d190 100644 --- a/src/engine/wpak/PowerEntry.java +++ b/src/engine/wpak/PowerEntry.java @@ -12,8 +12,8 @@ import java.util.ArrayList; public class PowerEntry { public String power_id; + public String power; public ArrayList powers = new ArrayList<>(); - public String powerbase; public String target_type; public int range; public String areaType; diff --git a/src/engine/wpak/PowersParser.java b/src/engine/wpak/PowersParser.java index 0bd3c1a3..ca34e430 100644 --- a/src/engine/wpak/PowersParser.java +++ b/src/engine/wpak/PowersParser.java @@ -42,7 +42,7 @@ public class PowersParser { } } - private static PowerEntry parsePowerEntry(String powerData) { + private static PowerEntry parsePowerEntry(String powerData) { PowerEntry powerEntry = new PowerEntry(); @@ -62,36 +62,48 @@ public class PowersParser { while (matcher.find()) powerHeader.add(matcher.group().trim()); - powerEntry.power_id = powerHeader.get(0); + java.util.Iterator iterator = powerHeader.iterator(); - if (powerHeader.size() != 22) - Logger.error(powerEntry.power_id); + powerEntry.power_id = iterator.next(); + powerEntry.power = iterator.next().replaceAll("\"", ""); PowerData power = new PowerData(); - - power.power = powerHeader.get(1).replaceAll("\"", ""); - power.power_type = powerHeader.get(2); - power.icon = Integer.parseInt(powerHeader.get(3)); + power.power_type = iterator.next(); + ; + power.icon = Integer.parseInt(iterator.next()); + power.powerBase = iterator.next().replaceAll("\"", ""); powerEntry.powers.add(power); - powerEntry.powerbase = powerHeader.get(4).replaceAll("\"", ""); - powerEntry.target_type = powerHeader.get(5); - powerEntry.range = Integer.parseInt(powerHeader.get(6)); - powerEntry.areaType = powerHeader.get(7); - powerEntry.areaRange = Integer.parseInt(powerHeader.get(8)); - powerEntry.excludeType = powerHeader.get(9); - powerEntry.costType = powerHeader.get(10); - powerEntry.cost = Float.parseFloat(powerHeader.get(11)); - powerEntry.difficulty = Integer.parseInt(powerHeader.get(12)); - powerEntry.precision = Integer.parseInt(powerHeader.get(13)); - powerEntry.init_time = Float.parseFloat(powerHeader.get(14)); - powerEntry.release_time = Float.parseFloat(powerHeader.get(15)); - powerEntry.recycle_time = Float.parseFloat(powerHeader.get(16)); - powerEntry.hitRollYN = Integer.parseInt(powerHeader.get(17)); - powerEntry.castingMode = powerHeader.get(18); - powerEntry.initAmin = Integer.parseInt(powerHeader.get(19)); - powerEntry.releaseAnim = Integer.parseInt(powerHeader.get(20)); - powerEntry.targetSelect = powerHeader.get(21); + powerEntry.target_type = iterator.next(); + + // Account for second definition + + if (powerEntry.target_type.equals("SPELL") || + powerEntry.target_type.equals("SKILL")) { + power = new PowerData(); + power.power_type = powerEntry.target_type; + power.icon = Integer.parseInt(iterator.next()); + power.powerBase = iterator.next().replaceAll("\"", ""); + powerEntry.powers.add(power); + powerEntry.target_type = iterator.next(); + } + + powerEntry.range = Integer.parseInt(iterator.next()); + powerEntry.areaType = iterator.next(); + powerEntry.areaRange = Integer.parseInt(iterator.next()); + powerEntry.excludeType = iterator.next(); + powerEntry.costType = iterator.next(); + powerEntry.cost = Float.parseFloat(iterator.next()); + powerEntry.difficulty = Integer.parseInt(iterator.next()); + powerEntry.precision = Integer.parseInt(iterator.next()); + powerEntry.init_time = Float.parseFloat(iterator.next()); + powerEntry.release_time = Float.parseFloat(iterator.next()); + powerEntry.recycle_time = Float.parseFloat(iterator.next()); + powerEntry.hitRollYN = Integer.parseInt(iterator.next()); + powerEntry.castingMode = iterator.next(); + powerEntry.initAmin = Integer.parseInt(iterator.next()); + powerEntry.releaseAnim = Integer.parseInt(iterator.next()); + powerEntry.targetSelect = iterator.next(); for (int x = 2; x < powerEntries.length; x++) {