private void addNonStackableActorCondition(Actor actor, ActorConditionEffect e, int duration) { final ActorConditionType type = e.conditionType; for (int i = actor.conditions.size() - 1; i >= 0; --i) { ActorCondition c = actor.conditions.get(i); if (!type.conditionTypeID.equals(c.conditionType.conditionTypeID)) continue; if (c.magnitude > e.magnitude) return; if (c.magnitude == e.magnitude) { if (c.duration >= duration) return; } // If the actor already has this condition, but of a lower magnitude, we remove the old one // and add this higher magnitude. actor.conditions.remove(i); actorConditionListeners.onActorConditionRemoved(actor, c); } ActorCondition c = e.createCondition(duration); actor.conditions.add(c); actorConditionListeners.onActorConditionAdded(actor, c); }