From f50e67e38581991bb55e5bebe7747f7dc14f4c1f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 16 Aug 2015 19:16:41 +0200 Subject: [PATCH] * Fixed card movement handling for face down cards. --- Mage.Common/src/mage/view/CardsView.java | 3 ++ .../src/mage/sets/iceage/Necropotence.java | 8 ++-- .../sets/khansoftarkir/VillainousWealth.java | 2 +- Mage.Sets/src/mage/sets/tempest/Lobotomy.java | 2 +- .../src/mage/sets/tempest/ScrollRack.java | 7 +++- .../java/org/mage/test/player/TestPlayer.java | 29 +++++++------- Mage/src/mage/players/Player.java | 9 ++--- Mage/src/mage/players/PlayerImpl.java | 40 ++++++++++--------- 8 files changed, 53 insertions(+), 47 deletions(-) diff --git a/Mage.Common/src/mage/view/CardsView.java b/Mage.Common/src/mage/view/CardsView.java index 2b72e78a1c2..4a7ee78da5b 100644 --- a/Mage.Common/src/mage/view/CardsView.java +++ b/Mage.Common/src/mage/view/CardsView.java @@ -152,6 +152,9 @@ public class CardsView extends LinkedHashMap { for (UUID uuid : abilityTargets) { MageObject mageObject = game.getObject(uuid); if (mageObject != null) { + if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) { + continue; + } names.add(GameLog.getColoredObjectIdNameForTooltip(mageObject)); } } diff --git a/Mage.Sets/src/mage/sets/iceage/Necropotence.java b/Mage.Sets/src/mage/sets/iceage/Necropotence.java index 0b1bb6d547e..40d11e6a202 100644 --- a/Mage.Sets/src/mage/sets/iceage/Necropotence.java +++ b/Mage.Sets/src/mage/sets/iceage/Necropotence.java @@ -143,10 +143,10 @@ class NecropotenceEffect extends OneShotEffect { Card card = controller.getLibrary().removeFromTop(game); if (controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, false)) { card.setFaceDown(true, game); - Effect returnToHandeffect = new ReturnToHandTargetEffect(false); - returnToHandeffect.setText("put that face down card into your hand"); - returnToHandeffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnToHandeffect, TargetController.YOU); + Effect returnToHandEffect = new ReturnToHandTargetEffect(false); + returnToHandEffect.setText("put that face down card into your hand"); + returnToHandEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnToHandEffect, TargetController.YOU); delayedAbility.setSourceId(source.getSourceId()); delayedAbility.setControllerId(source.getControllerId()); delayedAbility.setSourceObject(source.getSourceObject(game), game); diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/VillainousWealth.java b/Mage.Sets/src/mage/sets/khansoftarkir/VillainousWealth.java index 919ade12531..4780c7e18a2 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/VillainousWealth.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/VillainousWealth.java @@ -103,7 +103,7 @@ class VillainousWealthEffect extends OneShotEffect { if (player != null) { Cards cardsToExile = new CardsImpl(); cardsToExile.addAll(player.getLibrary().getTopCards(game, source.getManaCostsToPay().getX())); - controller.moveCards(cardsToExile, null, Zone.EXILED, source, game, true); + controller.moveCards(cardsToExile, null, Zone.EXILED, source, game); if (controller.chooseUse(Outcome.PlayForFree, "Cast cards exiled with " + mageObject.getLogName() + " without paying its mana cost?", source, game)) { OuterLoop: while (cardsToExile.count(filter, game) > 0) { diff --git a/Mage.Sets/src/mage/sets/tempest/Lobotomy.java b/Mage.Sets/src/mage/sets/tempest/Lobotomy.java index f96e3c8b7bb..440bfc01707 100644 --- a/Mage.Sets/src/mage/sets/tempest/Lobotomy.java +++ b/Mage.Sets/src/mage/sets/tempest/Lobotomy.java @@ -153,7 +153,7 @@ class LobotomyEffect extends OneShotEffect { } if (!cardsToExile.isEmpty()) { - controller.moveCards(cardsToExile, null, Zone.EXILED, source, game, true); + controller.moveCards(cardsToExile, null, Zone.EXILED, source, game); } targetPlayer.shuffleLibrary(game); return true; diff --git a/Mage.Sets/src/mage/sets/tempest/ScrollRack.java b/Mage.Sets/src/mage/sets/tempest/ScrollRack.java index 4d5ece41394..db4100fe0e7 100644 --- a/Mage.Sets/src/mage/sets/tempest/ScrollRack.java +++ b/Mage.Sets/src/mage/sets/tempest/ScrollRack.java @@ -27,6 +27,7 @@ */ package mage.sets.tempest; +import java.util.Set; import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; @@ -110,7 +111,11 @@ class ScrollRackEffect extends OneShotEffect { } // Put that many cards from the top of your library into your hand. if (amountExiled > 0) { - controller.moveCards(controller.getLibrary().getTopCards(game, amountExiled), null, Zone.HAND, source, game, false); + Set cards = controller.getLibrary().getTopCards(game, amountExiled); + for (Card card : cards) { + card.setFaceDown(true, game); + } + controller.moveCards(cards, null, Zone.HAND, source, game); } // Then look at the exiled cards and put them on top of your library in any order controller.putCardsOnTopOfLibrary(game.getExile().getExileZone(source.getSourceId()), game, source, true); diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index e76f6cc21ea..7806999ead1 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -1677,21 +1677,20 @@ public class TestPlayer implements Player { return computerPlayer.moveCards(cards, fromZone, toZone, source, game); } - @Override - public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) { - return computerPlayer.moveCards(cards, fromZone, toZone, source, game); - } - - @Override - public boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) { - return computerPlayer.moveCards(card, fromZone, toZone, source, game); - } - - @Override - public boolean moveCards(Set cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) { - return computerPlayer.moveCards(cards, fromZone, toZone, source, game); - } - +// @Override +// public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) { +// return computerPlayer.moveCards(cards, fromZone, toZone, source, game); +// } +// +// @Override +// public boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) { +// return computerPlayer.moveCards(card, fromZone, toZone, source, game); +// } +// +// @Override +// public boolean moveCards(Set cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) { +// return computerPlayer.moveCards(cards, fromZone, toZone, source, game); +// } @Override public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game) { return computerPlayer.moveCardToHandWithInfo(card, sourceId, game); diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index 88aa373b59c..4d450a9d58a 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -620,16 +620,13 @@ public interface Player extends MageItem, Copyable { */ boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game); - boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName); - +// boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName); boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game); - boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName); - +// boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName); boolean moveCards(Set cards, Zone fromZone, Zone toZone, Ability source, Game game); - boolean moveCards(Set cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName); - + // boolean moveCards(Set cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName); boolean moveCardsToExile(Set cards, Ability source, Game game, boolean withName, UUID exileId, String exileZoneName); /** diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index b5b2029a92e..6924f3e92b7 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -2873,14 +2873,14 @@ public abstract class PlayerImpl implements Player, Serializable { public UUID getCommanderId() { return this.commanderId; } +// +// @Override +// public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game) { +// return moveCards(cards, fromZone, toZone, source, game, true); +// } @Override public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game) { - return moveCards(cards, fromZone, toZone, source, game, true); - } - - @Override - public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) { Set cardList = new HashSet<>(); for (UUID cardId : cards) { if (fromZone == null) { @@ -2898,30 +2898,28 @@ public abstract class PlayerImpl implements Player, Serializable { } } } - return moveCards(cardList, fromZone, toZone, source, game, withName); + return moveCards(cardList, fromZone, toZone, source, game); } +// @Override +// public boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game) { +// return moveCards(card, fromZone, toZone, source, game, true); +// } @Override public boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game) { - return moveCards(card, fromZone, toZone, source, game, true); - } - - @Override - public boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) { Set cardList = new HashSet<>(); if (card != null) { cardList.add(card); } - return moveCards(cardList, fromZone, toZone, source, game, withName); + return moveCards(cardList, fromZone, toZone, source, game); } +// @Override +// public boolean moveCards(Set cards, Zone fromZone, Zone toZone, Ability source, Game game) { +// return moveCards(cards, fromZone, toZone, source, game, true); +// } @Override public boolean moveCards(Set cards, Zone fromZone, Zone toZone, Ability source, Game game) { - return moveCards(cards, fromZone, toZone, source, game, true); - } - - @Override - public boolean moveCards(Set cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) { if (cards.isEmpty()) { return true; } @@ -2931,6 +2929,7 @@ public abstract class PlayerImpl implements Player, Serializable { boolean result = false; for (Card card : cards) { fromZone = game.getState().getZone(card.getId()); + boolean withName = (fromZone.equals(Zone.BATTLEFIELD) || fromZone.equals(Zone.STACK)) || !card.isFaceDown(game); result |= moveCardToExileWithInfo(card, null, "", source == null ? null : source.getSourceId(), game, fromZone, withName); } return result; @@ -2940,20 +2939,23 @@ public abstract class PlayerImpl implements Player, Serializable { result = false; for (Card card : cards) { fromZone = game.getState().getZone(card.getId()); - result |= moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, withName); + boolean hideCard = fromZone.equals(Zone.LIBRARY) + || (card.isFaceDown(game) && !fromZone.equals(Zone.STACK) && !fromZone.equals(Zone.BATTLEFIELD)); + result |= moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, !hideCard); } return result; case BATTLEFIELD: result = false; for (Card card : cards) { fromZone = game.getState().getZone(card.getId()); - result |= putOntoBattlefieldWithInfo(card, game, fromZone, source == null ? null : source.getSourceId(), false, !withName); + result |= putOntoBattlefieldWithInfo(card, game, fromZone, source == null ? null : source.getSourceId(), false, !card.isFaceDown(game)); } return result; case LIBRARY: result = false; for (Card card : cards) { fromZone = game.getState().getZone(card.getId()); + boolean withName = fromZone.equals(Zone.BATTLEFIELD) || !card.isFaceDown(game); result |= moveCardToLibraryWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone, true, withName); } return result;