Refactor manager for action support

This commit is contained in:
2025-02-22 07:57:38 -05:00
parent e3e8fae90c
commit 7ed291860f
2 changed files with 29 additions and 28 deletions
+29 -1
View File
@@ -2,6 +2,8 @@ package engine.wpakpowers;
import engine.objects.AbstractCharacter; import engine.objects.AbstractCharacter;
import engine.objects.AbstractWorldObject; import engine.objects.AbstractWorldObject;
import engine.wpak.data.Effect;
import engine.wpak.data.ModifierEntry;
import engine.wpak.data.Power; import engine.wpak.data.Power;
import engine.wpak.data.PowerAction; import engine.wpak.data.PowerAction;
@@ -14,7 +16,33 @@ public class Actions {
public static void ApplyEffects(AbstractCharacter caster, AbstractWorldObject target, Power power, public static void ApplyEffects(AbstractCharacter caster, AbstractWorldObject target, Power power,
Integer rank, PowerAction powerAction) { Integer rank, PowerAction powerAction) {
System.out.println("PowerAction method called");
// Iterate effects for this powerAction and apply
for (Effect effect : powerAction.effects) {
// Create pojo to hold effect/modifiers stored in AWO
AppliedEffect appliedEffect = new AppliedEffect();
appliedEffect.effect = effect;
appliedEffect.rank = rank;
// Add modifier objects from behaviours to pojo.
// Anything from a float to an array can be returned
// based on the needs of the behaviour.
for (ModifierEntry modifierEntry : effect.mods) {
Object modifier = modifierEntry.type.behaviorType.apply(caster, target, power,
powerAction, 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() here?
} }
public static void Block(AbstractCharacter caster, AbstractWorldObject target, Power power, public static void Block(AbstractCharacter caster, AbstractWorldObject target, Power power,
@@ -353,33 +353,6 @@ public class WpakPowerManager {
powerAction.action_type.execute(caster, target, power, rank, powerAction.action_type.execute(caster, target, power, rank,
powerAction); powerAction);
// Iterate effects for this powerAction and apply
for (Effect effect : powerAction.effects) {
// Create pojo to hold effect/modifiers stored in AWO
AppliedEffect appliedEffect = new AppliedEffect();
appliedEffect.effect = effect;
appliedEffect.rank = rank;
// Add modifier objects from behaviours to pojo.
// Anything from a float to an array can be returned
// based on the needs of the behaviour.
for (ModifierEntry modifierEntry : effect.mods) {
Object modifier = modifierEntry.type.behaviorType.apply(caster, target, power,
powerAction, 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() here?
} }
} }