Some changes to target handling.

This commit is contained in:
LevelX2 2013-03-06 08:23:35 +01:00
parent dc376e49f1
commit 155b7a277b
3 changed files with 21 additions and 17 deletions

View file

@ -32,6 +32,7 @@ import mage.Constants;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.Constants.Outcome; import mage.Constants.Outcome;
import mage.Constants.Rarity; import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -128,21 +129,22 @@ class DimirCharmEffect extends OneShotEffect {
Card card = player.getLibrary().removeFromTop(game); Card card = player.getLibrary().removeFromTop(game);
if(card != null){ if(card != null){
cards.add(card); cards.add(card);
game.getState().setZone(card.getId(), Zone.PICK);
} }
} }
if(cards.size() > 0){ 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); 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); Card card = cards.get(target.getFirstTarget(), game);
if(card != null){ if(card != null){
card.moveToZone(Constants.Zone.LIBRARY, source.getId(), game, true); card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
cards.remove(card); cards.remove(card);
} }
for(Card card2 : cards.getCards(game)){ for(Card card2 : cards.getCards(game)){
if(card2 != null){ if(card2 != null){
card2.moveToZone(Constants.Zone.GRAVEYARD, source.getId(), game, true); card2.moveToZone(Zone.GRAVEYARD, source.getId(), game, true);
} }
} }
} }

View file

@ -29,10 +29,10 @@ package mage.sets.gatecrash;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.Constants.Outcome; import mage.Constants.Outcome;
import mage.Constants.Rarity; import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -103,22 +103,23 @@ class VizkopaConfessorEffect extends OneShotEffect<VizkopaConfessorEffect> {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget()); 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); int payLife = controller.getAmount(0, controller.getLife(),"Pay how many life?", game);
if (payLife > 0) { if (payLife > 0) {
controller.loseLife(payLife, game); 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()); cardsInHand.addAll(targetPlayer.getHand());
int count = Math.min(cardsInHand.size(), payLife); 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); target.setRequired(true);
Cards revealedCards = new CardsImpl(); Cards revealedCards = new CardsImpl();
if (targetPlayer.choose(Outcome.Discard, cardsInHand, target, game)) { if (targetPlayer.chooseTarget(Outcome.Discard, cardsInHand, target, source, game)) {
List<UUID> targets = target.getTargets(); List<UUID> targets = target.getTargets();
for (UUID targetId : targets) { for (UUID targetId : targets) {
Card card = game.getCard(targetId); Card card = game.getCard(targetId);
@ -128,16 +129,16 @@ class VizkopaConfessorEffect extends OneShotEffect<VizkopaConfessorEffect> {
} }
} }
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); targetInHand.setRequired(true);
if (!revealedCards.isEmpty()) { if (!revealedCards.isEmpty()) {
targetPlayer.revealCards("Vizkopa Confessor", revealedCards, game); 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); Card card = revealedCards.get(targetInHand.getFirstTarget(), game);
if (card != null) { if (card != null) {
card.moveToExile(null, null, source.getSourceId(), game); 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; return true;

View file

@ -28,9 +28,10 @@
package mage.sets.lorwyn; package mage.sets.lorwyn;
import java.util.UUID; import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity; import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect; import mage.abilities.effects.common.LoseLifeSourceEffect;
@ -81,7 +82,7 @@ class ThoughtseizeEffect extends OneShotEffect<ThoughtseizeEffect> {
} }
public ThoughtseizeEffect() { 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"; 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<ThoughtseizeEffect> {
player.revealCards("Thoughtseize", player.getHand(), game); player.revealCards("Thoughtseize", player.getHand(), game);
Player you = game.getPlayer(source.getControllerId()); Player you = game.getPlayer(source.getControllerId());
if (you != null) { if (you != null) {
TargetCard target = new TargetCard(Constants.Zone.PICK, filter); TargetCard target = new TargetCard(Zone.HAND, filter);
if (you.choose(Constants.Outcome.Benefit, player.getHand(), target, game)) { if (you.chooseTarget(outcome, player.getHand(), target, source, game)) {
Card card = player.getHand().get(target.getFirstTarget(), game); Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) { if (card != null) {
return player.discard(card, source, game); return player.discard(card, source, game);