forked from MagicBane/Server
Refactor manager for action support
This commit is contained in:
@@ -2,6 +2,8 @@ package engine.wpakpowers;
|
||||
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.AbstractWorldObject;
|
||||
import engine.wpak.data.Effect;
|
||||
import engine.wpak.data.ModifierEntry;
|
||||
import engine.wpak.data.Power;
|
||||
import engine.wpak.data.PowerAction;
|
||||
|
||||
@@ -14,7 +16,33 @@ public class Actions {
|
||||
|
||||
public static void ApplyEffects(AbstractCharacter caster, AbstractWorldObject target, Power power,
|
||||
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,
|
||||
|
||||
@@ -353,33 +353,6 @@ public class WpakPowerManager {
|
||||
|
||||
powerAction.action_type.execute(caster, target, power, rank,
|
||||
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?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user