refactor: fixed dies events support in single cards (part 4);

This commit is contained in:
Oleg Agafonov 2024-11-09 19:10:00 +04:00
parent dc9f349828
commit 0689c56597
19 changed files with 159 additions and 37 deletions

View file

@ -239,7 +239,7 @@ public class ConniveTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
addCard(Zone.HAND, playerA, "Grizzly Bears", 1);
//
addCustomEffect_DestroyTarget(playerA);
addCustomEffect_TargetDestroy(playerA);
addCard(Zone.BATTLEFIELD, playerA, "Razorclaw Bear", 1);
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
@ -267,7 +267,7 @@ public class ConniveTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
addCard(Zone.HAND, playerA, "Grizzly Bears", 1);
//
addCustomEffect_DestroyTarget(playerA);
addCustomEffect_TargetDestroy(playerA);
addCard(Zone.BATTLEFIELD, playerA, "Razorclaw Bear", 1);
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
@ -323,7 +323,7 @@ public class ConniveTest extends CardTestPlayerBase {
//
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
//
addCustomEffect_DestroyTarget(playerA);
addCustomEffect_TargetDestroy(playerA);
// connive lion
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Change of Plans");
@ -350,7 +350,7 @@ public class ConniveTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerA, "Razorclaw Bear", 1);
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
//
addCustomEffect_DestroyTarget(playerA);
addCustomEffect_TargetDestroy(playerA);
// connive lion
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Change of Plans");

View file

@ -46,7 +46,7 @@ public class IncubateTest extends CardTestPlayerBase {
@Test
public void test_Transform_Custom() {
// target transform
addCustomEffect_TransformTarget(playerA);
addCustomEffect_TargetTransform(playerA);
// Alluring Suitor, 2/3
// Deadly Dancer, 3/3
@ -74,7 +74,7 @@ public class IncubateTest extends CardTestPlayerBase {
@Test
public void test_Transform_IncubatorToken() {
// target transform
addCustomEffect_TransformTarget(playerA);
addCustomEffect_TargetTransform(playerA);
// Incubate 3. (Create an Incubator token with three +1/+1 counters on it and {2}: Transform this artifact.
// It transforms into a 0/0 Phyrexian artifact creature.)
@ -115,9 +115,9 @@ public class IncubateTest extends CardTestPlayerBase {
// use case: copy one side, can't tranform
// target transform
addCustomEffect_TransformTarget(playerA);
addCustomEffect_TargetTransform(playerA);
// target destroy
addCustomEffect_DestroyTarget(playerA);
addCustomEffect_TargetDestroy(playerA);
// Incubate 3. (Create an Incubator token with three +1/+1 counters on it and {2}: Transform this artifact.
// It transforms into a 0/0 Phyrexian artifact creature.)
@ -169,9 +169,9 @@ public class IncubateTest extends CardTestPlayerBase {
// use case: copy one side, can't tranform
// target transform
addCustomEffect_TransformTarget(playerA);
addCustomEffect_TargetTransform(playerA);
// target destroy
addCustomEffect_DestroyTarget(playerA);
addCustomEffect_TargetDestroy(playerA);
// Incubate 3. (Create an Incubator token with three +1/+1 counters on it and {2}: Transform this artifact.
// It transforms into a 0/0 Phyrexian artifact creature.)

View file

@ -136,7 +136,7 @@ public class GeodeGolemTest extends CardTestCommanderDuelBase {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 10);
//
addCustomEffect_TargetDamage(playerA, 3);
addCustomEffect_DestroyTarget(playerA);
addCustomEffect_TargetDestroy(playerA);
checkCommandCardCount("before 1", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Birgi, God of Storytelling", 1);

View file

@ -0,0 +1,57 @@
package org.mage.test.cards.single.m19;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author JayDi85
*/
public class AjanisLastStandTest extends CardTestPlayerBase {
@Test
public void test_TriggerOnAlive() {
addCustomEffect_TargetDestroy(playerA);
// Whenever a creature or planeswalker you control dies, you may sacrifice Ajani's Last Stand.
// If you do, create a 4/4 white Avatar creature token with flying.
addCard(Zone.BATTLEFIELD, playerA, "Ajani's Last Stand");
//
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "target destroy");
addTarget(playerA, "Grizzly Bears"); // to destroy
setChoice(playerA, true); // yes to sacrifice
setStopAt(1, PhaseStep.END_TURN);
setStrictChooseMode(true);
execute();
assertGraveyardCount(playerA, "Ajani's Last Stand", 1);
assertGraveyardCount(playerA, "Grizzly Bears", 1);
assertTokenCount(playerA, "Avatar Token", 1);
}
@Test
public void test_NoTriggerOnSelfDies() {
addCustomEffect_AllDestroy(playerA);
// Whenever a creature or planeswalker you control dies, you may sacrifice Ajani's Last Stand.
// If you do, create a 4/4 white Avatar creature token with flying.
addCard(Zone.BATTLEFIELD, playerA, "Ajani's Last Stand");
//
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears");
// destroy all without triggers (cause no sacrifice cost can be pay here)
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "all destroy");
setStopAt(1, PhaseStep.END_TURN);
setStrictChooseMode(true);
execute();
assertGraveyardCount(playerA, "Ajani's Last Stand", 1);
assertGraveyardCount(playerA, "Grizzly Bears", 1);
assertTokenCount(playerA, "Avatar Token", 0);
}
}

View file

@ -112,7 +112,7 @@ public class GluttonousHellkiteTest extends CardTestPlayerBase {
@Test
public void test_CastWithSac_SacFullAndBlink() {
addCustomEffect_BlinkTarget(playerA);
addCustomEffect_TargetBlink(playerA);
// When you cast this spell, each player sacrifices X creatures. Gluttonous Hellkite enters the battlefield
// with two +1/+1 counters on it for each creature sacrificed this way.

View file

@ -314,7 +314,7 @@ public class SacrificeDiesTriggerTest extends CardTestPlayerBase {
@Test
public void test_MultiModesDiesTrigger_ByDamage() {
addCustomEffect_BlinkTarget(playerA);
addCustomEffect_TargetBlink(playerA);
// When Junji, the Midnight Sky dies, choose one
// Each opponent discards two cards and loses 2 life.
@ -346,7 +346,7 @@ public class SacrificeDiesTriggerTest extends CardTestPlayerBase {
@Test
public void test_MultiModesDiesTrigger_BySacrificeCost() {
addCustomEffect_BlinkTarget(playerA);
addCustomEffect_TargetBlink(playerA);
// When Junji, the Midnight Sky dies, choose one
// Each opponent discards two cards and loses 2 life.

View file

@ -318,9 +318,6 @@ public abstract class MageTestPlayerBase {
/**
* Add cost modification effect to the game (all cast cost will be increaded or decreased for controller)
*
* @param controller
* @param modificationAmount
*/
protected void addCustomEffect_SpellCostModification(TestPlayer controller, int modificationAmount) {
Effect effect;
@ -339,9 +336,6 @@ public abstract class MageTestPlayerBase {
/**
* Add target damage ability that can be called by text: "target damage xxx"
*
* @param controller
* @param damageAmount
*/
protected void addCustomEffect_TargetDamage(TestPlayer controller, int damageAmount) {
Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(damageAmount).setText("target damage " + damageAmount), new ManaCostsImpl<>(""));
@ -355,10 +349,8 @@ public abstract class MageTestPlayerBase {
/**
* Add target destroy ability that can be called by text "target destroy"
*
* @param controller
*/
protected void addCustomEffect_DestroyTarget(TestPlayer controller) {
protected void addCustomEffect_TargetDestroy(TestPlayer controller) {
Ability ability = new SimpleActivatedAbility(new DestroyTargetEffect().setText("target destroy"), new ManaCostsImpl<>(""));
ability.addTarget(new TargetPermanent());
addCustomCardWithAbility(
@ -369,11 +361,21 @@ public abstract class MageTestPlayerBase {
}
/**
* Add target transform ability that can be called by text "target transform"
*
* @param controller
* Add all destroy ability that can be called by text "all destroy"
*/
protected void addCustomEffect_TransformTarget(TestPlayer controller) {
protected void addCustomEffect_AllDestroy(TestPlayer controller) {
Ability ability = new SimpleActivatedAbility(new DestroyAllEffect(StaticFilters.FILTER_PERMANENT).setText("all destroy"), new ManaCostsImpl<>(""));
addCustomCardWithAbility(
"all destroy for " + controller.getName(),
controller,
ability
);
}
/**
* Add target transform ability that can be called by text "target transform"
*/
protected void addCustomEffect_TargetTransform(TestPlayer controller) {
Ability ability = new SimpleActivatedAbility(new TransformTargetEffect().setText("target transform"), new ManaCostsImpl<>(""));
ability.addTarget(new TargetPermanent());
addCustomCardWithAbility(
@ -385,10 +387,8 @@ public abstract class MageTestPlayerBase {
/**
* Add target blink ability that can be called by text "target blink"
*
* @param controller
*/
protected void addCustomEffect_BlinkTarget(TestPlayer controller) {
protected void addCustomEffect_TargetBlink(TestPlayer controller) {
Ability ability = new SimpleActivatedAbility(
new ExileThenReturnTargetEffect(true, true).setText("target blink"),
new ManaCostsImpl<>("")
@ -403,8 +403,6 @@ public abstract class MageTestPlayerBase {
/**
* Return target card to hand that can be called by text "return from ..."
*
* @param controller
*/
protected void addCustomEffect_ReturnFromAnyToHand(TestPlayer controller) {
// graveyard