mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
more paths require manapool
This commit is contained in:
@@ -96,7 +96,7 @@ public class ComputerUtilMana {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean payManaCost(final ManaCostBeingPaid cost, final SpellAbility sa, final Player ai, final boolean test, final int extraMana, boolean checkPlayable, boolean clearManaPaid) {
|
private static boolean payManaCost(final ManaCostBeingPaid cost, final SpellAbility sa, final Player ai, final boolean test, final int extraMana, boolean checkPlayable, boolean clearManaPaid) {
|
||||||
adjustManaCostToAvoidNegEffects(cost, sa.getSourceCard());
|
adjustManaCostToAvoidNegEffects(cost, sa.getSourceCard(), ai);
|
||||||
|
|
||||||
final ManaPool manapool = ai.getManaPool();
|
final ManaPool manapool = ai.getManaPool();
|
||||||
List<ManaCostShard> unpaidShards = cost.getUnpaidShards();
|
List<ManaCostShard> unpaidShards = cost.getUnpaidShards();
|
||||||
@@ -194,7 +194,7 @@ public class ComputerUtilMana {
|
|||||||
String manaProduced = toPay.isSnow() ? "S" : GameActionUtil.generatedMana(saPayment);
|
String manaProduced = toPay.isSnow() ? "S" : GameActionUtil.generatedMana(saPayment);
|
||||||
manaProduced = AbilityManaPart.applyManaReplacement(saPayment, manaProduced);
|
manaProduced = AbilityManaPart.applyManaReplacement(saPayment, manaProduced);
|
||||||
//System.out.println(manaProduced);
|
//System.out.println(manaProduced);
|
||||||
payMultipleMana(cost, manaProduced);
|
payMultipleMana(cost, manaProduced, ai);
|
||||||
|
|
||||||
// remove from available lists
|
// remove from available lists
|
||||||
for (Collection<SpellAbility> kv : sourcesForShards.values()) {
|
for (Collection<SpellAbility> kv : sourcesForShards.values()) {
|
||||||
@@ -346,14 +346,14 @@ public class ComputerUtilMana {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void adjustManaCostToAvoidNegEffects(ManaCostBeingPaid cost, final Card card) {
|
private static void adjustManaCostToAvoidNegEffects(ManaCostBeingPaid cost, final Card card, Player ai) {
|
||||||
// Make mana needed to avoid negative effect a mandatory cost for the AI
|
// Make mana needed to avoid negative effect a mandatory cost for the AI
|
||||||
for (String manaPart : card.getSVar("ManaNeededToAvoidNegativeEffect").split(",")) {
|
for (String manaPart : card.getSVar("ManaNeededToAvoidNegativeEffect").split(",")) {
|
||||||
// convert long color strings to short color strings
|
// convert long color strings to short color strings
|
||||||
byte mask = MagicColor.fromName(manaPart);
|
byte mask = MagicColor.fromName(manaPart);
|
||||||
|
|
||||||
// make mana mandatory for AI
|
// make mana mandatory for AI
|
||||||
if (!cost.needsColor(mask) && cost.getColorlessManaAmount() > 0) {
|
if (!cost.needsColor(mask, ai.getManaPool()) && cost.getColorlessManaAmount() > 0) {
|
||||||
ManaCostShard shard = ManaCostShard.valueOf(mask);
|
ManaCostShard shard = ManaCostShard.valueOf(mask);
|
||||||
cost.increaseShard(shard, 1);
|
cost.increaseShard(shard, 1);
|
||||||
cost.decreaseColorlessMana(1);
|
cost.decreaseColorlessMana(1);
|
||||||
@@ -390,9 +390,9 @@ public class ComputerUtilMana {
|
|||||||
choice = abMana.getExpressChoice();
|
choice = abMana.getExpressChoice();
|
||||||
abMana.clearExpressChoice();
|
abMana.clearExpressChoice();
|
||||||
byte colorMask = MagicColor.fromName(choice);
|
byte colorMask = MagicColor.fromName(choice);
|
||||||
if (abMana.canProduce(choice, manaAb) && testCost.isAnyPartPayableWith(colorMask)) {
|
if (abMana.canProduce(choice, manaAb) && testCost.isAnyPartPayableWith(colorMask, ai.getManaPool())) {
|
||||||
choiceString.append(choice);
|
choiceString.append(choice);
|
||||||
payMultipleMana(testCost, choice);
|
payMultipleMana(testCost, choice, ai);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -400,8 +400,8 @@ public class ComputerUtilMana {
|
|||||||
if (!testCost.isPaid()) {
|
if (!testCost.isPaid()) {
|
||||||
// Loop over combo colors
|
// Loop over combo colors
|
||||||
for (String color : comboColors) {
|
for (String color : comboColors) {
|
||||||
if (testCost.isAnyPartPayableWith(MagicColor.fromName(color))) {
|
if (testCost.isAnyPartPayableWith(MagicColor.fromName(color), ai.getManaPool())) {
|
||||||
payMultipleMana(testCost, color);
|
payMultipleMana(testCost, color, ai);
|
||||||
if (nMana != 1) {
|
if (nMana != 1) {
|
||||||
choiceString.append(" ");
|
choiceString.append(" ");
|
||||||
}
|
}
|
||||||
@@ -447,12 +447,12 @@ public class ComputerUtilMana {
|
|||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private final static String payMultipleMana(ManaCostBeingPaid testCost, String mana) {
|
private final static String payMultipleMana(ManaCostBeingPaid testCost, String mana, final Player p) {
|
||||||
List<String> unused = new ArrayList<String>(4);
|
List<String> unused = new ArrayList<String>(4);
|
||||||
for (String manaPart : TextUtil.split(mana, ' ')) {
|
for (String manaPart : TextUtil.split(mana, ' ')) {
|
||||||
if (StringUtils.isNumeric(manaPart)) {
|
if (StringUtils.isNumeric(manaPart)) {
|
||||||
for (int i = Integer.parseInt(manaPart); i > 0; i--) {
|
for (int i = Integer.parseInt(manaPart); i > 0; i--) {
|
||||||
boolean wasNeeded = testCost.ai_payMana("1");
|
boolean wasNeeded = testCost.ai_payMana("1", p.getManaPool());
|
||||||
if (!wasNeeded) {
|
if (!wasNeeded) {
|
||||||
unused.add(Integer.toString(i));
|
unused.add(Integer.toString(i));
|
||||||
break;
|
break;
|
||||||
@@ -461,7 +461,7 @@ public class ComputerUtilMana {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String color = MagicColor.toShortString(manaPart);
|
String color = MagicColor.toShortString(manaPart);
|
||||||
boolean wasNeeded = testCost.ai_payMana(color);
|
boolean wasNeeded = testCost.ai_payMana(color, p.getManaPool());
|
||||||
if (!wasNeeded) {
|
if (!wasNeeded) {
|
||||||
unused.add(color);
|
unused.add(color);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public class ManaCostBeingPaid {
|
|||||||
|
|
||||||
// takes a Short Color and returns true if it exists in the mana cost.
|
// takes a Short Color and returns true if it exists in the mana cost.
|
||||||
// Easier for split costs
|
// Easier for split costs
|
||||||
public final boolean needsColor(final byte colorMask) {
|
public final boolean needsColor(final byte colorMask, final ManaPool pool) {
|
||||||
for (ManaCostShard shard : unpaidShards.keySet()) {
|
for (ManaCostShard shard : unpaidShards.keySet()) {
|
||||||
if (shard == ManaCostShard.COLORLESS) {
|
if (shard == ManaCostShard.COLORLESS) {
|
||||||
continue;
|
continue;
|
||||||
@@ -197,7 +197,7 @@ public class ManaCostBeingPaid {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (shardCanBePaidWithColor(shard, colorMask)) {
|
else if (pool.canPayForShardWithColor(shard, colorMask)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,9 +205,9 @@ public class ManaCostBeingPaid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// isNeeded(String) still used by the Computer, might have problems activating Snow abilities
|
// isNeeded(String) still used by the Computer, might have problems activating Snow abilities
|
||||||
public final boolean isAnyPartPayableWith(byte colorMask) {
|
public final boolean isAnyPartPayableWith(byte colorMask, final ManaPool pool) {
|
||||||
for (ManaCostShard shard : unpaidShards.keySet()) {
|
for (ManaCostShard shard : unpaidShards.keySet()) {
|
||||||
if (shardCanBePaidWithColor(shard, colorMask)) {
|
if (pool.canPayForShardWithColor(shard, colorMask)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,9 +264,9 @@ public class ManaCostBeingPaid {
|
|||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean ai_payMana(final String mana) {
|
public final boolean ai_payMana(final String mana, final ManaPool pool) {
|
||||||
final byte colorMask = MagicColor.fromName(mana);
|
final byte colorMask = MagicColor.fromName(mana);
|
||||||
if (!this.isAnyPartPayableWith(colorMask)) {
|
if (!this.isAnyPartPayableWith(colorMask, pool)) {
|
||||||
//System.out.println("ManaCost : addMana() error, mana not needed - " + mana);
|
//System.out.println("ManaCost : addMana() error, mana not needed - " + mana);
|
||||||
return false;
|
return false;
|
||||||
//throw new RuntimeException("ManaCost : addMana() error, mana not needed - " + mana);
|
//throw new RuntimeException("ManaCost : addMana() error, mana not needed - " + mana);
|
||||||
@@ -275,7 +275,7 @@ public class ManaCostBeingPaid {
|
|||||||
Predicate<ManaCostShard> predCanBePaid = new Predicate<ManaCostShard>() {
|
Predicate<ManaCostShard> predCanBePaid = new Predicate<ManaCostShard>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(ManaCostShard ms) {
|
public boolean apply(ManaCostShard ms) {
|
||||||
return shardCanBePaidWithColor(ms, colorMask);
|
return pool.canPayForShardWithColor(ms, colorMask);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -361,10 +361,6 @@ public class ManaCostBeingPaid {
|
|||||||
return pool.canPayForShardWithColor(shard, color);
|
return pool.canPayForShardWithColor(shard, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shardCanBePaidWithColor(ManaCostShard shard, byte manaColor) {
|
|
||||||
// add color changing matrix here to support Daxos of Melethis
|
|
||||||
return shard.canBePaidWithManaOfColor(manaColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void combineManaCost(final ManaCost extra) {
|
public final void combineManaCost(final ManaCost extra) {
|
||||||
for (ManaCostShard shard : extra) {
|
for (ManaCostShard shard : extra) {
|
||||||
|
|||||||
@@ -107,10 +107,10 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
|||||||
byte colorNeeded = 0;
|
byte colorNeeded = 0;
|
||||||
|
|
||||||
for (final byte color : MagicColor.WUBRG) {
|
for (final byte color : MagicColor.WUBRG) {
|
||||||
if (manaCost.isAnyPartPayableWith(color)) { colorCanUse |= color; }
|
if (manaCost.isAnyPartPayableWith(color, player.getManaPool())) { colorCanUse |= color; }
|
||||||
if (manaCost.needsColor(color)) { colorNeeded |= color; }
|
if (manaCost.needsColor(color, player.getManaPool())) { colorNeeded |= color; }
|
||||||
}
|
}
|
||||||
boolean canUseColorless = manaCost.isAnyPartPayableWith((byte)0);
|
boolean canUseColorless = manaCost.isAnyPartPayableWith((byte)0, player.getManaPool());
|
||||||
|
|
||||||
List<SpellAbility> abilities = new ArrayList<SpellAbility>();
|
List<SpellAbility> abilities = new ArrayList<SpellAbility>();
|
||||||
// you can't remove unneeded abilities inside a for (am:abilities) loop :(
|
// you can't remove unneeded abilities inside a for (am:abilities) loop :(
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public final class InputSelectCardsForConvoke extends InputSelectManyBase<Card>
|
|||||||
|
|
||||||
byte chosenColor = player.getController().chooseColorAllowColorless("Convoke " + card.toString() + " for which color?", card, CardUtil.getColors(card));
|
byte chosenColor = player.getController().chooseColorAllowColorless("Convoke " + card.toString() + " for which color?", card, CardUtil.getColors(card));
|
||||||
|
|
||||||
if (remainingCost.getColorlessManaAmount() > 0 && (chosenColor == 0 || !remainingCost.needsColor(chosenColor))) {
|
if (remainingCost.getColorlessManaAmount() > 0 && (chosenColor == 0 || !remainingCost.needsColor(chosenColor, player.getManaPool()))) {
|
||||||
registerConvoked(card, ManaCostShard.COLORLESS, chosenColor);
|
registerConvoked(card, ManaCostShard.COLORLESS, chosenColor);
|
||||||
} else {
|
} else {
|
||||||
for (ManaCostShard shard : remainingCost.getDistinctShards()) {
|
for (ManaCostShard shard : remainingCost.getDistinctShards()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user