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

4
src/engine/wpak/PowersParser.java

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

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

@ -16,7 +16,7 @@ public class Effect { @@ -16,7 +16,7 @@ public class Effect {
public String effect_name;
public int icon;
public HashSet<String> sources = new HashSet<>();
public ArrayList<EffectModifier> mods = new ArrayList<>();
public ArrayList<ModifierEntry> mods = new ArrayList<>();
public ArrayList<ConditionEntry> conditions = new ArrayList<>();
// 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; @@ -10,7 +10,7 @@ package engine.wpak.data;
import engine.mbEnums;
public class EffectModifier {
public class ModifierEntry {
public mbEnums.ModType type;
public float min;
public float max;

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

@ -17,7 +17,7 @@ import java.util.HashMap; @@ -17,7 +17,7 @@ import java.util.HashMap;
public class Power {
public String power_id;
public String power;
public ArrayList<PowerData> powers = new ArrayList<>();
public ArrayList<PowerEntry> powers = new ArrayList<>();
public mbEnums.PowerTargetType target_type;
public int range;
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; @@ -10,7 +10,7 @@ package engine.wpak.data;
import engine.mbEnums;
public class PowerData {
public class PowerEntry {
public mbEnums.PowerType power_type;
public int icon;
public String powerBase;
Loading…
Cancel
Save