diff --git a/Mage.Sets/src/mage/cards/p/PerchProtection.java b/Mage.Sets/src/mage/cards/p/PerchProtection.java new file mode 100644 index 00000000000..8f7773d6f96 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PerchProtection.java @@ -0,0 +1,87 @@ +package mage.cards.p; + +import mage.abilities.Ability; +import mage.abilities.condition.common.GiftWasPromisedCondition; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.ExileSpellEffect; +import mage.abilities.effects.common.continuous.GainAbilityControllerEffect; +import mage.abilities.effects.common.continuous.LifeTotalCantChangeControllerEffect; +import mage.abilities.keyword.GiftAbility; +import mage.abilities.keyword.ProtectionFromEverythingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.GiftType; +import mage.constants.Outcome; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.SwanSongBirdToken; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PerchProtection extends CardImpl { + + public PerchProtection(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{W}{W}"); + + // Gift an extra turn + this.addAbility(new GiftAbility(this, GiftType.EXTRA_TURN)); + + // Create four 2/2 blue Bird creature tokens with flying. If the gift was promised, all permanents you control phase out, and until your next turn, your life total can't change and you gain protection from everything. + this.getSpellAbility().addEffect(new CreateTokenEffect(new SwanSongBirdToken(), 4)); + this.getSpellAbility().addEffect(new PerchProtectionEffect()); + + // Exile Perch Protection. + this.getSpellAbility().addEffect(new ExileSpellEffect().concatBy("
")); + } + + private PerchProtection(final PerchProtection card) { + super(card); + } + + @Override + public PerchProtection copy() { + return new PerchProtection(this); + } +} + +class PerchProtectionEffect extends OneShotEffect { + + PerchProtectionEffect() { + super(Outcome.Benefit); + staticText = "if the gift was promised, all permanents you control phase out, " + + "and until your next turn, your life total can't change and you gain protection from everything"; + } + + private PerchProtectionEffect(final PerchProtectionEffect effect) { + super(effect); + } + + @Override + public PerchProtectionEffect copy() { + return new PerchProtectionEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + if (GiftWasPromisedCondition.FALSE.apply(game, source)) { + return false; + } + for (Permanent permanent : game.getBattlefield().getActivePermanents( + StaticFilters.FILTER_CONTROLLED_PERMANENT, source.getControllerId(), source, game + )) { + permanent.phaseOut(game); + } + game.addEffect(new LifeTotalCantChangeControllerEffect(Duration.UntilYourNextTurn), source); + game.addEffect(new GainAbilityControllerEffect( + new ProtectionFromEverythingAbility(), Duration.UntilYourNextTurn + ), source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/BloomburrowCommander.java b/Mage.Sets/src/mage/sets/BloomburrowCommander.java index cd13700f032..b7a25d74f00 100644 --- a/Mage.Sets/src/mage/sets/BloomburrowCommander.java +++ b/Mage.Sets/src/mage/sets/BloomburrowCommander.java @@ -59,6 +59,7 @@ public final class BloomburrowCommander extends ExpansionSet { cards.add(new SetCardInfo("Martial Impetus", 108, Rarity.UNCOMMON, mage.cards.m.MartialImpetus.class)); cards.add(new SetCardInfo("Narset, Parter of Veils", 76, Rarity.RARE, mage.cards.n.NarsetParterOfVeils.class)); cards.add(new SetCardInfo("Nissa, Who Shakes the World", 84, Rarity.RARE, mage.cards.n.NissaWhoShakesTheWorld.class)); + cards.add(new SetCardInfo("Perch Protection", 11, Rarity.RARE, mage.cards.p.PerchProtection.class)); cards.add(new SetCardInfo("Pollywog Prodigy", 15, Rarity.RARE, mage.cards.p.PollywogProdigy.class)); cards.add(new SetCardInfo("Prosperous Innkeeper", 121, Rarity.UNCOMMON, mage.cards.p.ProsperousInnkeeper.class)); cards.add(new SetCardInfo("Rapid Hybridization", 111, Rarity.UNCOMMON, mage.cards.r.RapidHybridization.class)); diff --git a/Mage/src/main/java/mage/constants/GiftType.java b/Mage/src/main/java/mage/constants/GiftType.java index 0b4454290d6..14a32e8c014 100644 --- a/Mage/src/main/java/mage/constants/GiftType.java +++ b/Mage/src/main/java/mage/constants/GiftType.java @@ -5,6 +5,7 @@ import mage.game.Game; import mage.game.permanent.token.FishNoAbilityToken; import mage.game.permanent.token.FoodToken; import mage.game.permanent.token.TreasureToken; +import mage.game.turn.TurnMod; import mage.players.Player; /** @@ -26,6 +27,10 @@ public enum GiftType { TAPPED_FISH( "a tapped Fish", "create a tapped 1/1 blue Fish creature token", (p, g, s) -> new FishNoAbilityToken().putOntoBattlefield(1, g, s, p.getId(), true, false) + ), + EXTRA_TURN( + "an extra turn", "take an extra turn after this one", + (p, g, s) -> g.getState().getTurnMods().add(new TurnMod(p.getId()).withExtraTurn()) ); private interface GiftResolver {