Tests: added tests for Moritte of the Frost (related to #7546);

This commit is contained in:
Oleg Agafonov 2021-02-22 21:55:17 +04:00
parent 2accab79c5
commit 4050577d6b
2 changed files with 122 additions and 6 deletions

View file

@ -13,7 +13,7 @@ import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.util.functions.CopyApplier;
@ -24,6 +24,8 @@ import java.util.UUID;
*/
public final class MoritteOfTheFrost extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("a permanent you control");
public MoritteOfTheFrost(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{U}{U}");
@ -37,11 +39,7 @@ public final class MoritteOfTheFrost extends CardImpl {
this.addAbility(new ChangelingAbility());
// You may have Moritte of the Frost enter the battlefield as a copy of a permanent you control, except it's legendary and snow in addition to its other types and, if it's a creature, it enters with two additional +1/+1 counters on it and has changeling.
this.addAbility(new EntersBattlefieldAbility(new CopyPermanentEffect(
StaticFilters.FILTER_CONTROLLED_PERMANENT, new MoritteOfTheFrostCopyApplier()
).setText("as a copy of a permanent you control, except it's legendary and snow in addition to its other types " +
"and, if it's a creature, it enters with two additional +1/+1 counters on it and has changeling."
), true));
this.addAbility(new EntersBattlefieldAbility(new CopyPermanentEffect(filter, new MoritteOfTheFrostCopyApplier()), true));
}
private MoritteOfTheFrost(final MoritteOfTheFrost card) {
@ -56,6 +54,12 @@ public final class MoritteOfTheFrost extends CardImpl {
class MoritteOfTheFrostCopyApplier extends CopyApplier {
@Override
public String getText() {
return ", except it's legendary and snow in addition to its other types and, if it's a creature, "
+ "it enters with two additional +1/+1 counters on it and has changeling";
}
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
blueprint.addSuperType(SuperType.LEGENDARY);

View file

@ -0,0 +1,112 @@
package org.mage.test.cards.single.khm;
import mage.cards.Card;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author JayDi85
*/
public class MoritteOfTheFrostTest extends CardTestPlayerBase {
@Test
public void test_MustBeAnyTypeInHand() {
// bug: can't cast by mana from Myr Reservoir
// {T}: Add {C}{C}. Spend this mana only to cast Myr spells or activate abilities of Myr.
addCard(Zone.BATTLEFIELD, playerA, "Myr Reservoir");
//
// Changeling (This card is every creature type.)
addCard(Zone.HAND, playerA, "Moritte of the Frost");// {2}{G}{U}{U}
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
// prepare mana
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {C}{C}");
// cast myr and remove to to graveyard due 0/0
checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Moritte of the Frost", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Moritte of the Frost");
setChoice(playerA, "No"); // no copy
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerA, "Moritte of the Frost", 1); // removed to graveyard due 0/0
}
@Test
public void test_MustBeAnyTypeOnBattlefield() {
// {T}: Add {C}{C}. Spend this mana only to cast Myr spells or activate abilities of Myr.
addCard(Zone.BATTLEFIELD, playerA, "Myr Reservoir");
//
// Changeling (This card is every creature type.)
addCard(Zone.HAND, playerA, "Moritte of the Frost");// {2}{G}{U}{U}
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
//
// Minion creatures get +1/+1.
addCard(Zone.BATTLEFIELD, playerA, "Balthor the Defiled", 1);
// prepare mana
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {C}{C}");
// cast myr and keep on battlefield due boost
checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Moritte of the Frost", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Moritte of the Frost");
setChoice(playerA, "No"); // no copy
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Moritte of the Frost", 1); // boosted +1/+1
}
@Test
public void test_MustBeAnyTypeAfterCopy() {
// {T}: Add {C}{C}. Spend this mana only to cast Myr spells or activate abilities of Myr.
addCard(Zone.BATTLEFIELD, playerA, "Myr Reservoir");
//
// Changeling (This card is every creature type.)
// You may have Moritte of the Frost enter the battlefield as a copy of a permanent you control,
// except it's legendary and snow in addition to its other types and, if it's a creature, it enters
// with two additional +1/+1 counters on it and has changeling.
addCard(Zone.HAND, playerA, "Moritte of the Frost");// {2}{G}{U}{U}
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
//
// Minion creatures get +1/+1.
addCard(Zone.BATTLEFIELD, playerA, "Balthor the Defiled", 1);
//
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1); // 2/2
// prepare mana
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {C}{C}");
// cast myr and copy
checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Moritte of the Frost", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Moritte of the Frost");
setChoice(playerA, "Yes"); // use copy
setChoice(playerA, "Grizzly Bears"); // copy target
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Grizzly Bears", 2);
// boosted by copy and balthor
Card card = currentGame.getBattlefield().getAllActivePermanents().stream().filter(p -> p.isCopy()).findFirst().orElse(null);
Assert.assertNotNull("Can't find copy", card);
Assert.assertEquals("Copy power", 2 + 2 + 1, card.getPower().getValue());
Assert.assertEquals("Copy Toughness", 2 + 2 + 1, card.getToughness().getValue());
}
}