Browse Source

Power Conditions parsed

feature-config-parsing2
MagicBot 3 months ago
parent
commit
ff6d236ea7
  1. 12
      src/engine/wpak/PowersParser.java
  2. 2
      src/engine/wpak/data/PowerEntry.java

12
src/engine/wpak/PowersParser.java

@ -23,10 +23,10 @@ import java.util.regex.Pattern;
public class PowersParser { public class PowersParser {
private static String powersPath = ConfigManager.DEFAULT_DATA_DIR + "wpak/Powers.cfg";
private static final Pattern POWER_REGEX = Pattern.compile("(?<=POWERBEGIN)(.+?)(?=POWEREND)", Pattern.DOTALL); private static final Pattern POWER_REGEX = Pattern.compile("(?<=POWERBEGIN)(.+?)(?=POWEREND)", Pattern.DOTALL);
private static final Pattern STRSPLIT_REGEX = Pattern.compile("([^\"]\\S*|\"[^\"]*\")\\s*"); private static final Pattern STRSPLIT_REGEX = Pattern.compile("([^\"]\\S*|\"[^\"]*\")\\s*");
private static final Pattern CONDITION_REGEX = Pattern.compile("(?<=CONDITIONBEGIN)(.+?)(?=CONDITIONEND)", Pattern.DOTALL); private static final Pattern CONDITION_REGEX = Pattern.compile("(?<=CONDITIONBEGIN)(.+?)(?=CONDITIONEND)", Pattern.DOTALL);
private static final String powersPath = ConfigManager.DEFAULT_DATA_DIR + "wpak/Powers.cfg";
public static void parseWpakFile() throws IOException { public static void parseWpakFile() throws IOException {
@ -203,7 +203,6 @@ public class PowersParser {
equipmentPreReq.slot = mbEnums.EquipSlotType.valueOf(args.get(0)); equipmentPreReq.slot = mbEnums.EquipSlotType.valueOf(args.get(0));
equipmentPreReq.skill = args.get(1).replaceAll("\"", ""); equipmentPreReq.skill = args.get(1).replaceAll("\"", "");
;
equipmentPreReq.level = Integer.parseInt(args.get(2)); equipmentPreReq.level = Integer.parseInt(args.get(2));
powerEntry.equipmentPreReq = equipmentPreReq; powerEntry.equipmentPreReq = equipmentPreReq;
break; break;
@ -289,6 +288,15 @@ public class PowersParser {
} }
} }
// Parse power conditions
String[] conditions = conditionString.toString().split("\n");
for (String condition : conditions) {
String[] parameters = condition.trim().split("\\s+");
powerEntry.conditions.put(parameters[0], Float.parseFloat(parameters[1]));
}
} catch (Exception e) { } catch (Exception e) {
Logger.error(powerEntry.power_id + " " + e); Logger.error(powerEntry.power_id + " " + e);
} }

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

@ -12,6 +12,7 @@ import engine.mbEnums;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap;
public class PowerEntry { public class PowerEntry {
public String power_id; public String power_id;
@ -64,5 +65,6 @@ public class PowerEntry {
public ArrayList<EffectPreReq> targetEffectPrereqs = new ArrayList<>(); public ArrayList<EffectPreReq> targetEffectPrereqs = new ArrayList<>();
public boolean canCastWhileFlying = false; public boolean canCastWhileFlying = false;
public boolean isProjectile = false; public boolean isProjectile = false;
public HashMap<String, Float> conditions = new HashMap<>();
} }

Loading…
Cancel
Save