Browse Source

Support for multiple power enrties.

feature-config-parsing2
MagicBot 4 months ago
parent
commit
218de2bb70
  1. 2
      src/engine/wpak/PowerData.java
  2. 2
      src/engine/wpak/PowerEntry.java
  3. 62
      src/engine/wpak/PowersParser.java

2
src/engine/wpak/PowerData.java

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
package engine.wpak;
public class PowerData {
public String power;
public String power_type;
public int icon;
public String powerBase;
}

2
src/engine/wpak/PowerEntry.java

@ -12,8 +12,8 @@ import java.util.ArrayList; @@ -12,8 +12,8 @@ import java.util.ArrayList;
public class PowerEntry {
public String power_id;
public String power;
public ArrayList<PowerData> powers = new ArrayList<>();
public String powerbase;
public String target_type;
public int range;
public String areaType;

62
src/engine/wpak/PowersParser.java

@ -42,7 +42,7 @@ public class PowersParser { @@ -42,7 +42,7 @@ public class PowersParser {
}
}
private static PowerEntry parsePowerEntry(String powerData) {
private static <Iterator> PowerEntry parsePowerEntry(String powerData) {
PowerEntry powerEntry = new PowerEntry();
@ -62,36 +62,48 @@ public class PowersParser { @@ -62,36 +62,48 @@ public class PowersParser {
while (matcher.find())
powerHeader.add(matcher.group().trim());
powerEntry.power_id = powerHeader.get(0);
java.util.Iterator<String> 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_type = iterator.next();
;
power.icon = Integer.parseInt(iterator.next());
power.powerBase = iterator.next().replaceAll("\"", "");
powerEntry.powers.add(power);
powerEntry.target_type = iterator.next();
power.power = powerHeader.get(1).replaceAll("\"", "");
power.power_type = powerHeader.get(2);
power.icon = Integer.parseInt(powerHeader.get(3));
// 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.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.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++) {

Loading…
Cancel
Save