From e0c7083145cab214e43ae5ccfce3fd9924a2c85e Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 16 Sep 2014 14:15:19 +0200 Subject: [PATCH] * Fixed that deathtouch and lifelink did not work if the source permanent left the battlefield before the damage was dealt (e.g. Marath removing its last +1/+1 counter). --- .../abilities/keywords/DeathtouchTest.java | 50 +++++++++++++------ .../mage/game/permanent/PermanentImpl.java | 2 +- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/DeathtouchTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/DeathtouchTest.java index 87d05839b70..d6603a162f9 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/DeathtouchTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/DeathtouchTest.java @@ -40,10 +40,31 @@ import org.mage.test.serverside.base.CardTestPlayerBase; */ public class DeathtouchTest extends CardTestPlayerBase { + @Test + public void simpleDeathtouchDuringCombat() { + addCard(Zone.BATTLEFIELD, playerA, "Archangel of Thune"); + // Creature - Rat 1/1 + // Deathtouch + addCard(Zone.BATTLEFIELD, playerB, "Typhoid Rats"); + + + attack(2, playerB, "Typhoid Rats"); + block(2, playerA, "Archangel of Thune", "Typhoid Rats"); + + setStopAt(2, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertLife(playerA, 23); + assertLife(playerB, 20); + + assertGraveyardCount(playerA, "Archangel of Thune", 1); + assertGraveyardCount(playerB, "Typhoid Rats", 1); + } + /** - * Checks if cards put into play with Lord of the Void triggered ability - * are correctly controlled by the controller of Lord of the Void - * e.g. the top card of the library of the current controller of Oracle of Mul Daya is revealed + * Checks if a creature getting damage from Marath abilitity dies + * from Deathtouch, if Marath is equiped with Deathtouch giving Equipment + * and Marath dies from removing the +1/+1 counters. */ @Test public void testMarathWillOfTheWild() { @@ -51,15 +72,17 @@ public class DeathtouchTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerA, "Forest"); addCard(Zone.BATTLEFIELD, playerA, "Plains"); addCard(Zone.BATTLEFIELD, playerA, "Swamp", 10); + // Equipped creature has deathtouch and lifelink. addCard(Zone.BATTLEFIELD, playerA, "Basilisk Collar"); /* {R}{G}{W} Legendary Creature - Elemental Beast Marath, Will of the Wild enters the battlefield with a number of +1/+1 counters on it equal to the amount of mana spent to cast it. {X}, Remove X +1/+1 counters from Marath: Choose one - - * Put X +1/+1 counters on target creature; or Marath deals X damage to target creature or player; or put an X/X green Elemental creature token onto the battlefield. X can't be 0 - - */ + * Put X +1/+1 counters on target creature + * Marath deals X damage to target creature or player + * Put an X/X green Elemental creature token onto the battlefield. X can't be 0 + */ addCard(Zone.HAND, playerA, "Marath, Will of the Wild", 1); addCard(Zone.BATTLEFIELD, playerB, "Archangel of Thune"); @@ -68,20 +91,19 @@ public class DeathtouchTest extends CardTestPlayerBase { castSpell(1, PhaseStep.PRECOMBAT_MAIN , playerA, "Marath, Will of the Wild"); activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip {2}", "Marath, Will of the Wild"); - activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{X},Remove X +1/+1 counters from Marath: Choose one - Put X +1/+1 counters on target creature; or {source} deals X damage to target creature or player; or put an X/X green Elemental creature token onto the battlefield."); + activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{X},Remove X +1/+1 counters from Marath: Choose one - Put X +1/+1 counters on target creature; or {source} deals X damage to target creature or player; or put an X/X green Elemental creature token onto the battlefield.", "Archangel of Thune"); setChoice(playerA, "X=3"); - setModeChoice(playerA, "1"); // Marath deals X damage to target creature or player + setModeChoice(playerA, "2"); // Marath deals X damage to target creature or player setStopAt(1, PhaseStep.END_TURN); execute(); - // under control - assertLife(playerA, 20); - Permanent equipment = getPermanent("Basilisk Collar", playerA); - Assert.assertTrue("Equipment is attached to Marath", equipment.getAttachedTo() != null); - // assertPermanentCount(playerA, "Marath, Will of the Wild", 0); - // assertPermanentCount(playerB, "Archangel of Thune", 0); + assertLife(playerA, 23); + assertLife(playerB, 20); + + assertPermanentCount(playerA, "Marath, Will of the Wild", 0); + assertPermanentCount(playerB, "Archangel of Thune", 0); } diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index 2b3f2348d2d..2be89c8756d 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -621,7 +621,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { damageDone = damageCreature(damageAmount, sourceId, game, preventable, combat, markDamage, appliedEffects); } if (damageDone > 0) { - Permanent source = game.getPermanent(sourceId); + Permanent source = game.getPermanentOrLKIBattlefield(sourceId); if (source != null && source.getAbilities().containsKey(LifelinkAbility.getInstance().getId())) { Player player = game.getPlayer(source.getControllerId()); player.gainLife(damageAmount, game);