From 31797c7c4faf2e2da335cf20bb5895e8f8eda0a7 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 14 Dec 2022 09:43:01 -0500 Subject: [PATCH] [ONE] Implement Blue Sun's Twilight --- .../src/mage/cards/b/BlueSunsTwilight.java | 69 +++++++++++++++++++ .../src/mage/sets/PhyrexiaAllWillBeOne.java | 1 + 2 files changed, 70 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/BlueSunsTwilight.java diff --git a/Mage.Sets/src/mage/cards/b/BlueSunsTwilight.java b/Mage.Sets/src/mage/cards/b/BlueSunsTwilight.java new file mode 100644 index 0000000000..d0db602e86 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BlueSunsTwilight.java @@ -0,0 +1,69 @@ +package mage.cards.b; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.common.CreateTokenCopyTargetEffect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.ComparisonType; +import mage.constants.Duration; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.ManaValuePredicate; +import mage.game.Game; +import mage.target.TargetPermanent; +import mage.target.targetadjustment.TargetAdjuster; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class BlueSunsTwilight extends CardImpl { + + public BlueSunsTwilight(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{U}{U}"); + + // Gain control of target creature with mana value X or less. If X is 5 or more, create a token that's a copy of that creature. + this.getSpellAbility().addEffect(new GainControlTargetEffect(Duration.Custom, true)); + this.getSpellAbility().addEffect(new ConditionalOneShotEffect( + new CreateTokenCopyTargetEffect(), BlueSunsTwilightCondition.instance, + "If X is 5 or more, create a token that's a copy of that creature" + )); + this.getSpellAbility().setTargetAdjuster(BlueSunsTwilightAdjuster.instance); + } + + private BlueSunsTwilight(final BlueSunsTwilight card) { + super(card); + } + + @Override + public BlueSunsTwilight copy() { + return new BlueSunsTwilight(this); + } +} + +enum BlueSunsTwilightCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + return source.getManaCostsToPay().getX() >= 5; + } +} + +enum BlueSunsTwilightAdjuster implements TargetAdjuster { + instance; + + @Override + public void adjustTargets(Ability ability, Game game) { + int xValue = ability.getManaCostsToPay().getX(); + FilterPermanent filter = new FilterCreaturePermanent("creature with mana value " + xValue + " or less"); + filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1)); + ability.getTargets().clear(); + ability.addTarget(new TargetPermanent(filter)); + } +} diff --git a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java index 74573b977c..ebae4350f3 100644 --- a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java +++ b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java @@ -20,6 +20,7 @@ public final class PhyrexiaAllWillBeOne extends ExpansionSet { this.blockName = "Phyrexia: All Will Be One"; this.hasBoosters = false; // temporary + cards.add(new SetCardInfo("Blue Sun's Twilight", 43, Rarity.RARE, mage.cards.b.BlueSunsTwilight.class)); cards.add(new SetCardInfo("Forest", 276, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Island", 273, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mountain", 275, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));