* Fixed another problem with available mana generation (e.g. with Nykthos, Shrine to Nyx).

This commit is contained in:
LevelX2 2015-02-13 15:03:29 +01:00
parent 0722276ca4
commit 8620fe5a7d
3 changed files with 50 additions and 3 deletions

View file

@ -167,6 +167,6 @@ class NykthosDynamicManaEffect extends ManaEffect {
break;
}
}
return computedMana;
return computedMana.copy();
}
}

View file

@ -164,6 +164,41 @@ public class ManaOptionsTest extends CardTestPlayerBase {
Assert.assertEquals("{R}{G}{U}{W}{B}", getManaOption(1, manaOptions));
}
// Nykthos, Shrine to Nyx
// {T}: Add {1} to your mana pool.
// {2}, {T}: Choose a color. Add to your mana pool an amount of mana of that color equal to your devotion to that color. (Your devotion to a color is the number of mana symbols of that color in the mana costs of permanents you control.)
@Test
public void testNykthos1() {
addCard(Zone.BATTLEFIELD, playerA, "Sedge Scorpion", 4);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.BATTLEFIELD, playerA, "Nykthos, Shrine to Nyx", 1);
setStopAt(1, PhaseStep. UPKEEP);
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit",1, manaOptions.size());
Assert.assertEquals("{G}{G}{G}{G}{G}", getManaOption(0, 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);
setStopAt(1, PhaseStep. UPKEEP);
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit",2, manaOptions.size());
Assert.assertEquals("{G}{G}{G}{G}{G}", getManaOption(0, manaOptions));
Assert.assertEquals("{R}{R}{R}{G}", getManaOption(1, manaOptions));
}
private String getManaOption(int index, ManaOptions manaOptions) {
if (manaOptions.size() < index + 1) {
return "";

View file

@ -114,7 +114,7 @@ public class ManaOptions extends ArrayList<Mana> {
if (abilities.size() == 1) {
//if there is only one mana option available add it to all the existing options
ManaAbility ability = abilities.get(0);
List<Mana> netManas = abilities.get(0).getNetMana(game);
List<Mana> netManas = abilities.get(0).getNetMana(game);
// no mana costs
if (ability.getManaCosts().isEmpty()) {
if (netManas.size() == 1) {
@ -154,7 +154,9 @@ public class ManaOptions extends ArrayList<Mana> {
List<Mana> copy = copy();
this.clear();
for (ManaAbility ability: abilities) {
List<Mana> netManas = ability.getNetMana(game);
if (ability.getManaCosts().isEmpty()) {
for (Mana netMana: netManas) {
for (Mana mana: copy) {
@ -167,12 +169,22 @@ public class ManaOptions extends ArrayList<Mana> {
}
else {
for (Mana netMana: netManas) {
CombineWithExisting:
for (Mana mana: copy) {
Mana newMana = new Mana();
newMana.add(mana);
if (mana.includesMana(ability.getManaCosts().getMana())) {
if (mana.includesMana(ability.getManaCosts().getMana())) { // costs can be paid
newMana.subtractCost(ability.getManaCosts().getMana());
newMana.add(netMana);
// if the new mana is more than another already existing than replace
for(Mana existingMana: this) {
Mana moreValuable = Mana.getMoreValuableMana(newMana, existingMana);
if (moreValuable != null) {
existingMana.setToMana(moreValuable);
continue CombineWithExisting;
}
}
// no existing Mana includes this new mana so add
this.add(newMana);
}
}