|
|
|
@ -18,6 +18,7 @@ import java.nio.file.Files;
@@ -18,6 +18,7 @@ import java.nio.file.Files;
|
|
|
|
|
import java.nio.file.Paths; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
@ -56,11 +57,12 @@ public class PowersParser {
@@ -56,11 +57,12 @@ public class PowersParser {
|
|
|
|
|
private static PowerEntry parsePowerEntry(String powerData) { |
|
|
|
|
|
|
|
|
|
PowerEntry powerEntry = new PowerEntry(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder conditionString = new StringBuilder(); |
|
|
|
|
StringBuilder powerString = new StringBuilder(); |
|
|
|
|
|
|
|
|
|
StringBuilder conditionBuilder = new StringBuilder(); |
|
|
|
|
StringBuilder powerBuilder = new StringBuilder(); |
|
|
|
|
String conditionString; |
|
|
|
|
String powerString; |
|
|
|
|
java.util.Iterator<String> iterator; |
|
|
|
|
java.util.Iterator<String> argumentIterator; |
|
|
|
|
int endPos = 0; |
|
|
|
|
|
|
|
|
|
// Separate out any conditions from the power data
|
|
|
|
@ -68,26 +70,25 @@ public class PowersParser {
@@ -68,26 +70,25 @@ public class PowersParser {
|
|
|
|
|
Matcher matcher = CONDITION_REGEX.matcher(powerData); |
|
|
|
|
|
|
|
|
|
while (matcher.find()) { |
|
|
|
|
conditionString.append(matcher.group().trim()); |
|
|
|
|
powerString.append(powerData, endPos, matcher.start()); |
|
|
|
|
conditionBuilder.append(matcher.group().trim()); |
|
|
|
|
powerBuilder.append(powerData, endPos, matcher.start()); |
|
|
|
|
endPos = matcher.end(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
powerString.append(powerData.substring(endPos)); |
|
|
|
|
powerBuilder.append(powerData.substring(endPos)); |
|
|
|
|
|
|
|
|
|
// Cleanup dangling tags and lines that contain a # and leading/trailing blank lines
|
|
|
|
|
|
|
|
|
|
powerString = new StringBuilder(powerString.toString().replaceAll("CONDITIONBEGINCONDITIONEND", "")); |
|
|
|
|
powerString = new StringBuilder(powerString.toString().replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "")); |
|
|
|
|
|
|
|
|
|
conditionString = new StringBuilder(conditionString.toString().replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "")); |
|
|
|
|
powerString = powerBuilder.toString().replaceAll("CONDITIONBEGINCONDITIONEND", "") |
|
|
|
|
.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", ""); |
|
|
|
|
conditionString = conditionBuilder.toString().replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", ""); |
|
|
|
|
|
|
|
|
|
// Parse header line in power data
|
|
|
|
|
|
|
|
|
|
String[] lineData = powerString.toString().trim().split("\n"); |
|
|
|
|
ArrayList<String> powerHeader = new ArrayList<>(); |
|
|
|
|
List<String> lineData = Arrays.asList(powerString.trim().split("\n")); |
|
|
|
|
List<String> powerHeader = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
String headerString = lineData[0]; |
|
|
|
|
String headerString = lineData.get(0); |
|
|
|
|
headerString = headerString.replace("\n", " "); |
|
|
|
|
|
|
|
|
|
matcher = STRSPLIT_REGEX.matcher(headerString); |
|
|
|
@ -95,7 +96,7 @@ public class PowersParser {
@@ -95,7 +96,7 @@ public class PowersParser {
|
|
|
|
|
while (matcher.find()) |
|
|
|
|
powerHeader.add(matcher.group().trim()); |
|
|
|
|
|
|
|
|
|
java.util.Iterator<String> iterator = powerHeader.iterator(); |
|
|
|
|
iterator = powerHeader.iterator(); |
|
|
|
|
|
|
|
|
|
powerEntry.power_id = iterator.next(); |
|
|
|
|
powerEntry.power = iterator.next().replaceAll("\"", ""); |
|
|
|
@ -128,6 +129,7 @@ public class PowersParser {
@@ -128,6 +129,7 @@ public class PowersParser {
|
|
|
|
|
powerEntry.cost = Float.parseFloat(iterator.next()); |
|
|
|
|
powerEntry.difficulty = Float.parseFloat(iterator.next()); |
|
|
|
|
powerEntry.precision = Float.parseFloat(iterator.next()); |
|
|
|
|
// Cleanup init_time in client data which is 0.35.1 or some such
|
|
|
|
|
powerEntry.init_time = Float.parseFloat(iterator.next().replaceAll("(\\.0)+$", "")); |
|
|
|
|
powerEntry.release_time = Float.parseFloat(iterator.next()); |
|
|
|
|
powerEntry.recycle_time = Float.parseFloat(iterator.next()); |
|
|
|
@ -139,133 +141,137 @@ public class PowersParser {
@@ -139,133 +141,137 @@ public class PowersParser {
|
|
|
|
|
|
|
|
|
|
// Process key value pairs after header
|
|
|
|
|
|
|
|
|
|
iterator = Arrays.stream(lineData).iterator(); |
|
|
|
|
iterator = lineData.iterator(); |
|
|
|
|
iterator.next(); // Ignore header
|
|
|
|
|
|
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
|
|
|
|
|
String lineValue = iterator.next(); |
|
|
|
|
String[] lineValues = lineValue.split("="); |
|
|
|
|
String key = lineValues[0].trim(); |
|
|
|
|
List<String> lineValues = Arrays.asList(lineValue.split("=")); |
|
|
|
|
String key = lineValues.get(0).trim(); |
|
|
|
|
ActionEntry actionEntry; |
|
|
|
|
String[] arguments; |
|
|
|
|
Matcher matcher1; |
|
|
|
|
ArrayList<String> args; |
|
|
|
|
List<String> arguments; |
|
|
|
|
Matcher argumentMatcher; |
|
|
|
|
|
|
|
|
|
switch (key) { |
|
|
|
|
case "ACTION": |
|
|
|
|
actionEntry = new ActionEntry(); |
|
|
|
|
arguments = lineValues[1].trim().split("\\s+"); |
|
|
|
|
|
|
|
|
|
actionEntry.effect_id = arguments[0]; |
|
|
|
|
actionEntry.minTrains = Integer.parseInt(arguments[1]); |
|
|
|
|
actionEntry.maxTrains = Integer.parseInt(arguments[2]); |
|
|
|
|
actionEntry.duration = Float.parseFloat(arguments[3]); |
|
|
|
|
actionEntry.curve = mbEnums.CompoundCurveType.valueOf(arguments[4]); |
|
|
|
|
actionEntry.stackingCategory = arguments[5]; |
|
|
|
|
actionEntry.stackingPriority = Integer.parseInt(arguments[6]); |
|
|
|
|
actionEntry.categoryToPower = mbEnums.CategoryToPowerType.valueOf(arguments[7]); |
|
|
|
|
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); |
|
|
|
|
actionEntry.effect_id = arguments.get(0); |
|
|
|
|
actionEntry.minTrains = Integer.parseInt(arguments.get(1)); |
|
|
|
|
actionEntry.maxTrains = Integer.parseInt(arguments.get(2)); |
|
|
|
|
actionEntry.duration = Float.parseFloat(arguments.get(3)); |
|
|
|
|
actionEntry.curve = mbEnums.CompoundCurveType.valueOf(arguments.get(4)); |
|
|
|
|
actionEntry.stackingCategory = arguments.get(5); |
|
|
|
|
actionEntry.stackingPriority = Integer.parseInt(arguments.get(6)); |
|
|
|
|
actionEntry.categoryToPower = mbEnums.CategoryToPowerType.valueOf(arguments.get(7)); |
|
|
|
|
powerEntry.actionEntries.add(actionEntry); |
|
|
|
|
break; |
|
|
|
|
case "MaxLevel": |
|
|
|
|
powerEntry.maxLevel = Integer.parseInt(lineValues[1].trim()); |
|
|
|
|
powerEntry.maxLevel = Integer.parseInt(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "HateValue": |
|
|
|
|
arguments = lineValues[1].trim().split("\\s+"); |
|
|
|
|
powerEntry.hateValue = Integer.parseInt(arguments[0]); |
|
|
|
|
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); |
|
|
|
|
powerEntry.hateValue = Integer.parseInt(arguments.get(0)); |
|
|
|
|
|
|
|
|
|
// Not all entries have a curve. Defaults to DefaultFlat;
|
|
|
|
|
|
|
|
|
|
if (arguments.length > 1) |
|
|
|
|
powerEntry.hateCurve = mbEnums.CompoundCurveType.valueOf(arguments[1]); |
|
|
|
|
if (arguments.size() > 1) |
|
|
|
|
powerEntry.hateCurve = mbEnums.CompoundCurveType.valueOf(arguments.get(1)); |
|
|
|
|
break; |
|
|
|
|
case "LOOPANIMID": |
|
|
|
|
powerEntry.loopAnimID = Integer.parseInt(lineValues[1].trim()); |
|
|
|
|
powerEntry.loopAnimID = Integer.parseInt(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "GRANTOVERRIDEVAR": |
|
|
|
|
powerEntry.grantOverrideVar = lineValues[1].trim(); |
|
|
|
|
powerEntry.grantOverrideVar = lineValues.get(1).trim(); |
|
|
|
|
break; |
|
|
|
|
case "DESCRIPTION": |
|
|
|
|
powerEntry.description.add(lineValues[1].trim()); |
|
|
|
|
powerEntry.description.add(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "CATEGORY": |
|
|
|
|
powerEntry.category = lineValues[1].trim(); |
|
|
|
|
powerEntry.category = lineValues.get(1).trim(); |
|
|
|
|
break; |
|
|
|
|
case "CURVE": |
|
|
|
|
arguments = lineValues[1].trim().split("\\s+"); |
|
|
|
|
powerEntry.curves.put(arguments[0], mbEnums.CompoundCurveType.valueOf(arguments[1])); |
|
|
|
|
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); |
|
|
|
|
powerEntry.curves.put(arguments.get(0), mbEnums.CompoundCurveType.valueOf(arguments.get(1))); |
|
|
|
|
break; |
|
|
|
|
case "EQPREREQ": |
|
|
|
|
EquipmentPreReq equipmentPreReq = new EquipmentPreReq(); |
|
|
|
|
matcher1 = STRSPLIT_REGEX.matcher(lineValues[1].trim()); |
|
|
|
|
args = new ArrayList<>(); |
|
|
|
|
argumentMatcher = STRSPLIT_REGEX.matcher(lineValues.get(1).trim()); |
|
|
|
|
arguments = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
while (argumentMatcher.find()) |
|
|
|
|
arguments.add(argumentMatcher.group().trim()); |
|
|
|
|
|
|
|
|
|
while (matcher1.find()) |
|
|
|
|
args.add(matcher1.group().trim()); |
|
|
|
|
argumentIterator = arguments.iterator(); |
|
|
|
|
|
|
|
|
|
equipmentPreReq.slot = mbEnums.EquipSlotType.valueOf(args.get(0)); |
|
|
|
|
equipmentPreReq.skill = args.get(1).replaceAll("\"", ""); |
|
|
|
|
equipmentPreReq.level = Integer.parseInt(args.get(2)); |
|
|
|
|
powerEntry.equipmentPreReq = equipmentPreReq; |
|
|
|
|
while (argumentIterator.hasNext()) { |
|
|
|
|
EquipmentPreReq equipmentPreReq = new EquipmentPreReq(); |
|
|
|
|
equipmentPreReq.slot = mbEnums.EquipSlotType.valueOf(arguments.get(0)); |
|
|
|
|
equipmentPreReq.skill = arguments.get(1).replaceAll("\"", ""); |
|
|
|
|
equipmentPreReq.required = Integer.parseInt(arguments.get(2)); |
|
|
|
|
powerEntry.equipmentPreReq.add(equipmentPreReq); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "CANCASTWHILEMOVING": |
|
|
|
|
powerEntry.canCastWhileMoving = Boolean.parseBoolean(lineValues[1].trim()); |
|
|
|
|
powerEntry.canCastWhileMoving = Boolean.parseBoolean(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "CANCASTWHILEFLYING": |
|
|
|
|
powerEntry.canCastWhileFlying = Boolean.parseBoolean(lineValues[1].trim()); |
|
|
|
|
powerEntry.canCastWhileFlying = Boolean.parseBoolean(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "BLADETRAILS": |
|
|
|
|
powerEntry.bladeTrails = Boolean.parseBoolean(lineValues[1].trim()); |
|
|
|
|
powerEntry.bladeTrails = Boolean.parseBoolean(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "EFFECTPREREQ": |
|
|
|
|
EffectDescription effectPreReq = new EffectDescription(); |
|
|
|
|
arguments = lineValues[1].trim().split("\\s+"); |
|
|
|
|
effectPreReq.effect_id = arguments[9]; |
|
|
|
|
effectPreReq.level = Integer.parseInt(arguments[1]); |
|
|
|
|
effectPreReq.message = arguments[2]; |
|
|
|
|
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); |
|
|
|
|
effectPreReq.effect_id = arguments.get(9); |
|
|
|
|
effectPreReq.level = Integer.parseInt(arguments.get(1)); |
|
|
|
|
effectPreReq.message = arguments.get(2); |
|
|
|
|
powerEntry.effectPreReqs.add(effectPreReq); |
|
|
|
|
break; |
|
|
|
|
case "MONSTERTYPERESTRICTS": |
|
|
|
|
arguments = lineValues[1].trim().split("\\s+"); |
|
|
|
|
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); |
|
|
|
|
|
|
|
|
|
for (String restriction : arguments) |
|
|
|
|
powerEntry.monsterRestricts.add(mbEnums.MonsterType.valueOf(restriction.trim())); |
|
|
|
|
break; |
|
|
|
|
case "MONSTERTYPEPREREQS": |
|
|
|
|
arguments = lineValues[1].trim().split("\\s+"); |
|
|
|
|
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); |
|
|
|
|
|
|
|
|
|
for (String restriction : arguments) |
|
|
|
|
powerEntry.monsterPrereqs.add(mbEnums.MonsterType.valueOf(restriction.trim())); |
|
|
|
|
break; |
|
|
|
|
case "SHOULDCHECKPATH": |
|
|
|
|
powerEntry.shouldCheckPath = Boolean.parseBoolean(lineValues[1].trim()); |
|
|
|
|
powerEntry.shouldCheckPath = Boolean.parseBoolean(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "STICKY": |
|
|
|
|
powerEntry.sticky = Boolean.parseBoolean(lineValues[1].trim()); |
|
|
|
|
powerEntry.sticky = Boolean.parseBoolean(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "PULSEINFO": |
|
|
|
|
arguments = lineValues[1].trim().split("\\s+"); |
|
|
|
|
powerEntry.pulseCycle = Integer.parseInt(arguments[0]); |
|
|
|
|
powerEntry.pulseDuration = Integer.parseInt(arguments[1]); |
|
|
|
|
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); |
|
|
|
|
powerEntry.pulseCycle = Integer.parseInt(arguments.get(0)); |
|
|
|
|
powerEntry.pulseDuration = Integer.parseInt(arguments.get(1)); |
|
|
|
|
break; |
|
|
|
|
case "MAXNUMMOBTARGETS": |
|
|
|
|
powerEntry.maxMobTargets = Integer.parseInt(lineValues[1].trim()); |
|
|
|
|
powerEntry.maxMobTargets = Integer.parseInt(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "MAXNUMPLAYERTARGETS": |
|
|
|
|
powerEntry.maxPlayerTargets = Integer.parseInt(lineValues[1].trim()); |
|
|
|
|
powerEntry.maxPlayerTargets = Integer.parseInt(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "ISADMINPOWER": |
|
|
|
|
powerEntry.isAdminPower = Boolean.parseBoolean(lineValues[1].trim()); |
|
|
|
|
powerEntry.isAdminPower = Boolean.parseBoolean(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "ISPROJECTILE": |
|
|
|
|
powerEntry.isProjectile = Boolean.parseBoolean(lineValues[1].trim()); |
|
|
|
|
powerEntry.isProjectile = Boolean.parseBoolean(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "CASTERSPULSEPARTICLE": |
|
|
|
|
powerEntry.casterPulseParticle = Integer.parseInt(lineValues[1].trim()); |
|
|
|
|
powerEntry.casterPulseParticle = Integer.parseInt(lineValues.get(1).trim()); |
|
|
|
|
break; |
|
|
|
|
case "TARGETEFFECTPREREQS_ORED": |
|
|
|
|
EffectDescription preReq = new EffectDescription(); |
|
|
|
|
arguments = lineValues[1].trim().split("\\s+"); |
|
|
|
|
preReq.effect_id = arguments[0]; |
|
|
|
|
preReq.level = Integer.parseInt(arguments[1]); |
|
|
|
|
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); |
|
|
|
|
preReq.effect_id = arguments.get(0); |
|
|
|
|
preReq.level = Integer.parseInt(arguments.get(1)); |
|
|
|
|
powerEntry.targetEffectPrereqs.add(preReq); |
|
|
|
|
break; |
|
|
|
|
case "SOUNDS": // Values not parsed
|
|
|
|
@ -292,15 +298,15 @@ public class PowersParser {
@@ -292,15 +298,15 @@ public class PowersParser {
|
|
|
|
|
|
|
|
|
|
// Parse power conditions
|
|
|
|
|
|
|
|
|
|
if (!conditionString.toString().isEmpty()) { |
|
|
|
|
String[] conditions = conditionString.toString().split("\n"); |
|
|
|
|
if (conditionString.isEmpty() == false) { |
|
|
|
|
|
|
|
|
|
List<String> conditions = Arrays.asList(conditionString.split("\n")); |
|
|
|
|
|
|
|
|
|
for (String condition : conditions) { |
|
|
|
|
String[] parameters = condition.trim().split("\\s+"); |
|
|
|
|
powerEntry.conditions.put(parameters[0], Float.parseFloat(parameters[1])); |
|
|
|
|
List<String> parameters = Arrays.asList(condition.trim().split("\\s+")); |
|
|
|
|
powerEntry.conditions.put(parameters.get(0), Float.parseFloat(parameters.get(1))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return powerEntry; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|