* Karmic Justice - Fixed that it did not trigger for its own destroyment.

This commit is contained in:
LevelX2 2014-09-25 10:24:04 +02:00
parent f3ea64e27c
commit 7cacff2ce7
2 changed files with 48 additions and 4 deletions

View file

@ -39,8 +39,14 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class KarmicJusticeTest extends CardTestPlayerBase {
/*
Karmic Justice
Whenever a spell or ability an opponent controls destroys a noncreature permanent you control,
you may destroy target permanent that opponent controls.
*/
/**
* Karmic Justice triggers for its own destroyment
* Karmic Justice should triggers for its own destroyment
*/
@Test
public void testFirstTriggeredAbility() {
@ -62,4 +68,41 @@ public class KarmicJusticeTest extends CardTestPlayerBase {
}
/**
* Karmic Justice should triggers for each destroyed permanent
*/
@Test
public void testMultiplePermanentsDestroyedTriggeredAbility() {
// At the beginning of each upkeep, if you lost life last turn, put a 1/1 white Soldier creature token onto the battlefield.
addCard(Zone.BATTLEFIELD, playerA, "First Response",2);
addCard(Zone.BATTLEFIELD, playerA, "Karmic Justice");
// Planar Cleansing {3}{W}{W}{W}
// Sorcery
// Destroy all nonland permanents.
addCard(Zone.HAND, playerB, "Planar Cleansing");
addCard(Zone.BATTLEFIELD, playerB, "Plains", 4);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 1);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Planar Cleansing");
setChoice(playerA, "Yes");
addTarget(playerA, "Plains");
setChoice(playerA, "Yes");
addTarget(playerA, "Swamp");
setChoice(playerA, "Yes");
addTarget(playerA, "Mountain");
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerB, "Planar Cleansing", 1);
assertGraveyardCount(playerA, "Karmic Justice", 1);
assertGraveyardCount(playerA, "First Response", 2);
assertGraveyardCount(playerB, "Mountain", 1);
assertGraveyardCount(playerB, "Swamp", 1);
assertGraveyardCount(playerB, "Plains", 1);
}
}

View file

@ -37,6 +37,7 @@ import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard;
import java.util.*;
import mage.game.events.GameEvent.EventType;
/**
@ -61,8 +62,8 @@ public class TriggeredAbilities extends HashMap<String, TriggeredAbility> {
public void checkTriggers(GameEvent event, Game game) {
for (Iterator<TriggeredAbility> it = this.values().iterator(); it.hasNext();) {
TriggeredAbility ability = it.next();
// for effects like when leaves battlefield use ShortLKI to check if permanent was in the correct zone before (e.g. Oblivion Ring)
if (ability.isInUseableZone(game, null, event.getType().equals(GameEvent.EventType.ZONE_CHANGE))) {
// for effects like when leaves battlefield or destroyed use ShortLKI to check if permanent was in the correct zone before (e.g. Oblivion Ring or Karmic Justice)
if (ability.isInUseableZone(game, null, event.getType().equals(EventType.ZONE_CHANGE) || event.getType().equals(EventType.DESTROYED_PERMANENT))) {
if (!game.getContinuousEffects().preventedByRuleModification(event, ability, game, false)) {
MageObject object = null;
@ -89,7 +90,7 @@ public class TriggeredAbilities extends HashMap<String, TriggeredAbility> {
}
}
}
private boolean checkAbilityStillExists(TriggeredAbility ability, GameEvent event, MageObject object) {
boolean exists = true;
if (!object.getAbilities().contains(ability)) {