mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
fix regression: Michiko Konda, Truth Seeker
missing a check in SourceDealsDamageToYouTriggeredAbility::checkTrigger added test
This commit is contained in:
parent
0631521787
commit
518407be73
2 changed files with 100 additions and 2 deletions
|
|
@ -0,0 +1,92 @@
|
||||||
|
package org.mage.test.cards.single.sok;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xenohedron
|
||||||
|
*/
|
||||||
|
public class MichikoKondaTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
private static final String michiko = "Michiko Konda, Truth Seeker"; // 2/2
|
||||||
|
// Whenever a source an opponent controls deals damage to you, that player sacrifices a permanent.
|
||||||
|
private static final String pinger = "Cunning Sparkmage"; // 0/1
|
||||||
|
private static final String pingAbility = "{T}: {this} deals 1 damage to any target";
|
||||||
|
private static final String devil = "Mayhem Devil"; // 3/3
|
||||||
|
// Whenever a player sacrifices a permanent, Mayhem Devil deals 1 damage to any target.
|
||||||
|
private static final String elves = "Elves of Deep Shadow";
|
||||||
|
private static final String manaAbility = "{T}: Add {B}. {this} deals 1 damage to you.";
|
||||||
|
private static final String zombie = "Walking Corpse"; // vanilla 2/2
|
||||||
|
private static final String vampire = "Barony Vampire"; // vanilla 3/2
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOppDealsToYou() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, michiko);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, devil);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, zombie);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, vampire);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, pinger);
|
||||||
|
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, pingAbility, playerA);
|
||||||
|
setChoice(playerB, vampire); // to sacrifice
|
||||||
|
addTarget(playerA, devil); // resulting ping
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertLife(playerA, 19);
|
||||||
|
assertLife(playerB, 20);
|
||||||
|
assertPermanentCount(playerA, 3);
|
||||||
|
assertPermanentCount(playerB, 1);
|
||||||
|
assertGraveyardCount(playerB, 1);
|
||||||
|
assertPermanentCount(playerA, michiko, 1);
|
||||||
|
assertDamageReceived(playerA, devil, 1);
|
||||||
|
assertGraveyardCount(playerB, vampire, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOppDealsToYours() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, michiko);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, devil);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, zombie);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, vampire);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, pinger);
|
||||||
|
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, pingAbility, zombie);
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertLife(playerA, 20);
|
||||||
|
assertLife(playerB, 20);
|
||||||
|
assertPermanentCount(playerA, 3);
|
||||||
|
assertPermanentCount(playerB, 2);
|
||||||
|
assertPermanentCount(playerA, michiko, 1);
|
||||||
|
assertDamageReceived(playerA, zombie, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testYouDealToYourself() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, michiko);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, devil);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, zombie);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, vampire);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, elves);
|
||||||
|
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, manaAbility);
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertLife(playerA, 19);
|
||||||
|
assertLife(playerB, 20);
|
||||||
|
assertPermanentCount(playerA, 4);
|
||||||
|
assertPermanentCount(playerB, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,8 @@ import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xenohedron
|
* @author xenohedron
|
||||||
*/
|
*/
|
||||||
|
|
@ -59,9 +61,13 @@ public class SourceDealsDamageToYouTriggeredAbility extends TriggeredAbilityImpl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
|
UUID sourceControllerId = game.getControllerId(event.getSourceId());
|
||||||
|
if (sourceControllerId == null || !game.getOpponents(getControllerId()).contains(sourceControllerId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
switch (event.getType()) {
|
switch (event.getType()) {
|
||||||
case DAMAGED_PLAYER:
|
case DAMAGED_PLAYER:
|
||||||
if (!this.isControlledBy(event.getTargetId())) {
|
if (!event.getTargetId().equals(this.getControllerId())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -85,7 +91,7 @@ public class SourceDealsDamageToYouTriggeredAbility extends TriggeredAbilityImpl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.getAllEffects().setValue("damage", damageAmount);
|
this.getAllEffects().setValue("damage", damageAmount);
|
||||||
this.getAllEffects().setTargetPointer(new FixedTarget(game.getControllerId(event.getSourceId())));
|
this.getAllEffects().setTargetPointer(new FixedTarget(sourceControllerId));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue