From 7bc8649585ad4d4aac668aa7555412a3b7907813 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 25 Jun 2015 14:31:23 +0200 Subject: [PATCH] * Animate Dead - Fixed that the target card in graveyard was not handled correct, if the Animate Dead reentered the Battlefield(e.g. with Worldgorger Dragon combo). --- .../cards/triggers/WorldgorgerDragonTest.java | 35 +++++++++++-------- .../java/org/mage/test/player/TestPlayer.java | 14 +++++--- .../effects/AuraReplacementEffect.java | 18 +++++----- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/WorldgorgerDragonTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/WorldgorgerDragonTest.java index c1f2238dfb1..db1557a3bd4 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/WorldgorgerDragonTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/WorldgorgerDragonTest.java @@ -5,9 +5,10 @@ */ package org.mage.test.cards.triggers; + import mage.constants.PhaseStep; import mage.constants.Zone; -import org.junit.Ignore; +import org.junit.Assert; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -133,7 +134,6 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase { * */ @Test - @Ignore public void testWithAnimateDeadDifferentTargets() { addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); @@ -153,35 +153,40 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase { // When Staunch Defenders enters the battlefield, you gain 4 life. addCard(Zone.BATTLEFIELD, playerA, "Staunch Defenders", 1); + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {B}"); + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {B}"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Animate Dead", "Worldgorger Dragon"); - addTarget(playerA, "Worldgorger Dragon"); - addTarget(playerA, "Worldgorger Dragon"); - addTarget(playerA, "Silvercoat Lion"); - - activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); - activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); - activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); - activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); - activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); + + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); + setChoice(playerA, "Worldgorger Dragon"); + + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB, 9); - setChoice(playerA, "X=7"); + setChoice(playerA, "Silvercoat Lion"); + + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB, 9); + setChoice(playerA, "X=9"); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); + assertGraveyardCount(playerA, "Volcanic Geyser", 1); assertGraveyardCount(playerA, "Worldgorger Dragon", 1); assertPermanentCount(playerA, "Silvercoat Lion", 1); - assertLife(playerA, 24); + assertLife(playerA, 28); assertLife(playerB, 11); - assertGraveyardCount(playerA, "Volcanic Geyser", 1); + Assert.assertEquals("Mana pool", "[]", playerA.getManaAvailable(currentGame).toString()); } 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 6de99aff263..9fe14c7e861 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 @@ -628,8 +628,10 @@ public class TestPlayer implements Player { if (targetCardInGraveyard.canTarget(targetObject.getId(), game)) { if (alreadyTargetted != null && !alreadyTargetted.contains(targetObject.getId())) { targetCardInGraveyard.add(targetObject.getId(), game); - choices.remove(choose2); targetFound = true; + if (target.getTargets().size() >= target.getMaxNumberOfTargets()) { + break; + } } } } @@ -810,10 +812,12 @@ public class TestPlayer implements Player { @Override public int announceXMana(int min, int max, String message, Game game, Ability ability) { if (!choices.isEmpty()) { - if (choices.get(0).startsWith("X=")) { - int xValue = Integer.parseInt(choices.get(0).substring(2)); - choices.remove(0); - return xValue; + for(String choice: choices) { + if (choice.startsWith("X=")) { + int xValue = Integer.parseInt(choice.substring(2)); + choices.remove(choice); + return xValue; + } } } return computerPlayer.announceXMana(min, max, message, game, ability); diff --git a/Mage/src/mage/abilities/effects/AuraReplacementEffect.java b/Mage/src/mage/abilities/effects/AuraReplacementEffect.java index aa892d608e7..e5cdec0b930 100644 --- a/Mage/src/mage/abilities/effects/AuraReplacementEffect.java +++ b/Mage/src/mage/abilities/effects/AuraReplacementEffect.java @@ -27,26 +27,25 @@ */ package mage.abilities.effects; +import java.util.UUID; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.effects.common.AttachEffect; +import mage.cards.Card; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.Zone; -import mage.MageObject; -import mage.abilities.Ability; -import mage.cards.Card; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; import mage.game.permanent.PermanentCard; +import mage.game.stack.Spell; import mage.game.stack.StackAbility; import mage.players.Player; import mage.target.Target; - -import java.util.UUID; -import mage.abilities.SpellAbility; -import mage.abilities.effects.common.AttachEffect; -import mage.game.stack.Spell; import mage.target.common.TargetCardInGraveyard; /** @@ -118,6 +117,9 @@ public class AuraReplacementEffect extends ReplacementEffectImpl { if (targetId == null) { Target target = card.getSpellAbility().getTargets().get(0); enchantCardInGraveyard = target instanceof TargetCardInGraveyard; + if (enchantCardInGraveyard && target != null) { + target.clearChosen(); + } Player player = game.getPlayer(card.getOwnerId()); Outcome auraOutcome = Outcome.BoostCreature; Ability: for (Ability ability:card.getAbilities()) {