mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Fixed cards with any color lands produce ability:
* Fixed ManaOptions result (no more duplicated records with same options); * Fixed mana types searching (now mana search return {Any} type too); * Fixed cards: Fellwar Stone, Harvester Druid, Reflecting Pool (#4125), Sylvok Explorer, Exotic Orchard (#3374), Naga Vitalist;
This commit is contained in:
parent
8fe1c46ade
commit
68c6551188
8 changed files with 301 additions and 65 deletions
|
@ -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");
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -221,6 +221,19 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
return new Mana(0, 0, 0, 0, 0, 0, 0, notNegative(num, "Colorless"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Mana} object with the passed in {@code num} of Any
|
||||
* mana. {@code num} can not be a negative value. Negative values will be
|
||||
* logged and set to 0.
|
||||
*
|
||||
* @param num value of Any mana to create.
|
||||
* @return a {@link Mana} object with the passed in {@code num} of Any
|
||||
* mana.
|
||||
*/
|
||||
public static Mana AnyMana(int num) {
|
||||
return new Mana(0, 0, 0, 0, 0, 0, notNegative(num, "Any"), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mana from the passed in {@link Mana} object to this object.
|
||||
*
|
||||
|
|
|
@ -225,6 +225,9 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
|
|||
if (types.getColorless() > 0) {
|
||||
netManas.add(Mana.ColorlessMana(1));
|
||||
}
|
||||
if (types.getAny() > 0) {
|
||||
netManas.add(Mana.AnyMana(1));
|
||||
}
|
||||
return netManas;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,10 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.game.Game;
|
||||
|
||||
|
@ -326,4 +329,19 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
payCombinations.add(newMana);
|
||||
payCombinationsStrings.add(newMana.toString());
|
||||
}
|
||||
|
||||
|
||||
public void removeDuplicated(){
|
||||
Set<String> list = new HashSet<>();
|
||||
|
||||
for(int i = this.size() - 1; i >= 0; i--){
|
||||
String s = this.get(i).toString();
|
||||
if (list.contains(s)){
|
||||
// remove duplicated
|
||||
this.remove(i);
|
||||
}else{
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2439,6 +2439,10 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
for (Abilities<ActivatedManaAbilityImpl> manaAbilities : sourceWithCosts) {
|
||||
available.addManaWithCost(manaAbilities, game);
|
||||
}
|
||||
|
||||
// remove duplicated variants (see ManaOptionsTest for info - when thats rises)
|
||||
available.removeDuplicated();
|
||||
|
||||
return available;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue