Iterate through all effects for action

This commit is contained in:
2025-02-20 14:13:13 -05:00
parent fac426a09c
commit 99acc4736f
5 changed files with 33 additions and 29 deletions
+2 -2
View File
@@ -121,7 +121,7 @@ public enum PowersManager {
// Add EffectsBase
ArrayList<EffectsBase> effectList = new ArrayList<>();
for (Effect entry : WpakPowerManager.effect_data.values()) {
for (Effect entry : WpakPowerManager._effectsLookup.values()) {
EffectsBase effectBase = new EffectsBase(entry);
effectList.add(effectBase);
PowersManager.effectsBaseByToken.put(effectBase.getToken(), effectBase);
@@ -136,7 +136,7 @@ public enum PowersManager {
HashMap<String, EffectsBase> effects = PowersManager.effectsBaseByIDString;
for (PowerAction powerAction : WpakPowerManager.power_actions.values()) {
for (PowerAction powerAction : WpakPowerManager._powerActionLookup.values()) {
AbstractPowerAction apa;
String type = powerAction.action_type;
String IDString = powerAction.action_id;
+1 -1
View File
@@ -56,7 +56,7 @@ public class EffectsParser {
while (matcher.find()) {
try {
Effect effect = parseEffectEntry(matcher.group());
WpakPowerManager.effect_data.put(effect.effect_id, effect);
WpakPowerManager._effectsLookup.put(effect.effect_id, effect);
}catch(Exception e){
Logger.error("EFFECT PARSE FAILED: " + e);
}
+1 -1
View File
@@ -54,7 +54,7 @@ public class PowerActionParser {
while (matcher.find()) {
PowerAction powerAction = parsePowerActionEntry(matcher.group().trim());
WpakPowerManager.power_actions.put(Hasher.SBStringHash(powerAction.action_id),powerAction);
WpakPowerManager._powerActionLookup.put(Hasher.SBStringHash(powerAction.action_id), powerAction);
}
}
+1 -1
View File
@@ -52,7 +52,7 @@ public class PowersParser {
while (matcher.find()) {
Power power = parsePowerEntry(matcher.group().trim());
WpakPowerManager.powers.put(Hasher.SBStringHash(power.power_id),power);
WpakPowerManager._powersLookup.put(Hasher.SBStringHash(power.power_id), power);
}
}
+28 -24
View File
@@ -41,9 +41,9 @@ import java.util.HashSet;
import static engine.math.FastMath.sqr;
public class WpakPowerManager {
public static HashMap<String, Effect> effect_data = new HashMap<>();
public static HashMap<Integer, PowerAction> power_actions = new HashMap<>();
public static HashMap<Integer, Power> powers = new HashMap<>();
public static HashMap<String, Effect> _effectsLookup = new HashMap<>();
public static HashMap<Integer, PowerAction> _powerActionLookup = new HashMap<>();
public static HashMap<Integer, Power> _powersLookup = new HashMap<>();
private static JobScheduler js;
@@ -98,7 +98,7 @@ public class WpakPowerManager {
}
//lookup the power that was cast
Power powerCast = powers.get(msg.getPowerUsedID());
Power powerCast = _powersLookup.get(msg.getPowerUsedID());
if (powerCast == null) {
ChatManager.chatSayInfo(playerCharacter, "This power is not implemented yet.");
return true;
@@ -291,7 +291,7 @@ public class WpakPowerManager {
}
public static void finishUsePower(PerformActionMsg msg, PlayerCharacter caster, AbstractWorldObject target) {
Power powerUsed = powers.get(msg.getPowerUsedID());
Power powerUsed = _powersLookup.get(msg.getPowerUsedID());
if (powerUsed == null)
return;
if (powerUsed.maxMobTargets > 1 || powerUsed.maxPlayerTargets > 1) {
@@ -337,34 +337,38 @@ public class WpakPowerManager {
for (ActionEntry actionEntry : power.actionEntries) {
Effect effect = effect_data.get(actionEntry.action_id);
PowerAction powerAction = _powerActionLookup.get(actionEntry.action_id);
if (effect == null) {
Logger.error("Null effect for " + actionEntry.action_id);
if (powerAction == null) {
Logger.error("Null PowerAction for " + actionEntry.action_id);
continue;
}
// Create pojo to hold effect/modifiers stored in AWO
// Iterate effects for this powerAction and apply
AppliedEffect appliedEffect = new AppliedEffect();
appliedEffect.effect = effect;
appliedEffect.rank = rank;
for (Effect effect : powerAction.effects) {
// Add calculated modifiers to pojo
// Create pojo to hold effect/modifiers stored in AWO
for (ModifierEntry modifierEntry : effect.mods) {
Object modifier = modifierEntry.type.behaviorType.apply(caster, target, power,
actionEntry, effect, modifierEntry, rank);
appliedEffect.modifiers.put(modifierEntry.type, modifier);
AppliedEffect appliedEffect = new AppliedEffect();
appliedEffect.effect = effect;
appliedEffect.rank = rank;
// Add calculated modifiers to pojo
for (ModifierEntry modifierEntry : effect.mods) {
Object modifier = modifierEntry.type.behaviorType.apply(caster, target, power,
actionEntry, effect, modifierEntry, rank);
appliedEffect.modifiers.put(modifierEntry.type, modifier);
}
// Add this power effect to the target
// or overwrite the old value
target._effects.put(effect, appliedEffect);
// target.updateBonuses()?
}
// Add this power effect to the target
// or overwrite the old value
target._effects.put(effect, appliedEffect);
// target.updateBonuses()?
}
}
public static void sendPowerMsg(PlayerCharacter playerCharacter, int type, PerformActionMsg msg) {