From 7175b5e45874f9b2d6193fadfb1a8b2e0db6a72f Mon Sep 17 00:00:00 2001 From: theelk801 Date: Thu, 17 Jul 2025 11:35:15 -0400 Subject: [PATCH] [FIN] fix PuPu UFO setting its toughness to 0 --- Mage.Sets/src/mage/cards/p/PuPuUFO.java | 55 +++++++++++++++++++------ 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/Mage.Sets/src/mage/cards/p/PuPuUFO.java b/Mage.Sets/src/mage/cards/p/PuPuUFO.java index 9e1fac28305..6a272783a8d 100644 --- a/Mage.Sets/src/mage/cards/p/PuPuUFO.java +++ b/Mage.Sets/src/mage/cards/p/PuPuUFO.java @@ -1,14 +1,14 @@ package mage.cards.p; import mage.MageInt; +import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; -import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; -import mage.abilities.dynamicvalue.common.StaticValue; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect; -import mage.abilities.effects.common.continuous.SetBasePowerToughnessSourceEffect; +import mage.abilities.effects.common.continuous.SetBasePowerSourceEffect; import mage.abilities.hint.Hint; import mage.abilities.hint.ValueHint; import mage.abilities.keyword.FlyingAbility; @@ -16,9 +16,12 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; +import mage.constants.Outcome; import mage.constants.SubType; +import mage.filter.FilterPermanent; import mage.filter.StaticFilters; import mage.filter.common.FilterControlledPermanent; +import mage.game.Game; import java.util.UUID; @@ -27,10 +30,6 @@ import java.util.UUID; */ public final class PuPuUFO extends CardImpl { - private static final DynamicValue xValue - = new PermanentsOnBattlefieldCount(new FilterControlledPermanent(SubType.TOWN)); - private static final Hint hint = new ValueHint("Towns you control", xValue); - public PuPuUFO(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}"); @@ -48,12 +47,7 @@ public final class PuPuUFO extends CardImpl { )); // {3}: Until end of turn, this creature's base power becomes equal to the number of Towns you control. - this.addAbility(new SimpleActivatedAbility( - new SetBasePowerToughnessSourceEffect( - xValue, StaticValue.get(0), Duration.EndOfTurn, "until end of turn, " + - "this creature's base power becomes equal to the number of Towns you control" - ), new GenericManaCost(3) - ).addHint(hint)); + this.addAbility(new SimpleActivatedAbility(new PuPuUFOEffect(), new GenericManaCost(3)).addHint(PuPuUFOEffect.getHint())); } private PuPuUFO(final PuPuUFO card) { @@ -65,3 +59,38 @@ public final class PuPuUFO extends CardImpl { return new PuPuUFO(this); } } + +class PuPuUFOEffect extends OneShotEffect { + + private static final FilterPermanent filter = new FilterControlledPermanent(SubType.TOWN); + private static final Hint hint = new ValueHint("Towns you control", new PermanentsOnBattlefieldCount(filter)); + + public static Hint getHint() { + return hint; + } + + PuPuUFOEffect() { + super(Outcome.Benefit); + staticText = "until end of turn, {this}'s base power becomes equal to the number of Towns you control"; + } + + private PuPuUFOEffect(final PuPuUFOEffect effect) { + super(effect); + } + + @Override + public PuPuUFOEffect copy() { + return new PuPuUFOEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + if (source.getSourcePermanentIfItStillExists(game) == null) { + return false; + } + game.addEffect(new SetBasePowerSourceEffect( + game.getBattlefield().count(filter, source.getControllerId(), source, game), Duration.EndOfTurn + ), source); + return true; + } +}