/** * Adds a by sourceId gained triggered ability * * @param ability - the gained ability * @param sourceId - the source that assigned the ability * @param attachedTo - the object that gained the ability */ public void add(TriggeredAbility ability, UUID sourceId, MageObject attachedTo) { if (sourceId == null) { add(ability, attachedTo); } else if (attachedTo == null) { this.put(ability.getId() + "_" + sourceId, ability); } else { this.add(ability, attachedTo); List<UUID> uuidList = new LinkedList<>(); uuidList.add(sourceId); // if the object that gained the ability moves zone, also then the triggered ability must be removed uuidList.add(attachedTo.getId()); sources.put(getKey(ability, attachedTo), uuidList); } }
public void addAbility(Ability ability, MageObject attachedTo) { if (ability instanceof StaticAbility) { for (UUID modeId : ability.getModes().getSelectedModes()) { Mode mode = ability.getModes().get(modeId); for (Effect effect : mode.getEffects()) { if (effect instanceof ContinuousEffect) { addEffect((ContinuousEffect) effect, ability); } } } } else if (ability instanceof TriggeredAbility) { this.triggers.add((TriggeredAbility) ability, attachedTo); } }
this.triggers.add((TriggeredAbility) ability, sourceId, attachedTo);