From 7ac7de7f48197c456d194a936680cebf40297791 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Mon, 16 Jan 2023 18:52:56 -0500 Subject: [PATCH] [ONE] Implement White Sun's Twilight --- .../src/mage/cards/w/WhiteSunsTwilight.java | 78 +++++++++++++++++++ .../src/mage/sets/PhyrexiaAllWillBeOne.java | 1 + 2 files changed, 79 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/w/WhiteSunsTwilight.java diff --git a/Mage.Sets/src/mage/cards/w/WhiteSunsTwilight.java b/Mage.Sets/src/mage/cards/w/WhiteSunsTwilight.java new file mode 100644 index 0000000000..6efd54106e --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WhiteSunsTwilight.java @@ -0,0 +1,78 @@ +package mage.cards.w; + +import java.util.List; +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.PhyrexianMiteToken; +import mage.game.permanent.token.Token; + +/** + * @author TheElk801 + */ +public final class WhiteSunsTwilight extends CardImpl { + + public WhiteSunsTwilight(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{W}{W}"); + + // You gain X life. Create X 1/1 colorless Phyrexian Mite artifact creature tokens with toxic 1 and "This creature can't block." If X is 5 or more, destroy all other creatures. + this.getSpellAbility().addEffect(new GainLifeEffect(ManacostVariableValue.REGULAR)); + this.getSpellAbility().addEffect(new WhiteSunsTwilightEffect()); + } + + private WhiteSunsTwilight(final WhiteSunsTwilight card) { + super(card); + } + + @Override + public WhiteSunsTwilight copy() { + return new WhiteSunsTwilight(this); + } +} + +class WhiteSunsTwilightEffect extends OneShotEffect { + + WhiteSunsTwilightEffect() { + super(Outcome.Benefit); + staticText = "create X 1/1 colorless Phyrexian Mite artifact creature tokens with toxic 1 " + + "and \"This creature can't block.\" If X is 5 or more, destroy all other creatures"; + } + + private WhiteSunsTwilightEffect(final WhiteSunsTwilightEffect effect) { + super(effect); + } + + @Override + public WhiteSunsTwilightEffect copy() { + return new WhiteSunsTwilightEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int xValue = source.getManaCostsToPay().getX(); + Token token = new PhyrexianMiteToken(); + token.putOntoBattlefield(xValue, game, source); + if (xValue < 5) { + return true; + } + List tokenIds = token.getLastAddedTokenIds(); + for (Permanent permanent : game.getBattlefield().getActivePermanents( + StaticFilters.FILTER_PERMANENT_CREATURE, source.getSourceId(), game + )) { + if (!tokenIds.contains(permanent.getId())) { + permanent.destroy(source, game); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java index 87617fcc1e..3f7497aeb3 100644 --- a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java +++ b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java @@ -61,6 +61,7 @@ public final class PhyrexiaAllWillBeOne extends ExpansionSet { cards.add(new SetCardInfo("Urabrask's Forge", 153, Rarity.RARE, mage.cards.u.UrabrasksForge.class)); cards.add(new SetCardInfo("Venser, Corpse Puppet", 219, Rarity.RARE, mage.cards.v.VenserCorpsePuppet.class)); cards.add(new SetCardInfo("Vindictive Flamestoker", 154, Rarity.RARE, mage.cards.v.VindictiveFlamestoker.class)); + cards.add(new SetCardInfo("White Sun's Twilight", 38, Rarity.RARE, mage.cards.w.WhiteSunsTwilight.class)); } // @Override