mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
fixed tests, updated test framework
This commit is contained in:
parent
fa40ffe837
commit
f0df4267a3
2 changed files with 64 additions and 52 deletions
|
@ -1,6 +1,8 @@
|
|||
package org.mage.test.cards.dynamicvalue;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
@ -14,30 +16,18 @@ public class PartyCountTest extends CardTestPlayerBase {
|
|||
private static final String skrmshr = "Aven Skirmisher";
|
||||
private static final String dncstr = "Dromoka Dunecaster";
|
||||
private static final String ddgr = "Goldmeadow Dodger";
|
||||
private static final String mstfrm = "Mistform Sliver";
|
||||
private static final String glrdr = "Galerider Sliver";
|
||||
private static final String mtllc = "Metallic Sliver";
|
||||
private static final String pltd = "Plated Sliver";
|
||||
private static final String cleric = "Cleric";
|
||||
private static final String rogue = "Rogue";
|
||||
private static final String warrior = "Warrior";
|
||||
private static final String wizard = "Wizard";
|
||||
|
||||
private void setType(String creature, String type) {
|
||||
setChoice(playerA, type);
|
||||
activateAbility(2, PhaseStep.POSTCOMBAT_MAIN, playerA, creature);
|
||||
waitStackResolved(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleMember() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
||||
addCard(Zone.HAND, playerA, shpd);
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, shpd);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, shpd);
|
||||
|
||||
setStopAt(2, PhaseStep.END_TURN);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertLife(playerA, 22);
|
||||
}
|
||||
|
@ -48,11 +38,13 @@ public class PartyCountTest extends CardTestPlayerBase {
|
|||
addCard(Zone.HAND, playerA, skrmshr);
|
||||
addCard(Zone.HAND, playerA, shpd);
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr);
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, shpd);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, shpd);
|
||||
|
||||
setStopAt(2, PhaseStep.END_TURN);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertLife(playerA, 24);
|
||||
}
|
||||
|
@ -63,12 +55,14 @@ public class PartyCountTest extends CardTestPlayerBase {
|
|||
addCard(Zone.HAND, playerA, skrmshr, 2);
|
||||
addCard(Zone.HAND, playerA, shpd);
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr);
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr);
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, shpd);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, shpd);
|
||||
|
||||
setStopAt(2, PhaseStep.END_TURN);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertLife(playerA, 24);
|
||||
}
|
||||
|
@ -80,47 +74,37 @@ public class PartyCountTest extends CardTestPlayerBase {
|
|||
addCard(Zone.HAND, playerA, dncstr);
|
||||
addCard(Zone.HAND, playerA, shpd);
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr);
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, dncstr);
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, shpd);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, skrmshr);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, dncstr);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, shpd);
|
||||
|
||||
setStopAt(2, PhaseStep.END_TURN);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertLife(playerA, 26);
|
||||
}
|
||||
|
||||
private void makeCreature(String name, SubType... subTypes) {
|
||||
addCustomCardWithAbility("dude", playerA, null, null, CardType.CREATURE, "{1}", Zone.BATTLEFIELD, subTypes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOddCombos() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Tundra", 19);
|
||||
addCard(Zone.HAND, playerA, mstfrm);
|
||||
addCard(Zone.HAND, playerA, glrdr);
|
||||
addCard(Zone.HAND, playerA, mtllc);
|
||||
addCard(Zone.HAND, playerA, pltd);
|
||||
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(2, PhaseStep.PRECOMBAT_MAIN, playerA, mstfrm);
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, glrdr);
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, mtllc);
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, pltd);
|
||||
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, shpd);
|
||||
|
||||
setType(mstfrm, rogue);
|
||||
setType(mstfrm, wizard);
|
||||
setType(mstfrm, warrior);
|
||||
|
||||
setType(glrdr, rogue);
|
||||
setType(glrdr, cleric);
|
||||
|
||||
setType(mtllc, cleric);
|
||||
setType(mtllc, wizard);
|
||||
|
||||
setType(pltd, warrior);
|
||||
setType(pltd, wizard);
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, shpd);
|
||||
|
||||
setStopAt(2, PhaseStep.END_TURN);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertLife(playerA, 28);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.mage.test.serverside.base;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.AbilitiesImpl;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -381,8 +382,15 @@ public abstract class MageTestPlayerBase {
|
|||
|
||||
protected void addCustomCardWithAbility(String customName, TestPlayer controllerPlayer, Ability ability, SpellAbility spellAbility,
|
||||
CardType cardType, String spellCost, Zone putAtZone) {
|
||||
addCustomCardWithAbility(customName, controllerPlayer, ability, spellAbility, cardType, spellCost, putAtZone, null);
|
||||
}
|
||||
|
||||
protected void addCustomCardWithAbility(String customName, TestPlayer controllerPlayer, Ability ability, SpellAbility spellAbility,
|
||||
CardType cardType, String spellCost, Zone putAtZone, SubType... additionalSubTypes) {
|
||||
CustomTestCard.clearCustomAbilities(customName);
|
||||
CustomTestCard.addCustomAbility(customName, spellAbility, ability);
|
||||
CustomTestCard.clearAdditionalSubtypes(customName);
|
||||
CustomTestCard.addAdditionalSubtypes(customName, additionalSubTypes);
|
||||
|
||||
CardSetInfo testSet = new CardSetInfo(customName, "custom", "123", Rarity.COMMON);
|
||||
PermanentCard card = new PermanentCard(new CustomTestCard(controllerPlayer.getId(), testSet, cardType, spellCost), controllerPlayer.getId(), currentGame);
|
||||
|
@ -414,6 +422,7 @@ class CustomTestCard extends CardImpl {
|
|||
|
||||
static private final Map<String, Abilities<Ability>> abilitiesList = new HashMap<>(); // card name -> abilities
|
||||
static private final Map<String, SpellAbility> spellAbilitiesList = new HashMap<>(); // card name -> spell ability
|
||||
static private final Map<String, Set<SubType>> subTypesList = new HashMap<>(); // card name -> additional subtypes
|
||||
|
||||
static void addCustomAbility(String cardName, SpellAbility spellAbility, Ability ability) {
|
||||
if (!abilitiesList.containsKey(cardName)) {
|
||||
|
@ -430,6 +439,14 @@ class CustomTestCard extends CardImpl {
|
|||
spellAbilitiesList.remove(cardName);
|
||||
}
|
||||
|
||||
static void addAdditionalSubtypes(String cardName, SubType... subtypes) {
|
||||
subTypesList.computeIfAbsent(cardName, s -> new HashSet<>()).addAll(Arrays.asList(subtypes.clone()));
|
||||
}
|
||||
|
||||
static void clearAdditionalSubtypes(String cardName) {
|
||||
subTypesList.remove(cardName);
|
||||
}
|
||||
|
||||
CustomTestCard(UUID ownerId, CardSetInfo setInfo, CardType cardType, String spellCost) {
|
||||
super(ownerId, setInfo, new CardType[]{cardType}, spellCost);
|
||||
|
||||
|
@ -443,6 +460,17 @@ class CustomTestCard extends CardImpl {
|
|||
this.addAbility(ability.copy());
|
||||
}
|
||||
}
|
||||
|
||||
Set<SubType> subTypeSet = subTypesList.get(setInfo.getName());
|
||||
if (subTypeSet != null) {
|
||||
for (SubType subType : subTypeSet) {
|
||||
this.subtype.add(subType);
|
||||
}
|
||||
}
|
||||
if (cardType == CardType.CREATURE) {
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
}
|
||||
}
|
||||
|
||||
private CustomTestCard(final CustomTestCard card) {
|
||||
|
|
Loading…
Reference in a new issue