mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
Some fixes/improvements to generation of available mana.
This commit is contained in:
parent
4dc70048d5
commit
0e3d4b335a
14 changed files with 674 additions and 354 deletions
|
|
@ -29,7 +29,6 @@ package org.mage.test.AI.basic;
|
||||||
|
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBaseAI;
|
import org.mage.test.serverside.base.CardTestPlayerBaseAI;
|
||||||
|
|
||||||
|
|
@ -67,7 +66,6 @@ public class CastCreaturesTest extends CardTestPlayerBaseAI {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore // AI should cast Myr Enforcer -> Check why it does not
|
|
||||||
public void testSimpleCast3() {
|
public void testSimpleCast3() {
|
||||||
// Affinity for artifacts (This spell costs less to cast for each artifact you control.)
|
// Affinity for artifacts (This spell costs less to cast for each artifact you control.)
|
||||||
addCard(Zone.HAND, playerA, "Myr Enforcer");
|
addCard(Zone.HAND, playerA, "Myr Enforcer");
|
||||||
|
|
@ -81,4 +79,83 @@ public class CastCreaturesTest extends CardTestPlayerBaseAI {
|
||||||
|
|
||||||
assertPermanentCount(playerA, "Myr Enforcer", 1);
|
assertPermanentCount(playerA, "Myr Enforcer", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSimpleCast4() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
|
||||||
|
addCard(Zone.HAND, playerA, "Plains");
|
||||||
|
skipInitShuffling();
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerA, "Fireshrieker");
|
||||||
|
addCard(Zone.HAND, playerA, "Blazing Specter"); // {2}{R}{B}
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Plains", 2);
|
||||||
|
assertPermanentCount(playerA, "Fireshrieker", 0);
|
||||||
|
assertPermanentCount(playerA, "Blazing Specter", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCast4Creature() {
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Swamp", 1);
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Mountain", 1);
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Island", 1);
|
||||||
|
addCard(Zone.HAND, playerA, "Plains");
|
||||||
|
skipInitShuffling();
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerA, "Loyal Sentry"); // {W} 1/1
|
||||||
|
addCard(Zone.HAND, playerA, "Silvercoat Lion"); // {1}{W} 2/2
|
||||||
|
addCard(Zone.HAND, playerA, "Rootwater Commando"); // {2}{U} 2/2
|
||||||
|
addCard(Zone.HAND, playerA, "Bog Wraith"); // {3}{B} 3/3
|
||||||
|
|
||||||
|
setStopAt(7, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Plains", 1);
|
||||||
|
assertPermanentCount(playerA, "Mountain", 1);
|
||||||
|
assertPermanentCount(playerA, "Island", 1);
|
||||||
|
assertPermanentCount(playerA, "Swamp", 1);
|
||||||
|
|
||||||
|
// assertLife(playerB, 11); // 1 + 1+2 + 1+2+2 =
|
||||||
|
assertPermanentCount(playerA, "Loyal Sentry", 1);
|
||||||
|
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
||||||
|
assertPermanentCount(playerA, "Rootwater Commando", 1);
|
||||||
|
assertPermanentCount(playerA, "Bog Wraith", 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCast4Creature2() {
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Swamp", 1);
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Swamp", 1);
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Plains", 1);
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerA, "Island", 1);
|
||||||
|
addCard(Zone.HAND, playerA, "Plains");
|
||||||
|
skipInitShuffling();
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerA, "Loyal Sentry"); // {W} 1/1
|
||||||
|
addCard(Zone.HAND, playerA, "Steadfast Guard"); // {W}{W} 2/2
|
||||||
|
addCard(Zone.HAND, playerA, "Rootwater Commando"); // {2}{U} 2/2
|
||||||
|
addCard(Zone.HAND, playerA, "Bog Wraith"); // {3}{B} 3/3
|
||||||
|
|
||||||
|
setStopAt(7, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Plains", 2);
|
||||||
|
assertPermanentCount(playerA, "Island", 1);
|
||||||
|
assertPermanentCount(playerA, "Swamp", 1);
|
||||||
|
|
||||||
|
// assertLife(playerB, 11); // 1 + 1+2 + 1+2+2 =
|
||||||
|
assertPermanentCount(playerA, "Loyal Sentry", 1);
|
||||||
|
assertPermanentCount(playerA, "Steadfast Guard", 1);
|
||||||
|
assertPermanentCount(playerA, "Rootwater Commando", 1);
|
||||||
|
assertPermanentCount(playerA, "Bog Wraith", 1);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package org.mage.test.AI.basic;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBaseAI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class CastDestroySpellsTest extends CardTestPlayerBaseAI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testOrzhovCharm() {
|
||||||
|
// Choose one -
|
||||||
|
// Return target creature you control and all Auras you control attached to it to their owner's hand;
|
||||||
|
// or destroy target creature and you lose life equal to its toughness;
|
||||||
|
// or return target creature card with converted mana cost 1 or less from your graveyard to the battlefield.
|
||||||
|
addCard(Zone.HAND, playerA, "Orzhov Charm"); // {W}{B}
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Fetid Heath", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
|
||||||
|
|
||||||
|
// Cycling abilities you activate cost you up to {2} less to activate.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertLife(playerA, 18);
|
||||||
|
|
||||||
|
assertGraveyardCount(playerA, "Orzhov Charm", 1);
|
||||||
|
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -35,7 +35,8 @@ import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test checks if the calculated possible mana options are correct related to the given mana sources available.
|
* This test checks if the calculated possible mana options are correct related
|
||||||
|
* to the given mana sources available.
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
|
@ -95,7 +96,6 @@ public class ManaOptionsTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Chromatic Sphere
|
// Chromatic Sphere
|
||||||
// {1}, {T}, Sacrifice Chromatic Sphere: Add one mana of any color to your mana pool. Draw a card.
|
// {1}, {T}, Sacrifice Chromatic Sphere: Add one mana of any color to your mana pool. Draw a card.
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -146,6 +146,7 @@ public class ManaOptionsTest extends CardTestPlayerBase {
|
||||||
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
|
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
|
||||||
Assert.assertEquals("{1}{G}{G}{W}{W}", getManaOption(0, manaOptions));
|
Assert.assertEquals("{1}{G}{G}{W}{W}", getManaOption(0, manaOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crystal Quarry
|
// Crystal Quarry
|
||||||
// {T}: {1} Add to your mana pool.
|
// {T}: {1} Add to your mana pool.
|
||||||
// {5}, {T}: Add {W}{U}{B}{R}{G} to your mana pool.
|
// {5}, {T}: Add {W}{U}{B}{R}{G} to your mana pool.
|
||||||
|
|
@ -217,9 +218,15 @@ public class ManaOptionsTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMix1() {
|
public void testMix1() {
|
||||||
|
// {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);
|
addCard(Zone.BATTLEFIELD, playerA, "Chromatic Star", 1);
|
||||||
|
// {1}, {T}, Sacrifice Chromatic Sphere: Add one mana of any color to your mana pool. Draw a card.
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Chromatic Sphere", 1);
|
addCard(Zone.BATTLEFIELD, playerA, "Chromatic Sphere", 1);
|
||||||
|
// {T}: Add {1} to your mana pool. If you control an Urza's Mine and an Urza's Power-Plant, add {3} to your mana pool instead.
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Urza's Tower", 1);
|
addCard(Zone.BATTLEFIELD, playerA, "Urza's Tower", 1);
|
||||||
|
// {T}: Add {1} to your mana pool.
|
||||||
|
// {T}: Add {R} or {G} to your mana pool. Each opponent gains 1 life.
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Grove of the Burnwillows", 1);
|
addCard(Zone.BATTLEFIELD, playerA, "Grove of the Burnwillows", 1);
|
||||||
|
|
||||||
setStopAt(1, PhaseStep.UPKEEP);
|
setStopAt(1, PhaseStep.UPKEEP);
|
||||||
|
|
@ -232,6 +239,56 @@ public class ManaOptionsTest extends CardTestPlayerBase {
|
||||||
Assert.assertEquals("{Any}{Any}", getManaOption(1, manaOptions));
|
Assert.assertEquals("{Any}{Any}", getManaOption(1, manaOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFetidHeath() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Fetid Heath", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.UPKEEP);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
|
||||||
|
|
||||||
|
Assert.assertEquals("mana variations don't fit", 3, manaOptions.size());
|
||||||
|
Assert.assertEquals("{W}{W}", getManaOption(0, manaOptions));
|
||||||
|
Assert.assertEquals("{W}{B}", getManaOption(1, manaOptions));
|
||||||
|
Assert.assertEquals("{B}{B}", getManaOption(2, manaOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't use mana sources that only reduce available mana
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCabalCoffers1() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Cabal Coffers", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.UPKEEP);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
|
||||||
|
|
||||||
|
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
|
||||||
|
Assert.assertEquals("{W}{B}", getManaOption(0, manaOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCabalCoffers2() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Cabal Coffers", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.UPKEEP);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
private String getManaOption(int index, ManaOptions manaOptions) {
|
private String getManaOption(int index, ManaOptions manaOptions) {
|
||||||
if (manaOptions.size() < index + 1) {
|
if (manaOptions.size() < index + 1) {
|
||||||
return "";
|
return "";
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,12 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage;
|
package mage;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import mage.constants.ColoredManaSymbol;
|
import mage.constants.ColoredManaSymbol;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
|
import static mage.constants.ManaType.COLORLESS;
|
||||||
import mage.filter.FilterMana;
|
import mage.filter.FilterMana;
|
||||||
import mage.util.Copyable;
|
import mage.util.Copyable;
|
||||||
import mage.util.ThreadLocalStringBuilder;
|
import mage.util.ThreadLocalStringBuilder;
|
||||||
|
|
@ -57,7 +57,8 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
public static final Mana BlackMana = BlackMana(1);
|
public static final Mana BlackMana = BlackMana(1);
|
||||||
public static final Mana ColorlessMana = ColorlessMana(1);
|
public static final Mana ColorlessMana = ColorlessMana(1);
|
||||||
|
|
||||||
public Mana() {}
|
public Mana() {
|
||||||
|
}
|
||||||
|
|
||||||
public Mana(final Mana mana) {
|
public Mana(final Mana mana) {
|
||||||
this.red = mana.red;
|
this.red = mana.red;
|
||||||
|
|
@ -212,7 +213,6 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int count() {
|
public int count() {
|
||||||
return red + green + blue + white + black + colorless + any;
|
return red + green + blue + white + black + colorless + any;
|
||||||
}
|
}
|
||||||
|
|
@ -569,39 +569,38 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equalManaValue(Mana mana) {
|
public boolean equalManaValue(Mana mana) {
|
||||||
return this.any == mana.any &&
|
return this.any == mana.any
|
||||||
this.red == mana.red &&
|
&& this.red == mana.red
|
||||||
this.green == mana.green &&
|
&& this.green == mana.green
|
||||||
this.white == mana.white &&
|
&& this.white == mana.white
|
||||||
this.blue == mana.blue &&
|
&& this.blue == mana.blue
|
||||||
this.black == mana.black &&
|
&& this.black == mana.black
|
||||||
this.colorless == mana.colorless;
|
&& this.colorless == mana.colorless;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Don't takes any mana into account to be usable in calculating available mana
|
* Don't takes any mana into account to be usable in calculating available
|
||||||
|
* mana
|
||||||
|
*
|
||||||
* @param mana
|
* @param mana
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean includesMana(Mana mana) {
|
public boolean includesMana(Mana mana) {
|
||||||
return this.green >= mana.green &&
|
return this.green >= mana.green
|
||||||
this.blue >= mana.blue &&
|
&& this.blue >= mana.blue
|
||||||
this.white >= mana.white &&
|
&& this.white >= mana.white
|
||||||
this.black >= mana.black &&
|
&& this.black >= mana.black
|
||||||
this.red >= mana.red &&
|
&& this.red >= mana.red
|
||||||
(
|
&& (this.colorless >= mana.colorless
|
||||||
this.colorless >= mana.colorless ||
|
|| this.countColored() >= mana.countColored() + mana.colorless);
|
||||||
this.countColored() >= mana.countColored() + mana.colorless
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the mana that is more colored but does not contain
|
* Returns the mana that is more colored but does not contain one less mana
|
||||||
* one less mana in any color but colorless
|
* in any color but colorless if you call with {1}{W}{R} and {G}{W}{R} you
|
||||||
* if you call with {1}{W}{R} and {G}{W}{R} you get back {G}{W}{R}
|
* get back {G}{W}{R} if you call with {G}{W}{R} and {G}{W}{R} you get back
|
||||||
* if you call with {G}{W}{R} and {G}{W}{R} you get back {G}{W}{R}
|
* {G}{W}{R} if you call with {G}{W}{B} and {G}{W}{R} you get back null
|
||||||
* if you call with {G}{W}{B} and {G}{W}{R} you get back null
|
|
||||||
*
|
*
|
||||||
* @param mana1
|
* @param mana1
|
||||||
* @param mana2
|
* @param mana2
|
||||||
|
|
@ -617,13 +616,12 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
moreMana = mana1;
|
moreMana = mana1;
|
||||||
lessMana = mana2;
|
lessMana = mana2;
|
||||||
}
|
}
|
||||||
if (lessMana.getWhite() > moreMana.getWhite() ||
|
if (lessMana.getWhite() > moreMana.getWhite()
|
||||||
lessMana.getRed() > moreMana.getRed() ||
|
|| lessMana.getRed() > moreMana.getRed()
|
||||||
lessMana.getGreen() > moreMana.getGreen() ||
|
|| lessMana.getGreen() > moreMana.getGreen()
|
||||||
lessMana.getBlue() > moreMana.getBlue() ||
|
|| lessMana.getBlue() > moreMana.getBlue()
|
||||||
lessMana.getBlack() > moreMana.getBlack() ||
|
|| lessMana.getBlack() > moreMana.getBlack()
|
||||||
lessMana.getAny() > moreMana.getAny()
|
|| lessMana.getAny() > moreMana.getAny()) {
|
||||||
) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return moreMana;
|
return moreMana;
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,9 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.AbilityType;
|
|
||||||
import mage.constants.TimingRule;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.Costs;
|
import mage.abilities.costs.Costs;
|
||||||
import mage.abilities.costs.mana.ManaCosts;
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
|
|
@ -40,12 +35,14 @@ import mage.abilities.costs.mana.PhyrexianManaCost;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.Effects;
|
import mage.abilities.effects.Effects;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
import mage.constants.AbilityType;
|
||||||
import mage.constants.AsThoughEffectType;
|
import mage.constants.AsThoughEffectType;
|
||||||
import mage.constants.TargetController;
|
import mage.constants.TargetController;
|
||||||
|
import mage.constants.TimingRule;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -62,7 +59,7 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
||||||
this.checkPlayableMode = false;
|
this.checkPlayableMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActivatedAbilityImpl(ActivatedAbilityImpl ability) {
|
public ActivatedAbilityImpl(final ActivatedAbilityImpl ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
timing = ability.timing;
|
timing = ability.timing;
|
||||||
mayActivate = ability.mayActivate;
|
mayActivate = ability.mayActivate;
|
||||||
|
|
@ -192,8 +189,8 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//20091005 - 602.5d/602.5e
|
//20091005 - 602.5d/602.5e
|
||||||
if (timing == TimingRule.INSTANT || game.canPlaySorcery(playerId) ||
|
if (timing == TimingRule.INSTANT || game.canPlaySorcery(playerId)
|
||||||
game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.ACTIVATE_AS_INSTANT, this, controllerId, game)) {
|
|| game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.ACTIVATE_AS_INSTANT, this, controllerId, game)) {
|
||||||
if (costs.canPay(this, sourceId, controllerId, game) && canChooseTarget(game)) {
|
if (costs.canPay(this, sourceId, controllerId, game) && canChooseTarget(game)) {
|
||||||
this.activatorId = playerId;
|
this.activatorId = playerId;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -205,8 +202,7 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
||||||
protected boolean controlsAbility(UUID playerId, Game game) {
|
protected boolean controlsAbility(UUID playerId, Game game) {
|
||||||
if (this.controllerId != null && this.controllerId.equals(playerId)) {
|
if (this.controllerId != null && this.controllerId.equals(playerId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Card card = (Card) game.getObject(this.sourceId);
|
Card card = (Card) game.getObject(this.sourceId);
|
||||||
if (card != null && game.getState().getZone(this.sourceId) != Zone.BATTLEFIELD) {
|
if (card != null && game.getState().getZone(this.sourceId) != Zone.BATTLEFIELD) {
|
||||||
return card.getOwnerId().equals(playerId);
|
return card.getOwnerId().equals(playerId);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -75,7 +74,7 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpellAbility(SpellAbility ability) {
|
public SpellAbility(final SpellAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
this.spellAbilityType = ability.spellAbilityType;
|
this.spellAbilityType = ability.spellAbilityType;
|
||||||
this.cardName = ability.cardName;
|
this.cardName = ability.cardName;
|
||||||
|
|
@ -83,9 +82,9 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
||||||
|
|
||||||
public boolean spellCanBeActivatedRegularlyNow(UUID playerId, Game game) {
|
public boolean spellCanBeActivatedRegularlyNow(UUID playerId, Game game) {
|
||||||
MageObject object = game.getObject(sourceId);
|
MageObject object = game.getObject(sourceId);
|
||||||
return timing == TimingRule.INSTANT ||
|
return timing == TimingRule.INSTANT
|
||||||
object.hasAbility(FlashAbility.getInstance().getId(), game) ||
|
|| object.hasAbility(FlashAbility.getInstance().getId(), game)
|
||||||
game.canPlaySorcery(playerId);
|
|| game.canPlaySorcery(playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
*/
|
*/
|
||||||
package mage.abilities.costs.mana;
|
package mage.abilities.costs.mana;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.constants.ColoredManaSymbol;
|
import mage.constants.ColoredManaSymbol;
|
||||||
|
|
@ -130,6 +132,14 @@ public class HybridManaCost extends ManaCostImpl {
|
||||||
return mana1.equals(coloredManaSymbol) || mana2.equals(coloredManaSymbol);
|
return mana1.equals(coloredManaSymbol) || mana2.equals(coloredManaSymbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Mana> getManaOptions() {
|
||||||
|
List<Mana> manaList = new ArrayList<>();
|
||||||
|
manaList.add(new Mana(mana1));
|
||||||
|
manaList.add(new Mana(mana2));
|
||||||
|
return manaList;
|
||||||
|
}
|
||||||
|
|
||||||
public ColoredManaSymbol getMana1() {
|
public ColoredManaSymbol getMana1() {
|
||||||
return mana1;
|
return mana1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.costs.mana;
|
package mage.abilities.costs.mana;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
|
|
@ -40,15 +40,27 @@ import mage.players.ManaPool;
|
||||||
public interface ManaCost extends Cost {
|
public interface ManaCost extends Cost {
|
||||||
|
|
||||||
int convertedManaCost();
|
int convertedManaCost();
|
||||||
|
|
||||||
Mana getMana();
|
Mana getMana();
|
||||||
|
|
||||||
|
List<Mana> getManaOptions();
|
||||||
|
|
||||||
Mana getPayment();
|
Mana getPayment();
|
||||||
|
|
||||||
void assignPayment(Game game, Ability ability, ManaPool pool);
|
void assignPayment(Game game, Ability ability, ManaPool pool);
|
||||||
|
|
||||||
void setPayment(Mana mana);
|
void setPayment(Mana mana);
|
||||||
|
|
||||||
ManaCost getUnpaid();
|
ManaCost getUnpaid();
|
||||||
|
|
||||||
ManaOptions getOptions();
|
ManaOptions getOptions();
|
||||||
|
|
||||||
boolean testPay(Mana testMana);
|
boolean testPay(Mana testMana);
|
||||||
|
|
||||||
Filter getSourceFilter();
|
Filter getSourceFilter();
|
||||||
|
|
||||||
void setSourceFilter(Filter filter);
|
void setSourceFilter(Filter filter);
|
||||||
|
|
||||||
boolean containsColor(ColoredManaSymbol coloredManaSymbol);
|
boolean containsColor(ColoredManaSymbol coloredManaSymbol);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -25,23 +25,23 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.costs.mana;
|
package mage.abilities.costs.mana;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.constants.ColoredManaSymbol;
|
|
||||||
import mage.constants.ManaType;
|
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.CostImpl;
|
import mage.abilities.costs.CostImpl;
|
||||||
import mage.abilities.mana.ManaOptions;
|
import mage.abilities.mana.ManaOptions;
|
||||||
|
import mage.constants.ColoredManaSymbol;
|
||||||
|
import mage.constants.ManaType;
|
||||||
import mage.filter.Filter;
|
import mage.filter.Filter;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.ManaPool;
|
import mage.players.ManaPool;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.ManaUtil;
|
import mage.util.ManaUtil;
|
||||||
|
|
||||||
|
|
||||||
public abstract class ManaCostImpl extends CostImpl implements ManaCost {
|
public abstract class ManaCostImpl extends CostImpl implements ManaCost {
|
||||||
|
|
||||||
protected Mana payment;
|
protected Mana payment;
|
||||||
|
|
@ -74,6 +74,13 @@ public abstract class ManaCostImpl extends CostImpl implements ManaCost {
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Mana> getManaOptions() {
|
||||||
|
List<Mana> manaList = new ArrayList<>();
|
||||||
|
manaList.add(cost);
|
||||||
|
return manaList;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ManaOptions getOptions() {
|
public ManaOptions getOptions() {
|
||||||
return options;
|
return options;
|
||||||
|
|
@ -214,8 +221,7 @@ public abstract class ManaCostImpl extends CostImpl implements ManaCost {
|
||||||
String promptText = ManaUtil.addSpecialManaPayAbilities(ability, game, unpaid);
|
String promptText = ManaUtil.addSpecialManaPayAbilities(ability, game, unpaid);
|
||||||
if (player.playMana(unpaid, promptText, game)) {
|
if (player.playMana(unpaid, promptText, game)) {
|
||||||
assignPayment(game, ability, player.getManaPool());
|
assignPayment(game, ability, player.getManaPool());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
game.getState().getSpecialActions().removeManaActions();
|
game.getState().getSpecialActions().removeManaActions();
|
||||||
|
|
|
||||||
|
|
@ -60,4 +60,5 @@ public interface ManaCosts<T extends ManaCost> extends List<T>, ManaCost {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
ManaCosts<T> copy();
|
ManaCosts<T> copy();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,15 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
||||||
return mana;
|
return mana;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Mana> getManaOptions() {
|
||||||
|
List<Mana> manaVariants = new ArrayList<>();
|
||||||
|
for (ManaCost cost : this) {
|
||||||
|
manaVariants.addAll(cost.getManaOptions());
|
||||||
|
}
|
||||||
|
return manaVariants;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mana getPayment() {
|
public Mana getPayment() {
|
||||||
Mana manaTotal = new Mana();
|
Mana manaTotal = new Mana();
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
*/
|
*/
|
||||||
package mage.abilities.costs.mana;
|
package mage.abilities.costs.mana;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.constants.ColoredManaSymbol;
|
import mage.constants.ColoredManaSymbol;
|
||||||
|
|
@ -118,4 +120,12 @@ public class MonoHybridManaCost extends ManaCostImpl {
|
||||||
public boolean containsColor(ColoredManaSymbol coloredManaSymbol) {
|
public boolean containsColor(ColoredManaSymbol coloredManaSymbol) {
|
||||||
return mana.equals(coloredManaSymbol);
|
return mana.equals(coloredManaSymbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Mana> getManaOptions() {
|
||||||
|
List<Mana> manaList = new ArrayList<>();
|
||||||
|
manaList.add(new Mana(mana));
|
||||||
|
manaList.add(Mana.ColorlessMana(2));
|
||||||
|
return manaList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,6 @@ import mage.util.CardUtil;
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CommanderColorIdentityManaAbility extends ManaAbility {
|
public class CommanderColorIdentityManaAbility extends ManaAbility {
|
||||||
|
|
||||||
private FilterMana commanderMana;
|
private FilterMana commanderMana;
|
||||||
|
|
@ -73,7 +72,7 @@ public class CommanderColorIdentityManaAbility extends ManaAbility {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Mana> getNetMana(Game game) {
|
public List<Mana> getNetMana(Game game) {
|
||||||
if (netMana.isEmpty()) {
|
if (netMana.isEmpty() && game != null) {
|
||||||
Player controller = game.getPlayer(getControllerId());
|
Player controller = game.getPlayer(getControllerId());
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
if (commanderMana == null) {
|
if (commanderMana == null) {
|
||||||
|
|
@ -110,7 +109,6 @@ public class CommanderColorIdentityManaAbility extends ManaAbility {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommanderIdentityManaEffect extends ManaEffect {
|
class CommanderIdentityManaEffect extends ManaEffect {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.mana;
|
package mage.abilities.mana;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -37,14 +36,17 @@ import mage.game.Game;
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*
|
*
|
||||||
* this class is used to build a list of all possible mana combinations
|
* this class is used to build a list of all possible mana combinations it can
|
||||||
* it can be used to find all the ways to pay a mana cost
|
* be used to find all the ways to pay a mana cost or all the different mana
|
||||||
* or all the different mana combinations available to a player
|
* combinations available to a player
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ManaOptions extends ArrayList<Mana> {
|
public class ManaOptions extends ArrayList<Mana> {
|
||||||
|
|
||||||
public ManaOptions () {};
|
public ManaOptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
public ManaOptions(final ManaOptions options) {
|
public ManaOptions(final ManaOptions options) {
|
||||||
for (Mana mana : options) {
|
for (Mana mana : options) {
|
||||||
|
|
@ -75,8 +77,7 @@ public class ManaOptions extends ArrayList<Mana> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else if (abilities.size() > 1) {
|
||||||
else if (abilities.size() > 1) {
|
|
||||||
//perform a union of all existing options and the new options
|
//perform a union of all existing options and the new options
|
||||||
List<Mana> copy = copy();
|
List<Mana> copy = copy();
|
||||||
this.clear();
|
this.clear();
|
||||||
|
|
@ -167,11 +168,12 @@ public class ManaOptions extends ArrayList<Mana> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Mana netMana : netManas) {
|
for (Mana netMana : netManas) {
|
||||||
CombineWithExisting:
|
|
||||||
for (Mana previousMana : copy) {
|
for (Mana previousMana : copy) {
|
||||||
|
CombineWithExisting:
|
||||||
|
for (Mana manaOption : ability.getManaCosts().getManaOptions()) {
|
||||||
Mana newMana = new Mana(previousMana);
|
Mana newMana = new Mana(previousMana);
|
||||||
if (previousMana.includesMana(ability.getManaCosts().getMana())) { // costs can be paid
|
if (previousMana.includesMana(manaOption)) { // costs can be paid
|
||||||
newMana.subtractCost(ability.getManaCosts().getMana());
|
newMana.subtractCost(manaOption);
|
||||||
newMana.add(netMana);
|
newMana.add(netMana);
|
||||||
// if the new mana is in all colors more than another already existing than replace
|
// if the new mana is in all colors more than another already existing than replace
|
||||||
for (Mana existingMana : this) {
|
for (Mana existingMana : this) {
|
||||||
|
|
@ -187,6 +189,7 @@ public class ManaOptions extends ArrayList<Mana> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -210,8 +213,7 @@ public class ManaOptions extends ArrayList<Mana> {
|
||||||
if (options.size() == 1) {
|
if (options.size() == 1) {
|
||||||
//if there is only one mana option available add it to all the existing options
|
//if there is only one mana option available add it to all the existing options
|
||||||
addMana(options.get(0));
|
addMana(options.get(0));
|
||||||
}
|
} else if (options.size() > 1) {
|
||||||
else if (options.size() > 1) {
|
|
||||||
//perform a union of all existing options and the new options
|
//perform a union of all existing options and the new options
|
||||||
List<Mana> copy = copy();
|
List<Mana> copy = copy();
|
||||||
this.clear();
|
this.clear();
|
||||||
|
|
@ -240,7 +242,26 @@ public class ManaOptions extends ArrayList<Mana> {
|
||||||
// deactivated because it does cause loops TODO: Find reason
|
// deactivated because it does cause loops TODO: Find reason
|
||||||
repeatable = true; // only replace to any with mana costs only will be repeated if able
|
repeatable = true; // only replace to any with mana costs only will be repeated if able
|
||||||
}
|
}
|
||||||
for (Mana mana: this) {
|
List<Mana> copy = copy();
|
||||||
|
this.clear();
|
||||||
|
for (Mana mana : copy) {
|
||||||
|
Mana oldMan = mana.copy();
|
||||||
|
if (mana.includesMana(cost)) {
|
||||||
|
// colorless costs can be paid with different colored mana, can lead to different color combinations
|
||||||
|
if (cost.getColorless() > 0 && cost.getColorless() > mana.getColorless()) {
|
||||||
|
Mana coloredCost = cost.copy();
|
||||||
|
coloredCost.setColorless(0);
|
||||||
|
mana.subtract(coloredCost);
|
||||||
|
for (Mana payCombination : getPossiblePayCombinations(cost.getColorless(), mana)) {
|
||||||
|
Mana newMana = mana.copy();
|
||||||
|
newMana.subtract(payCombination);
|
||||||
|
newMana.add(addMana);
|
||||||
|
if (oldMan.contains(newMana) && oldMan.count() > newMana.count()) {
|
||||||
|
newMana.setToMana(oldMan);
|
||||||
|
}
|
||||||
|
this.add(newMana);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (mana.includesMana(cost)) {
|
while (mana.includesMana(cost)) {
|
||||||
mana.subtractCost(cost);
|
mana.subtractCost(cost);
|
||||||
mana.add(addMana);
|
mana.add(addMana);
|
||||||
|
|
@ -248,7 +269,65 @@ public class ManaOptions extends ArrayList<Mana> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Don't use mana that only reduce the available mana
|
||||||
|
if (oldMan.contains(mana) && oldMan.count() > mana.count()) {
|
||||||
|
mana.setToMana(oldMan);
|
||||||
|
}
|
||||||
|
this.add(mana);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Mana> getPossiblePayCombinations(int number, Mana manaAvailable) {
|
||||||
|
List<Mana> payCombinations = new ArrayList<>();
|
||||||
|
List<String> payCombinationsStrings = new ArrayList<>();
|
||||||
|
if (manaAvailable.countColored() > 0) {
|
||||||
|
|
||||||
|
for (int i = 0; i < number; i++) {
|
||||||
|
List<Mana> existingManas = new ArrayList<>();
|
||||||
|
if (i > 0) {
|
||||||
|
existingManas.addAll(payCombinations);
|
||||||
|
payCombinations.clear();
|
||||||
|
payCombinationsStrings.clear();
|
||||||
|
} else {
|
||||||
|
existingManas.add(new Mana());
|
||||||
|
}
|
||||||
|
for (Mana existingMana : existingManas) {
|
||||||
|
Mana manaToPay = manaAvailable.copy();
|
||||||
|
manaToPay.subtract(existingMana);
|
||||||
|
if (manaToPay.getBlack() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.BlackMana.toString())) {
|
||||||
|
manaToPay.subtract(Mana.BlackMana);
|
||||||
|
addManaCombination(Mana.BlackMana, existingMana, payCombinations, payCombinationsStrings);
|
||||||
|
}
|
||||||
|
if (manaToPay.getBlue() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.BlueMana.toString())) {
|
||||||
|
manaToPay.subtract(Mana.BlueMana);
|
||||||
|
addManaCombination(Mana.BlueMana, existingMana, payCombinations, payCombinationsStrings);
|
||||||
|
}
|
||||||
|
if (manaToPay.getGreen() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.GreenMana.toString())) {
|
||||||
|
manaToPay.subtract(Mana.GreenMana);
|
||||||
|
addManaCombination(Mana.GreenMana, existingMana, payCombinations, payCombinationsStrings);
|
||||||
|
}
|
||||||
|
if (manaToPay.getRed() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.RedMana.toString())) {
|
||||||
|
manaToPay.subtract(Mana.RedMana);
|
||||||
|
addManaCombination(Mana.RedMana, existingMana, payCombinations, payCombinationsStrings);
|
||||||
|
}
|
||||||
|
if (manaToPay.getWhite() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.WhiteMana.toString())) {
|
||||||
|
manaToPay.subtract(Mana.WhiteMana);
|
||||||
|
addManaCombination(Mana.WhiteMana, existingMana, payCombinations, payCombinationsStrings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
payCombinations.add(new Mana(0, 0, 0, 0, 0, number, 0));
|
||||||
|
}
|
||||||
|
return payCombinations;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addManaCombination(Mana mana, Mana existingMana, List<Mana> payCombinations, List<String> payCombinationsStrings) {
|
||||||
|
Mana newMana = existingMana.copy();
|
||||||
|
newMana.add(mana);
|
||||||
|
payCombinations.add(newMana);
|
||||||
|
payCombinationsStrings.add(newMana.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue