* Death Wish - Fixed that multiple cards could be selected instead of only one and added missing text to the tooltip.

This commit is contained in:
LevelX2 2015-10-09 00:26:39 +02:00
parent e609207783
commit 8a65ef6766

View file

@ -27,12 +27,13 @@
*/ */
package mage.sets.judgment; package mage.sets.judgment;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSourceEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
@ -42,9 +43,6 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author Plopman * @author Plopman
@ -55,9 +53,9 @@ public class DeathWish extends CardImpl {
super(ownerId, 64, "Death Wish", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{1}{B}{B}"); super(ownerId, 64, "Death Wish", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{1}{B}{B}");
this.expansionSetCode = "JUD"; this.expansionSetCode = "JUD";
// You may choose a card you own from outside the game and put it into your hand. You lose half your life, rounded up. Exile Death Wish. // You may choose a card you own from outside the game and put it into your hand. You lose half your life, rounded up. Exile Death Wish.
this.getSpellAbility().addEffect(new DeathWishEffect()); this.getSpellAbility().addEffect(new DeathWishEffect());
this.getSpellAbility().addEffect(new ExileSourceEffect());
} }
public DeathWish(final DeathWish card) { public DeathWish(final DeathWish card) {
@ -74,12 +72,9 @@ class DeathWishEffect extends OneShotEffect {
private static final String choiceText = "Choose a card you own from outside the game, and put it into your hand"; private static final String choiceText = "Choose a card you own from outside the game, and put it into your hand";
private static final FilterCard filter = new FilterCard("card");
public DeathWishEffect() { public DeathWishEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "You may choose a card you own from outside the game, reveal that card, and put it into your hand. Exile Death Wish"; this.staticText = "You may choose a card you own from outside the game, reveal that card, and put it into your hand. You lose half your life, rounded up";
} }
public DeathWishEffect(final DeathWishEffect effect) { public DeathWishEffect(final DeathWishEffect effect) {
@ -93,48 +88,30 @@ class DeathWishEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (player != null) { if (controller != null) {
while (player.chooseUse(Outcome.Benefit, choiceText, source, game)) { if (controller.chooseUse(Outcome.Benefit, choiceText, source, game)) {
Cards cards = player.getSideboard(); Cards cards = controller.getSideboard();
if(cards.isEmpty()) { if (cards.isEmpty()) {
game.informPlayer(player, "You have no cards outside the game."); game.informPlayer(controller, "You have no cards outside the game.");
break; } else {
} TargetCard target = new TargetCard(Zone.OUTSIDE, new FilterCard());
if (controller.choose(Outcome.Benefit, cards, target, game)) {
Set<Card> filtered = cards.getCards(filter, game); Card card = controller.getSideboard().get(target.getFirstTarget(), game);
if (filtered.isEmpty()) {
game.informPlayer(player, "You have no " + filter.getMessage() + " outside the game.");
break;
}
Cards filteredCards = new CardsImpl();
for (Card card : filtered) {
filteredCards.add(card.getId());
}
TargetCard target = new TargetCard(Zone.PICK, filter);
if (player.choose(Outcome.Benefit, filteredCards, target, game)) {
Card card = player.getSideboard().get(target.getFirstTarget(), game);
if (card != null) { if (card != null) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false); controller.moveCards(card, null, Zone.HAND, source, game);
}
} }
} }
} }
int amount = (player.getLife() + 1)/2; int amount = (controller.getLife() + 1) / 2;
if(amount > 0) if (amount > 0) {
{ controller.loseLife(amount, game);
player.loseLife(amount, game);
}
Card cardToExile = game.getCard(source.getSourceId());
if(cardToExile != null)
{
cardToExile.moveToExile(null, "", source.getSourceId(), game);
}
} }
return true; return true;
} }
return false;
}
} }