From 35ec25cef555bbc9bc6eec99554758c892007f22 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 17 Jun 2019 22:02:14 -0400 Subject: [PATCH] Implemented Yarok's Fenlurker --- .../src/mage/cards/y/YaroksFenlurker.java | 101 ++++++++++++++++++ Mage.Sets/src/mage/sets/CoreSet2020.java | 1 + 2 files changed, 102 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/y/YaroksFenlurker.java diff --git a/Mage.Sets/src/mage/cards/y/YaroksFenlurker.java b/Mage.Sets/src/mage/cards/y/YaroksFenlurker.java new file mode 100644 index 0000000000..2ca7468e5f --- /dev/null +++ b/Mage.Sets/src/mage/cards/y/YaroksFenlurker.java @@ -0,0 +1,101 @@ +package mage.cards.y; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.BoostSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetCardInHand; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class YaroksFenlurker extends CardImpl { + + public YaroksFenlurker(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}{B}"); + + this.subtype.add(SubType.HORROR); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // When Yarok's Fenlurker enters the battlefield, each opponent exiles a card from their hand. + this.addAbility(new EntersBattlefieldTriggeredAbility(new YaroksFenlurkerEffect())); + + // {2}{B}: Yarok's Fenlurker gets +1/+1 until end of turn. + this.addAbility(new SimpleActivatedAbility( + new BoostSourceEffect(1, 1, Duration.EndOfTurn), new ManaCostsImpl("{2}{B}") + )); + } + + private YaroksFenlurker(final YaroksFenlurker card) { + super(card); + } + + @Override + public YaroksFenlurker copy() { + return new YaroksFenlurker(this); + } +} + +class YaroksFenlurkerEffect extends OneShotEffect { + + YaroksFenlurkerEffect() { + super(Outcome.Benefit); + staticText = "each opponent exiles a card from their hand"; + } + + private YaroksFenlurkerEffect(final YaroksFenlurkerEffect effect) { + super(effect); + } + + @Override + public YaroksFenlurkerEffect copy() { + return new YaroksFenlurkerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Boolean applied = false; + Map cardsToExile = new HashMap<>(); + for (UUID opponentId : game.getOpponents(source.getControllerId())) { + Player opponent = game.getPlayer(opponentId); + if (opponent == null) { + continue; + } + int numberOfCardsToExile = Math.min(1, opponent.getHand().size()); + Target target = new TargetCardInHand(numberOfCardsToExile, StaticFilters.FILTER_CARD); + target.setRequired(true); + if (opponent.chooseTarget(Outcome.Exile, target, source, game)) { + Cards cards = new CardsImpl(target.getTargets()); + cardsToExile.put(opponentId, cards); + } + } + Cards cardsOpponentsChoseToExile = new CardsImpl(); + for (UUID opponentId : game.getOpponents(source.getControllerId())) { + Player opponent = game.getPlayer(opponentId); + if (opponent == null) { + continue; + } + cardsOpponentsChoseToExile.addAll(cardsToExile.get(opponentId)); + opponent.moveCards(cardsOpponentsChoseToExile, Zone.EXILED, source, game); + applied = true; + } + return applied; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/CoreSet2020.java b/Mage.Sets/src/mage/sets/CoreSet2020.java index 30ead543c4..8e92cdaab2 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2020.java +++ b/Mage.Sets/src/mage/sets/CoreSet2020.java @@ -52,5 +52,6 @@ public final class CoreSet2020 extends ExpansionSet { cards.add(new SetCardInfo("Silverback Shaman", 195, Rarity.COMMON, mage.cards.s.SilverbackShaman.class)); cards.add(new SetCardInfo("Thrashing Brontodon", 197, Rarity.UNCOMMON, mage.cards.t.ThrashingBrontodon.class)); cards.add(new SetCardInfo("Unsummon", 78, Rarity.COMMON, mage.cards.u.Unsummon.class)); + cards.add(new SetCardInfo("Yarok's Fenlurker", 123, Rarity.UNCOMMON, mage.cards.y.YaroksFenlurker.class)); } }