* Fixed that replacement or rule modifying effects of cards played with morph were wrongly applied on the stack (e.g. can't be countered of Akroma, Angel of Fury).

This commit is contained in:
LevelX2 2015-01-22 23:43:25 +01:00
parent dbffbad3cb
commit 89c8425d94
3 changed files with 52 additions and 17 deletions

View file

@ -27,10 +27,8 @@
*/
package org.mage.test.cards.abilities.keywords;
import mage.abilities.keyword.HexproofAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.permanent.Permanent;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -70,5 +68,5 @@ public class ManifestTest extends CardTestPlayerBase {
// not tapped
assertTapped("face down creature", false);
}
}

View file

@ -401,4 +401,33 @@ public class MorphTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "face down creature", 1);
}
/**
* I played a Akroma, Angel of Fury face down, and my opponent tried to counter it.
* The counter failed and Akroma face successfully play face down, when it should have
* been countered. (The card text on akroma should not prevent her from being countered).
*/
@Test
public void testRuleModifyingEffectsFromManifestedCardWontBeAppliedAbilities() {
addCard(Zone.HAND, playerA, "Akroma, Angel of Fury", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
addCard(Zone.HAND, playerB, "Counterspell", 1);
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Akroma, Angel of Fury");
setChoice(playerA, "Yes"); // cast it face down as 2/2 creature
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Counterspell", "Akroma, Angel of Fury");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerB, 20);
assertGraveyardCount(playerB, "Counterspell", 1);
assertGraveyardCount(playerA, "Akroma, Angel of Fury", 1);
}
}

View file

@ -67,6 +67,7 @@ import mage.game.events.GameEvent.EventType;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
import org.apache.log4j.Logger;
@ -416,6 +417,11 @@ public class ContinuousEffects implements Serializable {
if (permanent.isFaceDown() && !ability.getWorksFaceDown()) {
return false;
}
} else if (object instanceof Spell) {
Spell spell = (Spell)object;
if (spell.isFaceDown() && !ability.getWorksFaceDown()) {
return false;
}
}
}
return exists;
@ -651,24 +657,26 @@ public class ContinuousEffects implements Serializable {
}
for (Ability sourceAbility : continuousRuleModifyingEffects.getAbility(effect.getId())) {
if (!(sourceAbility instanceof StaticAbility) || sourceAbility.isInUseableZone(game, null, false)) {
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
effect.setValue("targetAbility", targetAbility);
if (effect.applies(event, sourceAbility, game)) {
if (!checkPlayableMode) {
String message = effect.getInfoMessage(sourceAbility, event, game);
if (message != null && !message.isEmpty()) {
if (effect.sendMessageToUser()) {
Player player = game.getPlayer(event.getPlayerId());
if (player != null) {
game.informPlayer(player, message);
if (checkAbilityStillExists(sourceAbility, effect, event, game)) {
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
effect.setValue("targetAbility", targetAbility);
if (effect.applies(event, sourceAbility, game)) {
if (!checkPlayableMode) {
String message = effect.getInfoMessage(sourceAbility, event, game);
if (message != null && !message.isEmpty()) {
if (effect.sendMessageToUser()) {
Player player = game.getPlayer(event.getPlayerId());
if (player != null) {
game.informPlayer(player, message);
}
}
if (effect.sendMessageToGameLog()) {
game.informPlayers(message);
}
}
if (effect.sendMessageToGameLog()) {
game.informPlayers(message);
}
}
return true;
}
return true;
}
}
}