Browse Source

PowerActionEntry parsing work.

feature-config-parsing2
MagicBot 3 months ago
parent
commit
e60a7a5ac0
  1. 18
      src/engine/wpak/PowerActionParser.java

18
src/engine/wpak/PowerActionParser.java

@ -9,6 +9,7 @@
package engine.wpak; package engine.wpak;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.wpak.data.EffectDescription;
import engine.wpak.data.PowerActionEntry; import engine.wpak.data.PowerActionEntry;
import java.io.IOException; import java.io.IOException;
@ -54,6 +55,8 @@ public class PowerActionParser {
private static PowerActionEntry parsePowerActionEntry(String powerActionData) { private static PowerActionEntry parsePowerActionEntry(String powerActionData) {
PowerActionEntry powerActionEntry = new PowerActionEntry(); PowerActionEntry powerActionEntry = new PowerActionEntry();
EffectDescription effectDescription;
// Remove all lines that contain a # and leading/trailing blank lines // Remove all lines that contain a # and leading/trailing blank lines
powerActionData = powerActionData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "").trim(); powerActionData = powerActionData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "").trim();
@ -62,9 +65,9 @@ public class PowerActionParser {
// Parse effect entry header // Parse effect entry header
Iterator iterator = Arrays.stream(lineData).iterator(); Iterator<String> entryIterator = Arrays.stream(lineData).iterator();
String headerLine = iterator.next().toString(); String headerLine = entryIterator.next();
ArrayList<String> headerData = new ArrayList<>(); ArrayList<String> headerData = new ArrayList<>();
Matcher matcher = STRSPLIT_REGEX.matcher(headerLine.trim()); Matcher matcher = STRSPLIT_REGEX.matcher(headerLine.trim());
@ -72,6 +75,17 @@ public class PowerActionParser {
while (matcher.find()) while (matcher.find())
headerData.add(matcher.group().trim()); headerData.add(matcher.group().trim());
Iterator<String> headerIterator = headerData.iterator();
powerActionEntry.action_id = headerIterator.next();
powerActionEntry.action_type = headerIterator.next();
while (headerIterator.hasNext()) {
effectDescription = new EffectDescription();
effectDescription.effect_id = headerIterator.next();
effectDescription.level = Integer.parseInt(headerIterator.next());
}
return powerActionEntry; return powerActionEntry;
} }
} }

Loading…
Cancel
Save