From 85baf357e3b4319254cfe8934c14ce158b69a01b Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 13 Sep 2014 11:23:01 +0200 Subject: [PATCH] * Morph - Fixed handling (card shown face down after cancel of morph cast). --- .../mage/abilities/keyword/MorphAbility.java | 28 ++++++++----------- Mage/src/mage/game/stack/Spell.java | 15 +++++++--- Mage/src/mage/players/PlayerImpl.java | 3 -- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Mage/src/mage/abilities/keyword/MorphAbility.java b/Mage/src/mage/abilities/keyword/MorphAbility.java index 21715a59e8..c7c667ff2f 100644 --- a/Mage/src/mage/abilities/keyword/MorphAbility.java +++ b/Mage/src/mage/abilities/keyword/MorphAbility.java @@ -113,15 +113,18 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost this(card, createCosts(morphCost)); } - public MorphAbility(Card card, Costs morphCosts) { + public MorphAbility(Card card, Costs morphCosts) { super(Zone.HAND, null); card.setMorphCard(true); this.setWorksFaceDown(true); name = ABILITY_KEYWORD; StringBuilder sb = new StringBuilder(); sb.append(ABILITY_KEYWORD).append(" "); - if (!(morphCosts instanceof ManaCosts)) { - sb.append("- "); + for (Cost cost :morphCosts) { + if (!(cost instanceof ManaCosts)) { + sb.append("- "); + break; + } } sb.append(morphCosts.getText()).append(" "); sb.append(REMINDER_TEXT); @@ -181,16 +184,14 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost public boolean askToActivateAlternativeCosts(Ability ability, Game game) { if (ability instanceof SpellAbility) { Player player = game.getPlayer(controllerId); - if (player != null) { + Spell spell = game.getStack().getSpell(ability.getId()); + if (player != null && spell != null) { this.resetMorph(); + spell.setFaceDown(true); // so only the back is visible for (AlternativeCost2 alternateCastingCost: alternateCosts) { if (alternateCastingCost.canPay(ability, sourceId, controllerId, game) && player.chooseUse(Outcome.Benefit, new StringBuilder("Cast this card as a 2/2 face-down creature for ").append(alternateCastingCost.getText(true)).append(" ?").toString(), game)) { - - Spell spell = game.getStack().getSpell(ability.getId()); - if (spell != null) { - spell.setFaceDown(true); - } activateMorph(alternateCastingCost, game); + activateMorph(alternateCastingCost, game); ability.getManaCostsToPay().clear(); ability.getCosts().clear(); for (Iterator it = ((Costs) alternateCastingCost).iterator(); it.hasNext();) { @@ -202,14 +203,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost } } } else { - Card card = game.getCard(getSourceId()); // face down was set to true in PlayerImpl.cast, reset it here if not cast face down - if (card != null) { - card.setFaceDown(false); - } - Spell spell = game.getStack().getSpell(ability.getId()); - if (spell != null) { - spell.setFaceDown(false); - } + spell.setFaceDown(false); } } } diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index 3856a9427a..2e48c4ebf7 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -79,6 +79,7 @@ public class Spell implements StackObject, Card { private UUID controllerId; private boolean copiedSpell; + private boolean faceDown; public Spell(Card card, SpellAbility ability, UUID controllerId, Zone fromZone) { this.card = card; @@ -119,6 +120,7 @@ public class Spell implements StackObject, Card { this.controllerId = spell.controllerId; this.fromZone = spell.fromZone; this.copiedSpell = spell.copiedSpell; + this.faceDown = spell.faceDown; } @@ -255,6 +257,9 @@ public class Spell implements StackObject, Card { } } else { updateOptionalCosts(0); + if (isFaceDown()) { + card.setFaceDown(true); + } result = card.putOntoBattlefield(game, fromZone, ability.getId(), controllerId); return result; } @@ -680,22 +685,24 @@ public class Spell implements StackObject, Card { @Override public void setFaceDown(boolean value) { - card.setFaceDown(value); + faceDown = value; } @Override public boolean turnFaceUp(Game game, UUID playerId) { - return card.turnFaceUp(game, playerId); + setFaceDown(false); + return true; } @Override public boolean turnFaceDown(Game game, UUID playerId) { - return card.turnFaceDown(game, playerId); + setFaceDown(true); + return true; } @Override public boolean isFaceDown() { - return card.isFaceDown(); + return faceDown; } @Override diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index f60babb93e..dc40f8b4f0 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -794,9 +794,6 @@ public abstract class PlayerImpl implements Player, Serializable { //20091005 - 601.2a Card card = game.getCard(ability.getSourceId()); if (card != null) { - if (card.isMorphCard() && !noMana) { //TODO: move to other place - card.setFaceDown(true); - } if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, ability.getId(), ability.getSourceId(), playerId))) { int bookmark = game.bookmarkState(); Zone fromZone = game.getState().getZone(card.getId());