From 91067e89cb0c8c6880333ee6a57f6d2c2732d996 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 5 Sep 2020 16:50:51 -0400 Subject: [PATCH] rewrote party count test to allow for more easily adding additional cases --- .../cards/dynamicvalue/PartyCountTest.java | 147 +++++++++++------- 1 file changed, 90 insertions(+), 57 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/dynamicvalue/PartyCountTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/dynamicvalue/PartyCountTest.java index 1a18557d7d..f029153b43 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/dynamicvalue/PartyCountTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/dynamicvalue/PartyCountTest.java @@ -1,5 +1,9 @@ package org.mage.test.cards.dynamicvalue; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.common.PartyCount; +import mage.abilities.effects.common.GainLifeEffect; import mage.constants.CardType; import mage.constants.PhaseStep; import mage.constants.SubType; @@ -12,18 +16,61 @@ import org.mage.test.serverside.base.CardTestPlayerBase; */ public class PartyCountTest extends CardTestPlayerBase { - private static final String shpd = "Shepherd of Heroes"; - private static final String skrmshr = "Aven Skirmisher"; - private static final String dncstr = "Dromoka Dunecaster"; - private static final String ddgr = "Goldmeadow Dodger"; + private void makeTester() { + addCustomCardWithAbility( + "tester", playerA, + new SimpleActivatedAbility( + new GainLifeEffect(PartyCount.instance), new ManaCostsImpl<>("{0}") + ) + ); + } + + private void useTester() { + activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{0}:"); + } + + private void makeCreature(String name, SubType... subTypes) { + addCustomCardWithAbility( + name, playerA, null, null, + CardType.CREATURE, "{1}", Zone.BATTLEFIELD, subTypes + ); + } @Test public void testSingleMember() { - addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); - addCard(Zone.HAND, playerA, shpd); + makeTester(); + makeCreature("crt1", SubType.CLERIC); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, shpd); + useTester(); + setStopAt(1, PhaseStep.END_TURN); + setStrictChooseMode(true); + execute(); + assertAllCommandsUsed(); + assertLife(playerA, 21); + } + + @Test + public void testSingleMember2() { + makeTester(); + makeCreature("crt1", SubType.CLERIC, SubType.WIZARD); + + useTester(); + setStopAt(1, PhaseStep.END_TURN); + setStrictChooseMode(true); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 21); + } + + @Test + public void testTwoMembers() { + makeTester(); + makeCreature("crt1", SubType.CLERIC); + makeCreature("crt2", SubType.WARRIOR); + + useTester(); setStopAt(1, PhaseStep.END_TURN); setStrictChooseMode(true); execute(); @@ -32,96 +79,82 @@ public class PartyCountTest extends CardTestPlayerBase { assertLife(playerA, 22); } - @Test - public void testTwoMembers() { - addCard(Zone.BATTLEFIELD, playerA, "Plains", 6); - addCard(Zone.HAND, playerA, skrmshr); - addCard(Zone.HAND, playerA, shpd); - - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, shpd); - - setStopAt(1, PhaseStep.END_TURN); - setStrictChooseMode(true); - execute(); - assertAllCommandsUsed(); - - assertLife(playerA, 24); - } - @Test public void testTwoMembers2() { - addCard(Zone.BATTLEFIELD, playerA, "Plains", 7); - addCard(Zone.HAND, playerA, skrmshr, 2); - addCard(Zone.HAND, playerA, shpd); - - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, shpd); + makeTester(); + makeCreature("crt1", SubType.CLERIC); + makeCreature("crt2", SubType.CLERIC); + useTester(); setStopAt(1, PhaseStep.END_TURN); setStrictChooseMode(true); execute(); assertAllCommandsUsed(); - assertLife(playerA, 24); + assertLife(playerA, 21); } @Test public void testThreeMembers() { - addCard(Zone.BATTLEFIELD, playerA, "Plains", 7); - addCard(Zone.HAND, playerA, skrmshr); - addCard(Zone.HAND, playerA, dncstr); - addCard(Zone.HAND, playerA, shpd); - - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, dncstr); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, shpd); + makeTester(); + makeCreature("crt1", SubType.CLERIC); + makeCreature("crt2", SubType.WARRIOR); + makeCreature("crt3", SubType.WIZARD); + useTester(); setStopAt(1, PhaseStep.END_TURN); setStrictChooseMode(true); execute(); assertAllCommandsUsed(); - assertLife(playerA, 26); + assertLife(playerA, 23); } - private void makeCreature(String name, SubType... subTypes) { - addCustomCardWithAbility(name, playerA, null, null, CardType.CREATURE, "{1}", Zone.BATTLEFIELD, subTypes); + @Test + public void testThreeMembers2() { + makeTester(); + makeCreature("crt1", SubType.CLERIC, SubType.WARRIOR); + makeCreature("crt2", SubType.CLERIC, SubType.WARRIOR); + makeCreature("crt3", SubType.CLERIC, SubType.WARRIOR, SubType.WIZARD); + + useTester(); + setStopAt(1, PhaseStep.END_TURN); + setStrictChooseMode(true); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 23); } @Test public void testOddCombos() { - addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); - addCard(Zone.HAND, playerA, shpd); - makeCreature("crtA", SubType.ROGUE, SubType.WIZARD, SubType.WARRIOR); - makeCreature("crtB", SubType.ROGUE, SubType.CLERIC); - makeCreature("crtC", SubType.CLERIC, SubType.WIZARD); - makeCreature("crtD", SubType.WARRIOR, SubType.WIZARD); - - castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, shpd); + makeTester(); + makeCreature("crt1", SubType.ROGUE, SubType.WIZARD, SubType.WARRIOR); + makeCreature("crt2", SubType.ROGUE, SubType.CLERIC); + makeCreature("crt3", SubType.CLERIC, SubType.WIZARD); + makeCreature("crt4", SubType.WARRIOR, SubType.WIZARD); + useTester(); setStopAt(1, PhaseStep.END_TURN); setStrictChooseMode(true); execute(); assertAllCommandsUsed(); - assertLife(playerA, 28); + assertLife(playerA, 24); } @Test public void testChangelings() { - addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); - addCard(Zone.BATTLEFIELD, playerA, "Impostor of the Sixth Pride", 4); - addCard(Zone.HAND, playerA, shpd); + makeTester(); + addCard(Zone.BATTLEFIELD, playerA, "Impostor of the Sixth Pride", 3); - castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, shpd); + useTester(); setStopAt(1, PhaseStep.END_TURN); setStrictChooseMode(true); execute(); assertAllCommandsUsed(); - assertLife(playerA, 28); + assertLife(playerA, 23); } }