[WOE] Implement The End (#10921)

This commit is contained in:
Susucre 2023-08-26 22:45:51 +02:00 committed by GitHub
parent f21a6be55f
commit fe93d68b1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 101 additions and 5 deletions

View file

@ -0,0 +1,95 @@
package mage.cards.t;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.XorLessLifeCondition;
import mage.abilities.effects.common.cost.SpellCostReductionSourceEffect;
import mage.abilities.effects.common.search.SearchTargetGraveyardHandLibraryForCardNameAndExileEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreatureOrPlaneswalker;
import java.util.UUID;
/**
*
* @author Susucr
*/
public final class TheEnd extends CardImpl {
public TheEnd(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{B}{B}");
// This spell costs {2} less to cast if your life total is 5 or less.
this.addAbility(new SimpleStaticAbility(
Zone.ALL,
new SpellCostReductionSourceEffect(
2,
new XorLessLifeCondition(XorLessLifeCondition.CheckType.CONTROLLER, 5)
).setCanWorksOnStackOnly(true).setText("This spell costs {2} less to cast if your life total is 5 or less.")
).setRuleAtTheTop(true));
// Exile target creature or planeswalker. Search its controller's graveyard, hand, and library for any number of cards with the same name as that permanent and exile them. That player shuffles, then draws card for each card exiled from their hand this way.
this.getSpellAbility().addEffect(new TheEndEffect());
this.getSpellAbility().addTarget(new TargetCreatureOrPlaneswalker());
}
private TheEnd(final TheEnd card) {
super(card);
}
@Override
public TheEnd copy() {
return new TheEnd(this);
}
}
class TheEndEffect extends SearchTargetGraveyardHandLibraryForCardNameAndExileEffect {
TheEndEffect() {
super(true, "its controller's", "any number of cards with the same name as that permanent");
this.staticText = "Exile target creature or planeswalker. Search its controller's graveyard, hand, and library for any number of cards with the same name as that permanent and exile them. That player shuffles, then draws card for each card exiled from their hand this way";
}
private TheEndEffect(final TheEndEffect effect) {
super(effect);
}
@Override
public TheEndEffect copy() {
return new TheEndEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if(permanent == null) {
return false;
}
String name = permanent.getName();
Player player = game.getPlayer(permanent.getControllerId());
if(player == null) {
return false;
}
player.moveCards(permanent, Zone.EXILED, source, game);
FilterCard filter = new FilterCard();
filter.add(new NamePredicate(name));
int cardsInHandBefore = player.getHand().count(filter, game);
boolean result = super.applySearchAndExile(game, source, name, player.getId());
int cardsExiled = cardsInHandBefore - player.getHand().count(filter, game);
if (cardsExiled > 0) {
player.drawCards(cardsExiled, source, game);
}
return result;
}
}

View file

@ -246,6 +246,7 @@ public final class WildsOfEldraine extends ExpansionSet {
cards.add(new SetCardInfo("Tattered Ratter", 152, Rarity.UNCOMMON, mage.cards.t.TatteredRatter.class));
cards.add(new SetCardInfo("Tempest Hart", 238, Rarity.UNCOMMON, mage.cards.t.TempestHart.class));
cards.add(new SetCardInfo("Tenacious Tomeseeker", 74, Rarity.UNCOMMON, mage.cards.t.TenaciousTomeseeker.class));
cards.add(new SetCardInfo("The End", 87, Rarity.RARE, mage.cards.t.TheEnd.class));
cards.add(new SetCardInfo("The Goose Mother", 204, Rarity.RARE, mage.cards.t.TheGooseMother.class));
cards.add(new SetCardInfo("The Huntsman's Redemption", 176, Rarity.RARE, mage.cards.t.TheHuntsmansRedemption.class));
cards.add(new SetCardInfo("The Princess Takes Flight", 23, Rarity.UNCOMMON, mage.cards.t.ThePrincessTakesFlight.class));

View file

@ -60,11 +60,11 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
if (cardName != null && controller != null) {
Player targetPlayer = game.getPlayer(targetPlayerId);
if (targetPlayer != null) {
FilterCard filter = new FilterCard("card named " + cardName);
FilterCard filter = new FilterCard("card named \"" + cardName + "\"");
filter.add(new NamePredicate(cardName));
// cards in Graveyard
int cardsCount = (cardName.isEmpty() ? 0 : targetPlayer.getGraveyard().count(filter, game));
int cardsCount = targetPlayer.getGraveyard().count(filter, game);
if (cardsCount > 0) {
filter.setMessage("card named " + cardName + " in the graveyard of " + targetPlayer.getName());
TargetCard target = new TargetCard((graveyardExileOptional ? 0 : cardsCount), cardsCount, Zone.GRAVEYARD, filter);
@ -74,7 +74,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
}
// cards in Hand
cardsCount = (cardName.isEmpty() ? 0 : targetPlayer.getHand().count(filter, game));
cardsCount = targetPlayer.getHand().count(filter, game);
filter.setMessage("card named " + cardName + " in the hand of " + targetPlayer.getName());
TargetCard target = new TargetCard(0, cardsCount, Zone.HAND, filter);
if (controller.choose(Outcome.Exile, targetPlayer.getHand(), target, source, game)) {
@ -84,7 +84,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
// cards in Library
Cards cardsInLibrary = new CardsImpl();
cardsInLibrary.addAllCards(targetPlayer.getLibrary().getCards(game));
cardsCount = (cardName.isEmpty() ? 0 : cardsInLibrary.count(filter, game));
cardsCount = cardsInLibrary.count(filter, game);
filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getLogName());
TargetCardInLibrary targetLib = new TargetCardInLibrary(0, cardsCount, filter);
if (controller.choose(Outcome.Exile, cardsInLibrary, targetLib, source, game)) {

View file

@ -28,7 +28,7 @@ public class NamePredicate implements Predicate<MageObject> {
@Override
public boolean apply(MageObject input, Game game) {
if (name == null) {
if (name == null || name.isEmpty()) {
return false;
}
// If a player names a card, the player may name either half of a split card, but not both.