diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/RenownTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/RenownTest.java index 7db71b19598..45dd3fad21e 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/RenownTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/RenownTest.java @@ -27,9 +27,12 @@ */ package org.mage.test.cards.abilities.keywords; +import mage.abilities.keyword.MenaceAbility; import mage.abilities.keyword.VigilanceAbility; import mage.constants.PhaseStep; import mage.constants.Zone; +import mage.game.permanent.Permanent; +import org.junit.Assert; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -50,17 +53,17 @@ public class RenownTest extends CardTestPlayerBase { attack(3, playerA, "Knight of the Pilgrim's Road"); // 3 damage attack(5, playerA, "Knight of the Pilgrim's Road"); // 4 damage attack(7, playerA, "Knight of the Pilgrim's Road"); // 4 damage - + setStopAt(7, PhaseStep.POSTCOMBAT_MAIN); execute(); assertPowerToughness(playerA, "Knight of the Pilgrim's Road", 4, 3); - + assertLife(playerA, 20); assertLife(playerB, 9); } - + /** * Test renown trigger */ @@ -76,19 +79,19 @@ public class RenownTest extends CardTestPlayerBase { attack(3, playerA, "Relic Seeker"); // 2 damage attack(5, playerA, "Relic Seeker"); // 3 damage - + setStopAt(5, PhaseStep.POSTCOMBAT_MAIN); execute(); assertPowerToughness(playerA, "Relic Seeker", 3, 3); assertHandCount(playerA, "Veteran's Sidearm", 1); - + assertLife(playerA, 20); assertLife(playerB, 15); - } - - /** + } + + /** * Test renown state */ @Test @@ -102,18 +105,19 @@ public class RenownTest extends CardTestPlayerBase { attack(3, playerA, "Honored Hierarch"); // 1 damage attack(5, playerA, "Honored Hierarch"); // 2 damage - + setStopAt(5, PhaseStep.POSTCOMBAT_MAIN); execute(); assertPowerToughness(playerA, "Honored Hierarch", 2, 2); assertTapped("Honored Hierarch", false); assertAbility(playerA, "Honored Hierarch", VigilanceAbility.getInstance(), true); - + assertLife(playerA, 20); assertLife(playerB, 17); - } + } + /** * Test renown > 1 */ @@ -121,7 +125,7 @@ public class RenownTest extends CardTestPlayerBase { public void testRhoxMaulers() { addCard(Zone.BATTLEFIELD, playerA, "Forest", 5); // Trample - // Renown 2 + // Renown 2 addCard(Zone.HAND, playerA, "Rhox Maulers"); // 4/4 castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Rhox Maulers"); @@ -129,14 +133,82 @@ public class RenownTest extends CardTestPlayerBase { attack(3, playerA, "Rhox Maulers"); // 4 damage attack(5, playerA, "Rhox Maulers"); // 6 damage attack(7, playerA, "Rhox Maulers"); // 6 damage - + setStopAt(7, PhaseStep.POSTCOMBAT_MAIN); execute(); assertPowerToughness(playerA, "Rhox Maulers", 6, 6); - + assertLife(playerA, 20); assertLife(playerB, 4); - } + } + + /** + * Test renown is gone after zone change + * + * /** + * Test renown is gone after zone change + */ + @Test + public void testRenownGoneAfterZoneChange() { + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 6); + // Trample + // Renown 2 + addCard(Zone.HAND, playerA, "Rhox Maulers"); // 4/4 + addCard(Zone.HAND, playerA, "Cloudshift"); // 4/4 + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Rhox Maulers"); + castSpell(5, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cloudshift", "Rhox Maulers"); + + attack(3, playerA, "Rhox Maulers"); // 4 damage + attack(5, playerA, "Rhox Maulers"); // 6 damage + attack(7, playerA, "Rhox Maulers"); // 4 damage + + setStopAt(7, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 6); + + assertPowerToughness(playerA, "Rhox Maulers", 4, 4); + Permanent rhoxMaulers = getPermanent("Rhox Maulers", playerA); + Assert.assertEquals("may not be renown", false, rhoxMaulers.isRenown()); + + } + + /* + Test renown can be gained again after zone change + */ + @Test + public void testRenownGainedGainAfterZoneChange() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 2); + // Renown 1 + // As long as Goblin Glory Chaser is renowned, it has menace. + addCard(Zone.HAND, playerA, "Goblin Glory Chaser"); // 1/1 {R} + addCard(Zone.HAND, playerA, "Cloudshift"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Goblin Glory Chaser"); + castSpell(5, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cloudshift", "Goblin Glory Chaser"); + + attack(3, playerA, "Goblin Glory Chaser"); // 1 damage + attack(5, playerA, "Goblin Glory Chaser"); // 2 damage + attack(7, playerA, "Goblin Glory Chaser"); // 1 damage + attack(9, playerA, "Goblin Glory Chaser"); // 2 damage + + setStopAt(9, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + Permanent goblin = getPermanent("Goblin Glory Chaser", playerA); + Assert.assertEquals("has has renown", true, goblin.isRenown()); + assertAbility(playerA, "Goblin Glory Chaser", new MenaceAbility(), true); + assertPowerToughness(playerA, "Goblin Glory Chaser", 2, 2); + + assertLife(playerA, 20); + assertLife(playerB, 14); + + } + } diff --git a/Mage/src/mage/abilities/keyword/RenownAbility.java b/Mage/src/mage/abilities/keyword/RenownAbility.java index f6f3f778257..96a8b1e8e75 100644 --- a/Mage/src/mage/abilities/keyword/RenownAbility.java +++ b/Mage/src/mage/abilities/keyword/RenownAbility.java @@ -48,7 +48,8 @@ public class RenownAbility extends TriggeredAbilityImpl { @Override public boolean checkInterveningIfClause(Game game) { - return getSourceObject(game) != null && !((Permanent) getSourceObject(game)).isRenown(); + Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId()); + return sourcePermanent != null && !sourcePermanent.isRenown(); } @Override