Browse Source

Naming conventions set

feature-config-parsing2
MagicBot 3 months ago
parent
commit
3842cce1ab
  1. 58
      src/engine/wpak/EffectsParser.java
  2. 4
      src/engine/wpak/PowersParser.java
  3. 2
      src/engine/wpak/data/Effect.java
  4. 2
      src/engine/wpak/data/ModifierEntry.java
  5. 2
      src/engine/wpak/data/Power.java
  6. 2
      src/engine/wpak/data/PowerEntry.java

58
src/engine/wpak/EffectsParser.java

@ -12,7 +12,7 @@ import engine.gameManager.ConfigManager;
import engine.mbEnums; import engine.mbEnums;
import engine.wpak.data.ConditionEntry; import engine.wpak.data.ConditionEntry;
import engine.wpak.data.Effect; import engine.wpak.data.Effect;
import engine.wpak.data.EffectModifier; import engine.wpak.data.ModifierEntry;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.io.IOException; import java.io.IOException;
@ -116,8 +116,8 @@ public class EffectsParser {
// Iterate effect entries from .wpak config data // Iterate effect entries from .wpak config data
while (matcher.find()) { while (matcher.find()) {
EffectModifier effectModifier = parseModEntry(matcher.group()); ModifierEntry modifierEntry = parseModEntry(matcher.group());
effect.mods.add(effectModifier); effect.mods.add(modifierEntry);
} }
// Parse Conditions // Parse Conditions
@ -148,9 +148,9 @@ public class EffectsParser {
return effect; return effect;
} }
private static EffectModifier parseModEntry(String modData) { private static ModifierEntry parseModEntry(String modData) {
EffectModifier effectModifier = new EffectModifier(); ModifierEntry modifierEntry = new ModifierEntry();
String[] modEntries = modData.trim().split("\n"); String[] modEntries = modData.trim().split("\n");
@ -162,22 +162,22 @@ public class EffectsParser {
while (matcher.find()) while (matcher.find())
modValues.add(matcher.group().trim()); modValues.add(matcher.group().trim());
effectModifier.type = mbEnums.ModType.valueOf(modValues.get(0).trim()); modifierEntry.type = mbEnums.ModType.valueOf(modValues.get(0).trim());
switch (effectModifier.type) { switch (modifierEntry.type) {
case AnimOverride: case AnimOverride:
effectModifier.min = Float.parseFloat(modValues.get(1).trim()); modifierEntry.min = Float.parseFloat(modValues.get(1).trim());
effectModifier.max = Float.parseFloat(modValues.get(2).trim()); modifierEntry.max = Float.parseFloat(modValues.get(2).trim());
break; break;
case Health: case Health:
case Mana: case Mana:
case Stamina: case Stamina:
effectModifier.min = Float.parseFloat(modValues.get(1).trim()); modifierEntry.min = Float.parseFloat(modValues.get(1).trim());
effectModifier.max = Float.parseFloat(modValues.get(2).trim()); modifierEntry.max = Float.parseFloat(modValues.get(2).trim());
effectModifier.value = Float.parseFloat(modValues.get(3).trim()); modifierEntry.value = Float.parseFloat(modValues.get(3).trim());
// Parameter 4 is always 0. // Parameter 4 is always 0.
effectModifier.compoundCurveType = mbEnums.CompoundCurveType.valueOf(modValues.get(5).trim()); modifierEntry.compoundCurveType = mbEnums.CompoundCurveType.valueOf(modValues.get(5).trim());
effectModifier.arg1 = modValues.get(6).trim(); modifierEntry.arg1 = modValues.get(6).trim();
break; break;
case Attr: case Attr:
case Resistance: case Resistance:
@ -192,12 +192,12 @@ public class EffectsParser {
case Slay: case Slay:
case Fade: case Fade:
case Durability: case Durability:
effectModifier.min = Float.parseFloat(modValues.get(1).trim()); modifierEntry.min = Float.parseFloat(modValues.get(1).trim());
effectModifier.max = Float.parseFloat(modValues.get(2).trim()); modifierEntry.max = Float.parseFloat(modValues.get(2).trim());
effectModifier.compoundCurveType = mbEnums.CompoundCurveType.valueOf(modValues.get(3).trim()); modifierEntry.compoundCurveType = mbEnums.CompoundCurveType.valueOf(modValues.get(3).trim());
if (modValues.size() > 4) if (modValues.size() > 4)
effectModifier.arg1 = modValues.get(4).trim(); // Some HeathFull entries do not have an argument modifierEntry.arg1 = modValues.get(4).trim(); // Some HeathFull entries do not have an argument
break; break;
case MeleeDamageModifier: case MeleeDamageModifier:
case OCV: case OCV:
@ -222,32 +222,32 @@ public class EffectsParser {
case ScanRange: case ScanRange:
case ScaleHeight: case ScaleHeight:
case ScaleWidth: case ScaleWidth:
effectModifier.min = Float.parseFloat(modValues.get(1).trim()); modifierEntry.min = Float.parseFloat(modValues.get(1).trim());
effectModifier.max = Float.parseFloat(modValues.get(2).trim()); modifierEntry.max = Float.parseFloat(modValues.get(2).trim());
effectModifier.compoundCurveType = mbEnums.CompoundCurveType.valueOf(modValues.get(3).trim()); modifierEntry.compoundCurveType = mbEnums.CompoundCurveType.valueOf(modValues.get(3).trim());
break; break;
case ItemName: case ItemName:
case BlockedPowerType: case BlockedPowerType:
case ImmuneTo: case ImmuneTo:
case BlackMantle: case BlackMantle:
effectModifier.arg1 = modValues.get(1).trim(); modifierEntry.arg1 = modValues.get(1).trim();
// Some BlockedPowerType entries have only one argument // Some BlockedPowerType entries have only one argument
if (modValues.size() > 2) if (modValues.size() > 2)
effectModifier.arg2 = modValues.get(2).trim(); modifierEntry.arg2 = modValues.get(2).trim();
break; break;
case NoMod: case NoMod:
case ConstrainedAmbidexterity: case ConstrainedAmbidexterity:
case ProtectionFrom: case ProtectionFrom:
case ExclusiveDamageCap: case ExclusiveDamageCap:
case IgnoreDamageCap: case IgnoreDamageCap:
effectModifier.arg1 = modValues.get(1).trim(); modifierEntry.arg1 = modValues.get(1).trim();
break; break;
case WeaponProc: case WeaponProc:
effectModifier.min = Float.parseFloat(modValues.get(1).trim()); modifierEntry.min = Float.parseFloat(modValues.get(1).trim());
effectModifier.arg1 = modValues.get(2).trim(); modifierEntry.arg1 = modValues.get(2).trim();
effectModifier.max = Float.parseFloat(modValues.get(3).trim()); modifierEntry.max = Float.parseFloat(modValues.get(3).trim());
break; break;
case BladeTrails: // These tags have no parms or are not parsed case BladeTrails: // These tags have no parms or are not parsed
case ImmuneToAttack: case ImmuneToAttack:
@ -268,12 +268,12 @@ public class EffectsParser {
case SeeInvisible: case SeeInvisible:
break; break;
default: default:
Logger.error("Unhandled type: " + effectModifier.type); Logger.error("Unhandled type: " + modifierEntry.type);
break; break;
} }
} }
return effectModifier; return modifierEntry;
} }
} }

4
src/engine/wpak/PowersParser.java

@ -101,7 +101,7 @@ public class PowersParser {
powerEntry.power_id = iterator.next(); powerEntry.power_id = iterator.next();
powerEntry.power = iterator.next().replaceAll("\"", ""); powerEntry.power = iterator.next().replaceAll("\"", "");
PowerData power = new PowerData(); PowerEntry power = new PowerEntry();
power.power_type = mbEnums.PowerType.valueOf(iterator.next()); power.power_type = mbEnums.PowerType.valueOf(iterator.next());
power.icon = Integer.parseInt(iterator.next()); power.icon = Integer.parseInt(iterator.next());
power.powerBase = iterator.next().replaceAll("\"", ""); power.powerBase = iterator.next().replaceAll("\"", "");
@ -112,7 +112,7 @@ public class PowersParser {
// Account for second definition // Account for second definition
if (nextValue.equals("SPELL") || nextValue.equals("SKILL")) { if (nextValue.equals("SPELL") || nextValue.equals("SKILL")) {
power = new PowerData(); power = new PowerEntry();
power.power_type = mbEnums.PowerType.valueOf(nextValue); power.power_type = mbEnums.PowerType.valueOf(nextValue);
power.icon = Integer.parseInt(iterator.next()); power.icon = Integer.parseInt(iterator.next());
power.powerBase = iterator.next().replaceAll("\"", ""); power.powerBase = iterator.next().replaceAll("\"", "");

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

@ -16,7 +16,7 @@ public class Effect {
public String effect_name; public String effect_name;
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<ModifierEntry> mods = new ArrayList<>();
public ArrayList<ConditionEntry> conditions = new ArrayList<>(); public ArrayList<ConditionEntry> conditions = new ArrayList<>();
// Additional variables outside of tags or parsed // Additional variables outside of tags or parsed

2
src/engine/wpak/data/EffectModifier.java → src/engine/wpak/data/ModifierEntry.java

@ -10,7 +10,7 @@ package engine.wpak.data;
import engine.mbEnums; import engine.mbEnums;
public class EffectModifier { public class ModifierEntry {
public mbEnums.ModType type; public mbEnums.ModType type;
public float min; public float min;
public float max; public float max;

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

@ -17,7 +17,7 @@ import java.util.HashMap;
public class Power { public class Power {
public String power_id; public String power_id;
public String power; public String power;
public ArrayList<PowerData> powers = new ArrayList<>(); public ArrayList<PowerEntry> powers = new ArrayList<>();
public mbEnums.PowerTargetType target_type; public mbEnums.PowerTargetType target_type;
public int range; public int range;
public mbEnums.AreaType areaType; public mbEnums.AreaType areaType;

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

@ -10,7 +10,7 @@ package engine.wpak.data;
import engine.mbEnums; import engine.mbEnums;
public class PowerData { public class PowerEntry {
public mbEnums.PowerType power_type; public mbEnums.PowerType power_type;
public int icon; public int icon;
public String powerBase; public String powerBase;
Loading…
Cancel
Save