Merge pull request #4283 from JayDi85/ui-choose-new

Added new choose dialog
This commit is contained in:
Oleg Agafonov 2017-12-28 02:59:09 +04:00 committed by GitHub
commit 7954031f41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 1111 additions and 371 deletions

View file

@ -30,6 +30,7 @@ package org.mage.test.cards.mana;
import mage.abilities.keyword.FlyingAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -75,9 +76,10 @@ public class ConditionalManaTest extends CardTestPlayerBase {
@Test
public void testWorkingWithReflectingPool() {
addCard(Zone.BATTLEFIELD, playerA, "Cavern of Souls", 1);
addCard(Zone.BATTLEFIELD, playerA, "Reflecting Pool", 1); // can create white mana without restriction from the Cavern
addCard(Zone.HAND, playerA, "Silvercoat Lion", 1);
addCard(Zone.BATTLEFIELD, playerA, "Cavern of Souls", 1); // can give {C] or {any} mana ({any} with restrictions)
addCard(Zone.BATTLEFIELD, playerA, "Reflecting Pool", 1); // must give {C} or {any} mana from the Cavern, but without restrictions
addCard(Zone.HAND, playerA, "Silvercoat Lion", 1); // white bear
addCard(Zone.BATTLEFIELD, playerA, "Upwelling", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion");

View file

@ -33,10 +33,11 @@ import mage.constants.Zone;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import static org.mage.test.utils.ManaOptionsTestUtils.*;
/**
*
* @author LevelX2
* @author LevelX2, JayDi85
*/
public class HarvesterDruidTest extends CardTestPlayerBase {
@ -52,8 +53,10 @@ public class HarvesterDruidTest extends CardTestPlayerBase {
execute();
ManaOptions options = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("Player should be able to create 2 red and 1 blue mana", "{U}{R}{R}", options.get(0).toString());
Assert.assertEquals("Player should be able to create 1 red and 3 blue mana", "{U}{U}{R}", options.get(1).toString());
assertDuplicatedManaOptions(options);
Assert.assertEquals(2, options.size());
assertManaOptions("{U}{R}{R}", options);
assertManaOptions("{U}{U}{R}", options);
}
@Test
@ -68,9 +71,10 @@ public class HarvesterDruidTest extends CardTestPlayerBase {
execute();
ManaOptions options = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("Player should be able to create 3 red and 1 blue mana", "{U}{R}{R}{R}", options.get(0).toString());
Assert.assertEquals("Player should be able to create 2 red and 2 blue mana", "{U}{U}{R}{R}", options.get(1).toString());
Assert.assertEquals("Player should be able to create 2 red and 2 blue mana", "{U}{U}{R}{R}", options.get(2).toString());
Assert.assertEquals("Player should be able to create 1 red and 3 blue mana", "{U}{U}{U}{R}", options.get(3).toString());
assertDuplicatedManaOptions(options);
Assert.assertEquals(3, options.size());
assertManaOptions("{U}{R}{R}{R}", options);
assertManaOptions("{U}{U}{R}{R}", options);
assertManaOptions("{U}{U}{U}{R}", options);
}
}

View file

@ -1,15 +1,21 @@
package org.mage.test.cards.mana;
import mage.constants.Duration;
import mage.constants.ManaType;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import org.mage.test.utils.ManaOptionsTestUtils;
import static org.mage.test.utils.ManaOptionsTestUtils.manaOptionsContain;
/**
*
* @author escplan9
* @author escplan9, JayDi85
*/
public class NagaVitalistTest extends CardTestPlayerBase {
@ -21,21 +27,116 @@ public class NagaVitalistTest extends CardTestPlayerBase {
private final String nagaVitalist = "Naga Vitalist";
/*
Reported bug (issue #3315)
Naga Vitalist could not produce any color mana with a Gift of Paradise enchanted on a forest. All lands on board were forests.
*/
@Test
public void nagaVitalist_InteractionGiftOfParadise() {
/*
Gift of Paradise 2G
Enchantment - Aura
Enchant - Land
When Gift of Paradise enters the battlefield, you gain 3 life.
Enchanted land has "T: Add two mana of any one color to your mana pool."
*/
String giftParadise = "Gift of Paradise";
*/
private final String giftParadise = "Gift of Paradise";
@Test
public void nagaVitalist_GiftOfParadiseCanAnyColor() {
addCard(Zone.BATTLEFIELD, playerA, "Upwelling");
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.HAND, playerA, giftParadise);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
// manual mana cost, cause auto cost can get swamp to pay
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, giftParadise, "Swamp");
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
Assert.assertTrue("playerA must cast {Any}{Any}", manaOptionsContain(playerA.getManaAvailable(currentGame), "{Any}{Any}"));
}
public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(int giftCastTurn, int nagaManaTapTurn, String nagaManaTapColor){
// test errors on enchanted ability do not apply for "any mana search" on different steps
addCard(Zone.BATTLEFIELD, playerA, "Upwelling");
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.HAND, playerA, giftParadise);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerA, nagaVitalist, 1);
// cast and enchant swamp land to any color
activateManaAbility(giftCastTurn, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
activateManaAbility(giftCastTurn, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
activateManaAbility(giftCastTurn, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
castSpell(giftCastTurn, PhaseStep.PRECOMBAT_MAIN, playerA, giftParadise, "Swamp");
// activate red mana (by any from enchanted land)
activateManaAbility(nagaManaTapTurn, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add to your mana pool one mana of any");
setChoice(playerA, nagaManaTapColor);
setStopAt(nagaManaTapTurn, PhaseStep.PRECOMBAT_MAIN);
execute();
}
@Test
@Ignore // TODO: need to fix - on naga mana tap swamp do not have added ability "add 2 any mana" (but it have after step complete)
public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_SameStep1() {
nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(1, 1, "Red");
//logger.info(playerA.getManaPool().getMana().toString());
//logger.info(playerA.getManaAvailable(currentGame).toString());
//for(Permanent perm: currentGame.getBattlefield().getAllActivePermanents(playerA.getId())){
// logger.info(perm.getIdName() + ": " + perm.getAbilities().toString());
//}
assertTapped("Forest", true);
assertTapped(giftParadise, false);
assertTapped("Swamp", false);
assertTapped(nagaVitalist, true);
Assert.assertEquals(1, playerA.getManaPool().get(ManaType.RED));
}
@Test
public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_DiffStep1() {
nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(1, 2, "Red");
assertTapped("Forest", true);
assertTapped(giftParadise, false);
assertTapped("Swamp", false);
assertTapped(nagaVitalist, true);
Assert.assertEquals(1, playerA.getManaPool().get(ManaType.RED));
}
@Test
@Ignore // TODO: need to fix - on naga mana tap swamp do not have added ability "add 2 any mana" (but it have after step complete)
public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_SameStep3() {
nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(3, 3, "Red");
assertTapped("Forest", true);
assertTapped(giftParadise, false);
assertTapped("Swamp", false);
assertTapped(nagaVitalist, true);
Assert.assertEquals(1, playerA.getManaPool().get(ManaType.RED));
}
@Test
public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_DiffStep2() {
nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(3, 4, "Red");
assertTapped("Forest", true);
assertTapped(giftParadise, false);
assertTapped("Swamp", false);
assertTapped(nagaVitalist, true);
Assert.assertEquals(1, playerA.getManaPool().get(ManaType.RED));
}
/*
Reported bug (issue #3315)
Naga Vitalist could not produce any color mana with a Gift of Paradise enchanted on a forest. All lands on board were forests.
*/
@Test
public void nagaVitalist_InteractionGiftOfParadise() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.BATTLEFIELD, playerA, nagaVitalist);
addCard(Zone.BATTLEFIELD, playerA, "Upwelling"); // mana pools do not empty at the end of phases or turns
@ -43,7 +144,7 @@ public class NagaVitalistTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, giftParadise, "Forest");
activateManaAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add to your mana pool one mana of any type that a land you control could produce");
activateManaAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add to your mana pool one mana of any");
setChoice(playerA, "Red");
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
@ -51,6 +152,8 @@ public class NagaVitalistTest extends CardTestPlayerBase {
assertLife(playerA, 23); // gift of paradise ETB
assertTapped(nagaVitalist, true);
assertTapped(giftParadise, false);
assertTapped("Forest", false);
Assert.assertEquals("one red mana has to be in the mana pool", 1, playerA.getManaPool().get(ManaType.RED));
}
}

View file

@ -28,15 +28,18 @@
package org.mage.test.cards.mana;
import mage.abilities.mana.ManaOptions;
import mage.constants.ManaType;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import static org.mage.test.utils.ManaOptionsTestUtils.*;
/**
*
* @author LevelX2
* @author LevelX2, JayDi85
*/
public class ReflectingPoolTest extends CardTestPlayerBase {
@ -173,16 +176,122 @@ public class ReflectingPoolTest extends CardTestPlayerBase {
execute();
ManaOptions options = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("Player A should be able to create the ", "{G}{G}{G}", options.get(0).toString());
Assert.assertEquals("Player A should be able to create the ", "{W}{G}{G}", options.get(1).toString());
Assert.assertEquals("Player A should be able to create the ", "{W}{G}{G}", options.get(2).toString()); // ManaOption type optimzing seems not optimal yet
Assert.assertEquals("Player A should be able to create the ", "{W}{W}{G}", options.get(3).toString());
Assert.assertEquals("Player A should be able to create only 3 different mana options", 4, options.size());
Assert.assertEquals("Player A should be able to create only 3 different mana options", 3, options.size());
assertManaOptions("{G}{G}{G}", options);
assertManaOptions("{W}{G}{G}", options);
assertManaOptions("{W}{W}{G}", options);
options = playerB.getAvailableManaTest(currentGame);
Assert.assertEquals("Player B should be able to create the ", "{W}{G}", options.get(0).toString());
Assert.assertEquals("Player B should be able to create the ", "{W}{W}", options.get(1).toString());
Assert.assertEquals("Player B should be able to create only 3 different mana options", 2, options.size());
Assert.assertEquals("Player B should be able to create only 2 different mana options", 2, options.size());
assertManaOptions("{W}{G}", options);
assertManaOptions("{W}{W}", options);
}
@Test
public void testReflectingPoolGiveNonMana() {
addCard(Zone.HAND, playerA, bear1, 1);
addCard(Zone.BATTLEFIELD, playerA, "Reflecting Pool", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bear1); // do not have any mana
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
Assert.assertEquals(0, playerA.getManaPool().getMana().count());
assertPermanentCount(playerA, bear1, 0);
}
@Test
public void testReflectingPoolGiveNonMana2() {
addCard(Zone.HAND, playerA, bear1, 1);
addCard(Zone.BATTLEFIELD, playerA, "Reflecting Pool", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bear1); // do not have any mana
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
Assert.assertEquals(0, playerA.getManaPool().getMana().count());
assertPermanentCount(playerA, bear1, 0);
}
@Test
public void testReflectingPoolGiveBasicManaNeed() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
addCard(Zone.HAND, playerA, bear1G, 1);
addCard(Zone.BATTLEFIELD, playerA, "Reflecting Pool", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bear1G); // have {G} mana to cast
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertPermanentCount(playerA, bear1G, 1);
}
@Test
public void testReflectingPoolGiveBasicManaNotNeed() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
addCard(Zone.HAND, playerA, bear1G, 1);
addCard(Zone.BATTLEFIELD, playerA, "Reflecting Pool", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bear1G); // have only {W} mana, can't cast
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertPermanentCount(playerA, bear1G, 0);
}
@Test
public void testReflectingPoolAnyManaNeedWithoutCondition() {
// any mana source without conditions (use any mana at any time)
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerA, "City of Brass", 1);
String bear2GG = "Razorclaw Bear";
addCard(Zone.HAND, playerA, bear2GG, 1);
addCard(Zone.BATTLEFIELD, playerA, "Reflecting Pool", 1);
addCard(Zone.BATTLEFIELD, playerA, "Upwelling", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bear2GG); // 2 plains + 2 any -- can cast
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertPermanentCount(playerA, bear2GG, 1);
}
@Test
public void testReflectingPoolAnyManaNeedWithCondition() {
// any mana source have condition to use (Reflecting Pool must ignore that condition)
addCard(Zone.BATTLEFIELD, playerA, "Cavern of Souls", 1); // {C} or {any}
addCard(Zone.HAND, playerA, bear1G, 1);
addCard(Zone.BATTLEFIELD, playerA, "Reflecting Pool", 1);
addCard(Zone.BATTLEFIELD, playerA, "Upwelling", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bear1G); // {C} from cavern and {any} (green) from reflection
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertPermanentCount(playerA, bear1G, 1);
}
@Test
public void testReflectingPoolAnyManaTapped() {
// any mana source with tapped must allow use any too
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
addCard(Zone.BATTLEFIELD, playerA, "City of Brass", 1);
addCard(Zone.BATTLEFIELD, playerA, "Reflecting Pool", 1);
addCard(Zone.BATTLEFIELD, playerA, "Upwelling", 1);
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add one mana of any");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {W}");
setChoice(playerA,"Black");
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
logger.info(playerA.getManaPool().getMana().toString());
logger.info(playerA.getManaAvailable(currentGame).toString());
assertTapped("City of Brass", true);
assertTapped("Plains", true);
assertTapped("Reflecting Pool", false);
Assert.assertEquals(1, playerA.getManaPool().get(ManaType.BLACK));
}
}

View file

@ -27,9 +27,11 @@
*/
package org.mage.test.cards.mana;
import mage.constants.ManaType;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -60,7 +62,28 @@ public class VorinclexVoiceOfHungerTest extends CardTestPlayerBase {
execute();
assertPermanentCount(playerA, "Vedalken Mastermind", 1);
}
/**
* Vorinclex, Voice of Hunger is not mana doubling River of Tears.
*/
@Test
@Ignore // TODO: need to fix Vorinclex, Voice of Hunger -- it's double fireup mana tap event
public void testVorinclexVoiceofHungerRiverOfTearsManaMultiplier() {
addCard(Zone.BATTLEFIELD, playerA, "Upwelling", 1);
// Trample
// Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced.
// Whenever an opponent taps a land for mana, that land doesn't untap during its controller's next untap step.
addCard(Zone.BATTLEFIELD, playerA, "Vorinclex, Voice of Hunger", 1);
// {T}: Add {U} to your mana pool. If you played a land this turn, add {B} to your mana pool instead.
addCard(Zone.BATTLEFIELD, playerA, "River of Tears", 1);
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {U} to your mana pool");
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertManaPool(playerA, ManaType.BLUE, 2);
}
/**

View file

@ -837,22 +837,22 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
ManaPool manaPool = currentGame.getPlayer(player.getId()).getManaPool();
switch (color){
case COLORLESS:
Assert.assertEquals(manaPool.getColorless() + manaPool.getConditionalMana().stream().mapToInt(Mana::getColorless).sum(), amount);
Assert.assertEquals(amount,manaPool.getColorless() + manaPool.getConditionalMana().stream().mapToInt(Mana::getColorless).sum());
break;
case RED:
Assert.assertEquals(manaPool.getRed() + manaPool.getConditionalMana().stream().mapToInt(Mana::getRed).sum(), amount);
Assert.assertEquals(amount,manaPool.getRed() + manaPool.getConditionalMana().stream().mapToInt(Mana::getRed).sum());
break;
case BLUE:
Assert.assertEquals(manaPool.getBlue() + manaPool.getConditionalMana().stream().mapToInt(Mana::getBlue).sum(), amount);
Assert.assertEquals(amount,manaPool.getBlue() + manaPool.getConditionalMana().stream().mapToInt(Mana::getBlue).sum());
break;
case WHITE:
Assert.assertEquals(manaPool.getWhite() + manaPool.getConditionalMana().stream().mapToInt(Mana::getWhite).sum(), amount);
Assert.assertEquals(amount,manaPool.getWhite() + manaPool.getConditionalMana().stream().mapToInt(Mana::getWhite).sum());
break;
case GREEN:
Assert.assertEquals(manaPool.getGreen() + manaPool.getConditionalMana().stream().mapToInt(Mana::getGreen).sum(), amount);
Assert.assertEquals(amount,manaPool.getGreen() + manaPool.getConditionalMana().stream().mapToInt(Mana::getGreen).sum());
break;
case BLACK:
Assert.assertEquals(manaPool.getBlack() + manaPool.getConditionalMana().stream().mapToInt(Mana::getBlack).sum(), amount);
Assert.assertEquals(amount,manaPool.getBlack() + manaPool.getConditionalMana().stream().mapToInt(Mana::getBlack).sum());
break;
}
}

View file

@ -35,12 +35,13 @@ import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import static org.mage.test.utils.ManaOptionsTestUtils.*;
/**
* This test checks if the calculated possible mana options are correct related
* to the given mana sources available.
*
* @author LevelX2
* @author LevelX2, JayDi85
*/
public class ManaOptionsTest extends CardTestPlayerBase {
@ -52,9 +53,10 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
Assert.assertEquals("{G}{G}{G}", getManaOption(0, manaOptions));
assertManaOptions("{G}{G}{G}", manaOptions);
}
@ -69,12 +71,13 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 4, manaOptions.size());
Assert.assertEquals("{G}{G}{G}", getManaOption(0, manaOptions));
Assert.assertEquals("{W}{R}{G}{G}", getManaOption(1, manaOptions));
Assert.assertEquals("{W}{W}{R}{R}{G}", getManaOption(2, manaOptions));
Assert.assertEquals("{W}{W}{W}{R}{R}{R}", getManaOption(3, manaOptions));
assertManaOptions("{G}{G}{G}", manaOptions);
assertManaOptions("{W}{R}{G}{G}", manaOptions);
assertManaOptions("{W}{W}{R}{R}{G}", manaOptions);
assertManaOptions("{W}{W}{W}{R}{R}{R}", manaOptions);
}
@ -89,18 +92,19 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 10, manaOptions.size());
Assert.assertEquals("{C}{C}{C}", getManaOption(0, manaOptions));
Assert.assertEquals("{C}{C}{W}", getManaOption(1, manaOptions));
Assert.assertEquals("{C}{C}{U}", getManaOption(2, manaOptions));
Assert.assertEquals("{C}{W}{W}", getManaOption(3, manaOptions));
Assert.assertEquals("{C}{W}{U}", getManaOption(4, manaOptions));
Assert.assertEquals("{C}{U}{U}", getManaOption(5, manaOptions));
Assert.assertEquals("{W}{W}{W}", getManaOption(6, manaOptions));
Assert.assertEquals("{W}{W}{U}", getManaOption(7, manaOptions));
Assert.assertEquals("{W}{U}{U}", getManaOption(8, manaOptions));
Assert.assertEquals("{U}{U}{U}", getManaOption(9, manaOptions));
assertManaOptions("{C}{C}{C}", manaOptions);
assertManaOptions("{C}{C}{W}", manaOptions);
assertManaOptions("{C}{C}{U}", manaOptions);
assertManaOptions("{C}{W}{W}", manaOptions);
assertManaOptions("{C}{W}{U}", manaOptions);
assertManaOptions("{C}{U}{U}", manaOptions);
assertManaOptions("{W}{W}{W}", manaOptions);
assertManaOptions("{W}{W}{U}", manaOptions);
assertManaOptions("{W}{U}{U}", manaOptions);
assertManaOptions("{U}{U}{U}", manaOptions);
}
// Chromatic Sphere
@ -114,9 +118,10 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
Assert.assertEquals("{Any}{Any}", getManaOption(0, manaOptions));
assertManaOptions("{Any}{Any}", manaOptions);
}
// Orochi Leafcaller
@ -131,9 +136,10 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
Assert.assertEquals("{W}{W}{Any}{Any}", getManaOption(0, manaOptions));
assertManaOptions("{W}{W}{Any}{Any}", manaOptions);
}
// Crystal Quarry
@ -149,9 +155,10 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
Assert.assertEquals("{C}{W}{W}{G}{G}", getManaOption(0, manaOptions));
assertManaOptions("{C}{W}{W}{G}{G}", manaOptions);
}
// Crystal Quarry
@ -167,10 +174,11 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 2, manaOptions.size());
Assert.assertEquals("{C}{W}{W}{G}{G}{G}", getManaOption(0, manaOptions));
Assert.assertEquals("{W}{U}{B}{R}{G}", getManaOption(1, manaOptions));
assertManaOptions("{C}{W}{W}{G}{G}{G}", manaOptions);
assertManaOptions("{W}{U}{B}{R}{G}", manaOptions);
}
// Nykthos, Shrine to Nyx
@ -186,28 +194,30 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 2, manaOptions.size());
Assert.assertEquals("{C}{G}{G}{G}", getManaOption(0, manaOptions));
Assert.assertEquals("{G}{G}{G}{G}{G}", getManaOption(1, manaOptions));
assertManaOptions("{C}{G}{G}{G}", manaOptions);
assertManaOptions("{G}{G}{G}{G}{G}", manaOptions);
}
@Test
public void testNykthos2() {
addCard(Zone.BATTLEFIELD, playerA, "Sedge Scorpion", 4);
addCard(Zone.BATTLEFIELD, playerA, "Akroan Crusader", 3);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.BATTLEFIELD, playerA, "Nykthos, Shrine to Nyx", 1);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3); // {G}
addCard(Zone.BATTLEFIELD, playerA, "Nykthos, Shrine to Nyx", 1); // {C}
setStopAt(1, PhaseStep.UPKEEP);
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 3, manaOptions.size());
Assert.assertEquals("{C}{G}{G}{G}", getManaOption(0, manaOptions));
Assert.assertEquals("{G}{G}{G}{G}{G}", getManaOption(1, manaOptions));
Assert.assertEquals("{R}{R}{R}{G}", getManaOption(2, manaOptions));
assertManaOptions("{C}{G}{G}{G}", manaOptions);
assertManaOptions("{G}{G}{G}{G}{G}", manaOptions);
assertManaOptions("{R}{R}{R}{G}", manaOptions);
}
@Test
@ -220,13 +230,46 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
Assert.assertEquals("{C}{G}{Any}", getManaOption(0, manaOptions));
assertManaOptions("{C}{G}{Any}", manaOptions);
}
@Test
public void testMix1() {
public void testDuplicatedDontHave1() {
addCard(Zone.BATTLEFIELD, playerA, "City of Brass", 2); // Any
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
setStopAt(1, PhaseStep.UPKEEP);
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
}
@Test
public void testDuplicatedDontHave3() {
addCard(Zone.BATTLEFIELD, playerA, "Grove of the Burnwillows", 2); // R or G
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
setStopAt(1, PhaseStep.UPKEEP);
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
}
@Test
public void testDuplicatedHave() {
// getManaAvailable return any combination of mana variants evailable to player
// if mana ability cost another mana then if replaced in mana cost
// example:
// 1x forest
// 1x Chromatic Star ({1}, {T}, Sacrifice Chromatic Star: Add one mana of any color to your mana pool.)
// give {G}{Any}, but after pay it transform to {Any} (1 green will be pay)
// That's why there are can be duplicated records in getManaAvailable
// {1}, {T}, Sacrifice Chromatic Star: Add one mana of any color to your mana pool.
// When Chromatic Star is put into a graveyard from the battlefield, draw a card.
addCard(Zone.BATTLEFIELD, playerA, "Chromatic Star", 1);
@ -242,10 +285,9 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 2, manaOptions.size());
Assert.assertEquals("{Any}{Any}", getManaOption(0, manaOptions));
Assert.assertEquals("{Any}{Any}", getManaOption(1, manaOptions));
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertDuplicatedManaOptions(manaOptions);
assertManaOptions("{Any}{Any}", manaOptions);
}
@Test
@ -257,12 +299,13 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 4, manaOptions.size());
Assert.assertEquals("{C}{W}", getManaOption(0, manaOptions));
Assert.assertEquals("{W}{W}", getManaOption(1, manaOptions));
Assert.assertEquals("{W}{B}", getManaOption(2, manaOptions));
Assert.assertEquals("{B}{B}", getManaOption(3, manaOptions));
assertManaOptions("{C}{W}", manaOptions);
assertManaOptions("{W}{W}", manaOptions);
assertManaOptions("{W}{B}", manaOptions);
assertManaOptions("{B}{B}", manaOptions);
}
/**
@ -278,9 +321,10 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
Assert.assertEquals("{W}{B}", getManaOption(0, manaOptions));
assertManaOptions("{W}{B}", manaOptions);
}
@Test
@ -293,10 +337,11 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 2, manaOptions.size());
Assert.assertEquals("{W}{B}{B}", getManaOption(0, manaOptions));
Assert.assertEquals("{B}{B}{B}", getManaOption(1, manaOptions));
assertManaOptions("{W}{B}{B}", manaOptions);
assertManaOptions("{B}{B}{B}", manaOptions);
}
@Test
@ -312,9 +357,10 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
Assert.assertEquals("{C}{W}{B}", getManaOption(0, manaOptions));
assertManaOptions("{C}{W}{B}", manaOptions);
}
@Test
@ -331,9 +377,10 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
Assert.assertEquals("{C}{C}{C}{C}{W}{B}", getManaOption(0, manaOptions));
assertManaOptions("{C}{C}{C}{C}{W}{B}", manaOptions);
}
@Test
@ -349,17 +396,9 @@ public class ManaOptionsTest extends CardTestPlayerBase {
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
Assert.assertEquals("{B}{B}", getManaOption(0, manaOptions));
}
// TODO
// Test Calciform Pools combination mana lands
private String getManaOption(int index, ManaOptions manaOptions) {
if (manaOptions.size() < index + 1) {
return "";
}
return manaOptions.get(index).toString();
assertManaOptions("{B}{B}", manaOptions);
}
}

View file

@ -0,0 +1,48 @@
package org.mage.test.utils;
import mage.Mana;
import mage.abilities.mana.ManaOptions;
import org.junit.Assert;
import java.util.HashSet;
import java.util.Set;
public class ManaOptionsTestUtils {
public static String bear1W = "Silvercoat Lion"; // {1}{W}
public static String bearG = "Basking Rootwalla"; // {G}
public static String bear1 = "Augmenting Automaton"; // {1}
public static String bear1G = "Balduvian Bears"; // {1}{G}
public static String bear2C = "Matter Reshaper"; // {2}{C}
//mana info
//logger.info(playerA.getManaPool().getMana().toString());
//logger.info(playerA.getManaAvailable(currentGame).toString());
public static boolean manaOptionsContain(ManaOptions list, String searchMana){
for(Mana mana: list){
if (mana.toString().equals(searchMana)){
return true;
}
}
return false;
}
public static void assertManaOptions(String searchMana, ManaOptions manaList){
if(!manaOptionsContain(manaList, searchMana)){
Assert.fail("Can't find " + searchMana + " in " + manaList.toString());
}
}
public static void assertDuplicatedManaOptions(ManaOptions manaList){
Set<String> list = new HashSet<>();
for(Mana mana: manaList){
String s = mana.toString();
if(list.contains(s)){
Assert.fail("Founded duplicated mana option " + s + " in " + manaList.toString());
}else{
list.add(s);
}
}
}
}