Merge pull request #6012 from apetresc/syr-konrad-trigger-bug

Fix incorrect trigger for Syr Konrad (READY FOR REVIEW/MERGING)
This commit is contained in:
Evan Kranzler 2019-10-11 23:30:51 -04:00 committed by GitHub
commit c7084fcb3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 3 deletions

View file

@ -72,6 +72,7 @@ class SyrKonradTheGrimTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event; ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
// Whenever another creature dies
if (zEvent.isDiesEvent() if (zEvent.isDiesEvent()
&& zEvent.getTarget() != null && zEvent.getTarget() != null
&& !zEvent.getTargetId().equals(this.getSourceId()) && !zEvent.getTargetId().equals(this.getSourceId())
@ -79,6 +80,7 @@ class SyrKonradTheGrimTriggeredAbility extends TriggeredAbilityImpl {
return true; return true;
} }
Card card = game.getCard(zEvent.getTargetId()); Card card = game.getCard(zEvent.getTargetId());
// Or a creature card is put into a graveyard from anywhere other than the battlefield
if (card == null || !card.isCreature()) { if (card == null || !card.isCreature()) {
return false; return false;
} }
@ -86,7 +88,9 @@ class SyrKonradTheGrimTriggeredAbility extends TriggeredAbilityImpl {
&& zEvent.getFromZone() != Zone.BATTLEFIELD) { && zEvent.getFromZone() != Zone.BATTLEFIELD) {
return true; return true;
} }
return zEvent.getFromZone() == Zone.GRAVEYARD; // Or a creature card leaves your graveyard
return zEvent.getFromZone() == Zone.GRAVEYARD
&& zEvent.getPlayerId() == this.getControllerId();
} }
@Override @Override
@ -95,4 +99,4 @@ class SyrKonradTheGrimTriggeredAbility extends TriggeredAbilityImpl {
"from anywhere other than the battlefield, or a creature card leaves your graveyard, " + "from anywhere other than the battlefield, or a creature card leaves your graveyard, " +
"{this} deals 1 damage to each opponent."; "{this} deals 1 damage to each opponent.";
} }
} }

View file

@ -2,7 +2,6 @@ package org.mage.test.cards.single;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
import mage.constants.Zone; import mage.constants.Zone;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase; import org.mage.test.serverside.base.CardTestPlayerBase;

View file

@ -0,0 +1,33 @@
package org.mage.test.cards.single;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class SyrKonradTheGrimTest extends CardTestPlayerBase {
@Test
public void leavesOwnGraveyardTriggerTest() {
addCard(Zone.HAND, playerA, "Rest in Peace");
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerA, "Syr Konrad, the Grim");
// These leaving the graveyard *should* cause loss of life
addCard(Zone.GRAVEYARD, playerA, "Grizzly Bears", 2);
// These ones *shouldn't*
addCard(Zone.GRAVEYARD, playerB, "Grizzly Bears");
setStopAt(1, PhaseStep.UNTAP);
execute();
assertLife(playerB, 20);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Rest in Peace");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, 0);
assertGraveyardCount(playerB, 0);
assertLife(playerA, 20);
assertLife(playerB, 18);
}
}