From 496bc5014d147015dae59b42e90c9b7fbc74c836 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Thu, 1 Jul 2021 18:54:44 -0500 Subject: [PATCH] [AFR] Implemented Froghemoth (#7958) * [AFR] Implemented Froghemoth * [AFR] Froghemoth - Fixed targeting * [AFR] Froghemoth - Couple more fixups --- Mage.Sets/src/mage/cards/f/Froghemoth.java | 144 ++++++++++++++++++ .../sets/AdventuresInTheForgottenRealms.java | 1 + 2 files changed, 145 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/f/Froghemoth.java diff --git a/Mage.Sets/src/mage/cards/f/Froghemoth.java b/Mage.Sets/src/mage/cards/f/Froghemoth.java new file mode 100644 index 00000000000..f3666f62c4c --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/Froghemoth.java @@ -0,0 +1,144 @@ +package mage.cards.f; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.abilities.keyword.TrampleAbility; +import mage.abilities.keyword.HasteAbility; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.FilterCard; +import mage.filter.predicate.card.OwnerIdPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCardInGraveyard; + +/** + * + * @author weirddan455 + */ +public final class Froghemoth extends CardImpl { + + public Froghemoth(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}"); + + this.subtype.add(SubType.FROG); + this.subtype.add(SubType.HORROR); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // Haste + this.addAbility(HasteAbility.getInstance()); + + // Whenever Froghemoth deals combat damage to a player, exile up to that many target cards from their graveyard. + // Put a +1/+1 counter on Froghemoth for each creature exiled this way. You gain 1 life for each noncreature card exiled this way. + this.addAbility(new FroghemothTriggeredAbility()); + } + + private Froghemoth(final Froghemoth card) { + super(card); + } + + @Override + public Froghemoth copy() { + return new Froghemoth(this); + } +} + +class FroghemothTriggeredAbility extends DealsCombatDamageToAPlayerTriggeredAbility { + + public FroghemothTriggeredAbility() { + super(new FroghemothEffect(), false); + } + + private FroghemothTriggeredAbility(final FroghemothTriggeredAbility ability) { + super(ability); + } + + @Override + public FroghemothTriggeredAbility copy() { + return new FroghemothTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (super.checkTrigger(event, game)) { + Player controller = game.getPlayer(getControllerId()); + Player damagedPlayer = game.getPlayer(event.getPlayerId()); + if (controller != null && damagedPlayer != null) { + FilterCard filter = new FilterCard("cards from defender's graveyard"); + filter.add(new OwnerIdPredicate(damagedPlayer.getId())); + this.getTargets().clear(); + this.addTarget(new TargetCardInGraveyard(0, event.getAmount(), filter)); + return true; + } + } + return false; + } +} + +class FroghemothEffect extends OneShotEffect { + + public FroghemothEffect() { + super(Outcome.Exile); + this.staticText = "exile up to that many target cards from their graveyard. Put a +1/+1 counter on {this} for each creature exiled this way. You gain 1 life for each noncreature card exiled this way"; + } + + private FroghemothEffect(final FroghemothEffect effect) { + super(effect); + } + + @Override + public FroghemothEffect copy() { + return new FroghemothEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + Set cardsToExile = new HashSet<>(); + int numCounters = 0; + int lifeGain = 0; + for (UUID cardId : getTargetPointer().getTargets(game, source)) { + Card card = game.getCard(cardId); + if (card != null && game.getState().getZone(cardId) == Zone.GRAVEYARD && cardsToExile.add(card)) { + if (card.isCreature()) { + numCounters++; + } else { + lifeGain++; + } + } + } + if (!cardsToExile.isEmpty()) { + controller.moveCards(cardsToExile, Zone.EXILED, source, game); + if (numCounters > 0) { + Permanent permanent = source.getSourcePermanentIfItStillExists(game); + if (permanent != null) { + permanent.addCounters(CounterType.P1P1.createInstance(numCounters), source.getControllerId(), source, game); + } + } + if (lifeGain > 0) { + controller.gainLife(lifeGain, game, source); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java b/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java index 11a642007d9..dd47d45bd54 100644 --- a/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java +++ b/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java @@ -64,6 +64,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet { cards.add(new SetCardInfo("Flumph", 15, Rarity.RARE, mage.cards.f.Flumph.class)); cards.add(new SetCardInfo("Fly", 59, Rarity.UNCOMMON, mage.cards.f.Fly.class)); cards.add(new SetCardInfo("Forest", 278, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Froghemoth", 184, Rarity.RARE, mage.cards.f.Froghemoth.class)); cards.add(new SetCardInfo("Gloom Stalker", 16, Rarity.COMMON, mage.cards.g.GloomStalker.class)); cards.add(new SetCardInfo("Gnoll Hunter", 185, Rarity.COMMON, mage.cards.g.GnollHunter.class)); cards.add(new SetCardInfo("Grazilaxx, Illithid Scholar", 60, Rarity.RARE, mage.cards.g.GrazilaxxIllithidScholar.class));