- Fixed Last Rites

This commit is contained in:
jeffwadsworth 2020-02-12 16:09:38 -06:00
parent 42dfd16b02
commit 4b019a1201

View file

@ -1,4 +1,3 @@
package mage.cards.l; package mage.cards.l;
import java.util.UUID; import java.util.UUID;
@ -14,13 +13,13 @@ import mage.cards.Cards;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import mage.target.common.TargetCardInHand;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
/** /**
@ -32,7 +31,9 @@ public final class LastRites extends CardImpl {
public LastRites(UUID ownerId, CardSetInfo setInfo) { public LastRites(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{B}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{B}");
// Discard any number of cards. Target player reveals their hand, then you choose a nonland card from it for each card discarded this way. That player discards those cards. // Discard any number of cards. Target player reveals their hand, then
//you choose a nonland card from it for each card discarded
// this way. That player discards those cards.
this.getSpellAbility().addEffect(new LastRitesEffect()); this.getSpellAbility().addEffect(new LastRitesEffect());
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
@ -51,8 +52,10 @@ public final class LastRites extends CardImpl {
class LastRitesEffect extends OneShotEffect { class LastRitesEffect extends OneShotEffect {
LastRitesEffect() { LastRitesEffect() {
super(Outcome.Discard); super(Outcome.AIDontUseIt);
this.staticText = "Discard any number of cards. Target player reveals their hand, then you choose a nonland card from it for each card discarded this way. That player discards those cards"; this.staticText = "Discard any number of cards. Target player reveals "
+ "their hand, then you choose a nonland card from it for "
+ "each card discarded this way. That player discards those cards";
} }
LastRitesEffect(final LastRitesEffect effect) { LastRitesEffect(final LastRitesEffect effect) {
@ -70,8 +73,8 @@ class LastRitesEffect extends OneShotEffect {
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (controller != null && targetPlayer != null) { if (controller != null && targetPlayer != null) {
Cards cardsInHand = controller.getHand().copy(); Cards cardsInHand = controller.getHand().copy();
TargetCard target = new TargetCardInHand(0, cardsInHand.size(), new FilterCard("cards to discard")); TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.HAND, new FilterCard("cards to discard"));
controller.chooseTarget(outcome, cardsInHand, target, source, game); controller.chooseTarget(Outcome.AIDontUseIt, cardsInHand, target, source, game);
int discardCount = target.getTargets().size(); int discardCount = target.getTargets().size();
if (discardCount > 0) { if (discardCount > 0) {
for (UUID cardId : target.getTargets()) { for (UUID cardId : target.getTargets()) {
@ -80,7 +83,8 @@ class LastRitesEffect extends OneShotEffect {
controller.discard(card, source, game); controller.discard(card, source, game);
} }
} }
FilterCard filter = new FilterCard((discardCount > 1 ? "" : "a") + " nonland card" + (discardCount > 1 ? "s" : "")); FilterCard filter = new FilterCard((discardCount > 1 ? "" : "a")
+ " nonland card" + (discardCount > 1 ? "s" : ""));
filter.add(Predicates.not(CardType.LAND.getPredicate())); filter.add(Predicates.not(CardType.LAND.getPredicate()));
StaticValue discardValue = StaticValue.get(discardCount); StaticValue discardValue = StaticValue.get(discardCount);
Effect effect = new DiscardCardYouChooseTargetEffect(discardValue, filter, TargetController.ANY); Effect effect = new DiscardCardYouChooseTargetEffect(discardValue, filter, TargetController.ANY);