Battlefield Thaumaturge - fixed that it doesn't allow to cast spells without full available mana (#6698);

This commit is contained in:
Oleg Agafonov 2020-07-05 01:08:43 +04:00
parent 8e819ee614
commit 69d8fd1898
9 changed files with 144 additions and 32 deletions

View file

@ -1,16 +1,14 @@
package org.mage.test.cards.abilities.keywords;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import org.mage.test.serverside.base.CardTestPlayerBaseWithAIHelps;
/**
*
* @author LevelX2
*/
public class SupportTest extends CardTestPlayerBase {
public class SupportTest extends CardTestPlayerBaseWithAIHelps {
/**
* Support Ability can target its source. Its cannot really.
@ -18,22 +16,26 @@ public class SupportTest extends CardTestPlayerBase {
@Test
public void testCreatureSupport() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 7);
// When Gladehart Cavalry enters the battlefield, support 6.
// When Gladehart Cavalry enters the battlefield, support 6. <i>(Put a +1/+1 counter on each of up to six other target creatures.)</i>
// Whenever a creature you control with a +1/+1 counter on it dies, you gain 2 life.
addCard(Zone.HAND, playerA, "Gladehart Cavalry"); // {5}{G}{G} 6/6
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
addCard(Zone.BATTLEFIELD, playerA, "Pillarfield Ox");
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); // 2/2
addCard(Zone.BATTLEFIELD, playerA, "Pillarfield Ox"); // 2/4
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gladehart Cavalry");
addTarget(playerA, "Silvercoat Lion^Pillarfield Ox^Gladehart Cavalry");// Gladehart Cavalry should not be allowed
// test framework do not support possible target checks, so allow AI to cast and choose maximum targets
aiPlayPriority(1, PhaseStep.PRECOMBAT_MAIN, playerA);
//castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gladehart Cavalry");
//addTarget(playerA, "Silvercoat Lion^Pillarfield Ox^Gladehart Cavalry");// Gladehart Cavalry should not be allowed
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertPowerToughness(playerA, "Silvercoat Lion", 3, 3);
assertPowerToughness(playerA, "Pillarfield Ox", 3, 5);
assertPowerToughness(playerA, "Gladehart Cavalry", 6, 6);
assertPowerToughness(playerA, "Silvercoat Lion", 2 + 1, 2 + 1);
assertPowerToughness(playerA, "Pillarfield Ox", 2 + 1, 4 + 1);
assertPowerToughness(playerA, "Gladehart Cavalry", 6, 6); // no counters
}
}

View file

@ -138,4 +138,48 @@ public class CostReduceForEachTest extends CardTestPlayerBaseWithAIHelps {
assertPermanentCount(playerA, "Torgaar, Famine Incarnate", 1);
assertLife(playerB, 20 / 2);
}
@Test
public void test_AshnodsAltar_SacrificeCost() {
// Sacrifice a creature: Add {C}{C}.
addCard(Zone.BATTLEFIELD, playerA, "Ashnod's Altar", 1);
//
addCard(Zone.HAND, playerA, "Alloy Myr", 1); // {3}
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3 - 2);
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1); // give 2 mana on sacrifice
checkPlayableAbility("must play", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Alloy Myr", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Alloy Myr");
setChoice(playerA, "Balduvian Bears");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Alloy Myr", 1);
}
@Test
public void test_BattlefieldThaumaturge_TargetCostReduce() {
// Each instant and sorcery spell you cast costs {1} less to cast for each creature it targets.
addCard(Zone.BATTLEFIELD, playerA, "Battlefield Thaumaturge", 1);
//
// {3}{R}{R} sorcery
// Shower of Coals deals 2 damage to each of up to three target creatures and/or players.
addCard(Zone.HAND, playerA, "Shower of Coals", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5 - 3);
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears@bear", 3); // add 3 cost reduce on target
checkPlayableAbility("must play", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Shower of Coals", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Shower of Coals");
addTarget(playerA, "@bear.1^@bear.2^@bear.3");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerA, "Shower of Coals", 1);
}
}

View file

@ -2093,8 +2093,8 @@ public class TestPlayer implements Player {
|| target.getOriginalTarget() instanceof TargetPermanentOrPlayer
|| target.getOriginalTarget() instanceof TargetDefender) {
for (String targetDefinition : targets) {
checkTargetDefinitionMarksSupport(target, targetDefinition, "=");
if (targetDefinition.startsWith("targetPlayer=")) {
checkTargetDefinitionMarksSupport(target, targetDefinition, "=");
String playerName = targetDefinition.substring(targetDefinition.indexOf("targetPlayer=") + 13);
for (Player player : game.getPlayers().values()) {
if (player.getName().equals(playerName)
@ -2119,6 +2119,7 @@ public class TestPlayer implements Player {
String[] targetList = targetDefinition.split("\\^");
boolean targetFound = false;
for (String targetName : targetList) {
targetFound = false; // must have all valid targets from list
boolean originOnly = false;
boolean copyOnly = false;
if (targetName.endsWith("]")) {

View file

@ -1770,6 +1770,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
public void addTarget(TestPlayer player, String target, int timesToChoose) {
for (int i = 0; i < timesToChoose; i++) {
assertAliaseSupportInActivateCommand(target, true);
player.addTarget(target);
}
}