From d06ce44bd50ff7bf32da0c5728991311fbf75045 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 17 Aug 2024 15:58:48 -0400 Subject: [PATCH] Enum work --- src/engine/mbEnums.java | 12 ++++++++++++ src/engine/wpak/PowerData.java | 4 +++- src/engine/wpak/PowerEntry.java | 4 +++- src/engine/wpak/PowersParser.java | 14 ++++++++------ 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/engine/mbEnums.java b/src/engine/mbEnums.java index c75d7a05..46a451dd 100644 --- a/src/engine/mbEnums.java +++ b/src/engine/mbEnums.java @@ -3022,5 +3022,17 @@ public class mbEnums { PREFIX, SUFFIX; } + + public enum PowerType { + None, + SPELL, + SKILL; + } + + public enum CostType { + HEALTH, + MANA, + STAMINA; + } } diff --git a/src/engine/wpak/PowerData.java b/src/engine/wpak/PowerData.java index 1e8e686f..7b482500 100644 --- a/src/engine/wpak/PowerData.java +++ b/src/engine/wpak/PowerData.java @@ -8,8 +8,10 @@ package engine.wpak; +import engine.mbEnums; + public class PowerData { - public String power_type; + public mbEnums.PowerType power_type; public int icon; public String powerBase; } diff --git a/src/engine/wpak/PowerEntry.java b/src/engine/wpak/PowerEntry.java index c8a21303..23c480e2 100644 --- a/src/engine/wpak/PowerEntry.java +++ b/src/engine/wpak/PowerEntry.java @@ -8,6 +8,8 @@ package engine.wpak; +import engine.mbEnums; + import java.util.ArrayList; public class PowerEntry { @@ -19,7 +21,7 @@ public class PowerEntry { public String areaType; public int areaRange; public String excludeType; - public String costType; + public mbEnums.CostType costType; public float cost; public float difficulty; public float precision; diff --git a/src/engine/wpak/PowersParser.java b/src/engine/wpak/PowersParser.java index fe12cfe8..48be94af 100644 --- a/src/engine/wpak/PowersParser.java +++ b/src/engine/wpak/PowersParser.java @@ -9,6 +9,7 @@ package engine.wpak; import engine.gameManager.ConfigManager; +import engine.mbEnums; import org.pmw.tinylog.Logger; import java.io.IOException; @@ -70,29 +71,30 @@ public class PowersParser { powerEntry.power = iterator.next().replaceAll("\"", ""); PowerData power = new PowerData(); - power.power_type = iterator.next(); + power.power_type = mbEnums.PowerType.valueOf(iterator.next()); power.icon = Integer.parseInt(iterator.next()); power.powerBase = iterator.next().replaceAll("\"", ""); powerEntry.powers.add(power); - powerEntry.target_type = iterator.next(); + String nextValue = iterator.next(); // Account for second definition - if (powerEntry.target_type.equals("SPELL") || powerEntry.target_type.equals("SKILL")) { + if (nextValue.equals("SPELL") || nextValue.equals("SKILL")) { power = new PowerData(); - power.power_type = powerEntry.target_type; + power.power_type = mbEnums.PowerType.valueOf(nextValue); power.icon = Integer.parseInt(iterator.next()); power.powerBase = iterator.next().replaceAll("\"", ""); powerEntry.powers.add(power); powerEntry.target_type = iterator.next(); - } + } else + powerEntry.target_type = nextValue; 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.costType = mbEnums.CostType.valueOf(iterator.next()); powerEntry.cost = Float.parseFloat(iterator.next()); powerEntry.difficulty = Float.parseFloat(iterator.next()); powerEntry.precision = Float.parseFloat(iterator.next());