PowerActionEntry parsing work.

This commit is contained in:
2024-08-19 21:11:53 -04:00
parent 7e8cb056ed
commit e60a7a5ac0
+16 -2
View File
@@ -9,6 +9,7 @@
package engine.wpak;
import engine.gameManager.ConfigManager;
import engine.wpak.data.EffectDescription;
import engine.wpak.data.PowerActionEntry;
import java.io.IOException;
@@ -54,6 +55,8 @@ public class PowerActionParser {
private static PowerActionEntry parsePowerActionEntry(String powerActionData) {
PowerActionEntry powerActionEntry = new PowerActionEntry();
EffectDescription effectDescription;
// Remove all lines that contain a # and leading/trailing blank lines
powerActionData = powerActionData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "").trim();
@@ -62,9 +65,9 @@ public class PowerActionParser {
// 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<>();
Matcher matcher = STRSPLIT_REGEX.matcher(headerLine.trim());
@@ -72,6 +75,17 @@ public class PowerActionParser {
while (matcher.find())
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;
}
}