Browse Source

PowerActionEntry parsing work.

feature-config-parsing2
MagicBot 4 months ago
parent
commit
b935ae9fc4
  1. 47
      src/engine/wpak/PowerActionParser.java
  2. 21
      src/engine/wpak/data/PowerActionEntry.java

47
src/engine/wpak/PowerActionParser.java

@ -11,6 +11,7 @@ package engine.wpak; @@ -11,6 +11,7 @@ package engine.wpak;
import engine.gameManager.ConfigManager;
import engine.wpak.data.EffectDescription;
import engine.wpak.data.PowerActionEntry;
import org.pmw.tinylog.Logger;
import java.io.IOException;
import java.nio.file.Files;
@ -88,6 +89,52 @@ public class PowerActionParser { @@ -88,6 +89,52 @@ public class PowerActionParser {
// Process key value pairs after header
while (entryIterator.hasNext()) {
String lineValue = entryIterator.next();
String[] lineValues = lineValue.split("=");
String key = lineValues[0].trim();
String[] arguments;
switch (key) {
case "BODYPARTS":
arguments = lineValues[1].trim().split("\\s+");
for (String bodyPart : arguments)
powerActionEntry.bodyparts.add(Integer.parseInt(bodyPart));
break;
case "ISRESISTABLE":
powerActionEntry.isResistable = Boolean.parseBoolean(lineValues[1].trim());
break;
case "ISAGGRESSIVE":
powerActionEntry.isAggressive = Boolean.parseBoolean(lineValues[1].trim());
break;
case "BLADETRAILS":
powerActionEntry.bladeTrails = Boolean.parseBoolean(lineValues[1].trim());
break;
case "SHOULDSHOWWEAPONS":
powerActionEntry.shouldShowWeapons = Boolean.parseBoolean(lineValues[1].trim());
break;
case "SHOULDSHOWARMOR":
powerActionEntry.shouldShowArmor = Boolean.parseBoolean(lineValues[1].trim());
break;
case "APPLYEFFECTBLANK":
powerActionEntry.applyEffectBlank = Boolean.parseBoolean(lineValues[1].trim());
break;
case "WEAROFFEFFECTBLANK":
powerActionEntry.wearOffEffectBlank = Boolean.parseBoolean(lineValues[1].trim());
break;
case "ATTACKANIMS":
arguments = lineValues[1].trim().split("\\s+");
for (String bodyPart : arguments)
powerActionEntry.attackAnimations.add(Integer.parseInt(bodyPart));
break;
default:
Logger.error("Unhandled variable type:" + key + " for powerAction: " + powerActionEntry.action_id);
}
}
return powerActionEntry;
}
}

21
src/engine/wpak/data/PowerActionEntry.java

@ -8,6 +8,8 @@ @@ -8,6 +8,8 @@
package engine.wpak.data;
import engine.mbEnums;
import java.util.ArrayList;
public class PowerActionEntry {
@ -15,4 +17,23 @@ public class PowerActionEntry { @@ -15,4 +17,23 @@ public class PowerActionEntry {
public String action_id;
public String action_type;
public ArrayList<EffectDescription> effects;
// Additional variables after header go here.
public ArrayList<Integer> bodyparts = new ArrayList<>();
public boolean shouldShowWeapons = false;
public boolean shouldShowArmor = false;
public boolean bladeTrails = false;
public boolean isResistable = false;
public String effectID;
public ArrayList<Float> scaleFactor = new ArrayList<>();
public ArrayList<Integer> attackAnimations = new ArrayList<>();
public boolean isAggressive;
public mbEnums.DamageType damageType;
public boolean applyEffectBlank = false;
public boolean wearOffEffectBlank = false;
}

Loading…
Cancel
Save