mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
refactor: add FilterSource to match TargetSource (#13703)
Small fix of enabling TargetSource to choose/target a Command Object
This commit is contained in:
parent
fc15cefa23
commit
cfd51d7dce
42 changed files with 522 additions and 278 deletions
|
|
@ -0,0 +1,73 @@
|
|||
package org.mage.test.cards.single.drk;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public class DarkSphereTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* {@link mage.cards.d.DarkSphere Dark Sphere} {0}
|
||||
* Artifact
|
||||
* {T}, Sacrifice this artifact: The next time a source of your choice would deal damage to you this turn, prevent half that damage, rounded down.
|
||||
*/
|
||||
private static final String sphere = "Dark Sphere";
|
||||
|
||||
@Test
|
||||
public void test_DamageOnCreature_NoPrevent() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, sphere, 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Goblin Piker", 1); // 2/1
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Caelorna, Coral Tyrant"); // 0/8
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}, Sacrifice");
|
||||
setChoice(playerA, "Goblin Piker"); // source to prevent from
|
||||
|
||||
attack(2, playerB, "Goblin Piker", playerA);
|
||||
block(2, playerA, "Caelorna, Coral Tyrant", "Goblin Piker");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertDamageReceived(playerA, "Caelorna, Coral Tyrant", 2); // no prevent
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_DamageOnYou_Prevent() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, sphere, 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Craw Wurm", 1); // 6/4
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}, Sacrifice");
|
||||
setChoice(playerA, "Craw Wurm"); // source to prevent from
|
||||
|
||||
attack(2, playerB, "Craw Wurm", playerA);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20 - 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_DoubleStrike_Prevent_ThenConsumedAndNoPrevent() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, sphere, 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Blade Historian", 1); // 2/3 "Attacking creatures you control have double strike."
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}, Sacrifice");
|
||||
setChoice(playerA, "Blade Historian"); // source to prevent from
|
||||
|
||||
attack(2, playerB, "Blade Historian", playerA);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20 - 3);
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ public class CircleOfProtectionTest extends CardTestPlayerBase {
|
|||
execute();
|
||||
|
||||
assertDamageReceived(playerA, "Caelorna, Coral Tyrant", 2); // no prevent
|
||||
assertLife(playerB, 20);
|
||||
assertLife(playerA, 20);
|
||||
assertTappedCount("Plains", true, 1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class StoryCircleTest extends CardTestPlayerBase {
|
|||
setChoice(playerA, "Green"); // color chosen
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{W}");
|
||||
setChoice(playerA, "Goblin Piker"); // TODO: this should not be a valid choice for TargetSource(chosencolor)
|
||||
// no valid choice
|
||||
|
||||
attack(2, playerB, "Goblin Piker", playerA);
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ public class StoryCircleTest extends CardTestPlayerBase {
|
|||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20); // TODO: Should not prevent.
|
||||
assertLife(playerA, 20 - 2);
|
||||
assertTappedCount("Plains", true, 4);
|
||||
}
|
||||
|
||||
|
|
@ -144,13 +144,13 @@ public class StoryCircleTest extends CardTestPlayerBase {
|
|||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{W}", null, "Lightning Bolt");
|
||||
setChoice(playerA, "Lightning Bolt"); // TODO: this should not be a valid choice for TargetSource(chosencolor)
|
||||
// no valid choice
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20); // TODO: Should not prevent.
|
||||
assertLife(playerA, 20 - 3);
|
||||
assertGraveyardCount(playerB, "Lightning Bolt", 1);
|
||||
assertTappedCount("Plains", true, 4);
|
||||
}
|
||||
|
|
@ -192,13 +192,13 @@ public class StoryCircleTest extends CardTestPlayerBase {
|
|||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Blisterstick Shaman");
|
||||
addTarget(playerB, playerA); // target for Shaman trigger
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{W}", null, "stack ability (When");
|
||||
setChoice(playerA, "Blisterstick Shaman"); // TODO: this should not be a valid choice for TargetSource(chosencolor)
|
||||
// no valid choice
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20); // TODO: Should not prevent.
|
||||
assertLife(playerA, 20 - 1);
|
||||
assertPermanentCount(playerB, "Blisterstick Shaman", 1);
|
||||
assertTappedCount("Plains", true, 4);
|
||||
}
|
||||
|
|
@ -238,14 +238,14 @@ public class StoryCircleTest extends CardTestPlayerBase {
|
|||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "{R},", playerA);
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{W}", null, "stack ability ({R}");
|
||||
setChoice(playerA, "Anaba Shaman"); // TODO: this should not be a valid choice for TargetSource(chosencolor)
|
||||
// no valid choice
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertTappedCount("Anaba Shaman", true, 1);
|
||||
assertLife(playerA, 20); // TODO: Should not prevent.
|
||||
assertLife(playerA, 20 - 1);
|
||||
assertTappedCount("Plains", true, 4);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
package org.mage.test.cards.single.tmp;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public class CircleOfProtectionShadowTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* {@link mage.cards.c.CircleOfProtectionShadow Circle of Protection: Shadow} {1}{W}
|
||||
* Enchantment
|
||||
* {1}: The next time a creature of your choice with shadow would deal damage to you this turn, prevent that damage.
|
||||
*/
|
||||
private static final String circle = "Circle of Protection: Shadow";
|
||||
|
||||
@Test
|
||||
public void test_NotShadow_NoPrevent() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, circle, 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Goblin Piker", 1); // 2/1
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}");
|
||||
// no creature with shadow to choose
|
||||
|
||||
attack(2, playerB, "Goblin Piker", playerA);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20 - 2);
|
||||
assertTappedCount("Plains", true, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Shadow_Prevent() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, circle, 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Dauthi Marauder", 1); // 2/1
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}");
|
||||
setChoice(playerA, "Dauthi Marauder");
|
||||
|
||||
attack(2, playerB, "Dauthi Marauder", playerA);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertTappedCount("Plains", true, 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package org.mage.test.cards.single.tmp;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public class InvulnerabilityTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* {@link mage.cards.i.Invulnerability Invulnerability} {1}{W}
|
||||
* Instant
|
||||
* Buyback {3} (You may pay an additional {3} as you cast this spell. If you do, put this card into your hand as it resolves.)
|
||||
* The next time a source of your choice would deal damage to you this turn, prevent that damage.
|
||||
*/
|
||||
private static final String invulnerability = "Invulnerability";
|
||||
|
||||
@Test
|
||||
public void test_EmblemDamage_Prevent() {
|
||||
addCard(Zone.HAND, playerA, invulnerability, 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Chandra, Awakened Inferno", 1); // +2: Each opponent gets an emblem with “At the beginning of your upkeep, this emblem deals 1 damage to you.”
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "+2");
|
||||
|
||||
checkEmblemCount("Chandra Emblem has been created", 2, PhaseStep.POSTCOMBAT_MAIN, playerA, "Emblem Chandra", 1);
|
||||
|
||||
// turn 3: prevent
|
||||
castSpell(3, PhaseStep.UPKEEP, playerA, invulnerability);
|
||||
setChoice(playerA, false); // don't pay for Buyback
|
||||
setChoice(playerA, "Emblem Chandra"); // choice for source
|
||||
checkLife("prevention turn 3", 3, PhaseStep.POSTCOMBAT_MAIN, playerA, 20);
|
||||
|
||||
// turn 5: no prevent to check effect ending
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(5, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20 - 1);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue