/** @param effect */ public void addEffect(Effect effect) { Map<String, Effect> mapToUpdate = getMapForEffect(effect); Effect existingEffect = mapToUpdate.get(effect.getStack()); if (existingEffect != null) { // Check stack level if (existingEffect.getSkillStackLvl() > effect.getSkillStackLvl()) return; // Check skill level (when stack level same) if (existingEffect.getSkillStackLvl() == effect.getSkillStackLvl() && existingEffect.getSkillLevel() > effect.getSkillLevel()) return; existingEffect.endEffect(); } if (effect.isToggle() && mapToUpdate.size() >= 3) { Iterator<Effect> iter = mapToUpdate.values().iterator(); Effect nextEffect = iter.next(); nextEffect.endEffect(); iter.remove(); } mapToUpdate.put(effect.getStack(), effect); effect.startEffect(false); if (!effect.isPassive()) { broadCastEffects(); } }
/** * @param effect * @return */ private Map<String, Effect> getMapForEffect(Effect effect) { if (effect.isPassive()) return passiveEffectMap; if (effect.isToggle()) return noshowEffects; return abnormalEffectMap; }