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 @@
package engine.wpak; package engine.wpak;
public class PowerData { public class PowerData {
public String power;
public String power_type; public String power_type;
public int icon; public int icon;
public String powerBase;
} }

2
src/engine/wpak/PowerEntry.java

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

62
src/engine/wpak/PowersParser.java

@ -42,7 +42,7 @@ public class PowersParser {
} }
} }
private static PowerEntry parsePowerEntry(String powerData) { private static <Iterator> PowerEntry parsePowerEntry(String powerData) {
PowerEntry powerEntry = new PowerEntry(); PowerEntry powerEntry = new PowerEntry();
@ -62,36 +62,48 @@ public class PowersParser {
while (matcher.find()) while (matcher.find())
powerHeader.add(matcher.group().trim()); powerHeader.add(matcher.group().trim());
powerEntry.power_id = powerHeader.get(0); java.util.Iterator<String> iterator = powerHeader.iterator();
if (powerHeader.size() != 22) powerEntry.power_id = iterator.next();
Logger.error(powerEntry.power_id); powerEntry.power = iterator.next().replaceAll("\"", "");
PowerData power = new PowerData(); 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("\"", ""); // Account for second definition
power.power_type = powerHeader.get(2);
power.icon = Integer.parseInt(powerHeader.get(3)); 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.powers.add(power);
powerEntry.target_type = iterator.next();
}
powerEntry.powerbase = powerHeader.get(4).replaceAll("\"", ""); powerEntry.range = Integer.parseInt(iterator.next());
powerEntry.target_type = powerHeader.get(5); powerEntry.areaType = iterator.next();
powerEntry.range = Integer.parseInt(powerHeader.get(6)); powerEntry.areaRange = Integer.parseInt(iterator.next());
powerEntry.areaType = powerHeader.get(7); powerEntry.excludeType = iterator.next();
powerEntry.areaRange = Integer.parseInt(powerHeader.get(8)); powerEntry.costType = iterator.next();
powerEntry.excludeType = powerHeader.get(9); powerEntry.cost = Float.parseFloat(iterator.next());
powerEntry.costType = powerHeader.get(10); powerEntry.difficulty = Integer.parseInt(iterator.next());
powerEntry.cost = Float.parseFloat(powerHeader.get(11)); powerEntry.precision = Integer.parseInt(iterator.next());
powerEntry.difficulty = Integer.parseInt(powerHeader.get(12)); powerEntry.init_time = Float.parseFloat(iterator.next());
powerEntry.precision = Integer.parseInt(powerHeader.get(13)); powerEntry.release_time = Float.parseFloat(iterator.next());
powerEntry.init_time = Float.parseFloat(powerHeader.get(14)); powerEntry.recycle_time = Float.parseFloat(iterator.next());
powerEntry.release_time = Float.parseFloat(powerHeader.get(15)); powerEntry.hitRollYN = Integer.parseInt(iterator.next());
powerEntry.recycle_time = Float.parseFloat(powerHeader.get(16)); powerEntry.castingMode = iterator.next();
powerEntry.hitRollYN = Integer.parseInt(powerHeader.get(17)); powerEntry.initAmin = Integer.parseInt(iterator.next());
powerEntry.castingMode = powerHeader.get(18); powerEntry.releaseAnim = Integer.parseInt(iterator.next());
powerEntry.initAmin = Integer.parseInt(powerHeader.get(19)); powerEntry.targetSelect = iterator.next();
powerEntry.releaseAnim = Integer.parseInt(powerHeader.get(20));
powerEntry.targetSelect = powerHeader.get(21);
for (int x = 2; x < powerEntries.length; x++) { for (int x = 2; x < powerEntries.length; x++) {

Loading…
Cancel
Save