Debug code added
This commit is contained in:
@@ -35,8 +35,7 @@ public class PowerActionParser {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
fileData = Files.readAllBytes(Paths.get(powerActionPath));
|
fileData = Files.readAllBytes(Paths.get(powerActionPath));
|
||||||
} catch (
|
} catch (IOException e) {
|
||||||
IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,98 +58,114 @@ public class PowerActionParser {
|
|||||||
EffectDescription effectDescription;
|
EffectDescription effectDescription;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 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();
|
||||||
|
|
||||||
String[] lineData = powerActionData.split("\n");
|
String[] lineData = powerActionData.split("\n");
|
||||||
|
|
||||||
// Parse effect entry header
|
// Parse effect entry header
|
||||||
|
|
||||||
Iterator<String> entryIterator = Arrays.stream(lineData).iterator();
|
Iterator<String> entryIterator = Arrays.stream(lineData).iterator();
|
||||||
|
|
||||||
String headerLine = entryIterator.next();
|
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());
|
||||||
|
|
||||||
while (matcher.find())
|
while (matcher.find())
|
||||||
headerData.add(matcher.group().trim());
|
headerData.add(matcher.group().trim());
|
||||||
|
|
||||||
Iterator<String> headerIterator = headerData.iterator();
|
Iterator<String> headerIterator = headerData.iterator();
|
||||||
|
powerActionEntry.action_id = headerIterator.next();
|
||||||
|
powerActionEntry.action_type = headerIterator.next();
|
||||||
|
|
||||||
powerActionEntry.action_id = headerIterator.next();
|
switch (powerActionEntry.action_type) {
|
||||||
powerActionEntry.action_type = headerIterator.next();
|
case "RemoveEffect":
|
||||||
|
effectDescription = new EffectDescription();
|
||||||
while (headerIterator.hasNext()) {
|
effectDescription.effect_id = headerIterator.next();
|
||||||
effectDescription = new EffectDescription();
|
powerActionEntry.effects.add(effectDescription);
|
||||||
effectDescription.effect_id = headerIterator.next();
|
case "CreateMob":
|
||||||
effectDescription.level = Integer.parseInt(headerIterator.next());
|
powerActionEntry.arg1 = Integer.parseInt(headerIterator.next());
|
||||||
}
|
powerActionEntry.arg2 = Integer.parseInt(headerIterator.next());
|
||||||
|
break;
|
||||||
// Process key value pairs after header
|
case "ApplyEffect":
|
||||||
|
case "DeferredPower ":
|
||||||
|
while (headerIterator.hasNext()) {
|
||||||
while (entryIterator.hasNext()) {
|
effectDescription = new EffectDescription();
|
||||||
String lineValue = entryIterator.next();
|
effectDescription.effect_id = headerIterator.next();
|
||||||
String[] lineValues = lineValue.split("=");
|
effectDescription.level = Integer.parseInt(headerIterator.next());
|
||||||
String key = lineValues[0].trim();
|
powerActionEntry.effects.add(effectDescription);
|
||||||
String[] arguments;
|
}
|
||||||
|
|
||||||
switch (key) {
|
|
||||||
case "BODYPARTS":
|
|
||||||
arguments = lineValues[1].trim().split("\\s+");
|
|
||||||
|
|
||||||
for (String bodyPart : arguments)
|
|
||||||
powerActionEntry.bodyparts.add(Integer.parseInt(bodyPart));
|
|
||||||
break;
|
break;
|
||||||
case "FEMALEBODYPARTS":
|
|
||||||
arguments = lineValues[1].trim().split("\\s+");
|
|
||||||
|
|
||||||
for (String bodyPart : arguments)
|
|
||||||
powerActionEntry.femaleBodyParts.add(Integer.parseInt(bodyPart));
|
|
||||||
break;
|
|
||||||
case "SCALEFACTOR":
|
|
||||||
arguments = lineValues[1].trim().split("\\s+");
|
|
||||||
|
|
||||||
for (String bodyPart : arguments)
|
|
||||||
powerActionEntry.scaleFactor.add(Float.parseFloat(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;
|
|
||||||
case "WEAROFFEFFECTOTHER": // Keys not parsed go here.
|
|
||||||
case "WEAROFFEFFECTSELF":
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
Logger.error("Unhandled variable type:" + key + " for powerAction: " + powerActionEntry.action_id);
|
Logger.error("Unhandled type " + powerActionEntry.action_type + " for Pow4erAction: " + powerActionEntry.action_id);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// 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 "FEMALEBODYPARTS":
|
||||||
|
arguments = lineValues[1].trim().split("\\s+");
|
||||||
|
|
||||||
|
for (String bodyPart : arguments)
|
||||||
|
powerActionEntry.femaleBodyParts.add(Integer.parseInt(bodyPart));
|
||||||
|
break;
|
||||||
|
case "SCALEFACTOR":
|
||||||
|
arguments = lineValues[1].trim().split("\\s+");
|
||||||
|
|
||||||
|
for (String bodyPart : arguments)
|
||||||
|
powerActionEntry.scaleFactor.add(Float.parseFloat(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;
|
||||||
|
case "WEAROFFEFFECTOTHER": // Keys not parsed go here.
|
||||||
|
case "WEAROFFEFFECTSELF":
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Logger.error("Unhandled variable type:" + key + " for powerAction: " + powerActionEntry.action_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(powerActionEntry.action_id + " " + e);
|
Logger.error(powerActionEntry.action_id + " " + e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,5 +33,7 @@ public class PowerActionEntry {
|
|||||||
public mbEnums.DamageType damageType;
|
public mbEnums.DamageType damageType;
|
||||||
public boolean applyEffectBlank = false;
|
public boolean applyEffectBlank = false;
|
||||||
public boolean wearOffEffectBlank = false;
|
public boolean wearOffEffectBlank = false;
|
||||||
|
public int arg1;
|
||||||
|
public int arg2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user