Browse Source

Merge branch 'feature-config-parsing2' into feature-config-usage

feature-config-usage
FatBoy-DOTC 4 months ago
parent
commit
bc50408c45
  1. 16
      src/engine/gameManager/PowersManager.java
  2. 24
      src/engine/wpak/EffectsParser.java
  3. 64
      src/engine/wpak/PowerActionParser.java
  4. 164
      src/engine/wpak/PowersParser.java
  5. 21
      src/engine/wpak/data/ConditionEntry.java
  6. 3
      src/engine/wpak/data/EffectEntry.java
  7. 2
      src/engine/wpak/data/EquipmentPreReq.java
  8. 2
      src/engine/wpak/data/PowerEntry.java

16
src/engine/gameManager/PowersManager.java

@ -145,7 +145,21 @@ public enum PowersManager {
PowersParser.parseWpakFile(); PowersParser.parseWpakFile();
PowerActionParser.parseWpakFile(); PowerActionParser.parseWpakFile();
InitializeEffects(); //InitializeEffects();
ArrayList<EffectsBase> ebList = dbEffectsBaseHandler.getAllEffectsBase();
for (EffectsBase eb : ebList) {
PowersManager.effectsBaseByToken.put(eb.getToken(), eb);
PowersManager.effectsBaseByIDString.put(eb.getIDString(), eb);
}
// Add Fail Conditions
EffectsBase.getFailConditions(PowersManager.effectsBaseByIDString);
// Add Modifiers to Effects
dbEffectsBaseHandler.cacheAllEffectModifiers();

24
src/engine/wpak/EffectsParser.java

@ -10,6 +10,7 @@ package engine.wpak;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.mbEnums; import engine.mbEnums;
import engine.wpak.data.ConditionEntry;
import engine.wpak.data.EffectEntry; import engine.wpak.data.EffectEntry;
import engine.wpak.data.EffectModifier; import engine.wpak.data.EffectModifier;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -17,8 +18,7 @@ import org.pmw.tinylog.Logger;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -60,12 +60,14 @@ public class EffectsParser {
EffectEntry effectEntry = new EffectEntry(); EffectEntry effectEntry = new EffectEntry();
// Remove all lines that contain a # and leading/trailing blank lines // Parse fields that lie outside the other tags
effectEntry.isItemEffect = effectData.contains("IsItemEffect"); effectEntry.isItemEffect = effectData.contains("IsItemEffect");
effectEntry.isSpireEffect = effectData.contains("IsSpireEffect"); effectEntry.isSpireEffect = effectData.contains("IsSpireEffect");
effectEntry.ignoreNoMod = effectData.contains("IgnoreNoMod"); effectEntry.ignoreNoMod = effectData.contains("IgnoreNoMod");
effectEntry.dontSave = effectData.contains("DontSave"); effectEntry.dontSave = effectData.contains("DontSave");
// Remove all lines that contain a # and leading/trailing blank lines
effectData = effectData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", ""); effectData = effectData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "");
effectData = effectData.trim(); effectData = effectData.trim();
@ -126,8 +128,20 @@ public class EffectsParser {
String[] conditions = matcher.group().trim().split("\n"); String[] conditions = matcher.group().trim().split("\n");
for (String condition : conditions) { for (String condition : conditions) {
String[] parameters = condition.trim().split("\\s+"); List<String> parameters = Arrays.asList(condition.trim().split("\\s+"));
effectEntry.conditions.put(parameters[0], Float.parseFloat(parameters[1])); Iterator<String> iterator = parameters.iterator();
ConditionEntry conditionEntry = new ConditionEntry();
conditionEntry.condition = iterator.next();
conditionEntry.arg = Integer.parseInt(iterator.next());
if (iterator.hasNext())
conditionEntry.curveType = mbEnums.CompoundCurveType.valueOf(iterator.next());
while (iterator.hasNext())
conditionEntry.damageTypes.add(mbEnums.DamageType.valueOf(iterator.next().toUpperCase()));
effectEntry.conditions.add(conditionEntry);
} }
} }

64
src/engine/wpak/PowerActionParser.java

@ -22,6 +22,7 @@ import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -66,14 +67,13 @@ public class PowerActionParser {
powerActionData = powerActionData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "").trim(); powerActionData = powerActionData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "").trim();
String[] lineData = powerActionData.split("\n"); List<String> lineData = Arrays.asList(powerActionData.split("\n"));
// Parse effect entry header // Parse effect entry header
Iterator<String> entryIterator = Arrays.stream(lineData).iterator(); Iterator<String> entryIterator = lineData.iterator();
String headerLine = entryIterator.next(); String headerLine = entryIterator.next();
ArrayList<String> headerData = new ArrayList<>(); List<String> headerData = new ArrayList<>();
Matcher matcher = STRSPLIT_REGEX.matcher(headerLine.trim()); Matcher matcher = STRSPLIT_REGEX.matcher(headerLine.trim());
@ -206,90 +206,90 @@ public class PowerActionParser {
while (entryIterator.hasNext()) { while (entryIterator.hasNext()) {
String lineValue = entryIterator.next(); String lineValue = entryIterator.next();
String[] lineValues = lineValue.split("="); List<String> lineValues = Arrays.asList(lineValue.split("="));
String key = lineValues[0].trim(); String key = lineValues.get(0).trim();
String[] arguments; List<String> arguments;
switch (key) { switch (key) {
case "BODYPARTS": case "BODYPARTS":
arguments = lineValues[1].trim().split("\\s+"); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String bodyPart : arguments) for (String bodyPart : arguments)
powerActionEntry.bodyparts.add(Integer.parseInt(bodyPart)); powerActionEntry.bodyparts.add(Integer.parseInt(bodyPart));
break; break;
case "FEMALEBODYPARTS": case "FEMALEBODYPARTS":
arguments = lineValues[1].trim().split("\\s+"); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String bodyPart : arguments) for (String bodyPart : arguments)
powerActionEntry.femaleBodyParts.add(Integer.parseInt(bodyPart)); powerActionEntry.femaleBodyParts.add(Integer.parseInt(bodyPart));
break; break;
case "SCALEFACTOR": case "SCALEFACTOR":
arguments = lineValues[1].trim().split("\\s+"); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String scaleFactor : arguments) for (String scaleFactor : arguments)
powerActionEntry.scaleFactor.add(Float.parseFloat(scaleFactor)); powerActionEntry.scaleFactor.add(Float.parseFloat(scaleFactor));
break; break;
case "ISRESISTABLE": case "ISRESISTABLE":
powerActionEntry.isResistible = Boolean.parseBoolean(lineValues[1].trim()); powerActionEntry.isResistible = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "ISAGGRESSIVE": case "ISAGGRESSIVE":
powerActionEntry.isAggressive = Boolean.parseBoolean(lineValues[1].trim()); powerActionEntry.isAggressive = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "BLADETRAILS": case "BLADETRAILS":
powerActionEntry.bladeTrails = Boolean.parseBoolean(lineValues[1].trim()); powerActionEntry.bladeTrails = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "SHOULDSHOWWEAPONS": case "SHOULDSHOWWEAPONS":
powerActionEntry.shouldShowWeapons = Boolean.parseBoolean(lineValues[1].trim()); powerActionEntry.shouldShowWeapons = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "SHOULDSHOWARMOR": case "SHOULDSHOWARMOR":
powerActionEntry.shouldShowArmor = Boolean.parseBoolean(lineValues[1].trim()); powerActionEntry.shouldShowArmor = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "APPLYEFFECTBLANK": case "APPLYEFFECTBLANK":
powerActionEntry.applyEffectBlank = Boolean.parseBoolean(lineValues[1].trim()); powerActionEntry.applyEffectBlank = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "WEAROFFEFFECTBLANK": case "WEAROFFEFFECTBLANK":
powerActionEntry.wearOffEffectBlank = Boolean.parseBoolean(lineValues[1].trim()); powerActionEntry.wearOffEffectBlank = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "ATTACKANIMS": case "ATTACKANIMS":
arguments = lineValues[1].trim().split("\\s+"); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String animation : arguments) for (String animation : arguments)
powerActionEntry.attackAnimations.add(Integer.parseInt(animation)); powerActionEntry.attackAnimations.add(Integer.parseInt(animation));
break; break;
case "REMOVEALL": case "REMOVEALL":
powerActionEntry.removeAll = Boolean.parseBoolean(lineValues[1].trim()); powerActionEntry.removeAll = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "EFFECTID": case "EFFECTID":
effectDescription = new EffectDescription(); effectDescription = new EffectDescription();
effectDescription.effect_id = lineValues[1].trim(); effectDescription.effect_id = lineValues.get(1).trim();
powerActionEntry.effects.add(effectDescription); powerActionEntry.effects.add(effectDescription);
break; break;
case "LEVELCAP": case "LEVELCAP":
arguments = lineValues[1].trim().split("\\s+"); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
powerActionEntry.levelCap = Integer.parseInt(arguments[0]); powerActionEntry.levelCap = Integer.parseInt(arguments.get(0));
if (arguments.length > 1) // Not all level caps have a curve if (arguments.size() > 1) // Not all level caps have a curve
powerActionEntry.levelCurve = mbEnums.CompoundCurveType.valueOf(arguments[1]); powerActionEntry.levelCurve = mbEnums.CompoundCurveType.valueOf(arguments.get(1));
break; break;
case "CLEARAGGRO": case "CLEARAGGRO":
powerActionEntry.clearAggro = Boolean.parseBoolean(lineValues[1].trim()); powerActionEntry.clearAggro = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "TARGETBECOMESPET": case "TARGETBECOMESPET":
powerActionEntry.targetBecomesPet = Boolean.parseBoolean(lineValues[1].trim()); powerActionEntry.targetBecomesPet = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "DESTROYOLDPET": case "DESTROYOLDPET":
powerActionEntry.destroyOldPet = Boolean.parseBoolean(lineValues[1].trim()); powerActionEntry.destroyOldPet = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "DAMAGETYPE": case "DAMAGETYPE":
powerActionEntry.damageType = mbEnums.DamageType.valueOf(lineValues[1].trim().toUpperCase()); powerActionEntry.damageType = mbEnums.DamageType.valueOf(lineValues.get(1).trim().toUpperCase());
break; break;
case "ROOTFSMID": case "ROOTFSMID":
powerActionEntry.rootFsmID = mbEnums.MobBehaviourType.valueOf(lineValues[1].trim()); powerActionEntry.rootFsmID = mbEnums.MobBehaviourType.valueOf(lineValues.get(1).trim());
break; break;
case "SPLASHDAMAGE": case "SPLASHDAMAGE":
arguments = lineValues[1].trim().split("\\s+"); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
powerActionEntry.splashDamageMin = Integer.parseInt(arguments[0]); powerActionEntry.splashDamageMin = Integer.parseInt(arguments.get(0));
powerActionEntry.splashDamageMax = Integer.parseInt(arguments[1]); powerActionEntry.splashDamageMax = Integer.parseInt(arguments.get(1));
break; break;
case "APPLYEFFECTOTHER": case "APPLYEFFECTOTHER":
case "APPLYEFFECTSELF": case "APPLYEFFECTSELF":

164
src/engine/wpak/PowersParser.java

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

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

@ -0,0 +1,21 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
//
package engine.wpak.data;
import engine.mbEnums;
import java.util.EnumSet;
public class ConditionEntry {
public String condition;
public int arg;
public mbEnums.CompoundCurveType curveType;
public EnumSet<mbEnums.DamageType> damageTypes = EnumSet.noneOf(mbEnums.DamageType.class);
}

3
src/engine/wpak/data/EffectEntry.java

@ -11,7 +11,6 @@ package engine.wpak.data;
import engine.powers.effectmodifiers.AbstractEffectModifier; import engine.powers.effectmodifiers.AbstractEffectModifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
public class EffectEntry { public class EffectEntry {
@ -20,7 +19,7 @@ public class EffectEntry {
public int icon; public int icon;
public HashSet<String> sources = new HashSet<>(); public HashSet<String> sources = new HashSet<>();
public ArrayList<EffectModifier> mods = new ArrayList<>(); public ArrayList<EffectModifier> mods = new ArrayList<>();
public HashMap<String, Float> conditions = new HashMap<>(); public ArrayList<ConditionEntry> conditions = new ArrayList<>();
public boolean isItemEffect; public boolean isItemEffect;
public boolean isSpireEffect; public boolean isSpireEffect;

2
src/engine/wpak/data/EquipmentPreReq.java

@ -14,6 +14,6 @@ public class EquipmentPreReq {
public mbEnums.EquipSlotType slot; public mbEnums.EquipSlotType slot;
public String skill; public String skill;
public int level; public int required;
} }

2
src/engine/wpak/data/PowerEntry.java

@ -50,7 +50,7 @@ public class PowerEntry {
public boolean canCastWhileMoving = false; public boolean canCastWhileMoving = false;
public boolean bladeTrails = false; public boolean bladeTrails = false;
public ArrayList<EffectDescription> effectPreReqs = new ArrayList<>(); public ArrayList<EffectDescription> effectPreReqs = new ArrayList<>();
public EquipmentPreReq equipmentPreReq; public ArrayList<EquipmentPreReq> equipmentPreReq = new ArrayList<>();
public EnumSet<mbEnums.MonsterType> monsterRestricts = EnumSet.noneOf(mbEnums.MonsterType.class); public EnumSet<mbEnums.MonsterType> monsterRestricts = EnumSet.noneOf(mbEnums.MonsterType.class);
public EnumSet<mbEnums.MonsterType> monsterPrereqs = EnumSet.noneOf(mbEnums.MonsterType.class); public EnumSet<mbEnums.MonsterType> monsterPrereqs = EnumSet.noneOf(mbEnums.MonsterType.class);
public boolean shouldCheckPath = false; public boolean shouldCheckPath = false;

Loading…
Cancel
Save