Implemented Yarok's Fenlurker

This commit is contained in:
Evan Kranzler 2019-06-17 22:02:14 -04:00
parent 1c7d4e22fa
commit 35ec25cef5
2 changed files with 102 additions and 0 deletions

View file

@ -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<UUID, Cards> 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;
}
}

View file

@ -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));
}
}