Implemented September requested cards Spellbane Centaur, Denying Wind, Diamond Kaleidoscope, and Ersatz Gnomes.

This commit is contained in:
fireshoes 2016-10-03 00:43:12 -05:00
parent 002da57ccd
commit 886b8fa676
7 changed files with 431 additions and 10 deletions

View file

@ -27,16 +27,18 @@
*/
package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.FilterObject;
import mage.filter.FilterPermanent;
import mage.filter.FilterStackObject;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.stack.StackAbility;
import mage.game.stack.StackObject;
/**
@ -46,13 +48,13 @@ import mage.game.stack.StackObject;
public class CantBeTargetedAllEffect extends ContinuousRuleModifyingEffectImpl {
private FilterPermanent filterTarget;
private FilterStackObject filterSource;
private FilterObject filterSource;
public CantBeTargetedAllEffect(FilterPermanent filterTarget, Duration duration) {
this(filterTarget, null, duration);
}
public CantBeTargetedAllEffect(FilterPermanent filterTarget, FilterStackObject filterSource, Duration duration) {
public CantBeTargetedAllEffect(FilterPermanent filterTarget, FilterObject filterSource, Duration duration) {
super(duration, Outcome.Benefit);
this.filterTarget = filterTarget;
this.filterSource = filterSource;
@ -88,13 +90,15 @@ public class CantBeTargetedAllEffect extends ContinuousRuleModifyingEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && filterTarget.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
if (filterSource == null) {
return true;
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
MageObject sourceObject;
if (stackObject instanceof StackAbility) {
sourceObject = ((StackAbility) stackObject).getSourceObject(game);
} else {
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
if (sourceObject != null && filterSource.match(sourceObject, source.getSourceId(), sourceObject.getControllerId(), game)) {
return true;
}
sourceObject = stackObject;
}
if (sourceObject != null && filterSource.match(sourceObject, game)) {
return true;
}
}
return false;