* Morph - Fixed handling (card shown face down after cancel of morph cast).

This commit is contained in:
LevelX2 2014-09-13 11:23:01 +02:00
parent 5578e4c158
commit 85baf357e3
3 changed files with 22 additions and 24 deletions

View file

@ -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<Cost> 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);
}
}
}

View file

@ -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

View file

@ -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());