* Replaced some card classes by framework classes. Some minor changes to cards.

This commit is contained in:
LevelX2 2015-07-21 14:55:15 +02:00
parent 00e4e3be6c
commit 1728eb01e0
33 changed files with 406 additions and 911 deletions

View file

@ -30,7 +30,7 @@ package mage.sets.commander2013;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
@ -40,12 +40,11 @@ import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.token.Token; import mage.game.permanent.token.Token;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
@ -57,6 +56,7 @@ import mage.target.targetpointer.FixedTarget;
public class EndrekSahrMasterBreeder extends CardImpl { public class EndrekSahrMasterBreeder extends CardImpl {
private static final FilterSpell filter = new FilterSpell("a creature spell"); private static final FilterSpell filter = new FilterSpell("a creature spell");
static { static {
filter.add(new CardTypePredicate(CardType.CREATURE)); filter.add(new CardTypePredicate(CardType.CREATURE));
} }
@ -74,7 +74,9 @@ public class EndrekSahrMasterBreeder extends CardImpl {
// Whenever you cast a creature spell, put X 1/1 black Thrull creature tokens onto the battlefield, where X is that spell's converted mana cost. // Whenever you cast a creature spell, put X 1/1 black Thrull creature tokens onto the battlefield, where X is that spell's converted mana cost.
this.addAbility(new SpellCastControllerTriggeredAbility(new EndrekSahrMasterBreederEffect(), filter, false, true)); this.addAbility(new SpellCastControllerTriggeredAbility(new EndrekSahrMasterBreederEffect(), filter, false, true));
// When you control seven or more Thrulls, sacrifice Endrek Sahr, Master Breeder. // When you control seven or more Thrulls, sacrifice Endrek Sahr, Master Breeder.
this.addAbility(new EndrekSahrMasterBreederTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterCreaturePermanent("Thrull", "seven or more Thrulls"), Filter.ComparisonType.GreaterThan, 6,
new SacrificeSourceEffect()));
} }
public EndrekSahrMasterBreeder(final EndrekSahrMasterBreeder card) { public EndrekSahrMasterBreeder(final EndrekSahrMasterBreeder card) {
@ -87,37 +89,6 @@ public class EndrekSahrMasterBreeder extends CardImpl {
} }
} }
class EndrekSahrMasterBreederTriggeredAbility extends StateTriggeredAbility {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
static {
filter.add(new SubtypePredicate("Thrull"));
}
public EndrekSahrMasterBreederTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public EndrekSahrMasterBreederTriggeredAbility(final EndrekSahrMasterBreederTriggeredAbility ability) {
super(ability);
}
@Override
public EndrekSahrMasterBreederTriggeredAbility copy() {
return new EndrekSahrMasterBreederTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(filter, this.getControllerId(), game) >= 7);
}
@Override
public String getRule() {
return "When you control seven or more Thrulls, sacrifice {this}.";
}
}
class EndrekSahrMasterBreederEffect extends OneShotEffect { class EndrekSahrMasterBreederEffect extends OneShotEffect {
public EndrekSahrMasterBreederEffect() { public EndrekSahrMasterBreederEffect() {
@ -138,7 +109,7 @@ class EndrekSahrMasterBreederEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell == null) { if (spell == null) {
spell = (Spell) game.getLastKnownInformation(((FixedTarget)getTargetPointer()).getTarget(), Zone.STACK); spell = (Spell) game.getLastKnownInformation(((FixedTarget) getTargetPointer()).getTarget(), Zone.STACK);
} }
if (spell != null) { if (spell != null) {
int cmc = spell.getConvertedManaCost(); int cmc = spell.getConvertedManaCost();

View file

@ -30,13 +30,12 @@ package mage.sets.elvesvsgoblins;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.CardTypePredicate;
@ -55,7 +54,7 @@ public class SkirkShaman extends CardImpl {
Predicates.or( Predicates.or(
Predicates.and(new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.CREATURE)), Predicates.and(new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.CREATURE)),
Predicates.and(new CardTypePredicate(CardType.CREATURE), new ColorPredicate(ObjectColor.RED) Predicates.and(new CardTypePredicate(CardType.CREATURE), new ColorPredicate(ObjectColor.RED)
)))); ))));
} }
public SkirkShaman(UUID ownerId) { public SkirkShaman(UUID ownerId) {
@ -68,7 +67,7 @@ public class SkirkShaman extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Skirk Shaman can't be blocked except by artifact creatures and/or red creatures. // Skirk Shaman can't be blocked except by artifact creatures and/or red creatures.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
} }

View file

@ -29,14 +29,13 @@ package mage.sets.eventide;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.abilities.keyword.DefenderAbility; import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.AbilityPredicate; import mage.filter.predicate.mageobject.AbilityPredicate;
@ -44,7 +43,7 @@ import mage.filter.predicate.mageobject.AbilityPredicate;
/** /**
* *
* @author jeffwadsworth * @author jeffwadsworth
*
*/ */
public class NoggleBandit extends CardImpl { public class NoggleBandit extends CardImpl {
@ -64,7 +63,7 @@ public class NoggleBandit extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Noggle Bandit can't be blocked except by creatures with defender. // Noggle Bandit can't be blocked except by creatures with defender.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
} }

View file

@ -32,7 +32,7 @@ import java.util.UUID;
import mage.constants.*; import mage.constants.*;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SkipUntapOptionalAbility; import mage.abilities.common.SkipUntapOptionalAbility;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
@ -42,13 +42,13 @@ import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.common.SacrificeSourceEffect; import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect; import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.CardIdPredicate; import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.filter.predicate.permanent.ControllerControlsIslandPredicate; import mage.filter.predicate.permanent.ControllerControlsIslandPredicate;
@ -80,7 +80,9 @@ public class Seasinger extends CardImpl {
seasinger.add(new CardIdPredicate(this.getId())); seasinger.add(new CardIdPredicate(this.getId()));
// When you control no Islands, sacrifice Seasinger. // When you control no Islands, sacrifice Seasinger.
this.addAbility(new SeasingerTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterLandPermanent("Island", "no Islands"), Filter.ComparisonType.Equal, 0,
new SacrificeSourceEffect()));
// You may choose not to untap Seasinger during your untap step. // You may choose not to untap Seasinger during your untap step.
this.addAbility(new SkipUntapOptionalAbility()); this.addAbility(new SkipUntapOptionalAbility());
@ -104,29 +106,3 @@ public class Seasinger extends CardImpl {
return new Seasinger(this); return new Seasinger(this);
} }
} }
class SeasingerTriggeredAbility extends StateTriggeredAbility {
public SeasingerTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public SeasingerTriggeredAbility(final SeasingerTriggeredAbility ability) {
super(ability);
}
@Override
public SeasingerTriggeredAbility copy() {
return new SeasingerTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(ControllerControlsIslandPredicate.filter, controllerId, game) == 0);
}
@Override
public String getRule() {
return "When you control no islands, sacrifice {this}.";
}
}

View file

@ -29,7 +29,7 @@ package mage.sets.fallenempires;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
@ -43,10 +43,8 @@ import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.permanent.ControllerControlsIslandPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
/** /**
* *
@ -66,10 +64,12 @@ public class VodalianKnights extends CardImpl {
this.addAbility(FirstStrikeAbility.getInstance()); this.addAbility(FirstStrikeAbility.getInstance());
// Vodalian Knights can't attack unless defending player controls an Island. // Vodalian Knights can't attack unless defending player controls an Island.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island", "an Island"))));
// When you control no Islands, sacrifice Vodalian Knights. // When you control no Islands, sacrifice Vodalian Knights.
this.addAbility(new VodalianKnightsTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterLandPermanent("Island", "no Islands"), Filter.ComparisonType.Equal, 0,
new SacrificeSourceEffect()));
// {U}: Vodalian Knights gains flying until end of turn. // {U}: Vodalian Knights gains flying until end of turn.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), new ManaCostsImpl("{U}"))); this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), new ManaCostsImpl("{U}")));
@ -84,29 +84,3 @@ public class VodalianKnights extends CardImpl {
return new VodalianKnights(this); return new VodalianKnights(this);
} }
} }
class VodalianKnightsTriggeredAbility extends StateTriggeredAbility {
public VodalianKnightsTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public VodalianKnightsTriggeredAbility(final VodalianKnightsTriggeredAbility ability) {
super(ability);
}
@Override
public VodalianKnightsTriggeredAbility copy() {
return new VodalianKnightsTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(ControllerControlsIslandPredicate.filter, controllerId, game) == 0);
}
@Override
public String getRule() {
return "When you control no islands, sacrifice {this}.";
}
}

View file

@ -29,21 +29,19 @@ package mage.sets.fifthedition;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.SacrificeSourceEffect; import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent; import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.*; import mage.constants.*;
import mage.filter.Filter;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.permanent.ControllerControlsIslandPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
/** /**
* *
* @author KholdFuzion * @author KholdFuzion
*
*/ */
public class Dandan extends CardImpl { public class Dandan extends CardImpl {
@ -56,10 +54,12 @@ public class Dandan extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// Dandan can't attack unless defending player controls an Island. // Dandan can't attack unless defending player controls an Island.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island", "an Island"))));
// When you control no Islands, sacrifice Dandan. // When you control no Islands, sacrifice Dandan.
this.addAbility(new DandanTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterLandPermanent("Island", "no Islands"), Filter.ComparisonType.Equal, 0,
new SacrificeSourceEffect()));
} }
public Dandan(final Dandan card) { public Dandan(final Dandan card) {
@ -71,29 +71,3 @@ public class Dandan extends CardImpl {
return new Dandan(this); return new Dandan(this);
} }
} }
class DandanTriggeredAbility extends StateTriggeredAbility {
public DandanTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public DandanTriggeredAbility(final DandanTriggeredAbility ability) {
super(ability);
}
@Override
public DandanTriggeredAbility copy() {
return new DandanTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(ControllerControlsIslandPredicate.filter, controllerId, game) == 0);
}
@Override
public String getRule() {
return "When you control no Islands, sacrifice {this}.";
}
}

View file

@ -29,6 +29,7 @@ package mage.sets.fifthedition;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect; import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
@ -70,7 +71,7 @@ public class EvilEyeOfOrmsByGore extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, cantAttackFilter))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, cantAttackFilter)));
// Evil Eye of Orms-by-Gore can't be blocked except by Walls. // Evil Eye of Orms-by-Gore can't be blocked except by Walls.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(cantBeBlockedByFilter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(cantBeBlockedByFilter, Duration.WhileOnBattlefield)));
} }
public EvilEyeOfOrmsByGore(final EvilEyeOfOrmsByGore card) { public EvilEyeOfOrmsByGore(final EvilEyeOfOrmsByGore card) {

View file

@ -29,7 +29,7 @@ package mage.sets.iceage;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.SacrificeSourceEffect; import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent; import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent;
@ -37,10 +37,8 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
/** /**
* *
@ -56,10 +54,12 @@ public class GorillaPack extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// Gorilla Pack can't attack unless defending player controls a Forest. // Gorilla Pack can't attack unless defending player controls a Forest.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Forest","a Forest")))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Forest", "a Forest"))));
// When you control no Forests, sacrifice Gorilla Pack. // When you control no Forests, sacrifice Gorilla Pack.
this.addAbility(new GorillaPackTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterLandPermanent("Forest", "no Forests"), Filter.ComparisonType.Equal, 0,
new SacrificeSourceEffect()));
} }
public GorillaPack(final GorillaPack card) { public GorillaPack(final GorillaPack card) {
@ -71,35 +71,3 @@ public class GorillaPack extends CardImpl {
return new GorillaPack(this); return new GorillaPack(this);
} }
} }
class GorillaPackTriggeredAbility extends StateTriggeredAbility {
public static final FilterLandPermanent filter = new FilterLandPermanent("Forest");
{
filter.add(new SubtypePredicate("Forest"));
}
public GorillaPackTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public GorillaPackTriggeredAbility(final GorillaPackTriggeredAbility ability) {
super(ability);
}
@Override
public GorillaPackTriggeredAbility copy() {
return new GorillaPackTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(filter, controllerId, game) == 0);
}
@Override
public String getRule() {
return "When you control no forests, sacrifice {this}.";
}
}

View file

@ -30,9 +30,8 @@ package mage.sets.khansoftarkir;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.abilities.keyword.MorphAbility;
import mage.abilities.keyword.CantBeBlockedSourceAbility; import mage.abilities.keyword.CantBeBlockedSourceAbility;
import mage.abilities.keyword.MorphAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;

View file

@ -30,7 +30,7 @@ package mage.sets.khansoftarkir;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.condition.common.RaidCondition; import mage.abilities.condition.common.RaidCondition;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -38,7 +38,6 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.Filter; import mage.filter.Filter;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
@ -52,6 +51,7 @@ import mage.watchers.common.PlayerAttackedWatcher;
public class WarNameAspirant extends CardImpl { public class WarNameAspirant extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with power 1 or less"); private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with power 1 or less");
static { static {
filter.add(new PowerPredicate(Filter.ComparisonType.LessThan, 2)); filter.add(new PowerPredicate(Filter.ComparisonType.LessThan, 2));
} }
@ -74,7 +74,7 @@ public class WarNameAspirant extends CardImpl {
new PlayerAttackedWatcher()); new PlayerAttackedWatcher());
// War-Name Aspirant can't be blocked by creatures with power 1 or less. // War-Name Aspirant can't be blocked by creatures with power 1 or less.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
} }
public WarNameAspirant(final WarNameAspirant card) { public WarNameAspirant(final WarNameAspirant card) {

View file

@ -30,7 +30,7 @@ package mage.sets.limitedalpha;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
@ -38,17 +38,17 @@ import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.SacrificeSourceEffect; import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent; import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.*; import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.permanent.ControllerControlsIslandPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.common.TargetCreatureOrPlayer; import mage.target.common.TargetCreatureOrPlayer;
/** /**
* *
* @author KholdFuzion * @author KholdFuzion
*
*/ */
public class PirateShip extends CardImpl { public class PirateShip extends CardImpl {
@ -62,13 +62,15 @@ public class PirateShip extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// Pirate Ship can't attack unless defending player controls an Island. // Pirate Ship can't attack unless defending player controls an Island.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island", "an Island"))));
// {tap}: Pirate Ship deals 1 damage to target creature or player. // {tap}: Pirate Ship deals 1 damage to target creature or player.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost());
ability.addTarget(new TargetCreatureOrPlayer()); ability.addTarget(new TargetCreatureOrPlayer());
this.addAbility(ability); this.addAbility(ability);
// When you control no Islands, sacrifice Pirate Ship. // When you control no Islands, sacrifice Pirate Ship.
this.addAbility(new PirateShipTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterLandPermanent("Island", "no Islands"), Filter.ComparisonType.Equal, 0,
new SacrificeSourceEffect()));
} }
public PirateShip(final PirateShip card) { public PirateShip(final PirateShip card) {
@ -80,29 +82,3 @@ public class PirateShip extends CardImpl {
return new PirateShip(this); return new PirateShip(this);
} }
} }
class PirateShipTriggeredAbility extends StateTriggeredAbility {
public PirateShipTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public PirateShipTriggeredAbility(final PirateShipTriggeredAbility ability) {
super(ability);
}
@Override
public PirateShipTriggeredAbility copy() {
return new PirateShipTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(ControllerControlsIslandPredicate.filter, controllerId, game) == 0);
}
@Override
public String getRule() {
return "When you control no islands, sacrifice {this}.";
}
}

View file

@ -29,7 +29,7 @@ package mage.sets.limitedalpha;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.SacrificeSourceEffect; import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent; import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent;
@ -37,16 +37,14 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControllerControlsIslandPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
/** /**
* *
* @author KholdFuzion * @author KholdFuzion
*
*/ */
public class SeaSerpent extends CardImpl { public class SeaSerpent extends CardImpl {
@ -67,7 +65,9 @@ public class SeaSerpent extends CardImpl {
// Sea Serpent can't attack unless defending player controls an Island. // Sea Serpent can't attack unless defending player controls an Island.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(filter))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(filter)));
// When you control no Islands, sacrifice Sea Serpent. // When you control no Islands, sacrifice Sea Serpent.
this.addAbility(new SeaSerpentTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterLandPermanent("Island", "no Islands"), Filter.ComparisonType.Equal, 0,
new SacrificeSourceEffect()));
} }
public SeaSerpent(final SeaSerpent card) { public SeaSerpent(final SeaSerpent card) {
@ -79,29 +79,3 @@ public class SeaSerpent extends CardImpl {
return new SeaSerpent(this); return new SeaSerpent(this);
} }
} }
class SeaSerpentTriggeredAbility extends StateTriggeredAbility {
public SeaSerpentTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public SeaSerpentTriggeredAbility(final SeaSerpentTriggeredAbility ability) {
super(ability);
}
@Override
public SeaSerpentTriggeredAbility copy() {
return new SeaSerpentTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(ControllerControlsIslandPredicate.filter, controllerId, game) == 0);
}
@Override
public String getRule() {
return "When you control no islands, sacrifice {this}.";
}
}

View file

@ -29,13 +29,12 @@ package mage.sets.lorwyn;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.Filter; import mage.filter.Filter;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate; import mage.filter.predicate.mageobject.PowerPredicate;
@ -61,7 +60,7 @@ public class GoldmeadowDodger extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// Goldmeadow Dodger can't be blocked by creatures with power 4 or greater. // Goldmeadow Dodger can't be blocked by creatures with power 4 or greater.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
} }
public GoldmeadowDodger(final GoldmeadowDodger card) { public GoldmeadowDodger(final GoldmeadowDodger card) {

View file

@ -28,16 +28,17 @@
package mage.sets.magic2010; package mage.sets.magic2010;
import java.util.UUID; import java.util.UUID;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.MageInt; import mage.filter.common.FilterCreaturePermanent;
import mage.abilities.Ability; import mage.filter.predicate.Predicates;
import mage.abilities.EvasionAbility; import mage.filter.predicate.mageobject.ColorPredicate;
import mage.abilities.effects.RestrictionEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.permanent.Permanent;
/** /**
* *
@ -45,6 +46,12 @@ import mage.game.permanent.Permanent;
*/ */
public class DreadWarlock extends CardImpl { public class DreadWarlock extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("except by black creatures");
static {
filter.add(Predicates.not(new ColorPredicate(ObjectColor.BLACK)));
}
public DreadWarlock(UUID ownerId) { public DreadWarlock(UUID ownerId) {
super(ownerId, 94, "Dread Warlock", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{B}{B}"); super(ownerId, 94, "Dread Warlock", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{B}{B}");
this.expansionSetCode = "M10"; this.expansionSetCode = "M10";
@ -55,7 +62,7 @@ public class DreadWarlock extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Dread Warlock can't be blocked except by black creatures. // Dread Warlock can't be blocked except by black creatures.
this.addAbility(DreadWarlockAbility.getInstance()); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
} }
public DreadWarlock(final DreadWarlock card) { public DreadWarlock(final DreadWarlock card) {
@ -67,61 +74,3 @@ public class DreadWarlock extends CardImpl {
return new DreadWarlock(this); return new DreadWarlock(this);
} }
} }
class DreadWarlockAbility extends EvasionAbility {
private static DreadWarlockAbility instance;
public static DreadWarlockAbility getInstance() {
if (instance == null) {
instance = new DreadWarlockAbility();
}
return instance;
}
private DreadWarlockAbility() {
this.addEffect(new DreadWarlockEffect());
}
@Override
public String getRule() {
return "{this} can't be blocked except by black creatures.";
}
@Override
public DreadWarlockAbility copy() {
return getInstance();
}
}
class DreadWarlockEffect extends RestrictionEffect {
public DreadWarlockEffect() {
super(Duration.WhileOnBattlefield);
}
public DreadWarlockEffect(final DreadWarlockEffect effect) {
super(effect);
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (permanent.getAbilities().containsKey(DreadWarlockAbility.getInstance().getId())) {
return true;
}
return false;
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
if (blocker.getColor(game).isBlack()) {
return true;
}
return false;
}
@Override
public DreadWarlockEffect copy() {
return new DreadWarlockEffect(this);
}
}

View file

@ -31,14 +31,13 @@ import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DiesTriggeredAbility; import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.Filter; import mage.filter.Filter;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate; import mage.filter.predicate.mageobject.PowerPredicate;
@ -51,6 +50,7 @@ import mage.target.common.TargetOpponent;
public class ScuttlingDoomEngine extends CardImpl { public class ScuttlingDoomEngine extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with power 2 or less"); private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with power 2 or less");
static { static {
filter.add(new PowerPredicate(Filter.ComparisonType.LessThan, 3)); filter.add(new PowerPredicate(Filter.ComparisonType.LessThan, 3));
} }
@ -65,7 +65,7 @@ public class ScuttlingDoomEngine extends CardImpl {
this.toughness = new MageInt(6); this.toughness = new MageInt(6);
// Scuttling Doom Engine can't be blocked by creatures with power 2 or less. // Scuttling Doom Engine can't be blocked by creatures with power 2 or less.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
// When Scuttling Doom Engine dies, it deals 6 damage to target opponnent // When Scuttling Doom Engine dies, it deals 6 damage to target opponnent
Ability ability = new DiesTriggeredAbility(new DamageTargetEffect(6), false); Ability ability = new DiesTriggeredAbility(new DamageTargetEffect(6), false);
ability.addTarget(new TargetOpponent()); ability.addTarget(new TargetOpponent());

View file

@ -30,7 +30,7 @@ package mage.sets.masterseditionii;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.IsStepCondition; import mage.abilities.condition.common.IsStepCondition;
@ -51,13 +51,11 @@ import mage.constants.Duration;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterAttackingCreature; import mage.filter.common.FilterAttackingCreature;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.AbilityPredicate; import mage.filter.predicate.mageobject.AbilityPredicate;
import mage.filter.predicate.permanent.ControllerControlsIslandPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
@ -90,7 +88,7 @@ public class Marjhan extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// Marjhan can't attack unless defending player controls an Island. // Marjhan can't attack unless defending player controls an Island.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island", "an Island"))));
// {U}{U}: Marjhan gets -1/-0 until end of turn and deals 1 damage to target attacking creature without flying. // {U}{U}: Marjhan gets -1/-0 until end of turn and deals 1 damage to target attacking creature without flying.
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(-1, 0, Duration.EndOfTurn), new ManaCostsImpl("{U}{U}")); ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(-1, 0, Duration.EndOfTurn), new ManaCostsImpl("{U}{U}"));
@ -100,7 +98,9 @@ public class Marjhan extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// When you control no Islands, sacrifice Marjhan. // When you control no Islands, sacrifice Marjhan.
this.addAbility(new MarjhanTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterLandPermanent("Island", "no Islands"), Filter.ComparisonType.Equal, 0,
new SacrificeSourceEffect()));
} }
public Marjhan(final Marjhan card) { public Marjhan(final Marjhan card) {
@ -112,29 +112,3 @@ public class Marjhan extends CardImpl {
return new Marjhan(this); return new Marjhan(this);
} }
} }
class MarjhanTriggeredAbility extends StateTriggeredAbility {
public MarjhanTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public MarjhanTriggeredAbility(final MarjhanTriggeredAbility ability) {
super(ability);
}
@Override
public MarjhanTriggeredAbility copy() {
return new MarjhanTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(ControllerControlsIslandPredicate.filter, controllerId, game) == 0);
}
@Override
public String getRule() {
return "When you control no islands, sacrifice {this}.";
}
}

View file

@ -30,7 +30,7 @@ package mage.sets.mirage;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.costs.common.SacrificeTargetCost;
@ -44,13 +44,11 @@ import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterControlledLandPermanent; import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControllerControlsIslandPredicate;
import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetLandPermanent; import mage.target.common.TargetLandPermanent;
@ -76,7 +74,7 @@ public class KukemssaSerpent extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// Kukemssa Serpent can't attack unless defending player controls an Island. // Kukemssa Serpent can't attack unless defending player controls an Island.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island", "an Island"))));
// {U}, Sacrifice an Island: Target land an opponent controls becomes an Island until end of turn. // {U}, Sacrifice an Island: Target land an opponent controls becomes an Island until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesBasicLandTargetEffect(Duration.EndOfTurn, "Island"), new ManaCostsImpl("{U}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesBasicLandTargetEffect(Duration.EndOfTurn, "Island"), new ManaCostsImpl("{U}"));
@ -85,7 +83,9 @@ public class KukemssaSerpent extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// When you control no Islands, sacrifice Kukemssa Serpent. // When you control no Islands, sacrifice Kukemssa Serpent.
this.addAbility(new KukemssaSerpentTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterLandPermanent("Island", "no Islands"), Filter.ComparisonType.Equal, 0,
new SacrificeSourceEffect()));
} }
public KukemssaSerpent(final KukemssaSerpent card) { public KukemssaSerpent(final KukemssaSerpent card) {
@ -97,29 +97,3 @@ public class KukemssaSerpent extends CardImpl {
return new KukemssaSerpent(this); return new KukemssaSerpent(this);
} }
} }
class KukemssaSerpentTriggeredAbility extends StateTriggeredAbility {
public KukemssaSerpentTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public KukemssaSerpentTriggeredAbility(final KukemssaSerpentTriggeredAbility ability) {
super(ability);
}
@Override
public KukemssaSerpentTriggeredAbility copy() {
return new KukemssaSerpentTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(ControllerControlsIslandPredicate.filter, controllerId, game) == 0);
}
@Override
public String getRule() {
return "When you control no islands, sacrifice {this}.";
}
}

View file

@ -30,14 +30,14 @@ package mage.sets.nemesis;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.abilities.effects.common.combat.CantBlockCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBlockCreaturesSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.Filter; import mage.filter.Filter;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate; import mage.filter.predicate.mageobject.PowerPredicate;
@ -49,6 +49,7 @@ import mage.filter.predicate.mageobject.PowerPredicate;
public class SneakyHomunculus extends CardImpl { public class SneakyHomunculus extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with power 2 or greater"); private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with power 2 or greater");
static { static {
filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 1)); filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 1));
} }
@ -63,8 +64,12 @@ public class SneakyHomunculus extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// Sneaky Homunculus can't block or be blocked by creatures with power 2 or greater. // Sneaky Homunculus can't block or be blocked by creatures with power 2 or greater.
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)); Effect effect = new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield);
ability.addEffect(new CantBlockCreaturesSourceEffect(filter)); effect.setText("{this} can't block");
Ability ability = new SimpleEvasionAbility(effect);
effect = new CantBlockCreaturesSourceEffect(filter);
effect.setText("or be blocked by creatures with power 2 or greater");
ability.addEffect(effect);
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -29,14 +29,13 @@ package mage.sets.onslaught;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.AbilityPredicate; import mage.filter.predicate.mageobject.AbilityPredicate;
@ -63,7 +62,7 @@ public class ElvenRiders extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// Elven Riders can't be blocked except by Walls and/or creatures with flying. // Elven Riders can't be blocked except by Walls and/or creatures with flying.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
} }
public ElvenRiders(final ElvenRiders card) { public ElvenRiders(final ElvenRiders card) {

View file

@ -29,7 +29,7 @@ package mage.sets.planarchaos;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.SacrificeSourceEffect; import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent; import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent;
@ -37,10 +37,8 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
/** /**
* *
@ -56,10 +54,12 @@ public class BogSerpent extends CardImpl {
this.toughness = new MageInt(5); this.toughness = new MageInt(5);
// Bog Serpent can't attack unless defending player controls a Swamp. // Bog Serpent can't attack unless defending player controls a Swamp.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Swamp","a Swamp")))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Swamp", "a Swamp"))));
// When you control no Swamps, sacrifice Bog Serpent. // When you control no Swamps, sacrifice Bog Serpent.
this.addAbility(new BogSerpentTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterLandPermanent("Swamp", "no Swamps"), Filter.ComparisonType.Equal, 0,
new SacrificeSourceEffect()));
} }
public BogSerpent(final BogSerpent card) { public BogSerpent(final BogSerpent card) {
@ -71,35 +71,3 @@ public class BogSerpent extends CardImpl {
return new BogSerpent(this); return new BogSerpent(this);
} }
} }
class BogSerpentTriggeredAbility extends StateTriggeredAbility {
public static final FilterLandPermanent filter = new FilterLandPermanent("Swamp");
{
filter.add(new SubtypePredicate("Swamp"));
}
public BogSerpentTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public BogSerpentTriggeredAbility(final BogSerpentTriggeredAbility ability) {
super(ability);
}
@Override
public BogSerpentTriggeredAbility copy() {
return new BogSerpentTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(filter, controllerId, game) == 0);
}
@Override
public String getRule() {
return "When you control no swamps, sacrifice {this}.";
}
}

View file

@ -30,14 +30,13 @@ package mage.sets.ravnica;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.SacrificeControllerEffect; import mage.abilities.effects.common.SacrificeControllerEffect;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
@ -65,7 +64,7 @@ public class VindictiveMob extends CardImpl {
this.addAbility(new EntersBattlefieldTriggeredAbility(new SacrificeControllerEffect(new FilterCreaturePermanent(), 1, null))); this.addAbility(new EntersBattlefieldTriggeredAbility(new SacrificeControllerEffect(new FilterCreaturePermanent(), 1, null)));
// Vindictive Mob can't be blocked by Saprolings. // Vindictive Mob can't be blocked by Saprolings.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
} }
public VindictiveMob(final VindictiveMob card) { public VindictiveMob(final VindictiveMob card) {

View file

@ -29,15 +29,13 @@ package mage.sets.scourge;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesAllEffect;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.AbilityPredicate; import mage.filter.predicate.mageobject.AbilityPredicate;
@ -64,9 +62,7 @@ public class TreetopScout extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// Treetop Scout can't be blocked except by creatures with flying. // Treetop Scout can't be blocked except by creatures with flying.
this.addAbility(new SimpleStaticAbility( this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(onlyFlyingCreatures, Duration.WhileOnBattlefield)));
Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(onlyFlyingCreatures, Duration.WhileOnBattlefield)
));
} }
public TreetopScout(final TreetopScout card) { public TreetopScout(final TreetopScout card) {

View file

@ -30,13 +30,12 @@ package mage.sets.shadowmoor;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -62,7 +61,7 @@ public class BarrentonCragtreads extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// Barrenton Cragtreads can't be blocked by red creatures. // Barrenton Cragtreads can't be blocked by red creatures.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
} }

View file

@ -127,16 +127,17 @@ class LureboundScarecrowTriggeredAbility extends StateTriggeredAbility {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE || event.getType() == GameEvent.EventType.LOST_CONTROL if (event.getType() == GameEvent.EventType.ZONE_CHANGE || event.getType() == GameEvent.EventType.LOST_CONTROL
|| event.getType() == GameEvent.EventType.COLOR_CHANGED || event.getType() == GameEvent.EventType.COLOR_CHANGED
|| event.getType() == GameEvent.EventType.SPELL_CAST) { || event.getType() == GameEvent.EventType.SPELL_CAST) {
Card card = game.getCard(this.getSourceId()); Card card = game.getCard(this.getSourceId());
if (card != null) { if (card != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(card.getId() + "_color"); ObjectColor color = (ObjectColor) game.getState().getValue(card.getId() + "_color");
if (color != null) { if (color != null) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(controllerId)) { for (Permanent perm : game.getBattlefield().getAllActivePermanents(controllerId)) {
if (perm.getColor(game).contains(color)) if (perm.getColor(game).contains(color)) {
return false; return false;
}
} }
return true; return true;
} }

View file

@ -30,13 +30,12 @@ package mage.sets.shadowmoor;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -61,7 +60,7 @@ public class WanderbrineRootcutters extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// Wanderbrine Rootcutters can't be blocked by green creatures. // Wanderbrine Rootcutters can't be blocked by green creatures.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
} }

View file

@ -29,17 +29,14 @@ package mage.sets.tempestremastered;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.effects.common.SacrificeSourceEffect; import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.filter.Filter;
import mage.filter.Filter.ComparisonType; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.ToughnessPredicate; import mage.filter.predicate.mageobject.ToughnessPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
/** /**
* *
@ -47,6 +44,12 @@ import mage.game.events.GameEvent;
*/ */
public class EndangeredArmodon extends CardImpl { public class EndangeredArmodon extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with toughness 2 or less");
static {
filter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, 3));
}
public EndangeredArmodon(UUID ownerId) { public EndangeredArmodon(UUID ownerId) {
super(ownerId, 171, "Endangered Armodon", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{G}{G}"); super(ownerId, 171, "Endangered Armodon", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{G}{G}");
this.expansionSetCode = "TPR"; this.expansionSetCode = "TPR";
@ -55,7 +58,9 @@ public class EndangeredArmodon extends CardImpl {
this.toughness = new MageInt(5); this.toughness = new MageInt(5);
// When you control a creature with toughness 2 or less, sacrifice Endangered Armodon. // When you control a creature with toughness 2 or less, sacrifice Endangered Armodon.
this.addAbility(new EndangeredArmodonStateTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
filter, Filter.ComparisonType.GreaterThan, 0,
new SacrificeSourceEffect()));
} }
public EndangeredArmodon(final EndangeredArmodon card) { public EndangeredArmodon(final EndangeredArmodon card) {
@ -67,34 +72,3 @@ public class EndangeredArmodon extends CardImpl {
return new EndangeredArmodon(this); return new EndangeredArmodon(this);
} }
} }
class EndangeredArmodonStateTriggeredAbility extends StateTriggeredAbility {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature with toughness 2 or less");
static {
filter.add(new ToughnessPredicate(ComparisonType.LessThan, 3));
}
EndangeredArmodonStateTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
EndangeredArmodonStateTriggeredAbility(final EndangeredArmodonStateTriggeredAbility ability) {
super(ability);
}
@Override
public EndangeredArmodonStateTriggeredAbility copy() {
return new EndangeredArmodonStateTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return game.getBattlefield().contains(filter, this.getControllerId(), game, 1);
}
@Override
public String getRule() {
return "When you control a creature with toughness 2 or less, sacrifice {this}.";
}
}

View file

@ -29,13 +29,12 @@ package mage.sets.thedark;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
@ -60,7 +59,7 @@ public class BogRats extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// Bog Rats can't be blocked by Walls. // Bog Rats can't be blocked by Walls.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
} }
public BogRats(final BogRats card) { public BogRats(final BogRats card) {

View file

@ -32,7 +32,7 @@ import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -77,7 +77,7 @@ public class DaxosOfMeletis extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Daxos of Meletis can't be blocked by creatures with power 3 or greater. // Daxos of Meletis can't be blocked by creatures with power 3 or greater.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
// Whenever Daxos of Meletis deals combat damage to a player, exile the top card of that player's library. You gain life equal to that card's converted mana cost. Until end of turn, you may cast that card and you may spend mana as though it were mana of any color to cast it. // Whenever Daxos of Meletis deals combat damage to a player, exile the top card of that player's library. You gain life equal to that card's converted mana cost. Until end of turn, you may cast that card and you may spend mana as though it were mana of any color to cast it.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new DaxosOfMeletisEffect(), false, true)); this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new DaxosOfMeletisEffect(), false, true));

View file

@ -29,7 +29,7 @@ package mage.sets.timespiral;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.SacrificeSourceEffect; import mage.abilities.effects.common.SacrificeSourceEffect;
@ -39,10 +39,8 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.permanent.ControllerControlsIslandPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
/** /**
* *
@ -58,10 +56,12 @@ public class SlipstreamSerpent extends CardImpl {
this.toughness = new MageInt(6); this.toughness = new MageInt(6);
// Slipstream Serpent can't attack unless defending player controls an Island. // Slipstream Serpent can't attack unless defending player controls an Island.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island", "an Island"))));
// When you control no Islands, sacrifice Slipstream Serpent. // When you control no Islands, sacrifice Slipstream Serpent.
this.addAbility(new SlipstreamSerpentTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterLandPermanent("Island", "no Islands"), Filter.ComparisonType.Equal, 0,
new SacrificeSourceEffect()));
// Morph {5}{U} // Morph {5}{U}
this.addAbility(new MorphAbility(this, new ManaCostsImpl("{5}{U}"))); this.addAbility(new MorphAbility(this, new ManaCostsImpl("{5}{U}")));
@ -76,29 +76,3 @@ public class SlipstreamSerpent extends CardImpl {
return new SlipstreamSerpent(this); return new SlipstreamSerpent(this);
} }
} }
class SlipstreamSerpentTriggeredAbility extends StateTriggeredAbility {
public SlipstreamSerpentTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public SlipstreamSerpentTriggeredAbility(final SlipstreamSerpentTriggeredAbility ability) {
super(ability);
}
@Override
public SlipstreamSerpentTriggeredAbility copy() {
return new SlipstreamSerpentTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(ControllerControlsIslandPredicate.filter, controllerId, game) == 0);
}
@Override
public String getRule() {
return "When you control no islands, sacrifice {this}.";
}
}

View file

@ -29,14 +29,13 @@ package mage.sets.urzassaga;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.AbilityPredicate; import mage.filter.predicate.mageobject.AbilityPredicate;
@ -62,9 +61,7 @@ public class TreetopRangers extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Treetop Rangers can't be blocked except by creatures with flying. // Treetop Rangers can't be blocked except by creatures with flying.
this.addAbility(new SimpleStaticAbility( this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(onlyFlyingCreatures, Duration.WhileOnBattlefield)));
Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(onlyFlyingCreatures, Duration.WhileOnBattlefield)
));
} }
public TreetopRangers(final TreetopRangers card) { public TreetopRangers(final TreetopRangers card) {

View file

@ -27,6 +27,8 @@
*/ */
package mage.sets.vintagemasters; package mage.sets.vintagemasters;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.StateTriggeredAbility; import mage.abilities.StateTriggeredAbility;
@ -49,6 +51,7 @@ import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import static mage.sets.vintagemasters.CityInABottle.getArabianNightsNamePredicates;
/** /**
* *
@ -56,8 +59,6 @@ import mage.game.permanent.Permanent;
*/ */
public class CityInABottle extends CardImpl { public class CityInABottle extends CardImpl {
private static final FilterCard filterCard = new FilterCard("cards originally printed in the Arabian Nights expansion");
public CityInABottle(UUID ownerId) { public CityInABottle(UUID ownerId) {
super(ownerId, 265, "City in a Bottle", Rarity.MYTHIC, new CardType[]{CardType.ARTIFACT}, "{2}"); super(ownerId, 265, "City in a Bottle", Rarity.MYTHIC, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "VMA"; this.expansionSetCode = "VMA";
@ -77,90 +78,97 @@ public class CityInABottle extends CardImpl {
public CityInABottle copy() { public CityInABottle copy() {
return new CityInABottle(this); return new CityInABottle(this);
} }
static public List<NamePredicate> getArabianNightsNamePredicates() {
List<NamePredicate> namePredicatesArabianNights = new ArrayList<>();
namePredicatesArabianNights.add(new NamePredicate("Abu Ja'far"));
namePredicatesArabianNights.add(new NamePredicate("Aladdin"));
namePredicatesArabianNights.add(new NamePredicate("Aladdin's Lamp"));
namePredicatesArabianNights.add(new NamePredicate("Aladdin's Ring"));
namePredicatesArabianNights.add(new NamePredicate("Ali Baba"));
namePredicatesArabianNights.add(new NamePredicate("Ali from Cairo"));
namePredicatesArabianNights.add(new NamePredicate("Army of Allah"));
namePredicatesArabianNights.add(new NamePredicate("Bazaar of Baghdad"));
namePredicatesArabianNights.add(new NamePredicate("Bird Maiden"));
namePredicatesArabianNights.add(new NamePredicate("Bottle of Suleiman"));
namePredicatesArabianNights.add(new NamePredicate("Brass Man"));
namePredicatesArabianNights.add(new NamePredicate("Camel"));
namePredicatesArabianNights.add(new NamePredicate("City of Brass"));
namePredicatesArabianNights.add(new NamePredicate("Cuombajj Witches"));
namePredicatesArabianNights.add(new NamePredicate("Cyclone"));
namePredicatesArabianNights.add(new NamePredicate("Dancing Scimitar"));
namePredicatesArabianNights.add(new NamePredicate("Dandân"));
namePredicatesArabianNights.add(new NamePredicate("Desert"));
namePredicatesArabianNights.add(new NamePredicate("Desert Nomads"));
namePredicatesArabianNights.add(new NamePredicate("Desert Twister"));
namePredicatesArabianNights.add(new NamePredicate("Diamond Valley"));
namePredicatesArabianNights.add(new NamePredicate("Drop of Honey"));
namePredicatesArabianNights.add(new NamePredicate("Ebony Horse"));
namePredicatesArabianNights.add(new NamePredicate("El-Hajjâj"));
namePredicatesArabianNights.add(new NamePredicate("Elephant Graveyard"));
namePredicatesArabianNights.add(new NamePredicate("Erg Raiders"));
namePredicatesArabianNights.add(new NamePredicate("Erhnam Djinn"));
namePredicatesArabianNights.add(new NamePredicate("Eye for an Eye"));
namePredicatesArabianNights.add(new NamePredicate("Fishliver Oil"));
namePredicatesArabianNights.add(new NamePredicate("Flying Carpet"));
namePredicatesArabianNights.add(new NamePredicate("Flying Men"));
namePredicatesArabianNights.add(new NamePredicate("Ghazbán Ogre"));
namePredicatesArabianNights.add(new NamePredicate("Giant Tortoise"));
namePredicatesArabianNights.add(new NamePredicate("Guardian Beast"));
namePredicatesArabianNights.add(new NamePredicate("Hasran Ogress"));
namePredicatesArabianNights.add(new NamePredicate("Hurr Jackal"));
namePredicatesArabianNights.add(new NamePredicate("Ifh-Bíff Efreet"));
namePredicatesArabianNights.add(new NamePredicate("Island Fish Jasconius"));
namePredicatesArabianNights.add(new NamePredicate("Island of Wak-Wak"));
namePredicatesArabianNights.add(new NamePredicate("Jandor's Ring"));
namePredicatesArabianNights.add(new NamePredicate("Jandor's Saddlebags"));
namePredicatesArabianNights.add(new NamePredicate("Jeweled Bird"));
namePredicatesArabianNights.add(new NamePredicate("Jihad"));
namePredicatesArabianNights.add(new NamePredicate("Junún Efreet"));
namePredicatesArabianNights.add(new NamePredicate("Juzám Djinn"));
namePredicatesArabianNights.add(new NamePredicate("Khabál Ghoul"));
namePredicatesArabianNights.add(new NamePredicate("King Suleiman"));
namePredicatesArabianNights.add(new NamePredicate("Kird Ape"));
namePredicatesArabianNights.add(new NamePredicate("Library of Alexandria"));
namePredicatesArabianNights.add(new NamePredicate("Magnetic Mountain"));
namePredicatesArabianNights.add(new NamePredicate("Merchant Ship"));
namePredicatesArabianNights.add(new NamePredicate("Metamorphosis"));
namePredicatesArabianNights.add(new NamePredicate("Mijae Djinn"));
namePredicatesArabianNights.add(new NamePredicate("Moorish Cavalry"));
namePredicatesArabianNights.add(new NamePredicate("Nafs Asp"));
namePredicatesArabianNights.add(new NamePredicate("Oasis"));
namePredicatesArabianNights.add(new NamePredicate("Old Man of the Sea"));
namePredicatesArabianNights.add(new NamePredicate("Oubliette"));
namePredicatesArabianNights.add(new NamePredicate("Piety"));
namePredicatesArabianNights.add(new NamePredicate("Pyramids"));
namePredicatesArabianNights.add(new NamePredicate("Repentant Blacksmith"));
namePredicatesArabianNights.add(new NamePredicate("Ring of Ma'rûf"));
namePredicatesArabianNights.add(new NamePredicate("Rukh Egg"));
namePredicatesArabianNights.add(new NamePredicate("Sandals of Abdallah"));
namePredicatesArabianNights.add(new NamePredicate("Sandstorm"));
namePredicatesArabianNights.add(new NamePredicate("Serendib Djinn"));
namePredicatesArabianNights.add(new NamePredicate("Serendib Efreet"));
namePredicatesArabianNights.add(new NamePredicate("Shahrazad"));
namePredicatesArabianNights.add(new NamePredicate("Sindbad"));
namePredicatesArabianNights.add(new NamePredicate("Singing Tree"));
namePredicatesArabianNights.add(new NamePredicate("Sorceress Queen"));
namePredicatesArabianNights.add(new NamePredicate("Stone-Throwing Devils"));
namePredicatesArabianNights.add(new NamePredicate("Unstable Mutation"));
namePredicatesArabianNights.add(new NamePredicate("War Elephant"));
namePredicatesArabianNights.add(new NamePredicate("Wyluli Wolf"));
namePredicatesArabianNights.add(new NamePredicate("Ydwen Efreet"));
return namePredicatesArabianNights;
}
} }
class CityInABottleStateTriggeredAbility extends StateTriggeredAbility { class CityInABottleStateTriggeredAbility extends StateTriggeredAbility {
private static final FilterPermanent filter = new FilterPermanent("a nontoken permanent originally printed in the Arabian Nights expansion other than City in a Bottle"); private static final FilterPermanent filter = new FilterPermanent("a nontoken permanent originally printed in the Arabian Nights expansion other than City in a Bottle");
static { static {
filter.add(Predicates.not(new TokenPredicate())); filter.add(Predicates.not(new TokenPredicate()));
filter.add(Predicates.or( filter.add(Predicates.or(getArabianNightsNamePredicates()));
new NamePredicate("Abu Ja'far"),
new NamePredicate("Aladdin"),
new NamePredicate("Aladdin's Lamp"),
new NamePredicate("Aladdin's Ring"),
new NamePredicate("Ali Baba"),
new NamePredicate("Ali from Cairo"),
new NamePredicate("Army of Allah"),
new NamePredicate("Bazaar of Baghdad"),
new NamePredicate("Bird Maiden"),
new NamePredicate("Bottle of Suleiman"),
new NamePredicate("Brass Man"),
new NamePredicate("Camel"),
new NamePredicate("City of Brass"),
new NamePredicate("Cuombajj Witches"),
new NamePredicate("Cyclone"),
new NamePredicate("Dancing Scimitar"),
new NamePredicate("Dandân"),
new NamePredicate("Desert"),
new NamePredicate("Desert Nomads"),
new NamePredicate("Desert Twister"),
new NamePredicate("Diamond Valley"),
new NamePredicate("Drop of Honey"),
new NamePredicate("Ebony Horse"),
new NamePredicate("El-Hajjâj"),
new NamePredicate("Elephant Graveyard"),
new NamePredicate("Erg Raiders"),
new NamePredicate("Erhnam Djinn"),
new NamePredicate("Eye for an Eye"),
new NamePredicate("Fishliver Oil"),
new NamePredicate("Flying Carpet"),
new NamePredicate("Flying Men"),
new NamePredicate("Ghazbán Ogre"),
new NamePredicate("Giant Tortoise"),
new NamePredicate("Guardian Beast"),
new NamePredicate("Hasran Ogress"),
new NamePredicate("Hurr Jackal"),
new NamePredicate("Ifh-Bíff Efreet"),
new NamePredicate("Island Fish Jasconius"),
new NamePredicate("Island of Wak-Wak"),
new NamePredicate("Jandor's Ring"),
new NamePredicate("Jandor's Saddlebags"),
new NamePredicate("Jeweled Bird"),
new NamePredicate("Jihad"),
new NamePredicate("Junún Efreet"),
new NamePredicate("Juzám Djinn"),
new NamePredicate("Khabál Ghoul"),
new NamePredicate("King Suleiman"),
new NamePredicate("Kird Ape"),
new NamePredicate("Library of Alexandria"),
new NamePredicate("Magnetic Mountain"),
new NamePredicate("Merchant Ship"),
new NamePredicate("Metamorphosis"),
new NamePredicate("Mijae Djinn"),
new NamePredicate("Moorish Cavalry"),
new NamePredicate("Nafs Asp"),
new NamePredicate("Oasis"),
new NamePredicate("Old Man of the Sea"),
new NamePredicate("Oubliette"),
new NamePredicate("Piety"),
new NamePredicate("Pyramids"),
new NamePredicate("Repentant Blacksmith"),
new NamePredicate("Ring of Ma'rûf"),
new NamePredicate("Rukh Egg"),
new NamePredicate("Sandals of Abdallah"),
new NamePredicate("Sandstorm"),
new NamePredicate("Serendib Djinn"),
new NamePredicate("Serendib Efreet"),
new NamePredicate("Shahrazad"),
new NamePredicate("Sindbad"),
new NamePredicate("Singing Tree"),
new NamePredicate("Sorceress Queen"),
new NamePredicate("Stone-Throwing Devils"),
new NamePredicate("Unstable Mutation"),
new NamePredicate("War Elephant"),
new NamePredicate("Wyluli Wolf"),
new NamePredicate("Ydwen Efreet")));
} }
CityInABottleStateTriggeredAbility() { CityInABottleStateTriggeredAbility() {
@ -190,85 +198,10 @@ class CityInABottleStateTriggeredAbility extends StateTriggeredAbility {
class CityInABottleSacrificeEffect extends OneShotEffect { class CityInABottleSacrificeEffect extends OneShotEffect {
private static final FilterPermanent filter = new FilterPermanent("a nontoken permanent originally printed in the Arabian Nights expansion other than City in a Bottle"); private static final FilterPermanent filter = new FilterPermanent("a nontoken permanent originally printed in the Arabian Nights expansion other than City in a Bottle");
static { static {
filter.add(Predicates.not(new TokenPredicate())); filter.add(Predicates.not(new TokenPredicate()));
filter.add(Predicates.or( filter.add(Predicates.or(getArabianNightsNamePredicates()));
new NamePredicate("Abu Ja'far"),
new NamePredicate("Aladdin"),
new NamePredicate("Aladdin's Lamp"),
new NamePredicate("Aladdin's Ring"),
new NamePredicate("Ali Baba"),
new NamePredicate("Ali from Cairo"),
new NamePredicate("Army of Allah"),
new NamePredicate("Bazaar of Baghdad"),
new NamePredicate("Bird Maiden"),
new NamePredicate("Bottle of Suleiman"),
new NamePredicate("Brass Man"),
new NamePredicate("Camel"),
new NamePredicate("City of Brass"),
new NamePredicate("Cuombajj Witches"),
new NamePredicate("Cyclone"),
new NamePredicate("Dancing Scimitar"),
new NamePredicate("Dandân"),
new NamePredicate("Desert"),
new NamePredicate("Desert Nomads"),
new NamePredicate("Desert Twister"),
new NamePredicate("Diamond Valley"),
new NamePredicate("Drop of Honey"),
new NamePredicate("Ebony Horse"),
new NamePredicate("El-Hajjâj"),
new NamePredicate("Elephant Graveyard"),
new NamePredicate("Erg Raiders"),
new NamePredicate("Erhnam Djinn"),
new NamePredicate("Eye for an Eye"),
new NamePredicate("Fishliver Oil"),
new NamePredicate("Flying Carpet"),
new NamePredicate("Flying Men"),
new NamePredicate("Ghazbán Ogre"),
new NamePredicate("Giant Tortoise"),
new NamePredicate("Guardian Beast"),
new NamePredicate("Hasran Ogress"),
new NamePredicate("Hurr Jackal"),
new NamePredicate("Ifh-Bíff Efreet"),
new NamePredicate("Island Fish Jasconius"),
new NamePredicate("Island of Wak-Wak"),
new NamePredicate("Jandor's Ring"),
new NamePredicate("Jandor's Saddlebags"),
new NamePredicate("Jeweled Bird"),
new NamePredicate("Jihad"),
new NamePredicate("Junún Efreet"),
new NamePredicate("Juzám Djinn"),
new NamePredicate("Khabál Ghoul"),
new NamePredicate("King Suleiman"),
new NamePredicate("Kird Ape"),
new NamePredicate("Library of Alexandria"),
new NamePredicate("Magnetic Mountain"),
new NamePredicate("Merchant Ship"),
new NamePredicate("Metamorphosis"),
new NamePredicate("Mijae Djinn"),
new NamePredicate("Moorish Cavalry"),
new NamePredicate("Nafs Asp"),
new NamePredicate("Oasis"),
new NamePredicate("Old Man of the Sea"),
new NamePredicate("Oubliette"),
new NamePredicate("Piety"),
new NamePredicate("Pyramids"),
new NamePredicate("Repentant Blacksmith"),
new NamePredicate("Ring of Ma'rûf"),
new NamePredicate("Rukh Egg"),
new NamePredicate("Sandals of Abdallah"),
new NamePredicate("Sandstorm"),
new NamePredicate("Serendib Djinn"),
new NamePredicate("Serendib Efreet"),
new NamePredicate("Shahrazad"),
new NamePredicate("Sindbad"),
new NamePredicate("Singing Tree"),
new NamePredicate("Sorceress Queen"),
new NamePredicate("Stone-Throwing Devils"),
new NamePredicate("Unstable Mutation"),
new NamePredicate("War Elephant"),
new NamePredicate("Wyluli Wolf"),
new NamePredicate("Ydwen Efreet")));
} }
CityInABottleSacrificeEffect() { CityInABottleSacrificeEffect() {
@ -297,85 +230,9 @@ class CityInABottleSacrificeEffect extends OneShotEffect {
class CityInABottleCantPlayEffect extends ContinuousRuleModifyingEffectImpl { class CityInABottleCantPlayEffect extends ContinuousRuleModifyingEffectImpl {
private static final FilterCard filter = new FilterCard("cards originally printed in the Arabian Nights expansion"); private static final FilterCard filter = new FilterCard("cards originally printed in the Arabian Nights expansion");
static { static {
filter.add(Predicates.or( filter.add(Predicates.or(getArabianNightsNamePredicates()));
new NamePredicate("Abu Ja'far"),
new NamePredicate("Aladdin"),
new NamePredicate("Aladdin's Lamp"),
new NamePredicate("Aladdin's Ring"),
new NamePredicate("Ali Baba"),
new NamePredicate("Ali from Cairo"),
new NamePredicate("Army of Allah"),
new NamePredicate("Bazaar of Baghdad"),
new NamePredicate("Bird Maiden"),
new NamePredicate("Bottle of Suleiman"),
new NamePredicate("Brass Man"),
new NamePredicate("Camel"),
new NamePredicate("City in a Bottle"),
new NamePredicate("City of Brass"),
new NamePredicate("Cuombajj Witches"),
new NamePredicate("Cyclone"),
new NamePredicate("Dancing Scimitar"),
new NamePredicate("Dandân"),
new NamePredicate("Desert"),
new NamePredicate("Desert Nomads"),
new NamePredicate("Desert Twister"),
new NamePredicate("Diamond Valley"),
new NamePredicate("Drop of Honey"),
new NamePredicate("Ebony Horse"),
new NamePredicate("El-Hajjâj"),
new NamePredicate("Elephant Graveyard"),
new NamePredicate("Erg Raiders"),
new NamePredicate("Erhnam Djinn"),
new NamePredicate("Eye for an Eye"),
new NamePredicate("Fishliver Oil"),
new NamePredicate("Flying Carpet"),
new NamePredicate("Flying Men"),
new NamePredicate("Ghazbán Ogre"),
new NamePredicate("Giant Tortoise"),
new NamePredicate("Guardian Beast"),
new NamePredicate("Hasran Ogress"),
new NamePredicate("Hurr Jackal"),
new NamePredicate("Ifh-Bíff Efreet"),
new NamePredicate("Island Fish Jasconius"),
new NamePredicate("Island of Wak-Wak"),
new NamePredicate("Jandor's Ring"),
new NamePredicate("Jandor's Saddlebags"),
new NamePredicate("Jeweled Bird"),
new NamePredicate("Jihad"),
new NamePredicate("Junún Efreet"),
new NamePredicate("Juzám Djinn"),
new NamePredicate("Khabál Ghoul"),
new NamePredicate("King Suleiman"),
new NamePredicate("Kird Ape"),
new NamePredicate("Library of Alexandria"),
new NamePredicate("Magnetic Mountain"),
new NamePredicate("Merchant Ship"),
new NamePredicate("Metamorphosis"),
new NamePredicate("Mijae Djinn"),
new NamePredicate("Moorish Cavalry"),
new NamePredicate("Nafs Asp"),
new NamePredicate("Oasis"),
new NamePredicate("Old Man of the Sea"),
new NamePredicate("Oubliette"),
new NamePredicate("Piety"),
new NamePredicate("Pyramids"),
new NamePredicate("Repentant Blacksmith"),
new NamePredicate("Ring of Ma'rûf"),
new NamePredicate("Rukh Egg"),
new NamePredicate("Sandals of Abdallah"),
new NamePredicate("Sandstorm"),
new NamePredicate("Serendib Djinn"),
new NamePredicate("Serendib Efreet"),
new NamePredicate("Shahrazad"),
new NamePredicate("Sindbad"),
new NamePredicate("Singing Tree"),
new NamePredicate("Sorceress Queen"),
new NamePredicate("Stone-Throwing Devils"),
new NamePredicate("Unstable Mutation"),
new NamePredicate("War Elephant"),
new NamePredicate("Wyluli Wolf"),
new NamePredicate("Ydwen Efreet")));
} }
CityInABottleCantPlayEffect() { CityInABottleCantPlayEffect() {

View file

@ -29,23 +29,23 @@ package mage.sets.weatherlight;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.ObjectColor;
import mage.abilities.EvasionAbility; import mage.abilities.common.ControlsPermanentsControllerTriggeredAbility;
import mage.abilities.StateTriggeredAbility; import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.RestrictionEffect;
import mage.abilities.effects.common.SacrificeSourceEffect; import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent; import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.permanent.ControllerControlsIslandPredicate; import mage.filter.predicate.Predicates;
import mage.game.Game; import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
/** /**
* *
@ -53,6 +53,12 @@ import mage.game.permanent.Permanent;
*/ */
public class MantaRay extends CardImpl { public class MantaRay extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("except by blue creatures");
static {
filter.add(Predicates.not(new ColorPredicate(ObjectColor.BLUE)));
}
public MantaRay(UUID ownerId) { public MantaRay(UUID ownerId) {
super(ownerId, 42, "Manta Ray", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{U}{U}"); super(ownerId, 42, "Manta Ray", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{U}{U}");
this.expansionSetCode = "WTH"; this.expansionSetCode = "WTH";
@ -61,13 +67,16 @@ public class MantaRay extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// Manta Ray can't attack unless defending player controls an Island. // Manta Ray can't attack unless defending player controls an Island.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island", "an Island"))));
// Manta Ray can't be blocked except by blue creatures. // Manta Ray can't be blocked except by blue creatures.
this.addAbility(MantaRayAbility.getInstance()); this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
// When you control no Islands, sacrifice Manta Ray. // When you control no Islands, sacrifice Manta Ray.
this.addAbility(new MantaRayTriggeredAbility()); this.addAbility(new ControlsPermanentsControllerTriggeredAbility(
new FilterLandPermanent("Island", "no Islands"), Filter.ComparisonType.Equal, 0,
new SacrificeSourceEffect()));
} }
public MantaRay(final MantaRay card) { public MantaRay(final MantaRay card) {
@ -79,87 +88,3 @@ public class MantaRay extends CardImpl {
return new MantaRay(this); return new MantaRay(this);
} }
} }
class MantaRayTriggeredAbility extends StateTriggeredAbility {
public MantaRayTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeSourceEffect());
}
public MantaRayTriggeredAbility(final MantaRayTriggeredAbility ability) {
super(ability);
}
@Override
public MantaRayTriggeredAbility copy() {
return new MantaRayTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (game.getBattlefield().countAll(ControllerControlsIslandPredicate.filter, controllerId, game) == 0);
}
@Override
public String getRule() {
return "When you control no islands, sacrifice {this}.";
}
}
class MantaRayAbility extends EvasionAbility {
private static MantaRayAbility instance;
public static MantaRayAbility getInstance() {
if (instance == null) {
instance = new MantaRayAbility();
}
return instance;
}
private MantaRayAbility() {
this.addEffect(new MantaRayEffect());
}
@Override
public String getRule() {
return "{this} can't be blocked except by blue creatures.";
}
@Override
public MantaRayAbility copy() {
return getInstance();
}
}
class MantaRayEffect extends RestrictionEffect {
public MantaRayEffect() {
super(Duration.WhileOnBattlefield);
}
public MantaRayEffect(final MantaRayEffect effect) {
super(effect);
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (permanent.getAbilities().containsKey(MantaRayAbility.getInstance().getId())) {
return true;
}
return false;
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
if (blocker.getColor(game).isBlue()) {
return true;
}
return false;
}
@Override
public MantaRayEffect copy() {
return new MantaRayEffect(this);
}
}

View file

@ -0,0 +1,96 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.common;
import mage.abilities.StateTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.filter.Filter.ComparisonType;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
* State triggered ability that triggers if the ability controller controlls the
* defined number of permanents.
*
* @author LevelX2
*/
public class ControlsPermanentsControllerTriggeredAbility extends StateTriggeredAbility {
protected final FilterPermanent filter;
protected final ComparisonType type;
protected final int value;
public ControlsPermanentsControllerTriggeredAbility(FilterPermanent filter, ComparisonType type, int value, Effect effect) {
super(Zone.BATTLEFIELD, effect);
this.filter = filter;
this.value = value;
this.type = type;
}
public ControlsPermanentsControllerTriggeredAbility(final ControlsPermanentsControllerTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
this.type = ability.type;
this.value = ability.value;
}
@Override
public ControlsPermanentsControllerTriggeredAbility copy() {
return new ControlsPermanentsControllerTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int inputValue = game.getBattlefield().countAll(filter, getControllerId(), game);
switch (type) {
case Equal:
if (inputValue != value) {
return false;
}
break;
case GreaterThan:
if (inputValue <= value) {
return false;
}
break;
case LessThan:
if (inputValue >= value) {
return false;
}
break;
}
return true;
}
@Override
public String getRule() {
return "When you control " + filter.getMessage() + ", " + super.getRule();
}
}