* Gain cost modification abilities - fixed that commanders can't be played without full mana (example: gained Affinity by Mycosynth Golem, gained Convoke by Chief Engineer, see #7249 #7171, #6698);

This commit is contained in:
Oleg Agafonov 2020-12-18 18:33:44 +04:00
parent 53c5abea14
commit 384ff2e7ac
8 changed files with 145 additions and 28 deletions

View file

@ -238,8 +238,6 @@ public class ConvokeTest extends CardTestPlayerBaseWithAIHelps {
}
@Test
@Ignore
// TODO: fix gain ability for spells to apply in all zones instead stack only or change getPlayable to look ahead and simulate spell on stack (wtf)
public void test_Other_ConvokeAsGains() {
// {1}{U}
// Artifact spells you cast have convoke.

View file

@ -1,4 +1,3 @@
package org.mage.test.cards.abilities.other;
import mage.constants.PhaseStep;
@ -6,23 +5,23 @@ import mage.constants.Zone;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import org.mage.test.serverside.base.CardTestCommander4Players;
/**
*
* @author BetaSteward
*/
public class MycosynthGolemTest extends CardTestPlayerBase {
public class MycosynthGolemTest extends CardTestCommander4Players {
/**
* Mycosynth Golem Artifact Creature Golem 4/5, 11 (11) Affinity for
* artifacts (This spell costs {1} less to cast for each artifact you
* control.) Artifact creature spells you cast have affinity for artifacts.
* (They cost {1} less to cast for each artifact you control.)
*
*/
@Test
public void testSpellsAffinity() {
public void test_AffinityForNormalSpells() {
/*
bug:
Mycosynth Golem Artifact Creature Golem 4/5, 11 (11) Affinity for
artifacts (This spell costs {1} less to cast for each artifact you
control.) Artifact creature spells you cast have affinity for artifacts.
(They cost {1} less to cast for each artifact you control.)
*/
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
// Affinity for artifacts
@ -32,8 +31,10 @@ public class MycosynthGolemTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Alpha Myr");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Alpha Myr", 1);
assertHandCount(playerA, "Alpha Myr", 0);
@ -48,7 +49,5 @@ public class MycosynthGolemTest extends CardTestPlayerBase {
tappedLands++;
}
Assert.assertEquals("only one land may be tapped because the cost reduction", 1, tappedLands);
}
}

View file

@ -1,7 +1,12 @@
package org.mage.test.commander.duel;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.permanent.token.ArtifactWallToken;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestCommanderDuelBase;
@ -82,4 +87,81 @@ public class CommanderAffinityTest extends CardTestCommanderDuelBase {
assertAllCommandsUsed();
}
@Test
public void test_Gained_Affinity() {
// bug: Mycosynth Golem did not allow my commander, Karn, Silver Golem, to cost 0 even though I had 7+ artifacts on the board.
Ability ability = new SimpleActivatedAbility(Zone.ALL, new CreateTokenEffect(new ArtifactWallToken(), 7), new ManaCostsImpl("R"));
addCustomCardWithAbility("generate tokens", playerA, ability);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
//
addCard(Zone.COMMAND, playerA, "Karn, Silver Golem", 1); // {5}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
//
// Destroy target artifact.
addCard(Zone.HAND, playerA, "Ancient Grudge", 1); // {1}{R}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
//
// Artifact creature spells you cast have affinity for artifacts. (They cost {1} less to cast for each artifact you control.)
addCard(Zone.BATTLEFIELD, playerA, "Mycosynth Golem", 1);
// Affinity for artifacts
// Artifact creature spells you cast have affinity for artifacts.
// addCard(Zone.BATTLEFIELD, playerA, "Mycosynth Golem");
// addCard(Zone.HAND, playerA, "Alpha Myr"); // Creature - Myr 2/1
checkCommandCardCount("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Karn, Silver Golem", 1);
checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Karn, Silver Golem", true);
// first cast for 5 and destroy (prepare commander with additional cost)
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Karn, Silver Golem");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ancient Grudge", "Karn, Silver Golem");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkCommandCardCount("after destroy ", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Karn, Silver Golem", 1);
checkPlayableAbility("after destroy", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Karn, Silver Golem", false);
setChoice(playerA, "Yes"); // move to command zone
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
// can't do the second cast with additional cost (must pay 2 + 5, but have only R)
checkPlayableAbility("after move", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Karn, Silver Golem", false);
// generate artifact tokens
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{R}: Create");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPermanentCount("after tokens", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wall", 7);
checkPlayableAbility("after tokens", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Karn, Silver Golem", true);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
}
@Test
public void test_Gained_Convoke() {
// bug:
// https://github.com/magefree/mage/issues/7171
// Commander doesn't get 'convoke' when chief engineer is on the battlefield, so for instance I can't cast Breya by tapping other creatures.
// Artifact spells you cast have convoke.
addCard(Zone.BATTLEFIELD, playerA, "Chief Engineer", 1);
//
addCard(Zone.COMMAND, playerA, "Karn, Silver Golem", 1); // {5}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5 - 2);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 2);
// 3 mana + 2 convoke
checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Karn, Silver Golem", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Karn, Silver Golem");
addTarget(playerA, "Grizzly Bears"); // convoke cost
addTarget(playerA, "Grizzly Bears"); // convoke cost
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Karn, Silver Golem", 1);
}
}