Browse Source

Enum work

feature-config-parsing2
MagicBot 3 months ago
parent
commit
d06ce44bd5
  1. 12
      src/engine/mbEnums.java
  2. 4
      src/engine/wpak/PowerData.java
  3. 4
      src/engine/wpak/PowerEntry.java
  4. 14
      src/engine/wpak/PowersParser.java

12
src/engine/mbEnums.java

@ -3022,5 +3022,17 @@ public class mbEnums { @@ -3022,5 +3022,17 @@ public class mbEnums {
PREFIX,
SUFFIX;
}
public enum PowerType {
None,
SPELL,
SKILL;
}
public enum CostType {
HEALTH,
MANA,
STAMINA;
}
}

4
src/engine/wpak/PowerData.java

@ -8,8 +8,10 @@ @@ -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;
}

4
src/engine/wpak/PowerEntry.java

@ -8,6 +8,8 @@ @@ -8,6 +8,8 @@
package engine.wpak;
import engine.mbEnums;
import java.util.ArrayList;
public class PowerEntry {
@ -19,7 +21,7 @@ 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;

14
src/engine/wpak/PowersParser.java

@ -9,6 +9,7 @@ @@ -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 { @@ -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());

Loading…
Cancel
Save