From 51f2f051bbb3390c0cdbd506ad591ec43efff92d Mon Sep 17 00:00:00 2001 From: theelk801 Date: Wed, 17 Jul 2024 16:45:17 -0400 Subject: [PATCH] [BLB] Implement For the Common Good --- .../src/mage/cards/f/ForTheCommonGood.java | 92 +++++++++++++++++++ Mage.Sets/src/mage/sets/Bloomburrow.java | 1 + .../main/java/mage/filter/StaticFilters.java | 8 ++ 3 files changed, 101 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/f/ForTheCommonGood.java diff --git a/Mage.Sets/src/mage/cards/f/ForTheCommonGood.java b/Mage.Sets/src/mage/cards/f/ForTheCommonGood.java new file mode 100644 index 00000000000..caffb82a817 --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/ForTheCommonGood.java @@ -0,0 +1,92 @@ +package mage.cards.f; + +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenCopyTargetEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.abilities.keyword.IndestructibleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.permanent.TokenPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ForTheCommonGood extends CardImpl { + + private static final FilterPermanent filter = new FilterControlledPermanent("token you control"); + + static { + filter.add(TokenPredicate.TRUE); + } + + private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filter); + private static final Hint hint = new ValueHint("Tokens you control", xValue); + + public ForTheCommonGood(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{X}{G}"); + + // Create X tokens that are copies of target token you control. Then tokens you control gain indestructible until your next turn. You gain 1 life for each token you control. + this.getSpellAbility().addEffect(new ForTheCommonGoodEffect()); + this.getSpellAbility().addTarget(new TargetPermanent(filter)); + this.getSpellAbility().addEffect(new GainAbilityControlledEffect( + IndestructibleAbility.getInstance(), + Duration.EndOfTurn, StaticFilters.FILTER_PERMANENT_TOKEN + )); + this.getSpellAbility().addEffect(new GainLifeEffect(xValue)); + this.getSpellAbility().addHint(hint); + } + + private ForTheCommonGood(final ForTheCommonGood card) { + super(card); + } + + @Override + public ForTheCommonGood copy() { + return new ForTheCommonGood(this); + } +} + +class ForTheCommonGoodEffect extends OneShotEffect { + + ForTheCommonGoodEffect() { + super(Outcome.Benefit); + staticText = "create X tokens that are copies of target token you control"; + } + + private ForTheCommonGoodEffect(final ForTheCommonGoodEffect effect) { + super(effect); + } + + @Override + public ForTheCommonGoodEffect copy() { + return new ForTheCommonGoodEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + int xValue = source.getManaCostsToPay().getX(); + return permanent != null + && xValue > 0 + && new CreateTokenCopyTargetEffect(null, null, false, xValue) + .setSavedPermanent(permanent) + .apply(game, source); + } +} diff --git a/Mage.Sets/src/mage/sets/Bloomburrow.java b/Mage.Sets/src/mage/sets/Bloomburrow.java index e5d748c7f5d..8f4000f2dbf 100644 --- a/Mage.Sets/src/mage/sets/Bloomburrow.java +++ b/Mage.Sets/src/mage/sets/Bloomburrow.java @@ -70,6 +70,7 @@ public final class Bloomburrow extends ExpansionSet { cards.add(new SetCardInfo("Finneas, Ace Archer", 212, Rarity.RARE, mage.cards.f.FinneasAceArcher.class)); cards.add(new SetCardInfo("Flame Lash", 391, Rarity.COMMON, mage.cards.f.FlameLash.class)); cards.add(new SetCardInfo("Flowerfoot Swordmaster", 14, Rarity.UNCOMMON, mage.cards.f.FlowerfootSwordmaster.class)); + cards.add(new SetCardInfo("For the Common Good", 172, Rarity.RARE, mage.cards.f.ForTheCommonGood.class)); cards.add(new SetCardInfo("Forest", 278, Rarity.LAND, mage.cards.basiclands.Forest.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Fountainport Bell", 245, Rarity.COMMON, mage.cards.f.FountainportBell.class)); cards.add(new SetCardInfo("Fountainport", 253, Rarity.RARE, mage.cards.f.Fountainport.class)); diff --git a/Mage/src/main/java/mage/filter/StaticFilters.java b/Mage/src/main/java/mage/filter/StaticFilters.java index ea864e8b4bf..afd6a3958b7 100644 --- a/Mage/src/main/java/mage/filter/StaticFilters.java +++ b/Mage/src/main/java/mage/filter/StaticFilters.java @@ -988,6 +988,14 @@ public final class StaticFilters { FILTER_PERMANENT_TOKEN.setLockedFilter(true); } + + public static final FilterPermanent FILTER_PERMANENT_TOKENS = new FilterPermanent("tokens"); + + static { + FILTER_PERMANENT_TOKENS.add(TokenPredicate.TRUE); + FILTER_PERMANENT_TOKENS.setLockedFilter(true); + } + public static final FilterCreaturePermanent FILTER_CREATURE_TOKEN = new FilterCreaturePermanent("creature token"); static {