[LTR] Implement Nasty End

This commit is contained in:
theelk801 2023-06-18 20:24:59 -04:00
parent 8e1d8faaad
commit c99068c322
2 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,59 @@
package mage.cards.n;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.util.CardUtil;
import java.util.Collection;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class NastyEnd extends CardImpl {
public NastyEnd(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{B}");
// As an additional cost to cast this spell, sacrifice a creature.
this.getSpellAbility().addCost(new SacrificeTargetCost(StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT));
// Draw two cards. If the sacrificed creature was legendary, draw three cards instead.
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
new DrawCardSourceControllerEffect(3),
new DrawCardSourceControllerEffect(2),
NastyEndCondition.instance, "draw two cards. If the " +
"sacrificed creature was legendary, draw three cards instead"
));
}
private NastyEnd(final NastyEnd card) {
super(card);
}
@Override
public NastyEnd copy() {
return new NastyEnd(this);
}
}
enum NastyEndCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
return CardUtil
.castStream(source.getCosts().stream(), SacrificeTargetCost.class)
.map(SacrificeTargetCost::getPermanents)
.flatMap(Collection::stream)
.anyMatch(permanent -> permanent.isLegendary(game));
}
}

View file

@ -161,6 +161,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet {
cards.add(new SetCardInfo("Mount Doom", 258, Rarity.MYTHIC, mage.cards.m.MountDoom.class));
cards.add(new SetCardInfo("Mountain", 268, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mushroom Watchdogs", 180, Rarity.COMMON, mage.cards.m.MushroomWatchdogs.class));
cards.add(new SetCardInfo("Nasty End", 99, Rarity.COMMON, mage.cards.n.NastyEnd.class));
cards.add(new SetCardInfo("Nazgul", 100, Rarity.UNCOMMON, mage.cards.n.Nazgul.class));
cards.add(new SetCardInfo("Nimble Hobbit", 23, Rarity.COMMON, mage.cards.n.NimbleHobbit.class));
cards.add(new SetCardInfo("Nimrodel Watcher", 63, Rarity.COMMON, mage.cards.n.NimrodelWatcher.class));