From f476c6864b3b0d876f66478c55c6a013cada6846 Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Sat, 29 Jul 2023 19:46:00 +0200 Subject: [PATCH] [CMM] Implement Onakke Oathkeeper (#10693) * [CMM] Implement Onakke Oathkeeper * take authorship of new file * cleanup and extend CantAttackYouUnlessPayAllEffect. * further cleanup * cleanup * add Duration to CantAttackYouUnlessPayAllEffect constructors, cleanup two more text generation. * fix duration text --- .../src/mage/cards/a/ArchangelOfTithes.java | 9 +-- .../src/mage/cards/a/ArchonOfAbsolution.java | 8 ++- .../mage/cards/b/BairdStewardOfArgive.java | 18 +++-- .../src/mage/cards/c/CollectiveRestraint.java | 7 +- Mage.Sets/src/mage/cards/e/ElephantGrass.java | 16 +++-- .../src/mage/cards/f/ForbiddingSpirit.java | 7 +- Mage.Sets/src/mage/cards/g/GhostlyPrison.java | 14 +++- Mage.Sets/src/mage/cards/k/KoskunFalls.java | 20 +++--- .../mage/cards/n/NilsDisciplineEnforcer.java | 4 +- Mage.Sets/src/mage/cards/n/NornsAnnex.java | 11 +-- .../src/mage/cards/o/OnakkeOathkeeper.java | 62 +++++++++++++++++ Mage.Sets/src/mage/cards/p/Propaganda.java | 14 +++- .../src/mage/cards/s/SivitriDragonMaster.java | 7 +- .../src/mage/cards/s/SphereOfSafety.java | 3 +- Mage.Sets/src/mage/cards/w/WindbornMuse.java | 14 +++- Mage.Sets/src/mage/sets/CommanderMasters.java | 1 + .../CantAttackYouUnlessPayAllEffect.java | 69 +++++++++++++------ 17 files changed, 210 insertions(+), 74 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/o/OnakkeOathkeeper.java diff --git a/Mage.Sets/src/mage/cards/a/ArchangelOfTithes.java b/Mage.Sets/src/mage/cards/a/ArchangelOfTithes.java index 72c79e22716..4039111b548 100644 --- a/Mage.Sets/src/mage/cards/a/ArchangelOfTithes.java +++ b/Mage.Sets/src/mage/cards/a/ArchangelOfTithes.java @@ -1,7 +1,6 @@ package mage.cards.a; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -12,20 +11,22 @@ import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.Duration; import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class ArchangelOfTithes extends CardImpl { public ArchangelOfTithes(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{W}{W}"); this.subtype.add(SubType.ANGEL); this.power = new MageInt(3); this.toughness = new MageInt(5); @@ -53,7 +54,7 @@ public final class ArchangelOfTithes extends CardImpl { class ArchangelOfTithesPayManaToAttackAllEffect extends CantAttackYouUnlessPayAllEffect { ArchangelOfTithesPayManaToAttackAllEffect() { - super(new ManaCostsImpl<>("{1}"), true); + super(Duration.WhileOnBattlefield, new ManaCostsImpl<>("{1}"), Scope.YOU_AND_CONTROLLED_PLANESWALKERS); staticText = "As long as {this} is untapped, creatures can't attack you or planeswalkers you control unless their controller pays {1} for each of those creatures."; } diff --git a/Mage.Sets/src/mage/cards/a/ArchonOfAbsolution.java b/Mage.Sets/src/mage/cards/a/ArchonOfAbsolution.java index 84ad6308357..71a110a75ea 100644 --- a/Mage.Sets/src/mage/cards/a/ArchonOfAbsolution.java +++ b/Mage.Sets/src/mage/cards/a/ArchonOfAbsolution.java @@ -10,6 +10,7 @@ import mage.abilities.keyword.ProtectionAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.Duration; import mage.constants.SubType; import java.util.UUID; @@ -34,9 +35,10 @@ public final class ArchonOfAbsolution extends CardImpl { // Creatures can't attack you or a planeswalker you control unless their controller pays {1} for each of those creatures. this.addAbility(new SimpleStaticAbility(new CantAttackYouUnlessPayAllEffect( - new ManaCostsImpl<>("{1}"), true - ).setText("creatures can't attack you or planeswalkers you control " + - "unless their controller pays {1} for each of those creatures"))); + Duration.WhileOnBattlefield, + new ManaCostsImpl<>("{1}"), + CantAttackYouUnlessPayAllEffect.Scope.YOU_AND_CONTROLLED_PLANESWALKERS + ))); } private ArchonOfAbsolution(final ArchonOfAbsolution card) { diff --git a/Mage.Sets/src/mage/cards/b/BairdStewardOfArgive.java b/Mage.Sets/src/mage/cards/b/BairdStewardOfArgive.java index 7fa6af7d9c6..31dc785c727 100644 --- a/Mage.Sets/src/mage/cards/b/BairdStewardOfArgive.java +++ b/Mage.Sets/src/mage/cards/b/BairdStewardOfArgive.java @@ -1,7 +1,6 @@ package mage.cards.b; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; @@ -9,10 +8,9 @@ import mage.abilities.effects.common.combat.CantAttackYouUnlessPayAllEffect; import mage.abilities.keyword.VigilanceAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.SuperType; -import mage.constants.Zone; +import mage.constants.*; + +import java.util.UUID; /** * @author JRHerlehy Created on 4/4/18. @@ -32,8 +30,14 @@ public final class BairdStewardOfArgive extends CardImpl { this.addAbility(VigilanceAbility.getInstance()); // Creatures can't attack you or a planeswalker you control unless their controller pays {1} for each of those creatures. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackYouUnlessPayAllEffect(new ManaCostsImpl<>("{1}"), true) - .setText("Creatures can't attack you or planeswalkers you control unless their controller pays {1} for each of those creatures"))); + this.addAbility(new SimpleStaticAbility( + Zone.BATTLEFIELD, + new CantAttackYouUnlessPayAllEffect( + Duration.WhileOnBattlefield, + new ManaCostsImpl<>("{1}"), + CantAttackYouUnlessPayAllEffect.Scope.YOU_AND_CONTROLLED_PLANESWALKERS + ) + )); } private BairdStewardOfArgive(final BairdStewardOfArgive card) { diff --git a/Mage.Sets/src/mage/cards/c/CollectiveRestraint.java b/Mage.Sets/src/mage/cards/c/CollectiveRestraint.java index b978844654b..b78f2377cff 100644 --- a/Mage.Sets/src/mage/cards/c/CollectiveRestraint.java +++ b/Mage.Sets/src/mage/cards/c/CollectiveRestraint.java @@ -1,7 +1,6 @@ package mage.cards.c; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCosts; @@ -13,12 +12,14 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.AbilityWord; import mage.constants.CardType; +import mage.constants.Duration; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; +import java.util.UUID; + /** - * * @author Simown */ public final class CollectiveRestraint extends CardImpl { @@ -46,7 +47,7 @@ public final class CollectiveRestraint extends CardImpl { class CollectiveRestraintPayManaToAttackAllEffect extends CantAttackYouUnlessPayAllEffect { CollectiveRestraintPayManaToAttackAllEffect() { - super(null, false); + super(Duration.WhileOnBattlefield, new ManaCostsImpl<>("{X}")); staticText = "Creatures can't attack you unless their controller pays {X} for each creature they control that's attacking you, where X is the number of basic land types among lands you control."; } diff --git a/Mage.Sets/src/mage/cards/e/ElephantGrass.java b/Mage.Sets/src/mage/cards/e/ElephantGrass.java index c5d2e380bd1..5df6c63dd45 100644 --- a/Mage.Sets/src/mage/cards/e/ElephantGrass.java +++ b/Mage.Sets/src/mage/cards/e/ElephantGrass.java @@ -1,7 +1,6 @@ package mage.cards.e; -import java.util.UUID; import mage.ObjectColor; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; @@ -17,8 +16,9 @@ import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.ColorPredicate; +import java.util.UUID; + /** - * * @author Plopman */ public final class ElephantGrass extends CardImpl { @@ -32,7 +32,7 @@ public final class ElephantGrass extends CardImpl { } public ElephantGrass(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}"); // Cumulative upkeep {1} this.addAbility(new CumulativeUpkeepAbility(new ManaCostsImpl<>("{1}"))); @@ -41,7 +41,15 @@ public final class ElephantGrass extends CardImpl { this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackYouAllEffect(Duration.WhileOnBattlefield, filterBlack))); // Nonblack creatures can't attack you unless their controller pays {2} for each creature they control that's attacking you. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackYouUnlessPayAllEffect(new ManaCostsImpl<>("{2}"), false, filter))); + this.addAbility(new SimpleStaticAbility( + Zone.BATTLEFIELD, + new CantAttackYouUnlessPayAllEffect( + Duration.WhileOnBattlefield, + new ManaCostsImpl<>("{2}"), + CantAttackYouUnlessPayAllEffect.Scope.YOU_ONLY, + filter + ) + )); } private ElephantGrass(final ElephantGrass card) { diff --git a/Mage.Sets/src/mage/cards/f/ForbiddingSpirit.java b/Mage.Sets/src/mage/cards/f/ForbiddingSpirit.java index a9430369bd9..74bd3f79ff2 100644 --- a/Mage.Sets/src/mage/cards/f/ForbiddingSpirit.java +++ b/Mage.Sets/src/mage/cards/f/ForbiddingSpirit.java @@ -28,11 +28,10 @@ public final class ForbiddingSpirit extends CardImpl { // When Forbidding Spirit enters the battlefield, until your next turn, creatures can't attack you or a planeswalker you control unless their controller pays {2} for each of those creatures. ContinuousEffect effect = new CantAttackYouUnlessPayAllEffect( - new ManaCostsImpl<>("{2}"), true + Duration.UntilYourNextTurn, + new ManaCostsImpl<>("{2}"), + CantAttackYouUnlessPayAllEffect.Scope.YOU_AND_CONTROLLED_PLANESWALKERS ); - effect.setDuration(Duration.UntilYourNextTurn); - effect.setText("until your next turn, creatures can't attack you or planeswalkers you control " + - "unless their controller pays {2} for each of those creatures."); this.addAbility(new EntersBattlefieldTriggeredAbility(effect)); } diff --git a/Mage.Sets/src/mage/cards/g/GhostlyPrison.java b/Mage.Sets/src/mage/cards/g/GhostlyPrison.java index 2498c62a45a..89c288ccb3a 100644 --- a/Mage.Sets/src/mage/cards/g/GhostlyPrison.java +++ b/Mage.Sets/src/mage/cards/g/GhostlyPrison.java @@ -1,15 +1,17 @@ package mage.cards.g; -import java.util.UUID; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.combat.CantAttackYouUnlessPayAllEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.Duration; import mage.constants.Zone; +import java.util.UUID; + /** * * @author Loki @@ -17,10 +19,16 @@ import mage.constants.Zone; public final class GhostlyPrison extends CardImpl { public GhostlyPrison(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}"); // Creatures can't attack you unless their controller pays {2} for each creature they control that's attacking you - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackYouUnlessPayAllEffect(new ManaCostsImpl<>("{2}")))); + this.addAbility(new SimpleStaticAbility( + Zone.BATTLEFIELD, + new CantAttackYouUnlessPayAllEffect( + Duration.WhileOnBattlefield, + new ManaCostsImpl<>("{2}") + ) + )); } diff --git a/Mage.Sets/src/mage/cards/k/KoskunFalls.java b/Mage.Sets/src/mage/cards/k/KoskunFalls.java index a4552c2233e..cfd44d31488 100644 --- a/Mage.Sets/src/mage/cards/k/KoskunFalls.java +++ b/Mage.Sets/src/mage/cards/k/KoskunFalls.java @@ -1,7 +1,6 @@ package mage.cards.k; -import java.util.UUID; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.common.TapTargetCost; @@ -11,14 +10,13 @@ import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect; import mage.abilities.effects.common.combat.CantAttackYouUnlessPayAllEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SuperType; -import mage.constants.TargetController; -import mage.constants.Zone; +import mage.constants.*; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.permanent.TappedPredicate; import mage.target.common.TargetControlledCreaturePermanent; +import java.util.UUID; + /** * * @author fireshoes @@ -32,16 +30,22 @@ public final class KoskunFalls extends CardImpl { } public KoskunFalls(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}{B}"); this.supertype.add(SuperType.WORLD); // At the beginning of your upkeep, sacrifice Koskun Falls unless you tap an untapped creature you control. Effect effect = new SacrificeSourceUnlessPaysEffect(new TapTargetCost(new TargetControlledCreaturePermanent(1, 1, filterCreature, true))); effect.setText("sacrifice Koskun Falls unless you tap an untapped creature you control"); this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.YOU, false)); - + // Creatures can't attack you unless their controller pays {2} for each creature they control that's attacking you. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackYouUnlessPayAllEffect(new ManaCostsImpl<>("{2}")))); + this.addAbility(new SimpleStaticAbility( + Zone.BATTLEFIELD, + new CantAttackYouUnlessPayAllEffect( + Duration.WhileOnBattlefield, + new ManaCostsImpl<>("{2}") + ) + )); } private KoskunFalls(final KoskunFalls card) { diff --git a/Mage.Sets/src/mage/cards/n/NilsDisciplineEnforcer.java b/Mage.Sets/src/mage/cards/n/NilsDisciplineEnforcer.java index e747727794d..19ed4ab3304 100644 --- a/Mage.Sets/src/mage/cards/n/NilsDisciplineEnforcer.java +++ b/Mage.Sets/src/mage/cards/n/NilsDisciplineEnforcer.java @@ -111,9 +111,9 @@ class NilsDisciplineEnforcerCountersEffect extends OneShotEffect { class NilsDisciplineEnforcerEffect extends CantAttackYouUnlessPayAllEffect { NilsDisciplineEnforcerEffect() { - super(null, true); + super(Duration.WhileOnBattlefield, new ManaCostsImpl<>("{X}"), Scope.YOU_AND_CONTROLLED_PLANESWALKERS); staticText = "Each creature with one or more counters on it can't attack you or planeswalkers you control " - + "unless its controller pays {X}, where X is the number of counters on that creature."; + + "unless its controller pays {X}, where X is the number of counters on that creature."; } private NilsDisciplineEnforcerEffect(NilsDisciplineEnforcerEffect effect) { diff --git a/Mage.Sets/src/mage/cards/n/NornsAnnex.java b/Mage.Sets/src/mage/cards/n/NornsAnnex.java index 6212fcb6454..d13d1adc3c6 100644 --- a/Mage.Sets/src/mage/cards/n/NornsAnnex.java +++ b/Mage.Sets/src/mage/cards/n/NornsAnnex.java @@ -1,14 +1,15 @@ package mage.cards.n; -import java.util.UUID; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.combat.CantAttackYouUnlessPayAllEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Zone; +import mage.constants.Duration; + +import java.util.UUID; /** * @author Loki @@ -21,8 +22,10 @@ public final class NornsAnnex extends CardImpl { // {W/P} ({W/P} can be paid with either or 2 life.) // Creatures can't attack you or a planeswalker you control unless their controller pays {W/P} for each of those creatures. this.addAbility(new SimpleStaticAbility(new CantAttackYouUnlessPayAllEffect( - new ManaCostsImpl<>("{W/P}"), true - ).setText("creatures can't attack you or planeswalkers you control unless their controller pays {W/P} for each of those creatures"))); + Duration.WhileOnBattlefield, + new ManaCostsImpl<>("{W/P}"), + CantAttackYouUnlessPayAllEffect.Scope.YOU_AND_CONTROLLED_PLANESWALKERS + ))); } private NornsAnnex(final NornsAnnex card) { diff --git a/Mage.Sets/src/mage/cards/o/OnakkeOathkeeper.java b/Mage.Sets/src/mage/cards/o/OnakkeOathkeeper.java new file mode 100644 index 00000000000..0d2924acc93 --- /dev/null +++ b/Mage.Sets/src/mage/cards/o/OnakkeOathkeeper.java @@ -0,0 +1,62 @@ +package mage.cards.o; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.ExileSourceFromGraveCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; +import mage.abilities.effects.common.combat.CantAttackYouUnlessPayAllEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.common.FilterPlaneswalkerCard; +import mage.target.common.TargetCardInYourGraveyard; + +import java.util.UUID; + +/** + * @author Susucr + */ +public final class OnakkeOathkeeper extends CardImpl { + + public OnakkeOathkeeper(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}"); + + this.subtype.add(SubType.OGRE); + this.subtype.add(SubType.SPIRIT); + this.power = new MageInt(0); + this.toughness = new MageInt(4); + + // Creatures can't attack planeswalkers you control unless their controller pays {1} for each creature they control that's attacking a planeswalker you control. + this.addAbility(new SimpleStaticAbility( + Zone.BATTLEFIELD, + new CantAttackYouUnlessPayAllEffect( + Duration.WhileOnBattlefield, + new ManaCostsImpl<>("{1}"), + CantAttackYouUnlessPayAllEffect.Scope.CONTROLLED_PLANESWALKERS_ONLY + ) + )); + + // {4}{W}{W}, Exile Onakke Oathkeeper from your graveyard: Return target planeswalker card from your graveyard to the battlefield. + Ability ability = new SimpleActivatedAbility( + Zone.GRAVEYARD, new ReturnFromGraveyardToBattlefieldTargetEffect(), new ManaCostsImpl<>("{4}{W}{W}") + ); + ability.addCost(new ExileSourceFromGraveCost()); + ability.addTarget(new TargetCardInYourGraveyard(new FilterPlaneswalkerCard())); + this.addAbility(ability); + } + + private OnakkeOathkeeper(final OnakkeOathkeeper card) { + super(card); + } + + @Override + public OnakkeOathkeeper copy() { + return new OnakkeOathkeeper(this); + } +} diff --git a/Mage.Sets/src/mage/cards/p/Propaganda.java b/Mage.Sets/src/mage/cards/p/Propaganda.java index 32c10a7ddf4..c82a5dca59e 100644 --- a/Mage.Sets/src/mage/cards/p/Propaganda.java +++ b/Mage.Sets/src/mage/cards/p/Propaganda.java @@ -1,15 +1,17 @@ package mage.cards.p; -import java.util.UUID; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.combat.CantAttackYouUnlessPayAllEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.Duration; import mage.constants.Zone; +import java.util.UUID; + /** * * @author Loki @@ -17,10 +19,16 @@ import mage.constants.Zone; public final class Propaganda extends CardImpl { public Propaganda(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}"); // Creatures can't attack you unless their controller pays {2} for each creature they control that's attacking you. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackYouUnlessPayAllEffect(new ManaCostsImpl<>("{2}")))); + this.addAbility(new SimpleStaticAbility( + Zone.BATTLEFIELD, + new CantAttackYouUnlessPayAllEffect( + Duration.WhileOnBattlefield, + new ManaCostsImpl<>("{2}") + ) + )); } private Propaganda(final Propaganda card) { diff --git a/Mage.Sets/src/mage/cards/s/SivitriDragonMaster.java b/Mage.Sets/src/mage/cards/s/SivitriDragonMaster.java index 07c54bac227..090305bdf81 100644 --- a/Mage.Sets/src/mage/cards/s/SivitriDragonMaster.java +++ b/Mage.Sets/src/mage/cards/s/SivitriDragonMaster.java @@ -43,11 +43,10 @@ public final class SivitriDragonMaster extends CardImpl { // +1: Until your next turn, creatures can’t attack you or planeswalkers you // control unless their controller pays 2 life for each of those creatures. ContinuousEffect effect = new CantAttackYouUnlessPayAllEffect( - new PayLifeCost(2), true + Duration.UntilYourNextTurn, + new PayLifeCost(2), + CantAttackYouUnlessPayAllEffect.Scope.YOU_AND_CONTROLLED_PLANESWALKERS ); - effect.setDuration(Duration.UntilYourNextTurn); - effect.setText("until your next turn, creatures can't attack you or planeswalkers you control " + - "unless their controller pays 2 life for each of those creatures."); this.addAbility(new LoyaltyAbility(effect, 1)); // -3: Search your library for a Dragon card, reveal it, put it into your hand, then shuffle. diff --git a/Mage.Sets/src/mage/cards/s/SphereOfSafety.java b/Mage.Sets/src/mage/cards/s/SphereOfSafety.java index a2ac264d857..b799e5b77cf 100644 --- a/Mage.Sets/src/mage/cards/s/SphereOfSafety.java +++ b/Mage.Sets/src/mage/cards/s/SphereOfSafety.java @@ -12,6 +12,7 @@ import mage.abilities.hint.ValueHint; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.Duration; import mage.constants.Zone; import mage.filter.StaticFilters; import mage.game.Game; @@ -51,7 +52,7 @@ public final class SphereOfSafety extends CardImpl { class SphereOfSafetyPayManaToAttackAllEffect extends CantAttackYouUnlessPayAllEffect { SphereOfSafetyPayManaToAttackAllEffect() { - super(null, true); + super(Duration.WhileOnBattlefield, new ManaCostsImpl<>("{X}"), Scope.YOU_AND_CONTROLLED_PLANESWALKERS); staticText = "Creatures can't attack you or planeswalkers you control unless their controller pays {X} for each of those creatures, where X is the number of enchantments you control."; } diff --git a/Mage.Sets/src/mage/cards/w/WindbornMuse.java b/Mage.Sets/src/mage/cards/w/WindbornMuse.java index ae569a0349c..602f72ddeaa 100644 --- a/Mage.Sets/src/mage/cards/w/WindbornMuse.java +++ b/Mage.Sets/src/mage/cards/w/WindbornMuse.java @@ -1,7 +1,6 @@ package mage.cards.w; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; @@ -10,9 +9,12 @@ import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.Duration; import mage.constants.SubType; import mage.constants.Zone; +import java.util.UUID; + /** * * @author Loki @@ -20,7 +22,7 @@ import mage.constants.Zone; public final class WindbornMuse extends CardImpl { public WindbornMuse(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}"); this.subtype.add(SubType.SPIRIT); this.power = new MageInt(2); this.toughness = new MageInt(3); @@ -29,7 +31,13 @@ public final class WindbornMuse extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // Creatures can't attack you unless their controller pays {2} for each creature they control that's attacking you. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackYouUnlessPayAllEffect(new ManaCostsImpl<>("{2}")))); + this.addAbility(new SimpleStaticAbility( + Zone.BATTLEFIELD, + new CantAttackYouUnlessPayAllEffect( + Duration.WhileOnBattlefield, + new ManaCostsImpl<>("{2}") + ) + )); } diff --git a/Mage.Sets/src/mage/sets/CommanderMasters.java b/Mage.Sets/src/mage/sets/CommanderMasters.java index 88d9ab80c15..5719395e2a7 100644 --- a/Mage.Sets/src/mage/sets/CommanderMasters.java +++ b/Mage.Sets/src/mage/sets/CommanderMasters.java @@ -452,6 +452,7 @@ public final class CommanderMasters extends ExpansionSet { cards.add(new SetCardInfo("Omen of the Hunt", 906, Rarity.COMMON, mage.cards.o.OmenOfTheHunt.class)); cards.add(new SetCardInfo("Omen of the Sun", 831, Rarity.COMMON, mage.cards.o.OmenOfTheSun.class)); cards.add(new SetCardInfo("Omnath, Locus of Mana", 310, Rarity.MYTHIC, mage.cards.o.OmnathLocusOfMana.class)); + cards.add(new SetCardInfo("Onakke Oathkeeper", 722, Rarity.RARE, mage.cards.o.OnakkeOathkeeper.class)); cards.add(new SetCardInfo("Ondu Spiritdancer", 723, Rarity.RARE, mage.cards.o.OnduSpiritdancer.class)); cards.add(new SetCardInfo("Opal Palace", 422, Rarity.COMMON, mage.cards.o.OpalPalace.class)); cards.add(new SetCardInfo("Opulent Palace", 1017, Rarity.UNCOMMON, mage.cards.o.OpulentPalace.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouUnlessPayAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouUnlessPayAllEffect.java index 23e352f0cff..88d102b69a7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouUnlessPayAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouUnlessPayAllEffect.java @@ -6,42 +6,68 @@ import mage.abilities.costs.Cost; import mage.abilities.effects.PayCostToAttackBlockEffectImpl; import mage.constants.Duration; import mage.constants.Outcome; +import mage.filter.StaticFilters; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; /** - * @author LevelX2 + * @author LevelX2, Susucr */ public class CantAttackYouUnlessPayAllEffect extends PayCostToAttackBlockEffectImpl { + public enum Scope { + YOU_AND_CONTROLLED_PLANESWALKERS(true, true, + "you or planeswalkers you control", "of those creatures"), + YOU_ONLY(true, false, + "you", "creature they control that's attacking you"), + CONTROLLED_PLANESWALKERS_ONLY(false, true, + "planeswalkers you control", "creature they control that's attacking a planeswalker you control"); + + final boolean attackingYou; + final boolean attackingControlledPlaneswalkers; + // text replacing [!] in "[...] can't attack [!] unless [...] pays ..." + final String firstText; + // text replacing [!] in "unless their controller pays [...] for each [!]" + final String secondText; + + Scope(boolean attackingYou, boolean attackingControlledPlaneswalkers, String firstText, String secondText) { + this.attackingYou = attackingYou; + this.attackingControlledPlaneswalkers = attackingControlledPlaneswalkers; + this.firstText = firstText; + this.secondText = secondText; + } + } + private final FilterCreaturePermanent filterCreaturePermanent; - private final boolean payAlsoForAttackingPlaneswalker; + private final Scope scope; // Describe which attacked objects this effect cares about. - public CantAttackYouUnlessPayAllEffect(Cost cost) { - this(cost, false); + public CantAttackYouUnlessPayAllEffect(Duration duration, Cost cost) { + this(duration, cost, Scope.YOU_ONLY); } - public CantAttackYouUnlessPayAllEffect(Cost cost, boolean payAlsoForAttackingPlaneswalker) { - this(cost, payAlsoForAttackingPlaneswalker, null); + public CantAttackYouUnlessPayAllEffect(Duration duration, Cost cost, Scope scope) { + this(duration, cost, scope, StaticFilters.FILTER_PERMANENT_CREATURES); } - public CantAttackYouUnlessPayAllEffect(Cost cost, boolean payAlsoForAttackingPlaneswalker, FilterCreaturePermanent filter) { - super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK, cost); - this.payAlsoForAttackingPlaneswalker = payAlsoForAttackingPlaneswalker; + public CantAttackYouUnlessPayAllEffect(Duration duration, Cost cost, Scope scope, FilterCreaturePermanent filter) { + super(duration, Outcome.Detriment, RestrictType.ATTACK, cost); + this.scope = scope; this.filterCreaturePermanent = filter; - staticText = (filterCreaturePermanent == null ? "Creatures" : filterCreaturePermanent.getMessage()) - + " can't attack you " - + (payAlsoForAttackingPlaneswalker ? "or a planeswalker you control " : "") - + "unless their controller pays " - + (cost == null ? "" : cost.getText()) - + " for each creature they control that's attacking you"; + + String durationText = duration.toString(); + staticText = (durationText.isEmpty() ? "" : durationText + ", ") + + filterCreaturePermanent.getMessage() + + " can't attack " + scope.firstText + + " unless their controller pays " + + cost.getText() + + " for each " + scope.secondText; } - public CantAttackYouUnlessPayAllEffect(final CantAttackYouUnlessPayAllEffect effect) { + protected CantAttackYouUnlessPayAllEffect(final CantAttackYouUnlessPayAllEffect effect) { super(effect); - this.payAlsoForAttackingPlaneswalker = effect.payAlsoForAttackingPlaneswalker; + this.scope = effect.scope; this.filterCreaturePermanent = effect.filterCreaturePermanent; } @@ -54,16 +80,17 @@ public class CantAttackYouUnlessPayAllEffect extends PayCostToAttackBlockEffectI return false; } } + // attack target is controlling player - if (source.isControlledBy(event.getTargetId())) { + if (scope.attackingYou && source.isControlledBy(event.getTargetId())) { return true; } // or attack target is a planeswalker of the controlling player - if (payAlsoForAttackingPlaneswalker) { + if (scope.attackingControlledPlaneswalkers) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null - && permanent.isPlaneswalker(game) - && permanent.isControlledBy(source.getControllerId())) { + && permanent.isPlaneswalker(game) + && permanent.isControlledBy(source.getControllerId())) { return true; } }