From 67407a8780f76ce3efc912c0e49ba4fcbf800369 Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Tue, 1 Aug 2023 05:51:59 +0200 Subject: [PATCH] [LTC] Implement Motivated Pony (#10716) --- Mage.Sets/src/mage/cards/m/MotivatedPony.java | 132 ++++++++++++++++++ .../sets/TalesOfMiddleEarthCommander.java | 1 + .../common/AttacksTriggeredAbility.java | 2 +- .../effects/common/UntapAllEffect.java | 2 +- 4 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/m/MotivatedPony.java diff --git a/Mage.Sets/src/mage/cards/m/MotivatedPony.java b/Mage.Sets/src/mage/cards/m/MotivatedPony.java new file mode 100644 index 00000000000..041329efe47 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MotivatedPony.java @@ -0,0 +1,132 @@ +package mage.cards.m; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbility; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.UntapAllEffect; +import mage.abilities.effects.common.continuous.BoostAllEffect; +import mage.abilities.keyword.HasteAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.events.EntersTheBattlefieldEvent; +import mage.game.events.GameEvent; +import mage.players.Player; +import mage.watchers.Watcher; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author Susucr + */ +public final class MotivatedPony extends CardImpl { + + public MotivatedPony(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}"); + + this.subtype.add(SubType.HORSE); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // Haste + this.addAbility(HasteAbility.getInstance()); + + // Whenever Motivated Pony attacks, attacking creatures get +1/+1 until end of turn. If a Food entered the battlefield under your control this turn, untap those creatures and they get an additional +2/+2 until end of turn. + TriggeredAbility trigger = new AttacksTriggeredAbility(new MotivatedPonyEffect()); + trigger.addWatcher(new MotivatedPonyWatcher()); + this.addAbility(trigger); + } + + private MotivatedPony(final MotivatedPony card) { + super(card); + } + + @Override + public MotivatedPony copy() { + return new MotivatedPony(this); + } +} + +class MotivatedPonyWatcher extends Watcher { + + // players that had a Food enter this turn. + private final Set players = new HashSet<>(); + + MotivatedPonyWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD + && ((EntersTheBattlefieldEvent) event).getTarget().getSubtype(game).contains(SubType.FOOD)) { + players.add(event.getPlayerId()); + } + } + + @Override + public void reset() { + super.reset(); + players.clear(); + } + + public boolean checkPlayer(UUID playerId) { + return players.contains(playerId); + } + +} + +class MotivatedPonyEffect extends OneShotEffect { + + MotivatedPonyEffect() { + super(Outcome.BoostCreature); + staticText = "attacking creatures get +1/+1 until end of turn. If a Food entered the battlefield under " + + "your control this turn, untap those creatures and they get an additional +2/+2 until end of turn."; + } + + private MotivatedPonyEffect(final MotivatedPonyEffect ability) { + super(ability); + } + + @Override + public MotivatedPonyEffect copy() { + return new MotivatedPonyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MotivatedPonyWatcher watcher = game.getState().getWatcher(MotivatedPonyWatcher.class); + if (controller == null || watcher == null) { + return false; + } + + boolean additionalEffect = watcher.checkPlayer(controller.getId()); + int valueBoost = additionalEffect ? 1 + 2 : 1; + + game.addEffect(new BoostAllEffect( + valueBoost, + valueBoost, + Duration.EndOfTurn, + StaticFilters.FILTER_ATTACKING_CREATURES, + false + ), source); + + if (additionalEffect) { + new UntapAllEffect(StaticFilters.FILTER_ATTACKING_CREATURES).apply(game, source); + } + + return true; + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/TalesOfMiddleEarthCommander.java b/Mage.Sets/src/mage/sets/TalesOfMiddleEarthCommander.java index e088a30ba23..e6cf106944c 100644 --- a/Mage.Sets/src/mage/sets/TalesOfMiddleEarthCommander.java +++ b/Mage.Sets/src/mage/sets/TalesOfMiddleEarthCommander.java @@ -173,6 +173,7 @@ public final class TalesOfMiddleEarthCommander extends ExpansionSet { cards.add(new SetCardInfo("Monstrosity of the Lake", 22, Rarity.RARE, mage.cards.m.MonstrosityOfTheLake.class)); cards.add(new SetCardInfo("Moria Scavenger", 63, Rarity.RARE, mage.cards.m.MoriaScavenger.class)); cards.add(new SetCardInfo("Mortify", 269, Rarity.UNCOMMON, mage.cards.m.Mortify.class)); + cards.add(new SetCardInfo("Motivated Pony", 42, Rarity.RARE, mage.cards.m.MotivatedPony.class)); cards.add(new SetCardInfo("Mouth of Ronom", 370, Rarity.MYTHIC, mage.cards.m.MouthOfRonom.class)); cards.add(new SetCardInfo("Murmuring Bosk", 320, Rarity.RARE, mage.cards.m.MurmuringBosk.class)); cards.add(new SetCardInfo("Mystic Confluence", 193, Rarity.RARE, mage.cards.m.MysticConfluence.class)); diff --git a/Mage/src/main/java/mage/abilities/common/AttacksTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksTriggeredAbility.java index 5ae839e522b..6d63fac493d 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksTriggeredAbility.java @@ -37,7 +37,7 @@ public class AttacksTriggeredAbility extends TriggeredAbilityImpl { setTriggerPhrase("Whenever {this} attacks, "); } - public AttacksTriggeredAbility(final AttacksTriggeredAbility ability) { + protected AttacksTriggeredAbility(final AttacksTriggeredAbility ability) { super(ability); this.text = ability.text; this.setTargetPointer = ability.setTargetPointer; diff --git a/Mage/src/main/java/mage/abilities/effects/common/UntapAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/UntapAllEffect.java index 3cb389c5555..6dc0519684d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/UntapAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/UntapAllEffect.java @@ -22,7 +22,7 @@ public class UntapAllEffect extends OneShotEffect { this.filter = filter; } - public UntapAllEffect(final UntapAllEffect effect) { + protected UntapAllEffect(final UntapAllEffect effect) { super(effect); this.filter = effect.filter; }