forked from MagicBane/Server
Iterate through all effects for action
This commit is contained in:
@@ -121,7 +121,7 @@ public enum PowersManager {
|
|||||||
// Add EffectsBase
|
// Add EffectsBase
|
||||||
ArrayList<EffectsBase> effectList = new ArrayList<>();
|
ArrayList<EffectsBase> effectList = new ArrayList<>();
|
||||||
|
|
||||||
for (Effect entry : WpakPowerManager.effect_data.values()) {
|
for (Effect entry : WpakPowerManager._effectsLookup.values()) {
|
||||||
EffectsBase effectBase = new EffectsBase(entry);
|
EffectsBase effectBase = new EffectsBase(entry);
|
||||||
effectList.add(effectBase);
|
effectList.add(effectBase);
|
||||||
PowersManager.effectsBaseByToken.put(effectBase.getToken(), effectBase);
|
PowersManager.effectsBaseByToken.put(effectBase.getToken(), effectBase);
|
||||||
@@ -136,7 +136,7 @@ public enum PowersManager {
|
|||||||
|
|
||||||
HashMap<String, EffectsBase> effects = PowersManager.effectsBaseByIDString;
|
HashMap<String, EffectsBase> effects = PowersManager.effectsBaseByIDString;
|
||||||
|
|
||||||
for (PowerAction powerAction : WpakPowerManager.power_actions.values()) {
|
for (PowerAction powerAction : WpakPowerManager._powerActionLookup.values()) {
|
||||||
AbstractPowerAction apa;
|
AbstractPowerAction apa;
|
||||||
String type = powerAction.action_type;
|
String type = powerAction.action_type;
|
||||||
String IDString = powerAction.action_id;
|
String IDString = powerAction.action_id;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class EffectsParser {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
try {
|
try {
|
||||||
Effect effect = parseEffectEntry(matcher.group());
|
Effect effect = parseEffectEntry(matcher.group());
|
||||||
WpakPowerManager.effect_data.put(effect.effect_id, effect);
|
WpakPowerManager._effectsLookup.put(effect.effect_id, effect);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
Logger.error("EFFECT PARSE FAILED: " + e);
|
Logger.error("EFFECT PARSE FAILED: " + e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class PowerActionParser {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
|
||||||
PowerAction powerAction = parsePowerActionEntry(matcher.group().trim());
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class PowersParser {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
|
||||||
Power power = parsePowerEntry(matcher.group().trim());
|
Power power = parsePowerEntry(matcher.group().trim());
|
||||||
WpakPowerManager.powers.put(Hasher.SBStringHash(power.power_id),power);
|
WpakPowerManager._powersLookup.put(Hasher.SBStringHash(power.power_id), power);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ import java.util.HashSet;
|
|||||||
import static engine.math.FastMath.sqr;
|
import static engine.math.FastMath.sqr;
|
||||||
|
|
||||||
public class WpakPowerManager {
|
public class WpakPowerManager {
|
||||||
public static HashMap<String, Effect> effect_data = new HashMap<>();
|
public static HashMap<String, Effect> _effectsLookup = new HashMap<>();
|
||||||
public static HashMap<Integer, PowerAction> power_actions = new HashMap<>();
|
public static HashMap<Integer, PowerAction> _powerActionLookup = new HashMap<>();
|
||||||
public static HashMap<Integer, Power> powers = new HashMap<>();
|
public static HashMap<Integer, Power> _powersLookup = new HashMap<>();
|
||||||
|
|
||||||
private static JobScheduler js;
|
private static JobScheduler js;
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public class WpakPowerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//lookup the power that was cast
|
//lookup the power that was cast
|
||||||
Power powerCast = powers.get(msg.getPowerUsedID());
|
Power powerCast = _powersLookup.get(msg.getPowerUsedID());
|
||||||
if (powerCast == null) {
|
if (powerCast == null) {
|
||||||
ChatManager.chatSayInfo(playerCharacter, "This power is not implemented yet.");
|
ChatManager.chatSayInfo(playerCharacter, "This power is not implemented yet.");
|
||||||
return true;
|
return true;
|
||||||
@@ -291,7 +291,7 @@ public class WpakPowerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void finishUsePower(PerformActionMsg msg, PlayerCharacter caster, AbstractWorldObject target) {
|
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)
|
if (powerUsed == null)
|
||||||
return;
|
return;
|
||||||
if (powerUsed.maxMobTargets > 1 || powerUsed.maxPlayerTargets > 1) {
|
if (powerUsed.maxMobTargets > 1 || powerUsed.maxPlayerTargets > 1) {
|
||||||
@@ -337,34 +337,38 @@ public class WpakPowerManager {
|
|||||||
|
|
||||||
for (ActionEntry actionEntry : power.actionEntries) {
|
for (ActionEntry actionEntry : power.actionEntries) {
|
||||||
|
|
||||||
Effect effect = effect_data.get(actionEntry.action_id);
|
PowerAction powerAction = _powerActionLookup.get(actionEntry.action_id);
|
||||||
|
|
||||||
if (effect == null) {
|
if (powerAction == null) {
|
||||||
Logger.error("Null effect for " + actionEntry.action_id);
|
Logger.error("Null PowerAction for " + actionEntry.action_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create pojo to hold effect/modifiers stored in AWO
|
// Iterate effects for this powerAction and apply
|
||||||
|
|
||||||
AppliedEffect appliedEffect = new AppliedEffect();
|
for (Effect effect : powerAction.effects) {
|
||||||
appliedEffect.effect = effect;
|
|
||||||
appliedEffect.rank = rank;
|
|
||||||
|
|
||||||
// Add calculated modifiers to pojo
|
// Create pojo to hold effect/modifiers stored in AWO
|
||||||
|
|
||||||
for (ModifierEntry modifierEntry : effect.mods) {
|
AppliedEffect appliedEffect = new AppliedEffect();
|
||||||
Object modifier = modifierEntry.type.behaviorType.apply(caster, target, power,
|
appliedEffect.effect = effect;
|
||||||
actionEntry, effect, modifierEntry, rank);
|
appliedEffect.rank = rank;
|
||||||
appliedEffect.modifiers.put(modifierEntry.type, modifier);
|
|
||||||
|
// 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) {
|
public static void sendPowerMsg(PlayerCharacter playerCharacter, int type, PerformActionMsg msg) {
|
||||||
|
|||||||
Reference in New Issue
Block a user