diff --git a/Mage.Sets/src/mage/cards/a/AuriokSiegeSled.java b/Mage.Sets/src/mage/cards/a/AuriokSiegeSled.java index 4c859bc0dbd..bb360508011 100644 --- a/Mage.Sets/src/mage/cards/a/AuriokSiegeSled.java +++ b/Mage.Sets/src/mage/cards/a/AuriokSiegeSled.java @@ -1,11 +1,10 @@ - package mage.cards.a; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; -import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.common.combat.CantBeBlockedByTargetSourceEffect; import mage.abilities.effects.common.combat.MustBeBlockedByTargetSourceEffect; import mage.cards.CardImpl; @@ -13,8 +12,7 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.SubType; -import mage.constants.Zone; -import mage.filter.common.FilterCreaturePermanent; +import mage.filter.StaticFilters; import mage.target.common.TargetCreaturePermanent; /** @@ -23,12 +21,6 @@ import mage.target.common.TargetCreaturePermanent; */ public final class AuriokSiegeSled extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("artifact creature"); - - static { - filter.add(CardType.ARTIFACT.getPredicate()); - } - public AuriokSiegeSled(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{6}"); this.subtype.add(SubType.JUGGERNAUT); @@ -37,15 +29,17 @@ public final class AuriokSiegeSled extends CardImpl { // {1}: Target artifact creature blocks Auriok Siege Sled this turn if able. MustBeBlockedByTargetSourceEffect effect = new MustBeBlockedByTargetSourceEffect(Duration.EndOfTurn); - effect.setText("Target artifact creature blocks {this} this turn if able."); - Ability ability1 = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{1}")); - ability1.addTarget(new TargetCreaturePermanent(filter)); + effect.setText("target artifact creature blocks {this} this turn if able"); + Ability ability1 = new SimpleActivatedAbility(effect, new GenericManaCost(1)); + ability1.addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_PERMANENT_ARTIFACT_CREATURE)); this.addAbility(ability1); // {1}: Target artifact creature can't block Auriok Siege Sled this turn. - Ability ability2 = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CantBeBlockedByTargetSourceEffect(Duration.EndOfTurn), - new ManaCostsImpl("{1}")); - ability2.addTarget(new TargetCreaturePermanent(filter)); + Ability ability2 = new SimpleActivatedAbility( + new CantBeBlockedByTargetSourceEffect(Duration.EndOfTurn), + new GenericManaCost(1) + ); + ability2.addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_PERMANENT_ARTIFACT_CREATURE)); this.addAbility(ability2); } diff --git a/Mage.Sets/src/mage/cards/s/SabertoothAlleyCat.java b/Mage.Sets/src/mage/cards/s/SabertoothAlleyCat.java index 4d19a8f3f1f..020786b9e8c 100644 --- a/Mage.Sets/src/mage/cards/s/SabertoothAlleyCat.java +++ b/Mage.Sets/src/mage/cards/s/SabertoothAlleyCat.java @@ -1,4 +1,3 @@ - package mage.cards.s; import java.util.UUID; @@ -24,6 +23,12 @@ import mage.filter.predicate.mageobject.AbilityPredicate; */ public final class SabertoothAlleyCat extends CardImpl { + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures without defender"); + + static { + filter.add(Predicates.not(new AbilityPredicate(DefenderAbility.class))); + } + public SabertoothAlleyCat(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}{R}"); @@ -31,18 +36,14 @@ public final class SabertoothAlleyCat extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(1); - // Sabertooth Alley Cat attacks each turn if able. + // Sabertooth Alley Cat attacks each combat if able. this.addAbility(new AttacksEachCombatStaticAbility()); // {1}{R}: Creatures without defender can't block Sabertooth Alley Cat this turn. this.addAbility(new SimpleActivatedAbility( - Zone.BATTLEFIELD, - new CantBeBlockedByCreaturesSourceEffect( - (FilterCreaturePermanent) new FilterCreaturePermanent().add(Predicates.not(new AbilityPredicate(DefenderAbility.class))), - Duration.EndOfTurn - ) - .setText("Creatures without defender can't block {this} this turn"), - new ManaCostsImpl<>("{1}{R}"))); + new CantBeBlockedByCreaturesSourceEffect(filter, Duration.EndOfTurn), + new ManaCostsImpl<>("{1}{R}") + )); } private SabertoothAlleyCat(final SabertoothAlleyCat card) { diff --git a/Mage.Sets/src/mage/cards/s/ShrewdHatchling.java b/Mage.Sets/src/mage/cards/s/ShrewdHatchling.java index db9ce2c6952..efa72457f56 100644 --- a/Mage.Sets/src/mage/cards/s/ShrewdHatchling.java +++ b/Mage.Sets/src/mage/cards/s/ShrewdHatchling.java @@ -7,7 +7,7 @@ import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.RestrictionEffect; +import mage.abilities.effects.common.combat.CantBeBlockedByTargetSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.RemoveCounterSourceEffect; import mage.cards.CardImpl; @@ -18,8 +18,6 @@ import mage.constants.SubType; import mage.counters.CounterType; import mage.filter.FilterSpell; import mage.filter.predicate.mageobject.ColorPredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; import java.util.UUID; @@ -29,12 +27,12 @@ import java.util.UUID; */ public final class ShrewdHatchling extends CardImpl { - private static final FilterSpell filter = new FilterSpell("a blue spell"); - private static final FilterSpell filter2 = new FilterSpell("a red spell"); + private static final FilterSpell filterBlueSpell = new FilterSpell("a blue spell"); + private static final FilterSpell filterRedSpell = new FilterSpell("a red spell"); static { - filter.add(new ColorPredicate(ObjectColor.BLUE)); - filter2.add(new ColorPredicate(ObjectColor.RED)); + filterBlueSpell.add(new ColorPredicate(ObjectColor.BLUE)); + filterRedSpell.add(new ColorPredicate(ObjectColor.RED)); } public ShrewdHatchling(UUID ownerId, CardSetInfo setInfo) { @@ -49,19 +47,22 @@ public final class ShrewdHatchling extends CardImpl { CounterType.M1M1.createInstance(4) ), "with four -1/-1 counters on it")); - // {UR}: Target creature can't block Shrewd Hatchling this turn. - Ability ability = new SimpleActivatedAbility(new ShrewdHatchlingEffect(), new ManaCostsImpl<>("{U/R}")); + // {U/R}: Target creature can't block Shrewd Hatchling this turn. + Ability ability = new SimpleActivatedAbility( + new CantBeBlockedByTargetSourceEffect(Duration.EndOfTurn), + new ManaCostsImpl<>("{U/R}") + ); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); // Whenever you cast a blue spell, remove a -1/-1 counter from Shrewd Hatchling. this.addAbility(new SpellCastControllerTriggeredAbility( - new RemoveCounterSourceEffect(CounterType.M1M1.createInstance()), filter, false + new RemoveCounterSourceEffect(CounterType.M1M1.createInstance()), filterBlueSpell, false )); // Whenever you cast a red spell, remove a -1/-1 counter from Shrewd Hatchling. this.addAbility(new SpellCastControllerTriggeredAbility( - new RemoveCounterSourceEffect(CounterType.M1M1.createInstance()), filter2, false + new RemoveCounterSourceEffect(CounterType.M1M1.createInstance()), filterRedSpell, false )); } @@ -75,32 +76,3 @@ public final class ShrewdHatchling extends CardImpl { return new ShrewdHatchling(this); } } - -class ShrewdHatchlingEffect extends RestrictionEffect { - - public ShrewdHatchlingEffect() { - super(Duration.EndOfTurn); - staticText = "Target creature can't block {this} this turn"; - } - - public ShrewdHatchlingEffect(final ShrewdHatchlingEffect effect) { - super(effect); - } - - @Override - public boolean applies(Permanent permanent, Ability source, Game game) { - return permanent.getId().equals(source.getSourceId()); - } - - @Override - public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - UUID targetId = source.getFirstTarget(); - return targetId == null || !blocker.getId().equals(targetId); - } - - @Override - public ShrewdHatchlingEffect copy() { - return new ShrewdHatchlingEffect(this); - } - -} diff --git a/Mage.Sets/src/mage/cards/s/SpinEngine.java b/Mage.Sets/src/mage/cards/s/SpinEngine.java index 3eb073092b7..76075d21a00 100644 --- a/Mage.Sets/src/mage/cards/s/SpinEngine.java +++ b/Mage.Sets/src/mage/cards/s/SpinEngine.java @@ -3,16 +3,14 @@ package mage.cards.s; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; -import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.RestrictionEffect; +import mage.abilities.costs.mana.ColoredManaCost; +import mage.abilities.effects.common.combat.CantBeBlockedByTargetSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.ColoredManaSymbol; import mage.constants.Duration; import mage.constants.SubType; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; import java.util.UUID; @@ -29,7 +27,10 @@ public final class SpinEngine extends CardImpl { this.toughness = new MageInt(1); // {R}: Target creature can't block Spin Engine this turn - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SpinEngineEffect(), new ManaCostsImpl("{R}")); + Ability ability = new SimpleActivatedAbility( + new CantBeBlockedByTargetSourceEffect(Duration.EndOfTurn), + new ColoredManaCost(ColoredManaSymbol.R) + ); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } @@ -42,34 +43,4 @@ public final class SpinEngine extends CardImpl { public SpinEngine copy() { return new SpinEngine(this); } - -} - -class SpinEngineEffect extends RestrictionEffect { - - public SpinEngineEffect() { - super(Duration.EndOfTurn); - staticText = "Target creature can't block {this} this turn"; - } - - public SpinEngineEffect(final SpinEngineEffect effect) { - super(effect); - } - - @Override - public boolean applies(Permanent permanent, Ability source, Game game) { - return permanent.getId().equals(source.getSourceId()); - } - - @Override - public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - UUID targetId = source.getFirstTarget(); - return targetId == null || !blocker.getId().equals(targetId); - } - - @Override - public SpinEngineEffect copy() { - return new SpinEngineEffect(this); - } - }