* Fixed some problems with color changes of cards and spells - e.g. Painter's Servant (fixes #7325 fixes #6487).

This commit is contained in:
LevelX2 2021-01-08 11:03:39 +01:00
parent f6c70d5d4a
commit c67ce93ec4
13 changed files with 294 additions and 115 deletions

View file

@ -219,5 +219,57 @@ public class PaintersServantTest extends CardTestPlayerBase {
}
/**
* https://github.com/magefree/mage/issues/6487
* I was playing mtg and had a Painter's Servant on the board, naming blue.
* A player tried to cast a green sun's zenith, it was targeted by pyroblast
* and in response the painter was exiled but the zenith was still countered.
*/
@Test
public void testColorSpellEnds() {
setStrictChooseMode(true);
// As Painter's Servant enters the battlefield, choose a color.
// All cards that aren't on the battlefield, spells, and permanents are the chosen color in addition to their other colors.
addCard(Zone.HAND, playerA, "Painter's Servant", 1); // Artifact Creature {2}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
// Choose one - Counter target spell if it's blue; or destroy target permanent if it's blue.
addCard(Zone.HAND, playerA, "Pyroblast", 1); // Instant {R}
// Search your library for a green creature card with converted mana cost X or less, put it onto the battlefield, then shuffle your library.
// Shuffle Green Sun's Zenith into its owner's library.
addCard(Zone.HAND, playerB, "Green Sun's Zenith", 1); // Sorcery {X}{G}
addTarget(playerB, "Ambush Viper");
// Exile target artifact or enchantment.
addCard(Zone.HAND, playerB, "Altar's Light", 1); // Instant {2}{W}{W}
addCard(Zone.BATTLEFIELD, playerB, "Forest", 1);
addCard(Zone.BATTLEFIELD, playerB, "Plains", 6);
// Flash, Deathtouch
addCard(Zone.LIBRARY, playerB, "Ambush Viper", 2); // Creature 2/1 {1}{G}
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Painter's Servant");
setChoice(playerA, "Blue");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Green Sun's Zenith");
setChoice(playerB, "X=2");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, "Pyroblast", "Green Sun's Zenith");
setModeChoice(playerA, "1");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Altar's Light", "Painter's Servant", "Pyroblast");
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerA, "Pyroblast", 1);
assertGraveyardCount(playerB, "Altar's Light", 1);
assertLibraryCount(playerB, "Green Sun's Zenith", 1);
assertExileCount(playerA, "Painter's Servant", 1);
assertPermanentCount(playerB, "Ambush Viper", 1);
}
}

View file

@ -0,0 +1,127 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.test.commander.duel;
import java.io.FileNotFoundException;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.GameException;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestCommanderDuelBase;
/**
*
* @author LevelX2
*/
public class CommanderColorChangeTest extends CardTestCommanderDuelBase {
@Override
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
// When a player casts a spell or a creature attacks, exile Norin the Wary. Return it to the battlefield under its owner's control at the beginning of the next end step.
setDecknamePlayerA("CMDNorinTheWary.dck"); // Commander = Norin the Wary {R}
return super.createNewGameAndPlayers();
}
@Test
public void castCommanderWithAddedBlueColor() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
// As Painter's Servant enters the battlefield, choose a color.
// All cards that aren't on the battlefield, spells, and permanents are the chosen color in addition to their other colors.
addCard(Zone.HAND, playerA, "Painter's Servant", 1); // Artifact Creature {2}
// Whenever a player casts a blue spell, you may gain 1 life.
addCard(Zone.BATTLEFIELD, playerA, "Kraken's Eye", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Painter's Servant");
setChoice(playerA, "Blue");
// When a player casts a spell or a creature attacks, exile Norin the Wary.
// Return it to the battlefield under its owner's control at the beginning of the next end step.
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Norin the Wary");
setChoice(playerA, "Yes"); // Whenever a player casts a blue spell, you may gain 1 life. Choices: Yes - No
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Norin the Wary", 1);
Permanent norin = getPermanent("Norin the Wary", playerA);
Assert.assertEquals(true, norin.getColor(currentGame).isBlue());
Assert.assertEquals(true, norin.getColor(currentGame).isRed());
Permanent kraken = getPermanent("Kraken's Eye", playerA);
Assert.assertEquals(true, kraken.getColor(currentGame).isBlue());
assertLife(playerA, 41);
assertLife(playerB, 40);
}
/**
* I played a Painter's Servant, named black, but the other commanders get a extra colors
* Later it got removed but the commanders and some cards still have the extra color
* I played it again later, named green, and the previously affected cards get the extra color
* so now they have 2 extra colors and the commander get and additional color on top of that
* And finally I got the empty hand error #6738 on my turn for what I assume is the Painter's Servant + Grindstone combo I have,
* but nonetheless manage to tie the game so it go into a second game and the issue carry over,
* all the commanders have all the extra colors they gain from the first game
*/
@Test
public void castCommanderWithoutAddedBlueColor() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
// As Painter's Servant enters the battlefield, choose a color.
// All cards that aren't on the battlefield, spells, and permanents are the chosen color in addition to their other colors.
addCard(Zone.HAND, playerA, "Painter's Servant", 1); // Artifact Creature {2}
// Whenever a player casts a blue spell, you may gain 1 life.
addCard(Zone.BATTLEFIELD, playerA, "Kraken's Eye", 1);
// Exile target artifact or enchantment.
addCard(Zone.HAND, playerB, "Altar's Light", 1); // Instant {2}{W}{W}
addCard(Zone.BATTLEFIELD, playerB, "Plains", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Painter's Servant");
setChoice(playerA, "Blue");
// When a player casts a spell or a creature attacks, exile Norin the Wary.
// Return it to the battlefield under its owner's control at the beginning of the next end step.
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Norin the Wary");
setChoice(playerA, "Yes"); // Whenever a player casts a blue spell, you may gain 1 life. Choices: Yes - No
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Altar's Light", "Painter's Servant", "Norin the Wary");
setChoice(playerA, "Yes"); // Whenever a player casts a blue spell, you may gain 1 life. Choices: Yes - No
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Norin the Wary", 1);
assertAllCommandsUsed();
Permanent norin = getPermanent("Norin the Wary", playerA);
Assert.assertEquals(false, norin.getColor(currentGame).isBlue());
Assert.assertEquals(true, norin.getColor(currentGame).isRed());
Permanent kraken = getPermanent("Kraken's Eye", playerA);
Assert.assertEquals(false, kraken.getColor(currentGame).isBlue());
assertLife(playerA, 42);
assertLife(playerB, 40);
}
}