From 59afefd527b72eecfd37ccf688023f68b81bac0e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 28 Oct 2022 08:25:18 -0400 Subject: [PATCH] [BRO] Implemented Splitting the Powerstone --- .../mage/cards/s/SplittingThePowerstone.java | 63 +++++++++++++++++++ .../mage/cards/u/UrzaPowerstoneProdigy.java | 6 +- Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + .../effects/common/CreateTokenEffect.java | 4 ++ 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/s/SplittingThePowerstone.java diff --git a/Mage.Sets/src/mage/cards/s/SplittingThePowerstone.java b/Mage.Sets/src/mage/cards/s/SplittingThePowerstone.java new file mode 100644 index 0000000000..429324bee2 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SplittingThePowerstone.java @@ -0,0 +1,63 @@ +package mage.cards.s; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.token.PowerstoneToken; +import mage.util.CardUtil; + +import java.util.Collection; +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class SplittingThePowerstone extends CardImpl { + + public SplittingThePowerstone(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{U}"); + + // As an additional cost to cast this spell, sacrifice an artifact. + this.getSpellAbility().addCost(new SacrificeTargetCost(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_AN)); + + // Create two tapped Powerstone tokens. If the sacrificed artifact was legendary, draw a card. + this.getSpellAbility().addEffect(new CreateTokenEffect(new PowerstoneToken(), 2, false)); + this.getSpellAbility().addEffect(new ConditionalOneShotEffect( + new DrawCardSourceControllerEffect(1), SplittingThePowerstoneCondition.instance, + "If the sacrificed artifact was legendary, draw a card" + )); + } + + private SplittingThePowerstone(final SplittingThePowerstone card) { + super(card); + } + + @Override + public SplittingThePowerstone copy() { + return new SplittingThePowerstone(this); + } +} + +enum SplittingThePowerstoneCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + return CardUtil + .castStream(source.getCosts().stream(), SacrificeTargetCost.class) + .map(SacrificeTargetCost::getPermanents) + .flatMap(Collection::stream) + .filter(Objects::nonNull) + .anyMatch(MageObject::isLegendary); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/u/UrzaPowerstoneProdigy.java b/Mage.Sets/src/mage/cards/u/UrzaPowerstoneProdigy.java index 09a84a774f..13f5ed4652 100644 --- a/Mage.Sets/src/mage/cards/u/UrzaPowerstoneProdigy.java +++ b/Mage.Sets/src/mage/cards/u/UrzaPowerstoneProdigy.java @@ -47,9 +47,9 @@ public final class UrzaPowerstoneProdigy extends CardImpl { this.addAbility(ability); // Whenever you discard one or more artifact cards, create a tapped Powerstone token. This ability triggers only once each turn. - this.addAbility(new DiscardCardControllerTriggeredAbility(new CreateTokenEffect( - new PowerstoneToken(), 1, true, false - ), false, filter).setTriggersOnce(true)); + this.addAbility(new DiscardCardControllerTriggeredAbility( + new CreateTokenEffect(new PowerstoneToken(), 1, true), false, filter + ).setTriggersOnce(true)); } private UrzaPowerstoneProdigy(final UrzaPowerstoneProdigy card) { diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index ec5afb7ae1..6ec793a7ad 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -36,6 +36,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Queen Kayla bin-Kroog", 218, Rarity.RARE, mage.cards.q.QueenKaylaBinKroog.class)); cards.add(new SetCardInfo("Recruitment Officer", 23, Rarity.UNCOMMON, mage.cards.r.RecruitmentOfficer.class)); cards.add(new SetCardInfo("Scrapwork Cohort", 37, Rarity.COMMON, mage.cards.s.ScrapworkCohort.class)); + cards.add(new SetCardInfo("Splitting the Powerstone", 63, Rarity.UNCOMMON, mage.cards.s.SplittingThePowerstone.class)); cards.add(new SetCardInfo("Surge Engine", 81, Rarity.MYTHIC, mage.cards.s.SurgeEngine.class)); cards.add(new SetCardInfo("Swamp", 282, Rarity.LAND, mage.cards.basiclands.Swamp.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("The Mightstone and Weakstone", "238a", Rarity.RARE, mage.cards.t.TheMightstoneAndWeakstone.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/CreateTokenEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CreateTokenEffect.java index 316abc3532..ebaf3e35ef 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CreateTokenEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CreateTokenEffect.java @@ -43,6 +43,10 @@ public class CreateTokenEffect extends OneShotEffect { this(token, amount, false, false); } + public CreateTokenEffect(Token token, int amount, boolean tapped) { + this(token, amount, tapped, false); + } + public CreateTokenEffect(Token token, int amount, boolean tapped, boolean attacking) { this(token, StaticValue.get(amount), tapped, attacking); }