forked from MagicBane/Server
Iterate through all effects for action
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user