@Override protected void executeOverride(final RunningEffect linkedRE, final boolean trigger) { final ArrayList<RunningEffect> effectToRemove = new ArrayList<RunningEffect>(); if (this.m_target == null) { StateDecurse.m_logger.warn( (Object) "[Effect] Impossible d'appliquer un desenvoutement car la cible est null"); this.setNotified(true); return; } final RunningEffectManager effectManager = this.m_target.getRunningEffectManager(); if (effectManager == null) { return; } int newStateLevel = 0; newStateLevel = this.computeEffectsToRemove(effectToRemove, effectManager, newStateLevel); if (effectToRemove.isEmpty()) { this.setNotified(); return; } for (final RunningEffect anEffectToRemove : effectToRemove) { ((TimedRunningEffectManager) effectManager).removeEffect(anEffectToRemove, true); } this.notifyExecution(linkedRE, trigger); if (this.isValueComputationEnabled() && this.m_decreaseLevel && newStateLevel > 0) { this.applyNewState(newStateLevel, linkedRE); } }
protected int computeEffectsToRemove( final ArrayList<RunningEffect> effectToRemove, final RunningEffectManager effectManager, int newStateLevel) { for (final RunningEffect effect : effectManager) { if (!(effect instanceof StateRunningEffect)) { continue; } final State state = ((StateRunningEffect) effect).getState(); if (state.getStateBaseId() != this.m_value || (state.isInamovable() && !ApplyState.UNDECURSABLE_STATE.contains(state.getStateBaseId()))) { continue; } effectToRemove.add(effect); newStateLevel = state.getLevel() - this.m_levelToDecrease; } return newStateLevel; }