mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Merge branch 'manaEffect' into 'master'
ExpressPay different ComboMana if possible See merge request core-developers/forge!3893
This commit is contained in:
@@ -1241,7 +1241,7 @@ public class ComputerUtilMana {
|
|||||||
choice = abMana.getExpressChoice();
|
choice = abMana.getExpressChoice();
|
||||||
abMana.clearExpressChoice();
|
abMana.clearExpressChoice();
|
||||||
byte colorMask = ManaAtom.fromName(choice);
|
byte colorMask = ManaAtom.fromName(choice);
|
||||||
if (manaAb.canProduce(choice) && testCost.isAnyPartPayableWith(colorMask, ai.getManaPool())) {
|
if (manaAb.canProduce(choice) && satisfiesColorChoice(abMana, choiceString, choice) && testCost.isAnyPartPayableWith(colorMask, ai.getManaPool())) {
|
||||||
choiceString.append(choice);
|
choiceString.append(choice);
|
||||||
payMultipleMana(testCost, choice, ai);
|
payMultipleMana(testCost, choice, ai);
|
||||||
continue;
|
continue;
|
||||||
@@ -1251,7 +1251,7 @@ 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(ManaAtom.fromName(color), ai.getManaPool())) {
|
if (satisfiesColorChoice(abMana, choiceString, choice) && testCost.isAnyPartPayableWith(ManaAtom.fromName(color), ai.getManaPool())) {
|
||||||
payMultipleMana(testCost, color, ai);
|
payMultipleMana(testCost, color, ai);
|
||||||
if (nMana != 1) {
|
if (nMana != 1) {
|
||||||
choiceString.append(" ");
|
choiceString.append(" ");
|
||||||
@@ -1266,14 +1266,18 @@ public class ComputerUtilMana {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check if combo mana can produce most common color in hand
|
// check if combo mana can produce most common color in hand
|
||||||
String commonColor = ComputerUtilCard.getMostProminentColor(ai.getCardsIn(
|
String commonColor = ComputerUtilCard.getMostProminentColor(ai.getCardsIn(ZoneType.Hand));
|
||||||
ZoneType.Hand));
|
if (!commonColor.isEmpty() && satisfiesColorChoice(abMana, choiceString, MagicColor.toShortString(commonColor)) && abMana.getComboColors().contains(MagicColor.toShortString(commonColor))) {
|
||||||
if (!commonColor.isEmpty() && abMana.getComboColors().contains(MagicColor.toShortString(commonColor))) {
|
|
||||||
choice = MagicColor.toShortString(commonColor);
|
choice = MagicColor.toShortString(commonColor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// default to first color
|
// default to first available color
|
||||||
choice = comboColors[0];
|
for (String c : comboColors) {
|
||||||
|
if (satisfiesColorChoice(abMana, choiceString, c)) {
|
||||||
|
choice = c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (nMana != 1) {
|
if (nMana != 1) {
|
||||||
choiceString.append(" ");
|
choiceString.append(" ");
|
||||||
@@ -1288,6 +1292,10 @@ public class ComputerUtilMana {
|
|||||||
abMana.setExpressChoice(choiceString.toString());
|
abMana.setExpressChoice(choiceString.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean satisfiesColorChoice(AbilityManaPart abMana, StringBuilder choices, String choice) {
|
||||||
|
return !abMana.getOrigProduced().contains("Different") || !choices.toString().contains(choice);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* payMultipleMana.
|
* payMultipleMana.
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
|||||||
private static final long serialVersionUID = 794691267379929080L;
|
private static final long serialVersionUID = 794691267379929080L;
|
||||||
|
|
||||||
private final byte myColor;
|
private final byte myColor;
|
||||||
public byte getMyColor() { return myColor; }
|
|
||||||
private final float orderWeight;
|
private final float orderWeight;
|
||||||
|
|
||||||
private static final ColorSet[] cache = new ColorSet[32];
|
private static final ColorSet[] cache = new ColorSet[32];
|
||||||
|
|||||||
@@ -72,14 +72,16 @@ public class ManaEffect extends SpellAbilityEffect {
|
|||||||
choice = colorsProduced[differentChoice ? nMana : 0];
|
choice = colorsProduced[differentChoice ? nMana : 0];
|
||||||
} else {
|
} else {
|
||||||
byte chosenColor = p.getController().chooseColor(Localizer.getInstance().getMessage("lblSelectManaProduce"), sa,
|
byte chosenColor = p.getController().chooseColor(Localizer.getInstance().getMessage("lblSelectManaProduce"), sa,
|
||||||
differentChoice ? fullOptions : colorOptions);
|
differentChoice && (colorsNeeded == null || colorsNeeded.length <= nMana) ? fullOptions : colorOptions);
|
||||||
if (chosenColor == 0)
|
if (chosenColor == 0)
|
||||||
throw new RuntimeException("ManaEffect::resolve() /*combo mana*/ - " + p + " color mana choice is empty for " + card.getName());
|
throw new RuntimeException("ManaEffect::resolve() /*combo mana*/ - " + p + " color mana choice is empty for " + card.getName());
|
||||||
|
|
||||||
fullOptions = ColorSet.fromMask(fullOptions.getMyColor() - chosenColor);
|
if (differentChoice) {
|
||||||
|
fullOptions = ColorSet.fromMask(fullOptions.getColor() - chosenColor);
|
||||||
|
}
|
||||||
choice = MagicColor.toShortString(chosenColor);
|
choice = MagicColor.toShortString(chosenColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nMana > 0) {
|
if (nMana > 0) {
|
||||||
choiceString.append(" ");
|
choiceString.append(" ");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,8 +330,9 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (HumanPlay.playSpellAbility(getController(), chosen.getActivatingPlayer(), chosen)) {
|
if (HumanPlay.playSpellAbility(getController(), chosen.getActivatingPlayer(), chosen)) {
|
||||||
player.getManaPool().payManaFromAbility(saPaidFor, InputPayMana.this.manaCost, chosen);
|
if (chosen.getManaPart().meetsManaRestrictions(saPaidFor)) {
|
||||||
|
player.getManaPool().payManaFromAbility(saPaidFor, InputPayMana.this.manaCost, chosen);
|
||||||
|
}
|
||||||
onManaAbilityPaid();
|
onManaAbilityPaid();
|
||||||
onStateChanged();
|
onStateChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user