Merge branch 'master' of https://github.com/magefree/mage.git into MorphRework_v2

# Conflicts:
#	Mage.Sets/src/mage/cards/b/Banefire.java
This commit is contained in:
Steven Knipe 2023-10-01 22:59:27 -07:00
commit 26af2602e4
484 changed files with 6960 additions and 5629 deletions

View file

@ -1,6 +1,6 @@
package org.mage.test.cards.copy;
import mage.abilities.common.SourceBecomesTargetTriggeredAbility;
import mage.abilities.common.BecomesTargetSourceTriggeredAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.abilities.keyword.LifelinkAbility;
import mage.constants.PhaseStep;
@ -629,7 +629,7 @@ public class PhantasmalImageTest extends CardTestPlayerBase {
assertTrue("Phantasmal Image should not be a creature", !staffA.isCreature(currentGame));
assertTrue("Phantasmal Image should not be an Illusion", !staffA.hasSubtype(SubType.ILLUSION, currentGame));
assertTrue("Phantasmal Image should not be a Construct", !staffA.hasSubtype(SubType.CONSTRUCT, currentGame));
assertTrue("Phantasmal Image should have the sacrifice trigger", staffA.getAbilities(currentGame).containsClass(SourceBecomesTargetTriggeredAbility.class));
assertTrue("Phantasmal Image should have the sacrifice trigger", staffA.getAbilities(currentGame).containsClass(BecomesTargetSourceTriggeredAbility.class));
Permanent staffB = getPermanent("Chimeric Staff", playerB);
assertTrue("Chimeric Staff should be an artifact", staffB.isArtifact(currentGame));
@ -659,7 +659,7 @@ public class PhantasmalImageTest extends CardTestPlayerBase {
assertTrue("Phantasmal Image should be a Rogue", cloakA.hasSubtype(SubType.ROGUE, currentGame));
assertTrue("Phantasmal Image should be an Illusion", cloakA.hasSubtype(SubType.ILLUSION, currentGame));
assertTrue("Phantasmal Image should be an Equipment", cloakA.hasSubtype(SubType.EQUIPMENT, currentGame));
assertTrue("Phantasmal Image should have the sacrifice trigger", cloakA.getAbilities(currentGame).containsClass(SourceBecomesTargetTriggeredAbility.class));
assertTrue("Phantasmal Image should have the sacrifice trigger", cloakA.getAbilities(currentGame).containsClass(BecomesTargetSourceTriggeredAbility.class));
Permanent cloakB = getPermanent("Cloak and Dagger", playerB);
assertTrue("Cloak and Dagger should be an artifact", cloakB.isArtifact(currentGame));

View file

@ -0,0 +1,184 @@
package org.mage.test.cards.emblems;
import mage.cards.repository.CardRepository;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.command.emblems.EmblemOfCard;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author artemiswkearney
*/
public class EmblemOfCardTest extends CardTestPlayerBase {
@Test
public void testEmblemOfGriselbrand() {
// Flying, lifelink
// Pay 7 life: Draw seven cards.
addEmblem(playerA, new EmblemOfCard(
CardRepository.instance.findCard("Griselbrand", true).getMockCard()
));
setLife(playerA, 20);
assertHandCount(playerA, 0);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pay 7 life: Draw");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertHandCount(playerA, 7);
assertLife(playerA, 13);
assertEmblemCount(playerA, 1);
}
@Test
public void testEmblemOfYurlok() {
// Vigilance
// A player losing unspent mana causes that player to lose that much life.
// {1}, {T}: Each player adds {B}{R}{G}.
addEmblem(playerA, new EmblemOfCard(
CardRepository.instance.findCard("Yurlok of Scorch Thrash", true).getMockCard()
));
setLife(playerA, 20);
// {T}: Add {R}.
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
checkManaPool("after tapping Mountain", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 1);
checkPlayableAbility("can't tap emblem", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}, {T}:", false);
// wait for mana burn
setStopAt(1, PhaseStep.BEGIN_COMBAT);
checkLife("takes 1 point of mana burn", 1, PhaseStep.BEGIN_COMBAT, playerA, 19);
execute();
assertEmblemCount(playerA, 1);
}
@Test
public void testEmblemOfOmniscience() {
// You may cast spells from your hand without paying their mana costs.
addEmblem(playerA, new EmblemOfCard(
CardRepository.instance.findCard("Omniscience", true).getMockCard()
));
// Colossal Dreadmaw {4}{G}{G}
// Creature - Dinosaur 6/6
// Trample
addCard(Zone.HAND, playerA, "Colossal Dreadmaw");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Colossal Dreadmaw");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertPermanentCount(playerA, "Colossal Dreadmaw", 1);
assertEmblemCount(playerA, 1);
}
@Test
public void testEmblemOfParadoxEngine() {
// Whenever you cast a spell, untap all nonland permanents you control.
addEmblem(playerA, new EmblemOfCard(
CardRepository.instance.findCard("Paradox Engine", true).getMockCard()
));
// {T}: Add {G}.
addCard(Zone.BATTLEFIELD, playerA, "Mox Emerald");
// Sol Ring {1}
// Artifact
// {T}: Add {C}{C}.
addCard(Zone.HAND, playerA, "Sol Ring");
// Basalt Monolith {3}
// Artifact
// Basalt Monolith doesnt untap during your untap step.
// {T}: Add {C}{C}{C}.
// {3}: Untap Basalt Monolith.
addCard(Zone.HAND, playerA, "Basalt Monolith");
// Book of Rass {6}
// Artifact
// {2}, Pay 2 life: Draw a card.
// (just a dummy artifact to cast and spend the mana with)
addCard(Zone.HAND, playerA, "Book of Rass");
setLife(playerA, 20);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sol Ring");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Basalt Monolith");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Book of Rass");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}, Pay");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}, Pay");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}, Pay");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 14);
assertEmblemCount(playerA, 1);
}
@Test
public void testEmblemOfDoublingSeason() {
// If an effect would create one or more tokens under your control, it
// creates twice that many of those tokens instead.
// If an effect would put one or more counters on a permanent you
// control, it puts twice that many of those counters on that permanent instead.
addEmblem(playerA, new EmblemOfCard(
CardRepository.instance.findCard("Doubling Season", true).getMockCard()
));
// {T}: Add {W}.
addCard(Zone.BATTLEFIELD, playerA, "Plains", 6);
// Elspeth, Sun's Champion {4}{W}{W}
// Legendary Planeswalker Elspeth
// +1: Create three 1/1 white Soldier creature tokens.
// 3: Destroy all creatures with power 4 or greater.
// 7: You get an emblem with Creatures you control get +2/+2 and have flying.
// Loyalty: 4
addCard(Zone.HAND, playerA, "Elspeth, Sun's Champion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Elspeth, Sun's Champion");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPermanentCounters(
"Elspeth's loyalty is doubled",
1,
PhaseStep.PRECOMBAT_MAIN,
playerA,
"Elspeth, Sun's Champion",
CounterType.LOYALTY,
8
);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1: Create");
checkPlayableAbility("can't still activate Griselbrand", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pay 7 life:", false);
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPermanentCounters(
"+1 is not doubled",
1,
PhaseStep.PRECOMBAT_MAIN,
playerA,
"Elspeth, Sun's Champion",
CounterType.LOYALTY,
9
);
checkPermanentCount(
"Soldier tokens doubled",
1,
PhaseStep.PRECOMBAT_MAIN,
playerA,
"Soldier Token",
6
);
execute();
assertEmblemCount(playerA, 1);
}
}

View file

@ -0,0 +1,135 @@
package org.mage.test.cards.enchantments;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author xenohedron
*/
public class EnchantedPermanentLKITest extends CardTestPlayerBase {
// See issue #6326 and issue #11210
private static final String skyrider = "Skyrider Trainee"; // {4}{W} 3/3
// Skyrider Trainee has flying as long as it's enchanted.
private static final String golem = "Thran Golem"; // {5} 3/3
// As long as Thran Golem is enchanted, it gets +2/+2 and has flying, first strike, and trample.
private static final String rest = "Winter's Rest"; // {1}{U} Aura
// When Winter's Rest enters the battlefield, tap enchanted creature.
// As long as you control another snow permanent, enchanted creature doesn't untap during its controller's untap step.
private static final String bind = "Bind the Monster"; // {U} Aura
// When Bind the Monster enters the battlefield, tap enchanted creature. It deals damage to you equal to its power.
// Enchanted creature doesn't untap during its controller's untap step.
private static final String disperse = "Disperse"; // {1}{U} Instant
// Return target nonland permanent to its owner's hand.
private static final String apathy = "Dreadful Apathy"; // {2}{W} Aura
// Enchanted creature can't attack or block.
private static final String apathyAbility = "{2}{W}: Exile enchanted creature.";
private static final String flicker = "Flicker of Fate"; // {1}{W} Instant
// Exile target creature or enchantment, then return it to the battlefield under its owners control.
private static final String finesse = "Aura Finesse"; // {U} Instant
// Attach target Aura you control to target creature. Draw a card.
private static final String tundra = "Tundra"; // UW Dual land
@Test
public void testAuraRemoved() {
addCard(Zone.BATTLEFIELD, playerA, tundra, 4);
addCard(Zone.BATTLEFIELD, playerA, skyrider);
addCard(Zone.HAND, playerA, rest);
addCard(Zone.HAND, playerA, disperse);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, rest, skyrider);
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, 1);
checkAbility("Skyrider flying", 1, PhaseStep.PRECOMBAT_MAIN, playerA, skyrider, FlyingAbility.class, true);
// Creature enchanted, but trigger on stack
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, disperse, rest);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, disperse, 1);
assertTapped(skyrider, true);
assertHandCount(playerA, rest, 1);
}
@Test
public void testAuraRemovedDamaging() {
addCard(Zone.BATTLEFIELD, playerA, tundra, 3);
addCard(Zone.BATTLEFIELD, playerA, skyrider);
addCard(Zone.HAND, playerA, bind);
addCard(Zone.HAND, playerA, disperse);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bind, skyrider);
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, 1);
checkAbility("Skyrider flying", 1, PhaseStep.PRECOMBAT_MAIN, playerA, skyrider, FlyingAbility.class, true);
// Creature enchanted, but trigger on stack
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, disperse, bind);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, disperse, 1);
assertTapped(skyrider, true);
assertHandCount(playerA, bind, 1);
assertLife(playerA, 17);
}
@Test
public void testAuraFlickered() {
addCard(Zone.BATTLEFIELD, playerA, tundra, 8);
addCard(Zone.BATTLEFIELD, playerA, skyrider);
addCard(Zone.BATTLEFIELD, playerA, golem);
addCard(Zone.HAND, playerA, apathy);
addCard(Zone.HAND, playerA, flicker);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, apathy, skyrider);
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkAbility("Skyrider flying", 1, PhaseStep.PRECOMBAT_MAIN, playerA, skyrider, FlyingAbility.class, true);
activateAbility(1, PhaseStep.BEGIN_COMBAT, playerA, apathyAbility);
// In response:
castSpell(1, PhaseStep.BEGIN_COMBAT, playerA, flicker, apathy);
setChoice(playerA, golem); // when aura returns, choose what to enchant
// Skyrider should be exiled by the ability resolving (LKI of Dreadful Apathy enchanted creature)
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, flicker, 1);
assertExileCount(skyrider, 1);
assertAbility(playerA, golem, TrampleAbility.getInstance(), true); // now enchanted
}
@Test
public void testAuraMoved() {
addCard(Zone.BATTLEFIELD, playerA, tundra, 7);
addCard(Zone.BATTLEFIELD, playerA, skyrider);
addCard(Zone.BATTLEFIELD, playerA, golem);
addCard(Zone.HAND, playerA, apathy);
addCard(Zone.HAND, playerA, finesse);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, apathy, skyrider);
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkAbility("Skyrider flying", 1, PhaseStep.PRECOMBAT_MAIN, playerA, skyrider, FlyingAbility.class, true);
activateAbility(1, PhaseStep.BEGIN_COMBAT, playerA, apathyAbility);
// In response:
castSpell(1, PhaseStep.BEGIN_COMBAT, playerA, finesse, apathy);
addTarget(playerA, golem); // second target
// Golem should be exiled by the ability resolving (same zcc Dreadful Apathy)
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, finesse, 1);
assertExileCount(golem, 1);
assertAbility(playerA, skyrider, FlyingAbility.getInstance(), false); // no longer enchanted
}
}

View file

@ -50,4 +50,30 @@ public class NamePredicateTest extends CardTestPlayerBase {
assertNamePredicate("by inner - non existing name must return zero", 0, "Island", true);
assertNamePredicate("by inner - existing name must work", 3, "Forest", true);
}
@Test
public void testCityInABottle() {
String bottle = "City in a Bottle"; // Artifact {2}
// Whenever one or more other nontoken permanents with a name originally printed in the Arabian Nights expansion
// are on the battlefield, their controllers sacrifice them.
// Players cant cast spells or play lands with a name originally printed in the Arabian Nights expansion.
String nomads = "Desert Nomads"; // Creature {2}{R} (originally printed in Arabian Nights)
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5); // printed in Arabian Nights, but first printed in Alpha
addCard(Zone.BATTLEFIELD, playerA, "Camel"); // originally printed in Arabian Nights
addCard(Zone.HAND, playerA, bottle);
addCard(Zone.HAND, playerA, nomads);
checkPlayableAbility("Nomads, unbottled", 1, PhaseStep.PRECOMBAT_MAIN , playerA, "Cast Desert Nomads", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bottle);
checkGraveyardCount("Camel sacrificed" , 1, PhaseStep.BEGIN_COMBAT, playerA, "Camel", 1);
checkPlayableAbility("Nomads, bottled", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cast Desert Nomads", false);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerA, 1);
assertPermanentCount(playerA, bottle, 1);
assertPermanentCount(playerA, "Mountain", 5);
}
}

View file

@ -0,0 +1,39 @@
package org.mage.test.cards.single.c17;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author xenohedron
*/
public class ScalelordReckonerTest extends CardTestPlayerBase {
private static final String scalelord = "Scalelord Reckoner"; // 4/4 Flying
// Whenever a Dragon you control becomes the target of a spell or ability an opponent controls,
// destroy target nonland permanent that player controls.
@Test
public void testScalelordReckoner() {
String machete = "Trusty Machete"; // a nonland permanent to destroy
String shock = "Shock"; // a spell to target with
addCard(Zone.BATTLEFIELD, playerA, scalelord);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
addCard(Zone.BATTLEFIELD, playerB, machete, 1);
addCard(Zone.HAND, playerB, shock, 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, shock, scalelord);
addTarget(playerA, machete);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_COMBAT);
execute();
assertDamageReceived(playerA, scalelord, 2);
assertGraveyardCount(playerB, machete, 1);
}
}

View file

@ -0,0 +1,119 @@
package org.mage.test.cards.single.dmu;
import mage.abilities.keyword.DeathtouchAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.player.TestPlayer;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author xenohedron
*/
public class DanithaBenaliasHopeTest extends CardTestPlayerBase {
private static final String danitha = "Danitha, Benalia's Hope"; // {4}{W} 4/4 First strike, vigilance, lifelink
// When Danitha, Benalia's Hope enters the battlefield, you may put an Aura or Equipment card
// from your hand or graveyard onto the battlefield attached to Danitha.
private static final String wings = "Nimbus Wings"; // Enchanted creature gets +1/+2 and has flying.
private static final String flail = "Gorgon Flail"; // Equipped creature gets +1/+1 and has deathtouch.
private static final String swords = "Swords to Plowshares"; // Exile target creature. Its controller gains life equal to its power.
@Test
public void testAuraFromGraveyard() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
addCard(Zone.GRAVEYARD, playerA, wings);
addCard(Zone.HAND, playerA, danitha);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, danitha);
setChoice(playerA, true); // use ability
setChoice(playerA, wings);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, danitha, 5, 6);
assertAbility(playerA, danitha, FlyingAbility.getInstance(), true);
}
@Test
public void testNothingToAttach() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
addCard(Zone.HAND, playerA, danitha);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, danitha);
setChoice(playerA, true); // attempt to use ability
setChoice(playerA, TestPlayer.CHOICE_SKIP);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, danitha, 4, 4);
}
@Test
public void testEquipmentFromHand() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
addCard(Zone.HAND, playerA, flail);
addCard(Zone.HAND, playerA, danitha);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, danitha);
setChoice(playerA, true); // use ability
setChoice(playerA, flail);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, danitha, 5, 5);
assertAbility(playerA, danitha, DeathtouchAbility.getInstance(), true);
}
@Test
public void testEquipmentFromHandButExiled() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 6);
addCard(Zone.HAND, playerA, flail);
addCard(Zone.HAND, playerA, danitha);
addCard(Zone.HAND, playerA, swords);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, danitha);
setChoice(playerA, true); // use ability
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, swords, danitha);
setChoice(playerA, flail);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, flail, 1);
assertExileCount(playerA, danitha, 1);
assertLife(playerA, 24);
}
@Test
public void testAuraFromGraveyardButExiled() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 6);
addCard(Zone.GRAVEYARD, playerA, wings);
addCard(Zone.HAND, playerA, danitha);
addCard(Zone.HAND, playerA, swords);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, danitha);
setChoice(playerA, true); // use ability
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, swords, danitha);
setChoice(playerA, TestPlayer.CHOICE_SKIP); // no longer can attach Aura
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerA, wings, 1);
assertExileCount(playerA, danitha, 1);
assertLife(playerA, 24);
}
}

View file

@ -0,0 +1,70 @@
package org.mage.test.cards.single.j22;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author xenohedron
*/
public class AgrusKosEternalSoldierTest extends CardTestPlayerBase {
private static final String agrus = "Agrus Kos, Eternal Soldier"; // 3/4 Vigilance
// Whenever Agrus Kos, Eternal Soldier becomes the target of an ability that targets only it, you may pay {1}{R/W}.
// If you do, copy that ability for each other creature you control that ability could target. Each copy targets a different one of those creatures.
private static final String sparkmage = "Cunning Sparkmage"; // 0/1 Haste pinger
private static final String turtle = "Horned Turtle"; // 1/4
private static final String firewalker = "Kor Firewalker"; // 2/2 protection from red
// Whenever a player casts a red spell, you may gain 1 life.
@Test
public void testTriggerCopiesAbility() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, agrus);
addCard(Zone.BATTLEFIELD, playerA, turtle);
addCard(Zone.BATTLEFIELD, playerA, firewalker);
addCard(Zone.BATTLEFIELD, playerB, sparkmage);
addCard(Zone.BATTLEFIELD, playerA, "Plateau", 2);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{T}: {this} deals", agrus);
setChoice(playerA, true); // pay to copy
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertTapped(sparkmage, true);
assertTappedCount("Plateau", true, 2);
assertDamageReceived(playerA, agrus, 1);
assertDamageReceived(playerA, turtle, 1);
assertDamageReceived(playerA, firewalker, 0);
assertLife(playerA, 20);
assertLife(playerB, 20);
}
@Test
public void testTriggerDoesntCopySpell() {
setStrictChooseMode(true);
String shock = "Shock";
addCard(Zone.BATTLEFIELD, playerA, agrus);
addCard(Zone.BATTLEFIELD, playerA, turtle);
addCard(Zone.BATTLEFIELD, playerA, firewalker);
addCard(Zone.HAND, playerB, shock);
addCard(Zone.BATTLEFIELD, playerB, "Plateau");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, shock, agrus);
setChoice(playerA, true); // gain 1 life
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertDamageReceived(playerA, agrus, 2);
assertDamageReceived(playerA, turtle, 0);
assertDamageReceived(playerA, firewalker, 0);
assertLife(playerA, 21);
assertLife(playerB, 20);
}
}

View file

@ -14,10 +14,11 @@ public class BrineComberTest extends CardTestPlayerBase {
* Brine Comber
* {1}{W}{U}
* Creature Spirit
*
* Whenever Brine Comber enters the battlefield or becomes the target of an Aura spell, create a 1/1 white Spirit creature token with flying.
*
* Disturb {W}{U} (You may cast this card from your graveyard transformed for its disturb cost.)
* Brinebound Gift
* Enchant creature
* Whenever Brinebound Gift enters the battlefield or enchanted creature becomes the target of an Aura spell, create a 1/1 white Spirit creature token with flying.
*/
private static final String comber = "Brine Comber";
@ -74,4 +75,26 @@ public class BrineComberTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Hopeful Eidolon", 1);
assertPowerToughness(playerA, comber, 1+1, 1+1);
}
@Test
public void testDisturbSideTrigger() {
setStrictChooseMode(true);
String hatchling = "Kraken Hatchling"; // 0/4
String umbra = "Hyena Umbra"; // Aura - gives +1/+1 and first strike
addCard(Zone.BATTLEFIELD, playerA, hatchling);
addCard(Zone.BATTLEFIELD, playerA, "Tundra", 3);
addCard(Zone.GRAVEYARD, playerA, comber);
addCard(Zone.HAND, playerA, umbra);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Brinebound Gift using Disturb", hatchling);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, umbra, hatchling);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, "Spirit Token", 2); // one from enter, one from target of next Aura
assertPermanentCount(playerA, "Brinebound Gift", 1);
assertPowerToughness(playerA, hatchling, 1, 5);
}
}

View file

@ -0,0 +1,457 @@
package org.mage.test.cards.triggers;
import mage.abilities.keyword.FlyingAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.Filter;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class BecomesTargetTriggerTest extends CardTestPlayerBase {
@Test
public void testAshenmoorLiege() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
addCard(Zone.HAND, playerA, "Claustrophobia"); // {1}{U}{U}
// Other black creatures you control get +1/+1.
// Other red creatures you control get +1/+1.
// Whenever Ashenmoor Liege becomes the target of a spell or ability an opponent controls, that player loses 4 life.
addCard(Zone.BATTLEFIELD, playerB, "Ashenmoor Liege", 1); // 4/1
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Claustrophobia", "Ashenmoor Liege");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 16);
assertPermanentCount(playerA, "Claustrophobia", 1);
assertPowerToughness(playerB, "Ashenmoor Liege", 4, 1);
}
@Test
public void testVeneratedRotpriest() {
String rotpriest = "Venerated Rotpriest"; // 1/2
// Whenever a creature you control becomes the target of a spell, target opponent gets a poison counter.
String growth = "Giant Growth";
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
addCard(Zone.BATTLEFIELD, playerA, rotpriest);
addCard(Zone.HAND, playerA, growth);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, growth, rotpriest);
addTarget(playerA, playerB); // to get a poison counter
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertCounterCount(playerB, CounterType.POISON, 1);
assertPowerToughness(playerA, rotpriest, 4, 5);
}
private static final String gKeeper = "Glyph Keeper"; // 5/3 Flying
// Whenever this creature becomes the target of a spell or ability for the first time in a turn, counter that spell or ability.
private static final String bolt = "Lightning Bolt";
@Test
public void testGlyphKeeperCountersFirstSpell() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.HAND, playerA, bolt);
addCard(Zone.BATTLEFIELD, playerB, gKeeper);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, gKeeper);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, bolt, 1);
assertPermanentCount(playerB, gKeeper, 1);
}
@Test
public void testGlyphKeeperCountersFirstSpellEachTurn() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
addCard(Zone.HAND, playerA, bolt, 2);
addCard(Zone.BATTLEFIELD, playerB, gKeeper);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, gKeeper);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, gKeeper);
setStrictChooseMode(true);
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, bolt, 2);
assertPermanentCount(playerB, gKeeper, 1);
}
@Test
public void testGlyphKeeperCountersFirstSpellButNotSecondSpell() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
addCard(Zone.HAND, playerA, bolt, 2);
addCard(Zone.BATTLEFIELD, playerB, gKeeper);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, gKeeper);
castSpell(1, PhaseStep.BEGIN_COMBAT, playerA, bolt, gKeeper);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.DECLARE_ATTACKERS);
execute();
assertGraveyardCount(playerA, bolt, 2);
assertPermanentCount(playerB, gKeeper, 0);
}
@Test
public void testGlyphKeeperCountersFirstAbilityButNotSecondOne() {
/*
Soulstinger {3}{B}
Creature - Scorpion Demon 4/5
When Soulstinger enters the battlefield, put two -1/-1 counter on target creature you control.
When Soulstinger dies, you may put a -1/-1 counter on target creature for each -1/-1 counter on Soulstinger.
*/
String sStinger = "Soulstinger";
/*
Cartouche of Strength {2}{G}
Enchantment - Aura Cartouche
Enchant creature you control
When Cartouche of Strength enters the battlefield, you may have enchanted creature fight target creature an opponent controls.
Enchanted creature gets +1/+1 and has trample.
*/
String cStrength = "Cartouche of Strength";
String memnite = "Memnite"; // {0} 1/1
addCard(Zone.BATTLEFIELD, playerA, gKeeper);
addCard(Zone.HAND, playerA, sStinger);
addCard(Zone.HAND, playerA, cStrength);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 6);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 6);
addCard(Zone.BATTLEFIELD, playerB, memnite);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, sStinger);
addTarget(playerA, gKeeper); // should be countered by Glyph Keeper clause as first ability targetting it
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, cStrength, gKeeper); // should not be countered anymore
setChoice(playerA, true);
addTarget(playerA, memnite); // Cartouche of Strength fight
setStopAt(1, PhaseStep.BEGIN_COMBAT);
setStrictChooseMode(true);
execute();
assertPermanentCount(playerA, gKeeper, 1);
assertGraveyardCount(playerA, sStinger, 0); // countered
assertGraveyardCount(playerA, cStrength, 0); // should not be countered
assertPermanentCount(playerA, cStrength, 1);
assertGraveyardCount(playerB, memnite, 1); // dies from fight
assertPowerToughness(playerA, gKeeper, 6, 4, Filter.ComparisonScope.All);
// Soul Stinger should never have given it two -1/-1 counters
// And Cartouche of Strength gives +1/+1
assertCounterCount(playerA, gKeeper, CounterType.M1M1, 0);
}
@Test
public void testDiffusionSliver() {
String diffusion = "Diffusion Sliver"; // 1/1 Sliver
// Whenever a Sliver creature you control becomes the target of a spell or ability an opponent controls,
// counter that spell or ability unless its controller pays {2}.
String metallic = "Metallic Sliver"; // 1/1 Sliver
addCard(Zone.BATTLEFIELD, playerA, diffusion);
addCard(Zone.BATTLEFIELD, playerA, metallic);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
addCard(Zone.HAND, playerB, bolt, 1);
addCard(Zone.BATTLEFIELD, playerB, "Cunning Sparkmage", 1); // 0/1 Haste
// {T}: Cunning Sparkmage deals 1 damage to any target.
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, bolt, metallic);
setChoice(playerB, false); // choose not to pay
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "{T}: {this} deals", diffusion);
setChoice(playerB, false); // choose not to pay
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerB, bolt, 1);
assertTapped("Cunning Sparkmage", true);
assertPermanentCount(playerA, diffusion, 1);
assertPermanentCount(playerA, metallic, 1);
}
@Test
public void testThunderbreakRegent() {
String dragon = "Thunderbreak Regent"; // 4/4
// Whenever a Dragon you control becomes the target of a spell or ability an opponent controls, Thunderbreak Regent deals 3 damage to that player.
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
addCard(Zone.BATTLEFIELD, playerA, dragon);
addCard(Zone.HAND, playerB, bolt);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, bolt, dragon);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertDamageReceived(playerA, dragon, 3);
assertLife(playerB, 17);
}
@Test
public void testCloudCover() {
String cloud = "Cloud Cover"; // Enchantment
// Whenever another permanent you control becomes the target of a spell or ability an opponent controls,
// you may return that permanent to its owners hand.
String myr = "Omega Myr"; // 1/2
addCard(Zone.BATTLEFIELD, playerB, "Cunning Sparkmage");
addCard(Zone.BATTLEFIELD, playerA, cloud);
addCard(Zone.BATTLEFIELD, playerA, myr);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{T}: {this} deals", myr);
setChoice(playerA, true); // return to hand
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, myr, 1);
assertTapped("Cunning Sparkmage", true);
}
@Test
public void testIllusionaryArmor() {
String armor = "Illusionary Armor"; // Enchantment - Aura {4}{U}
// Enchant creature
// Enchanted creature gets +4/+4.
// When enchanted creature becomes the target of a spell or ability, sacrifice Illusionary Armor.
String beast = "Axebane Beast"; // 3/4
addCard(Zone.BATTLEFIELD, playerA, beast);
addCard(Zone.BATTLEFIELD, playerA, "Island", 5);
addCard(Zone.HAND, playerA, armor);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
addCard(Zone.HAND, playerB, bolt);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, armor, beast);
checkPT("Boosted", 1, PhaseStep.BEGIN_COMBAT, playerA, beast, 7, 8);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, bolt, beast);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerA, armor, 1);
assertPowerToughness(playerA, beast, 3, 4);
assertDamageReceived(playerA, beast, 3);
}
@Test
public void testFracturedLoyalty() {
String hatchling = "Kraken Hatchling"; // 0/4
String aura = "Fractured Loyalty"; // Enchantment - Aura {1}{R}
// Whenever enchanted creature becomes the target of a spell or ability,
// that spell or ability's controller gains control of that creature. (This effect lasts indefinitely.)
addCard(Zone.BATTLEFIELD, playerA, hatchling);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
addCard(Zone.HAND, playerA, aura);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
addCard(Zone.HAND, playerB, bolt);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, aura, hatchling);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, bolt, hatchling);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerB, bolt, 1);
assertPermanentCount(playerA, hatchling, 0);
assertDamageReceived(playerB, hatchling, 3);
}
@Test
public void testDormantGomazoa() {
String gomazoa = "Dormant Gomazoa"; // 5/5 Flying {1}{U}{U}
// Dormant Gomazoa enters the battlefield tapped.
// Dormant Gomazoa doesn't untap during your untap step.
// Whenever you become the target of a spell, you may untap Dormant Gomazoa.
addCard(Zone.HAND, playerA, gomazoa);
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
addCard(Zone.HAND, playerB, bolt);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, gomazoa);
checkPermanentTapped("Enters tapped", 1, PhaseStep.BEGIN_COMBAT, playerA, gomazoa, true, 1);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, bolt, playerA);
setChoice(playerA, true); // choose to untap
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerB, bolt, 1);
assertTapped(gomazoa, false);
assertLife(playerA, 17);
}
private static final String mammoth = "Battle Mammoth"; // 6/5 Trample
// Whenever a permanent you control becomes the target of a spell or ability an opponent controls, you may draw a card.
private static final String bear = "Runeclaw Bear"; // 2/2
private static final String cBond = "Common Bond"; // 1GW Instant
// Put a +1/+1 counter on target creature. Put a +1/+1 counter on target creature.
@Test
public void testBattleMammothSeparateTargets() {
addCard(Zone.BATTLEFIELD, playerA, mammoth);
addCard(Zone.BATTLEFIELD, playerA, bear);
addCard(Zone.BATTLEFIELD, playerB, "Savannah", 3);
addCard(Zone.HAND, playerB, cBond);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, cBond, mammoth+"^"+bear);
setChoice(playerA, "Whenever"); // order two triggers
setChoice(playerA, true); // draw a card
setChoice(playerA, true); // draw a card
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerB, cBond, 1);
assertPowerToughness(playerA, mammoth, 7, 6);
assertPowerToughness(playerA, bear, 3, 3);
assertHandCount(playerA, 2);
}
@Test
public void testBattleMammothSameTarget() {
addCard(Zone.BATTLEFIELD, playerA, mammoth);
addCard(Zone.BATTLEFIELD, playerA, bear);
addCard(Zone.BATTLEFIELD, playerB, "Savannah", 3);
addCard(Zone.HAND, playerB, cBond);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, cBond, bear+"^"+bear);
// Should be only one trigger here
setChoice(playerA, true); // draw a card
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerB, cBond, 1);
assertPowerToughness(playerA, bear, 4, 4);
assertHandCount(playerA, 1);
}
@Test
public void testBattleMammothRepeatAbility() {
addCard(Zone.BATTLEFIELD, playerA, mammoth);
addCard(Zone.BATTLEFIELD, playerA, bear);
addCard(Zone.BATTLEFIELD, playerB, "Forest", 8);
addCard(Zone.BATTLEFIELD, playerB, "Shapers of Nature"); // 3/3
// {3}{G}: Put a +1/+1 counter on target creature.
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{3}{G}: Put", bear);
setChoice(playerA, true); // draw a card
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{3}{G}: Put", bear);
setChoice(playerA, true); // draw a card
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPowerToughness(playerA, bear, 4, 4);
assertHandCount(playerA, 2);
}
@Test
public void testAngelicCubDoubleTarget() {
String cub = "Angelic Cub"; // 1/1
// Whenever Angelic Cub becomes the target of a spell or ability for the first time each turn, put a +1/+1 counter on it.
// As long as Angelic Cub has three or more +1/+1 counters on it, it has flying.
addCard(Zone.BATTLEFIELD, playerA, cub);
addCard(Zone.BATTLEFIELD, playerA, "Savannah", 3);
addCard(Zone.HAND, playerA, cBond);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, cBond, cub+"^"+cub);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPowerToughness(playerA, cub, 4, 4);
assertAbility(playerA, cub, FlyingAbility.getInstance(), true);
}
@Test
public void testUnsettledMarinerFieldOfRuin() {
// Reported bug: #10530
String mariner = "Unsettled Mariner"; // 2/2
// Whenever you or a permanent you control becomes the target of a spell or ability an opponent controls,
// counter that spell or ability unless its controller pays {1}.
String ruin = "Field of Ruin"; // 2/2
// {2}, {T}, Sacrifice Field of Ruin: Destroy target nonbasic land an opponent controls.
// Each player searches their library for a basic land card, puts it onto the battlefield, then shuffles.
addCard(Zone.BATTLEFIELD, playerA, mariner);
addCard(Zone.BATTLEFIELD, playerA, "Evolving Wilds");
addCard(Zone.BATTLEFIELD, playerB, ruin);
addCard(Zone.BATTLEFIELD, playerB, "Wastes", 2);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{2}, {T}, Sacrifice");
addTarget(playerB, "Evolving Wilds");
setChoice(playerB, false); // choose not to pay
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, 0);
assertGraveyardCount(playerB, ruin, 1);
}
@Test
public void testCounterAbilitySacrificedSource() {
// related to #10530, but this one works fine regardless...
String mariner = "Unsettled Mariner"; // 2/2
// Whenever you or a permanent you control becomes the target of a spell or ability an opponent controls,
// counter that spell or ability unless its controller pays {1}.
String felidar = "Felidar Cub"; // 2/2
// Sacrifice Felidar Cub: Destroy target enchantment.
String anthem = "Glorious Anthem"; // Creatures you control get +1/+1.
addCard(Zone.BATTLEFIELD, playerA, mariner);
addCard(Zone.BATTLEFIELD, playerA, anthem);
addCard(Zone.BATTLEFIELD, playerB, felidar);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Sacrifice");
addTarget(playerB, anthem);
setChoice(playerB, false); // choose not to pay
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerB, felidar, 1);
assertPowerToughness(playerA, mariner, 3, 3);
}
}

View file

@ -1,183 +0,0 @@
package org.mage.test.cards.triggers;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.Filter;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class TargetedTriggeredTest extends CardTestPlayerBase {
/**
* Tests that the first spell that targets Kira, Great Glass-Spinner is
* countered.
*
*/
@Test
// this does not currently work in test (????), because the target event will be fired earlier during tests,
// so the zone change counter for the fixed target of the counterspell will not work
// UPDATE: seems to work fine now? 04/19/2017 escplan9
public void testKiraGreatGlassSpinnerFirstSpellTurn() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.HAND, playerA, "Lightning Bolt");
addCard(Zone.BATTLEFIELD, playerB, "Kira, Great Glass-Spinner", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Kira, Great Glass-Spinner");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertPermanentCount(playerB, "Kira, Great Glass-Spinner", 1);
}
/**
* With Ashenmoor Liege on the battlefield, my opponent casts Claustrophobia
* on it without losing 4hp.
*/
@Test
public void testAshenmoorLiege() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
addCard(Zone.HAND, playerA, "Claustrophobia"); // {1}{U}{U}
// Other black creatures you control get +1/+1.
// Other red creatures you control get +1/+1.
// Whenever Ashenmoor Liege becomes the target of a spell or ability an opponent controls, that player loses 4 life.
addCard(Zone.BATTLEFIELD, playerB, "Ashenmoor Liege", 1); // 4/1
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Claustrophobia", "Ashenmoor Liege");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 16);
assertPermanentCount(playerA, "Claustrophobia", 1);
assertPowerToughness(playerB, "Ashenmoor Liege", 4, 1);
}
@Test
public void testGlyphKeeperCountersFirstSpell() {
/*
Glyph Keeper {3}{U}{U}
Creature - Sphinx
Flying 5/3
Whenever this creature becomes the target of a spell or ability for the first time in a turn, counter that spell or ability."
*/
String gKeeper = "Glyph Keeper";
String bolt = "Lightning Bolt"; // {R} instant deal 3 dmg
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.HAND, playerA, bolt);
addCard(Zone.BATTLEFIELD, playerB, gKeeper);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, gKeeper);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, bolt, 1);
assertPermanentCount(playerB, gKeeper, 1);
}
@Test
public void testGlyphKeeperCountersFirstSpellButNotSecondSpell() {
/*
Glyph Keeper {3}{U}{U}
Creature - Sphinx
Flying 5/3
Whenever this creature becomes the target of a spell or ability for the first time in a turn, counter that spell or ability."
*/
String gKeeper = "Glyph Keeper";
String bolt = "Lightning Bolt"; // {R} instant deal 3 dmg
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
addCard(Zone.HAND, playerA, bolt, 2);
addCard(Zone.BATTLEFIELD, playerB, gKeeper);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, gKeeper);
castSpell(1, PhaseStep.BEGIN_COMBAT, playerA, bolt, gKeeper);
setStopAt(1, PhaseStep.DECLARE_ATTACKERS);
execute();
assertGraveyardCount(playerA, bolt, 2);
assertPermanentCount(playerB, gKeeper, 0);
}
/*
NOTE: test was failing due to card bug, resolved as of 04/20/2017. See issue #3180
I had a Glyph Keeper on board (cloned with Vizier of many faces). -- note this test is a simplified version, next test will test on the Clone if needed
First I played a Soulstinger and targeted the Glyph Keeper, the ability was countered. Then on the same main phase I played a Cartouche of Strength targeting the Glyph Keeper, that was also countered.
Only the first should have been countered.
*/
@Test
public void testGlyphKeeperCountersFirstAbilityButNotSecondOne() {
/*
Glyph Keeper {3}{U}{U}
Creature - Sphinx
Flying 5/3
Whenever this creature becomes the target of a spell or ability for the first time in a turn, counter that spell or ability."
*/
String gKeeper = "Glyph Keeper";
/*
Soulstinger {3}{B}
Creature - Scorpion Demon 4/5
When Soulstinger enters the battlefield, put two -1/-1 counter on target creature you control.
When Soulstinger dies, you may put a -1/-1 counter on target creature for each -1/-1 counter on Soulstinger.
*/
String sStinger = "Soulstinger";
/*
Cartouche of Strength {2}{G}
Enchantment - Aura Cartouche
Enchant creature you control
When Cartouche of Strength enters the battlefield, you may have enchanted creature fight target creature an opponent controls.
Enchanted creature gets +1/+1 and has trample.
*/
String cStrength = "Cartouche of Strength";
String memnite = "Memnite"; // {0} 1/1
addCard(Zone.BATTLEFIELD, playerA, gKeeper);
addCard(Zone.HAND, playerA, sStinger);
addCard(Zone.HAND, playerA, cStrength);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 6);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 6);
addCard(Zone.BATTLEFIELD, playerB, memnite);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, sStinger);
addTarget(playerA, gKeeper); // should be countered by Glyph Keeper clause as first ability targetting it
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, cStrength, gKeeper); // should not be countered anymore
setChoice(playerA, true);
addTarget(playerA, memnite); // Cartouche of Strength fight
setStopAt(1, PhaseStep.BEGIN_COMBAT);
setStrictChooseMode(true);
execute();
assertPermanentCount(playerA, gKeeper, 1);
assertGraveyardCount(playerA, sStinger, 0); // countered
assertGraveyardCount(playerA, cStrength, 0); // should not be countered
assertPermanentCount(playerA, cStrength, 1);
assertGraveyardCount(playerB, memnite, 1); // dies from fight
assertPowerToughness(playerA, gKeeper, 6, 4, Filter.ComparisonScope.All); // Soul Stinger should never have given it two -1/-1 counters
//And Cartouche of Strength gives +1/+1
assertCounterCount(playerA, gKeeper, CounterType.M1M1, 0);
}
}

View file

@ -17,17 +17,19 @@ public class KiraGreatGlassSpinnerTest extends CardTestPlayerBase {
Flying
Creatures you control have "Whenever this creature becomes the target of a spell or ability for the first time each turn, counter that spell or ability."
*/
private final String kira = "Kira, Great Glass-Spinner";
private final String ugin = "Ugin, the Spirit Dragon";
private static final String kira = "Kira, Great Glass-Spinner";
private static final String ugin = "Ugin, the Spirit Dragon";
private static final String bolt = "Lightning Bolt";
@Test
public void counterFirst() {
addCard(Zone.BATTLEFIELD, playerA, ugin); // starts with 7 Loyality counters
addCard(Zone.BATTLEFIELD, playerA, ugin); // starts with 7 Loyalty counters
addCard(Zone.BATTLEFIELD, playerA, kira);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+2: {this} deals 3 damage", kira); // Ugin ability
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
@ -38,8 +40,7 @@ public class KiraGreatGlassSpinnerTest extends CardTestPlayerBase {
@Test
public void counterFirstResolveSecond() {
String ugin = "Ugin, the Spirit Dragon";
addCard(Zone.BATTLEFIELD, playerA, ugin); // starts with 7 Loyality counters
addCard(Zone.BATTLEFIELD, playerA, ugin); // starts with 7 Loyalty counters
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
addCard(Zone.HAND, playerA, "Unsummon", 1);
@ -48,6 +49,7 @@ public class KiraGreatGlassSpinnerTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Unsummon", kira);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
@ -59,12 +61,13 @@ public class KiraGreatGlassSpinnerTest extends CardTestPlayerBase {
@Test
public void counterFirstThisTurn_counterFirstOnNextTurn() {
addCard(Zone.BATTLEFIELD, playerA, ugin); // starts with 7 Loyality counters
addCard(Zone.BATTLEFIELD, playerA, ugin); // starts with 7 Loyalty counters
addCard(Zone.BATTLEFIELD, playerA, kira);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+2: {this} deals 3 damage to", kira); // Ugin ability
activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "+2: {this} deals 3 damage to", kira); // Ugin ability
setStrictChooseMode(true);
setStopAt(3, PhaseStep.END_TURN);
execute();
@ -72,4 +75,105 @@ public class KiraGreatGlassSpinnerTest extends CardTestPlayerBase {
assertCounterCount(playerA, ugin, CounterType.LOYALTY, 11);
}
@Test
public void testKiraGreatGlassSpinnerFirstSpellTurn() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.HAND, playerA, bolt);
addCard(Zone.BATTLEFIELD, playerB, kira, 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, kira);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, bolt, 1);
assertPermanentCount(playerB, kira, 1);
}
@Test
public void testKiraGreatGlassSpinnerRightAbility() {
// Reported bug: #8026
addCard(Zone.BATTLEFIELD, playerA, "Steadfast Guard", 1); // 2/2 Vigilance
addCard(Zone.BATTLEFIELD, playerA, "Angelic Benediction", 1); // Exalted
// Whenever a creature you control attacks alone, you may tap target creature.
addCard(Zone.BATTLEFIELD, playerB, kira, 1);
attack(1, playerA, "Steadfast Guard", playerB);
setChoice(playerA, "Whenever"); // choose trigger order - exalted at top of stack
addTarget(playerA, kira); // creature to tap
//setChoice(playerA, true); // choose yes to tap - gets countered before choice needed
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerB, 17); // exalted pumps 2/2 to 3/3, so 3 life lost
assertTapped(kira, false); // tap ability was countered
}
@Test
public void testKiraGreatGlassSpinnerRightAbilityOtherOrder() {
// Reported bug: #8026
addCard(Zone.BATTLEFIELD, playerA, "Steadfast Guard", 1); // 2/2 Vigilance
addCard(Zone.BATTLEFIELD, playerA, "Angelic Benediction", 1); // Exalted
// Whenever a creature you control attacks alone, you may tap target creature.
addCard(Zone.BATTLEFIELD, playerB, kira, 1);
attack(1, playerA, "Steadfast Guard", playerB);
setChoice(playerA, "exalted"); // just in case... try the other trigger order
addTarget(playerA, kira); // creature to tap
//setChoice(playerA, true); // choose yes to tap - gets countered before choice needed
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerB, 17); // exalted pumps 2/2 to 3/3, so 3 life lost
assertTapped(kira, false); // tap ability was countered
}
@Test
public void counterFirstBlinkCounterNext() {
addCard(Zone.BATTLEFIELD, playerA, ugin); // starts with 7 Loyalty counters
addCard(Zone.BATTLEFIELD, playerA, "Plateau", 2);
addCard(Zone.HAND, playerA, "Shock", 1);
addCard(Zone.HAND, playerA, "Cloudshift", 1);
addCard(Zone.BATTLEFIELD, playerA, kira);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+2: {this} deals 3 damage", kira); // Ugin ability, countered
castSpell(1, PhaseStep.BEGIN_COMBAT, playerA, "Cloudshift", kira); // not countered (second time being targeted)
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Shock", kira); // countered (zcc has changed, so first time again)
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, kira, 1);
assertCounterCount(playerA, ugin, CounterType.LOYALTY, 9);
assertGraveyardCount(playerA, "Shock", 1);
assertGraveyardCount(playerA, "Cloudshift", 1);
}
@Test
public void counterCorrectlyMultipleOnStack() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
addCard(Zone.HAND, playerA, "Battlegrowth", 1); // Instant {G} Put a +1/+1 counter on target creature.
addCard(Zone.HAND, playerA, "Dragonscale Boon", 1); // Instant {3}{G} Put two +1/+1 counters on target creature and untap it.
addCard(Zone.BATTLEFIELD, playerA, kira);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Battlegrowth", kira); // countered
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Dragonscale Boon", kira); // not countered (second target)
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, kira, 1);
assertGraveyardCount(playerA, "Battlegrowth", 1);
assertGraveyardCount(playerA, "Dragonscale Boon", 1);
assertPowerToughness(playerA, kira, 4, 4);
}
}

View file

@ -0,0 +1,84 @@
package org.mage.test.combat;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class CombatDamageByToughnessTest extends CardTestPlayerBase {
@Test
public void testByToughnessAll() {
addCard(Zone.BATTLEFIELD, playerA, "Doran, the Siege Tower", 1); // 0/5
// Each creature assigns combat damage equal to its toughness rather than its power.
addCard(Zone.BATTLEFIELD, playerB, "Kraken Hatchling", 1); // 0/4
attack(1, playerA, "Doran, the Siege Tower");
attack(2, playerB, "Kraken Hatchling");
setStrictChooseMode(true);
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerA, 20 - 4);
assertLife(playerB, 20 - 5);
}
@Test
public void testByToughnessControlled() {
addCard(Zone.BATTLEFIELD, playerA, "Belligerent Brontodon", 1); // 4/6
// Each creature you control assigns combat damage equal to its toughness rather than its power.
addCard(Zone.BATTLEFIELD, playerB, "Maritime Guard", 1); // 1/3
attack(1, playerA, "Belligerent Brontodon");
attack(2, playerB, "Maritime Guard");
setStrictChooseMode(true);
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerA, 20 - 1);
assertLife(playerB, 20 - 6);
}
@Test
public void testByToughnessFilter() {
addCard(Zone.BATTLEFIELD, playerA, "Ancient Lumberknot", 1); // 1/4
// Each creature you control with toughness greater than its power assigns combat damage equal to its toughness rather than its power.
addCard(Zone.BATTLEFIELD, playerA, "Goblin Piker", 1); // 2/1
attack(1, playerA, "Ancient Lumberknot");
attack(1, playerA, "Goblin Piker");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerB, 20 - 4 - 2);
}
@Test
public void testByToughnessTarget() {
addCard(Zone.BATTLEFIELD, playerA, "Walking Bulwark", 1); // 0/3 Defender
// {2}: Until end of turn, target creature with defender gains haste, can attack as though it didn't have defender,
// and assigns combat damage equal to its toughness rather than its power. Activate only as a sorcery.
addCard(Zone.BATTLEFIELD, playerA, "Wild-Field Scarecrow", 1); // 1/4 Defender
addCard(Zone.BATTLEFIELD, playerA, "Wastes", 2);
addCard(Zone.BATTLEFIELD, playerA, "Serra's Blessing", 1); // Creatures you control have vigilance
addCard(Zone.BATTLEFIELD, playerB, "Barony Vampire", 1); // 3/2
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}: Until", "Wild-Field Scarecrow");
attack(1, playerA, "Wild-Field Scarecrow");
attack(2, playerB, "Barony Vampire");
block(2, playerA, "Wild-Field Scarecrow", "Barony Vampire");
setStrictChooseMode(true);
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerB, 20 - 4);
assertDamageReceived(playerB, "Barony Vampire", 1);
assertDamageReceived(playerA, "Wild-Field Scarecrow", 3);
}
}

View file

@ -45,7 +45,7 @@ public class LoadCallbackClient implements CallbackClient {
// ignore bloaded logs
switch (callback.getMethod()) {
case CHATMESSAGE:
case GAME_INFORM:
case GAME_UPDATE_AND_INFORM:
case GAME_UPDATE:
break;
default:
@ -77,7 +77,7 @@ public class LoadCallbackClient implements CallbackClient {
break;
}
case GAME_INFORM:
case GAME_UPDATE_AND_INFORM:
case GAME_INFORM_PERSONAL: {
GameClientMessage message = (GameClientMessage) callback.getData();
gameView = message.getGameView();