[WOE] Implement Ego Drain (#10898)

* implements Ego Drain

* merge fix and cleanup

---------

Co-authored-by: xenohedron <xenohedron@users.noreply.github.com>
This commit is contained in:
Vivian Greenslade 2023-08-26 01:32:24 -02:30 committed by GitHub
parent a8802e25c2
commit 2720e41f32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 80 additions and 0 deletions

View file

@ -0,0 +1,79 @@
package mage.cards.e;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.discard.DiscardCardYouChooseTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetOpponent;
/**
*
* @author Xanderhall
*/
public final class EgoDrain extends CardImpl {
public EgoDrain(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{B}");
// Target opponent reveals their hand. You choose a nonland card from it. That player discards that card.
this.getSpellAbility().addTarget(new TargetOpponent());
this.getSpellAbility().addEffect(new DiscardCardYouChooseTargetEffect(StaticFilters.FILTER_CARD_NON_LAND));
// If you don't control a Faerie, exile a card from your hand.
this.getSpellAbility().addEffect(new EgoDrainEffect());
}
private EgoDrain(final EgoDrain card) {
super(card);
}
@Override
public EgoDrain copy() {
return new EgoDrain(this);
}
}
class EgoDrainEffect extends OneShotEffect {
private static final FilterPermanent filter = new FilterPermanent(SubType.FAERIE, "");
EgoDrainEffect() {
super(Outcome.Detriment);
this.staticText = "if you don't control a Faerie, exile a card from your hand.";
}
private EgoDrainEffect(final EgoDrainEffect effect) {
super(effect);
}
@Override
public EgoDrainEffect copy() {
return new EgoDrainEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
if (player.getHand().size() == 0 || game.getBattlefield().countAll(filter, player.getId(), game) >= 1) {
return true;
}
TargetCard target = new TargetCardInHand(new FilterCard("card in your hand (to exile)"));
return player.choose(Outcome.Detriment, player.getHand(), target, source, game)
&& player.moveCards(game.getCard(target.getFirstTarget()), Zone.EXILED, source, game);
}
}

View file

@ -74,6 +74,7 @@ public final class WildsOfEldraine extends ExpansionSet {
cards.add(new SetCardInfo("Edgewall Inn", 255, Rarity.UNCOMMON, mage.cards.e.EdgewallInn.class));
cards.add(new SetCardInfo("Edgewall Pack", 126, Rarity.COMMON, mage.cards.e.EdgewallPack.class));
cards.add(new SetCardInfo("Eerie Interference", 12, Rarity.UNCOMMON, mage.cards.e.EerieInterference.class));
cards.add(new SetCardInfo("Ego Drain", 86, Rarity.UNCOMMON, mage.cards.e.EgoDrain.class));
cards.add(new SetCardInfo("Elvish Archivist", 168, Rarity.RARE, mage.cards.e.ElvishArchivist.class));
cards.add(new SetCardInfo("Embereth Veteran", 127, Rarity.UNCOMMON, mage.cards.e.EmberethVeteran.class));
cards.add(new SetCardInfo("Eriette of the Charmed Apple", 202, Rarity.MYTHIC, mage.cards.e.ErietteOfTheCharmedApple.class));