rework batch events (#13066)

* add new framework for batch triggers

apply for tapped, untapped, sacrificed, milled

simplify Ob Nixilis, Captive Kingpin

* add a verify check

* fix mistakes

* add simple tests

* another test

* zone change - enters battlefield

* zone change: not battlefield

* zone change - leaves battlefield

* fix Kaya Spirit's Justice

* rename OneOrMoreCombatDamagePlayerTriggeredAbility

* refactor OneOrMoreDamagePlayerTriggeredAbility

* new YoureDealtDamageTriggeredAbility

* new OpponentDealtNoncombatDamageTriggeredAbility

* rework Risona, Asari Commander

* simplify War Elemental

* Add damage batch by source

rework some delayed triggered abilities

* fix Mindblade Render

* rework Initiative and a few others

* [temp] initiative test

* refactor: common style for DealsDamageSourceTriggeredAbility

* refactor cards to use common DealsDamageSourceTriggeredAbility

* update damage players batch triggers

* fix mistake in initiative

* new DealtDamageAnyTriggeredAbility

* new DealtCombatDamageToSourceTriggeredAbility

* update dealt damage to permanent batch triggered abilities

* refactor Hot Soup and param in DealtDamageAttachedTriggeredAbility

* a few more permanent batch triggered abilities

* fix mistake

* update some more damage batch triggers

* add test for Phyrexian Negator

* update Felix Five-Boots and enable test

update Wayta, Trainer Prodigy to align

* update damage batch by source triggers

* undo mistaken change

* fix verify

* cleanup unused methods

* Revert "[temp] initiative test"

This reverts commit 11ed19295f.

* Revert "add a verify check"

This reverts commit e7de47a656.

* fixes from checking text discrepancies

* fix Shriekwood Devourer

* merge fix

---------

Co-authored-by: Susucre <34709007+Susucre@users.noreply.github.com>
This commit is contained in:
xenohedron 2024-11-19 21:23:08 -05:00 committed by GitHub
parent cef2a1edc8
commit d06d594934
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
192 changed files with 2411 additions and 3363 deletions

View file

@ -0,0 +1,42 @@
package org.mage.test.cards.single.cmr;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author Susucr
*/
public class BlazingSunsteelTest extends CardTestPlayerBase {
/**
* {@link mage.cards.b.BlazingSunsteel Blazing Sunsteel} {1}{R}
* Artifact Equipment
* Equipped creature gets +1/+0 for each opponent you have.
* Whenever equipped creature is dealt damage, it deals that much damage to any target.
* Equip {4}
*/
private static final String sunsteel = "Blazing Sunsteel";
@Test
public void test_Trigger() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, sunsteel);
addCard(Zone.BATTLEFIELD, playerA, "Memnite");
addCard(Zone.HAND, playerA, "Lightning Bolt");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip", "Memnite");
castSpell(1, PhaseStep.BEGIN_COMBAT, playerA, "Lightning Bolt", "Memnite");
addTarget(playerA, playerB); // Sunsteel trigger
setStopAt(3, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerA, "Memnite", 1);
assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertLife(playerB, 20 - 3);
}
}

View file

@ -0,0 +1,62 @@
package org.mage.test.cards.single.mir;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author Susucr
*/
public class BindingAgonyTest extends CardTestPlayerBase {
/**
* {@link mage.cards.b.BindingAgony Binding Agony} {1}{B}
* Enchantment Aura
* Enchant creature
* Whenever enchanted creature is dealt damage, Binding Agony deals that much damage to that creatures controller.
*/
private static final String agony = "Binding Agony";
@Test
public void test_Trigger_Once_DoubleBlocked() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears");
addCard(Zone.HAND, playerA, agony);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
addCard(Zone.BATTLEFIELD, playerB, "Memnite");
addCard(Zone.BATTLEFIELD, playerB, "Centaur Courser");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, agony, "Grizzly Bears");
attack(1, playerA, "Grizzly Bears");
block(1, playerB, "Centaur Courser", "Grizzly Bears");
block(1, playerB, "Memnite", "Grizzly Bears");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerA, "Grizzly Bears", 1);
assertLife(playerA, 20 - 1 - 3);
}
@Test
public void test_NonCombat_NoTrigger() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears");
addCard(Zone.HAND, playerA, agony);
addCard(Zone.BATTLEFIELD, playerA, "Badlands", 3);
addCard(Zone.HAND, playerA, "Lightning Bolt");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, agony, "Grizzly Bears", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Grizzly Bears");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerB, "Grizzly Bears", 1);
assertLife(playerB, 20 - 3);
}
}

View file

@ -0,0 +1,74 @@
package org.mage.test.cards.single.mir;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author Susucr
*/
public class SunDropletTest extends CardTestPlayerBase {
/**
* {@link mage.cards.s.SunDroplet Sun Droplet} {2}
* Artifact
* Whenever youre dealt damage, put that many charge counters on Sun Droplet.
* At the beginning of each upkeep, you may remove a charge counter from Sun Droplet. If you do, you gain 1 life.
*/
private static final String droplet = "Sun Droplet";
@Test
public void test_Trigger_Combat() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerB, droplet);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 2); // 2/2
attack(1, playerA, "Grizzly Bears");
attack(1, playerA, "Grizzly Bears");
// Only one trigger.
setStopAt(1, PhaseStep.END_TURN);
execute();
assertCounterCount(playerB, droplet, CounterType.CHARGE, 2 * 2);
assertLife(playerB, 20 - 2 * 2);
}
@Test
public void test_Trigger_NonCombat() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerB, droplet);
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
addCard(Zone.HAND, playerA, "Lightning Bolt");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertCounterCount(playerB, droplet, CounterType.CHARGE, 3);
assertLife(playerB, 20 - 3);
}
@Test
public void test_NoTrigger_OtherPlayer() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerB, droplet);
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
addCard(Zone.HAND, playerA, "Lightning Bolt");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerA);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertCounterCount(playerB, droplet, CounterType.CHARGE, 0);
assertLife(playerA, 20 - 3);
}
}

View file

@ -0,0 +1,81 @@
package org.mage.test.cards.single.mir;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author Susucr
*/
public class WarElementalTest extends CardTestPlayerBase {
/**
* {@link mage.cards.w.WarElemental War Elemental} {R}{R}{R}
* Creature Elemental
* When War Elemental enters the battlefield, sacrifice it unless an opponent was dealt damage this turn.
* Whenever an opponent is dealt damage, put that many +1/+1 counters on War Elemental.
* 1/1
*/
private static final String elemental = "War Elemental";
@Test
public void test_Trigger_Combat() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, elemental);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears");
addCard(Zone.BATTLEFIELD, playerA, "Elite Vanguard");
addCard(Zone.BATTLEFIELD, playerB, "Memnite");
attack(1, playerA, "War Elemental");
attack(1, playerA, "Grizzly Bears");
attack(1, playerA, "Elite Vanguard");
block(1, playerB, "Memnite", "Elite Vanguard");
// Only one trigger.
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerA, 1);
assertGraveyardCount(playerB, 1);
assertCounterCount(playerA, elemental, CounterType.P1P1, 1 + 2);
assertLife(playerB, 20 - 1 - 2);
}
@Test
public void test_Trigger_NonCombat() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, elemental);
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
addCard(Zone.HAND, playerA, "Lightning Bolt");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertCounterCount(playerA, elemental, CounterType.P1P1, 3);
assertLife(playerB, 20 - 3);
}
@Test
public void test_NoTrigger_You() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, elemental);
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
addCard(Zone.HAND, playerA, "Lightning Bolt");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerA);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertCounterCount(playerA, elemental, CounterType.P1P1, 0);
assertLife(playerA, 20 - 3);
}
}

View file

@ -31,7 +31,7 @@ public class KayaSpiritsJusticeTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Astrid Peth");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);
// Exile all creatures and graveyards
// Exile all creatures. Exile all graveyards.
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Farewell");
setModeChoice(playerA, "2");
setModeChoice(playerA, "4");

View file

@ -0,0 +1,77 @@
package org.mage.test.cards.single.sth;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author Susucr
*/
public class WallOfEssenceTest extends CardTestPlayerBase {
/**
* {@link mage.cards.w.WallOfEssence Wall of Essence} {1}{W}
* Creature Wall
* Defender (This creature cant attack.)
* Whenever Wall of Essence is dealt combat damage, you gain that much life.
* 0/4
*/
private static final String wall = "Wall of Essence";
@Test
public void test_Trigger() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerB, wall);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears"); // 2/2
attack(1, playerA, "Grizzly Bears");
block(1, playerB, wall, "Grizzly Bears");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertDamageReceived(playerB, wall, 2);
assertLife(playerB, 20 + 2);
}
@Test
public void test_NotTrigger_OtherCombatDamage() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerB, wall);
addCard(Zone.BATTLEFIELD, playerB, "Memnite"); // 1/1
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears"); // 2/2
attack(1, playerA, "Grizzly Bears");
block(1, playerB, "Memnite", "Grizzly Bears");
block(1, playerB, wall, "Grizzly Bears");
setChoice(playerA, "X=2"); // 2 damage on Memnite, no damage to Wall
setStopAt(1, PhaseStep.END_TURN);
execute();
assertDamageReceived(playerB, wall, 0);
assertGraveyardCount(playerB, "Memnite", 1);
assertLife(playerB, 20);
}
@Test
public void test_NonCombat_NoTrigger() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerB, wall);
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
addCard(Zone.HAND, playerA, "Lightning Bolt");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", wall);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertDamageReceived(playerB, wall, 3);
assertLife(playerB, 20);
}
}

View file

@ -0,0 +1,65 @@
package org.mage.test.cards.single.uds;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author Susucr
*/
public class PhyrexianNegatorTest extends CardTestPlayerBase {
/**
* {@link mage.cards.p.PhyrexianNegator Phyrexian Negator} {2}{B}
* Creature Phyrexian Horror
* Trample
* Whenever Phyrexian Negator is dealt damage, sacrifice that many permanents.
* 5/5
*/
private static final String negator = "Phyrexian Negator";
@Test
public void test_Trigger_Combat() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, negator);
addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears");
addCard(Zone.BATTLEFIELD, playerB, "Memnite");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 10);
attack(1, playerA, negator);
block(1, playerB, "Grizzly Bears", negator);
block(1, playerB, "Memnite", negator);
setChoice(playerA, "X=2"); // damage to Bears
setChoice(playerA, "X=3"); // damage to Memnite
setChoice(playerA, "Mountain", 3); // sac those.
setStopAt(1, PhaseStep.END_TURN);
execute();
assertDamageReceived(playerA, negator, 3);
assertPermanentCount(playerA, "Mountain", 10 - 3);
}
@Test
public void test_Trigger_NonCombat() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, negator);
addCard(Zone.HAND, playerA, "Shock");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 10);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Shock", negator);
setChoice(playerA, "Mountain", 2); // sac those.
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertDamageReceived(playerA, negator, 2);
assertPermanentCount(playerA, "Mountain", 10 - 2);
}
}

View file

@ -0,0 +1,44 @@
package org.mage.test.cards.single.xln;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author Susucr
*/
public class JaceCunningCastawayTest extends CardTestPlayerBase {
/**
* {@link mage.cards.j.JaceCunningCastaway Jace, Cunning Castaway} {1}{U}{U}
* Legendary Planeswalker Jace
* +1: Whenever one or more creatures you control deal combat damage to a player this turn, draw a card, then discard a card.
* 2: Create a 2/2 blue Illusion creature token with When this creature becomes the target of a spell, sacrifice it.
* 5: Create two tokens that are copies of Jace, Cunning Castaway, except theyre not legendary.
* Loyalty: 3
*/
private static final String jace = "Jace, Cunning Castaway";
@Test
public void test_PlusOne_Trigger() {
setStrictChooseMode(true);
skipInitShuffling();
addCard(Zone.BATTLEFIELD, playerA, jace);
addCard(Zone.BATTLEFIELD, playerA, "Savannah Lions");
addCard(Zone.BATTLEFIELD, playerA, "Alaborn Trooper");
addCard(Zone.LIBRARY, playerA, "Taiga"); // for looting.
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1:");
attack(1, playerA, "Savannah Lions", playerB);
attack(1, playerA, "Alaborn Trooper", playerB);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerB, 20 - 2 - 2);
assertGraveyardCount(playerA, "Taiga", 1);
}
}

View file

@ -3,7 +3,6 @@ package org.mage.test.cards.triggers.damage;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -101,7 +100,6 @@ public class FelixFiveBootsTest extends CardTestPlayerBase {
}
@Test
@Ignore // see #12095
public void testSelectRightPartOfBatch() {
setStrictChooseMode(true);

View file

@ -6,7 +6,7 @@ import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* Tests the {@link mage.abilities.common.DiesOneOrMoreCreatureTriggeredAbility} batching.
* Tests the {@link mage.abilities.common.DiesOneOrMoreTriggeredAbility} batching.
*
* @author Susucr
*/