public void addEffect(ContinuousEffect effect, Ability source) { effects.addEffect(effect, source); }
/** * Adds a continuous ability with a reference to a sourceId. It's used for * effects that cease to exist again So this effects were removed again * before each applyEffecs * * @param effect * @param sourceId * @param source */ public synchronized void addEffect(ContinuousEffect effect, UUID sourceId, Ability source) { if (!(source instanceof MageSingleton)) { // because MageSingletons may never be removed by removing the temporary effecs they are not added to the temporaryEffects to prevent this effect.setTemporary(true); Set<Ability> abilities = temporaryEffects.get(effect); if (abilities == null) { abilities = new HashSet<>(); temporaryEffects.put(effect, abilities); } else if (abilities.contains(source)) { // this ability (for the continuous effect) is already added return; } abilities.add(source); // add the effect itself } addEffect(effect, source); }
@Override public boolean apply(Game game, Ability source) { StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget()); if(stackObject != null && game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) { TrickbindCantActivateEffect effect = new TrickbindCantActivateEffect(); effect.setTargetPointer(new FixedTarget(stackObject.getSourceId())); game.getContinuousEffects().addEffect(effect, source); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget()); if (stackObject != null && game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) { Permanent sourcePermanent = stackObject.getStackAbility().getSourcePermanentIfItStillExists(game); if (sourcePermanent != null) { InterdictCantActivateEffect effect = new InterdictCantActivateEffect(); effect.setTargetPointer(new FixedTarget(sourcePermanent, game)); game.getContinuousEffects().addEffect(effect, source); } return true; } return false; }