Some changes to RedirectionEffect class. Fixed that Harm's Way and Shaman en-Kor prevented the damage instead of only redirecting the damage.

This commit is contained in:
LevelX2 2015-10-20 17:16:13 +02:00
parent 606bf4d6e0
commit d58288da6d
7 changed files with 272 additions and 200 deletions

View file

@ -1,4 +1,4 @@
package org.mage.test.cards.replacement.prevent;
package org.mage.test.cards.replacement.redirect;
import mage.constants.PhaseStep;
import mage.constants.Zone;
@ -6,15 +6,17 @@ import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* Harm's Way:
* The next 2 damage that a source of your choice would deal to you and/or permanents you control this turn is dealt to target creature or player instead.
* Harm's Way: The next 2 damage that a source of your choice would deal to you
* and/or permanents you control this turn is dealt to target creature or player
* instead.
*
* @author noxx
*/
public class HarmsWayRedirectDamageTest extends CardTestPlayerBase {
/**
* Tests that 2 of 3 damage is redirected while 1 damage is still dealt to original target
* Tests that 2 of 3 damage is redirected while 1 damage is still dealt to
* original target
*/
@Test
public void testRedirectTwoDamage() {
@ -51,7 +53,7 @@ public class HarmsWayRedirectDamageTest extends CardTestPlayerBase {
attack(2, playerB, "Craw Wurm");
castSpell(2, PhaseStep.DECLARE_BLOCKERS, playerA, "Harm's Way", playerB);
setChoice(playerA, "Craw Wurm");
setStopAt(2, PhaseStep.END_TURN);
execute();
@ -79,8 +81,11 @@ public class HarmsWayRedirectDamageTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerB, "Magma Phoenix");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Harm's Way", playerB);
setChoice(playerA, "Magma Phoenix");
/** When Magma Phoenix dies, Magma Phoenix deals 3 damage to each creature and each player **/
setChoice(playerA, "Magma Phoenix");
/**
* When Magma Phoenix dies, Magma Phoenix deals 3 damage to each
* creature and each player *
*/
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", "Magma Phoenix");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
@ -91,4 +96,38 @@ public class HarmsWayRedirectDamageTest extends CardTestPlayerBase {
assertLife(playerB, 15); // 3 damage from dying Phoenix directly and 2 redirected damage from playerA
}
/**
* Tests that not preventable damage is redirected
*/
@Test
public void testRedirectNotPreventableDamage() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
// <i>Ferocious</i> If you control a creature with power 4 or greater, damage can't be prevented this turn.
// Wild Slash deals 2 damage to target creature or player.
addCard(Zone.HAND, playerA, "Wild Slash"); // {R}
addCard(Zone.BATTLEFIELD, playerA, "Serra Angel");
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
// The next 2 damage that a source of your choice would deal to you and/or permanents
// you control this turn is dealt to target creature or player instead.
addCard(Zone.HAND, playerB, "Harm's Way"); // {W}
addCard(Zone.BATTLEFIELD, playerB, "Plains");
addCard(Zone.BATTLEFIELD, playerB, "Birds of Paradise");
// the 2 damage can't be prevented and have to be redirected to Silvercoat Lion of player A
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wild Slash", "Birds of Paradise");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Harm's Way", "Silvercoat Lion", "Wild Slash");
setChoice(playerB, "Wild Slash");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Wild Slash", 1);
assertGraveyardCount(playerB, "Harm's Way", 1);
assertPermanentCount(playerB, "Birds of Paradise", 1);
assertGraveyardCount(playerA, "Silvercoat Lion", 1);
assertLife(playerA, 20);
assertLife(playerB, 20);
}
}

View file

@ -0,0 +1,94 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.cards.replacement.redirect;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class ShamenEnKorTest extends CardTestPlayerBase {
/**
* Tests that 2 of 3 damage is redirected while 1 damage is still dealt to
* original target
*/
@Test
public void testFirstAbilityNonCombatDamage() {
addCard(Zone.HAND, playerA, "Lightning Bolt");
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
// {0}: The next 1 damage that would be dealt to Shaman en-Kor this turn is dealt to target creature you control instead.
// {1}{W}: The next time a source of your choice would deal damage to target creature this turn, that damage is dealt to Shaman en-Kor instead.
addCard(Zone.BATTLEFIELD, playerB, "Shaman en-Kor"); // 1/2
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); // 2/2
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Shaman en-Kor");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{0}: The next 1 damage", "Silvercoat Lion", "Lightning Bolt");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{0}: The next 1 damage", "Silvercoat Lion", "Lightning Bolt");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertPermanentCount(playerB, "Shaman en-Kor", 1);
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
}
@Test
public void testSecondAbilityNonCombatDamage() {
addCard(Zone.HAND, playerA, "Lightning Bolt");
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
// {0}: The next 1 damage that would be dealt to Shaman en-Kor this turn is dealt to target creature you control instead.
// {1}{W}: The next time a source of your choice would deal damage to target creature this turn, that damage is dealt to Shaman en-Kor instead.
addCard(Zone.BATTLEFIELD, playerB, "Shaman en-Kor"); // 1/2
addCard(Zone.BATTLEFIELD, playerB, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); // 2/2
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Silvercoat Lion");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{1}{W}: The next time", "Silvercoat Lion", "Lightning Bolt");
setChoice(playerB, "Lightning Bolt");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertPermanentCount(playerB, "Silvercoat Lion", 1);
assertGraveyardCount(playerB, "Shaman en-Kor", 1);
}
}