diff --git a/Mage.Sets/src/mage/cards/w/WhiptongueHydra.java b/Mage.Sets/src/mage/cards/w/WhiptongueHydra.java new file mode 100644 index 0000000000..fae1fde2f1 --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WhiptongueHydra.java @@ -0,0 +1,91 @@ +package mage.cards.w; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.constants.SubType; +import mage.abilities.keyword.ReachAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.AbilityPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author TheElk801 + */ +public final class WhiptongueHydra extends CardImpl { + + public WhiptongueHydra(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{G}"); + + this.subtype.add(SubType.LIZARD); + this.subtype.add(SubType.HYDRA); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Reach + this.addAbility(ReachAbility.getInstance()); + + // When Whiptongue Hydra enters the battlefield, destroy all creatures with flying. Put a +1/+1 counter on Whiptongue Hydra for each creature destroyed this way. + this.addAbility(new EntersBattlefieldTriggeredAbility(new WhiptongueHydraEffect(), false)); + } + + public WhiptongueHydra(final WhiptongueHydra card) { + super(card); + } + + @Override + public WhiptongueHydra copy() { + return new WhiptongueHydra(this); + } +} + +class WhiptongueHydraEffect extends OneShotEffect { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); + + static { + filter.add(new AbilityPredicate(FlyingAbility.class)); + } + + public WhiptongueHydraEffect() { + super(Outcome.DestroyPermanent); + this.staticText = "destroy all creatures with flying. " + + "Put a +1/+1 counter on {this} for each permanent destroyed this way"; + } + + public WhiptongueHydraEffect(final WhiptongueHydraEffect effect) { + super(effect); + } + + @Override + public WhiptongueHydraEffect copy() { + return new WhiptongueHydraEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int destroyedPermanents = 0; + destroyedPermanents = game.getBattlefield().getActivePermanents( + filter, source.getControllerId(), source.getSourceId(), game + ).stream().filter( + (permanent) -> (permanent.destroy(source.getSourceId(), game, false)) + ).map((_item) -> 1).reduce(destroyedPermanents, Integer::sum); + if (destroyedPermanents > 0) { + return new AddCountersSourceEffect( + CounterType.P1P1.createInstance(destroyedPermanents), true + ).apply(game, source); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2018.java b/Mage.Sets/src/mage/sets/Commander2018.java index 9df3b67e07..a7562f0fb7 100644 --- a/Mage.Sets/src/mage/sets/Commander2018.java +++ b/Mage.Sets/src/mage/sets/Commander2018.java @@ -42,5 +42,6 @@ public final class Commander2018 extends ExpansionSet { cards.add(new SetCardInfo("Tawnos, Urza's Apprentice", 45, Rarity.MYTHIC, mage.cards.t.TawnosUrzasApprentice.class)); cards.add(new SetCardInfo("Thantis the Warweaver", 46, Rarity.MYTHIC, mage.cards.t.ThantisTheWarweaver.class)); cards.add(new SetCardInfo("Thopter Spy Network", 107, Rarity.RARE, mage.cards.t.ThopterSpyNetwork.class)); + cards.add(new SetCardInfo("Whiptongue Hydra", 36, Rarity.RARE, mage.cards.w.WhiptongueHydra.class)); } }