From 155b7a277b0361a3039a826a25ba73ec8cd4a20c Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 6 Mar 2013 08:23:35 +0100 Subject: [PATCH] Some changes to target handling. --- .../src/mage/sets/gatecrash/DimirCharm.java | 10 ++++++---- .../mage/sets/gatecrash/VizkopaConfessor.java | 19 ++++++++++--------- .../src/mage/sets/lorwyn/Thoughtseize.java | 9 +++++---- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Mage.Sets/src/mage/sets/gatecrash/DimirCharm.java b/Mage.Sets/src/mage/sets/gatecrash/DimirCharm.java index a670415d56..c5238f58b0 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/DimirCharm.java +++ b/Mage.Sets/src/mage/sets/gatecrash/DimirCharm.java @@ -32,6 +32,7 @@ import mage.Constants; import mage.Constants.CardType; import mage.Constants.Outcome; import mage.Constants.Rarity; +import mage.Constants.Zone; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.effects.OneShotEffect; @@ -128,21 +129,22 @@ class DimirCharmEffect extends OneShotEffect { Card card = player.getLibrary().removeFromTop(game); if(card != null){ cards.add(card); + game.getState().setZone(card.getId(), Zone.PICK); } } if(cards.size() > 0){ - TargetCard target = new TargetCard(Constants.Zone.PICK, new FilterCard("Card to put back on top of library")); + TargetCard target = new TargetCard(Zone.PICK, new FilterCard("Card to put back on top of library")); target.setRequired(true); - if(controller.choose(Outcome.Neutral, cards, target, game)){ + if(controller.chooseTarget(Outcome.Benefit, cards, target, source, game)){ Card card = cards.get(target.getFirstTarget(), game); if(card != null){ - card.moveToZone(Constants.Zone.LIBRARY, source.getId(), game, true); + card.moveToZone(Zone.LIBRARY, source.getId(), game, true); cards.remove(card); } for(Card card2 : cards.getCards(game)){ if(card2 != null){ - card2.moveToZone(Constants.Zone.GRAVEYARD, source.getId(), game, true); + card2.moveToZone(Zone.GRAVEYARD, source.getId(), game, true); } } } diff --git a/Mage.Sets/src/mage/sets/gatecrash/VizkopaConfessor.java b/Mage.Sets/src/mage/sets/gatecrash/VizkopaConfessor.java index f032e557ef..70544c767c 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/VizkopaConfessor.java +++ b/Mage.Sets/src/mage/sets/gatecrash/VizkopaConfessor.java @@ -29,10 +29,10 @@ package mage.sets.gatecrash; import java.util.List; import java.util.UUID; -import mage.Constants; import mage.Constants.CardType; import mage.Constants.Outcome; import mage.Constants.Rarity; +import mage.Constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; @@ -103,22 +103,23 @@ class VizkopaConfessorEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); - if (controller != null && targetPlayer != null) { + Card sourceCard = game.getCard(source.getSourceId()); + if (controller != null && targetPlayer != null && sourceCard != null) { int payLife = controller.getAmount(0, controller.getLife(),"Pay how many life?", game); if (payLife > 0) { controller.loseLife(payLife, game); - game.informPlayers(new StringBuilder("Vizkopa Confessor: ").append(controller.getName()).append(" pays ").append(payLife).append(" life").toString()); + game.informPlayers(new StringBuilder(sourceCard.getName()).append(": ").append(controller.getName()).append(" pays ").append(payLife).append(" life").toString()); - Cards cardsInHand = new CardsImpl(Constants.Zone.PICK); + Cards cardsInHand = new CardsImpl(); cardsInHand.addAll(targetPlayer.getHand()); int count = Math.min(cardsInHand.size(), payLife); - TargetCard target = new TargetCard(count, Constants.Zone.PICK, new FilterCard()); + TargetCard target = new TargetCard(count, Zone.HAND, new FilterCard()); target.setRequired(true); Cards revealedCards = new CardsImpl(); - if (targetPlayer.choose(Outcome.Discard, cardsInHand, target, game)) { + if (targetPlayer.chooseTarget(Outcome.Discard, cardsInHand, target, source, game)) { List targets = target.getTargets(); for (UUID targetId : targets) { Card card = game.getCard(targetId); @@ -128,16 +129,16 @@ class VizkopaConfessorEffect extends OneShotEffect { } } - TargetCard targetInHand = new TargetCard(Constants.Zone.PICK, new FilterCard("card to exile")); + TargetCard targetInHand = new TargetCard(Zone.HAND, new FilterCard("card to exile")); targetInHand.setRequired(true); if (!revealedCards.isEmpty()) { targetPlayer.revealCards("Vizkopa Confessor", revealedCards, game); - controller.choose(Constants.Outcome.Exile, revealedCards, targetInHand, game); + controller.chooseTarget(Outcome.Exile, revealedCards, targetInHand, source, game); Card card = revealedCards.get(targetInHand.getFirstTarget(), game); if (card != null) { card.moveToExile(null, null, source.getSourceId(), game); - game.informPlayers(new StringBuilder("Vizkopa Confessor: Exiled card ").append(card.getName()).toString()); + game.informPlayers(new StringBuilder(sourceCard.getName()).append(": Exiled card ").append(card.getName()).toString()); } } return true; diff --git a/Mage.Sets/src/mage/sets/lorwyn/Thoughtseize.java b/Mage.Sets/src/mage/sets/lorwyn/Thoughtseize.java index f4f12b4d97..d233a77687 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/Thoughtseize.java +++ b/Mage.Sets/src/mage/sets/lorwyn/Thoughtseize.java @@ -28,9 +28,10 @@ package mage.sets.lorwyn; import java.util.UUID; -import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Outcome; import mage.Constants.Rarity; +import mage.Constants.Zone; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.LoseLifeSourceEffect; @@ -81,7 +82,7 @@ class ThoughtseizeEffect extends OneShotEffect { } public ThoughtseizeEffect() { - super(Constants.Outcome.Discard); + super(Outcome.Discard); staticText = "Target player reveals his or her hand. You choose a nonland card from it. That player discards that card"; } @@ -96,8 +97,8 @@ class ThoughtseizeEffect extends OneShotEffect { player.revealCards("Thoughtseize", player.getHand(), game); Player you = game.getPlayer(source.getControllerId()); if (you != null) { - TargetCard target = new TargetCard(Constants.Zone.PICK, filter); - if (you.choose(Constants.Outcome.Benefit, player.getHand(), target, game)) { + TargetCard target = new TargetCard(Zone.HAND, filter); + if (you.chooseTarget(outcome, player.getHand(), target, source, game)) { Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { return player.discard(card, source, game);