mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
- Renamed a method to be more self-explanatory.
This commit is contained in:
@@ -192,7 +192,7 @@ public class ComputerUtil {
|
|||||||
if (unless != null && !unless.endsWith(">")) {
|
if (unless != null && !unless.endsWith(">")) {
|
||||||
final int amount = AbilityUtils.calculateAmount(source, unless, sa);
|
final int amount = AbilityUtils.calculateAmount(source, unless, sa);
|
||||||
|
|
||||||
final int usableManaSources = ComputerUtilMana.getAvailableMana(ComputerUtil.getOpponentFor(ai), true).size();
|
final int usableManaSources = ComputerUtilMana.getAvailableManaSources(ComputerUtil.getOpponentFor(ai), true).size();
|
||||||
|
|
||||||
// If the Unless isn't enough, this should be less likely to be used
|
// If the Unless isn't enough, this should be less likely to be used
|
||||||
if (amount > usableManaSources) {
|
if (amount > usableManaSources) {
|
||||||
|
|||||||
@@ -1113,7 +1113,7 @@ public class ComputerUtilMana {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//This method is currently used by AI to estimate available mana
|
//This method is currently used by AI to estimate available mana
|
||||||
public static CardCollection getAvailableMana(final Player ai, final boolean checkPlayable) {
|
public static CardCollection getAvailableManaSources(final Player ai, final boolean checkPlayable) {
|
||||||
final CardCollectionView list = CardCollection.combine(ai.getCardsIn(ZoneType.Battlefield), ai.getCardsIn(ZoneType.Hand));
|
final CardCollectionView list = CardCollection.combine(ai.getCardsIn(ZoneType.Battlefield), ai.getCardsIn(ZoneType.Hand));
|
||||||
final List<Card> manaSources = CardLists.filter(list, new Predicate<Card>() {
|
final List<Card> manaSources = CardLists.filter(list, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1220,7 +1220,7 @@ public class ComputerUtilMana {
|
|||||||
System.out.println("DEBUG_MANA_PAYMENT: sortedManaSources = " + sortedManaSources);
|
System.out.println("DEBUG_MANA_PAYMENT: sortedManaSources = " + sortedManaSources);
|
||||||
}
|
}
|
||||||
return sortedManaSources;
|
return sortedManaSources;
|
||||||
} // getAvailableMana()
|
} // getAvailableManaSources()
|
||||||
|
|
||||||
//This method is currently used by AI to estimate mana available
|
//This method is currently used by AI to estimate mana available
|
||||||
private static ListMultimap<Integer, SpellAbility> groupSourcesByManaColor(final Player ai, boolean checkPlayable) {
|
private static ListMultimap<Integer, SpellAbility> groupSourcesByManaColor(final Player ai, boolean checkPlayable) {
|
||||||
@@ -1241,7 +1241,7 @@ public class ComputerUtilMana {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loop over all current available mana sources
|
// Loop over all current available mana sources
|
||||||
for (final Card sourceCard : getAvailableMana(ai, checkPlayable)) {
|
for (final Card sourceCard : getAvailableManaSources(ai, checkPlayable)) {
|
||||||
if (DEBUG_MANA_PAYMENT) {
|
if (DEBUG_MANA_PAYMENT) {
|
||||||
System.out.println("DEBUG_MANA_PAYMENT: groupSourcesByManaColor sourceCard = " + sourceCard);
|
System.out.println("DEBUG_MANA_PAYMENT: groupSourcesByManaColor sourceCard = " + sourceCard);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class SpecialCardAi {
|
|||||||
// Black Lotus and Lotus Bloom
|
// Black Lotus and Lotus Bloom
|
||||||
public static class BlackLotus {
|
public static class BlackLotus {
|
||||||
public static boolean consider(Player ai, SpellAbility sa, ManaCostBeingPaid cost) {
|
public static boolean consider(Player ai, SpellAbility sa, ManaCostBeingPaid cost) {
|
||||||
CardCollection manaSources = ComputerUtilMana.getAvailableMana(ai, true);
|
CardCollection manaSources = ComputerUtilMana.getAvailableManaSources(ai, true);
|
||||||
int numManaSrcs = manaSources.size();
|
int numManaSrcs = manaSources.size();
|
||||||
|
|
||||||
CardCollection allCards = CardLists.filter(ai.getAllCards(), Arrays.asList(CardPredicates.Presets.NON_TOKEN,
|
CardCollection allCards = CardLists.filter(ai.getAllCards(), Arrays.asList(CardPredicates.Presets.NON_TOKEN,
|
||||||
@@ -504,7 +504,7 @@ public class SpecialCardAi {
|
|||||||
final CardCollectionView cards = ai.getCardsIn(new ZoneType[] {ZoneType.Hand, ZoneType.Battlefield, ZoneType.Command});
|
final CardCollectionView cards = ai.getCardsIn(new ZoneType[] {ZoneType.Hand, ZoneType.Battlefield, ZoneType.Command});
|
||||||
List<SpellAbility> all = ComputerUtilAbility.getSpellAbilities(cards, ai);
|
List<SpellAbility> all = ComputerUtilAbility.getSpellAbilities(cards, ai);
|
||||||
|
|
||||||
int numManaSrcs = CardLists.filter(ComputerUtilMana.getAvailableMana(ai, true), CardPredicates.Presets.UNTAPPED).size();
|
int numManaSrcs = CardLists.filter(ComputerUtilMana.getAvailableManaSources(ai, true), CardPredicates.Presets.UNTAPPED).size();
|
||||||
|
|
||||||
for (final SpellAbility testSa : ComputerUtilAbility.getOriginalAndAltCostAbilities(all, ai)) {
|
for (final SpellAbility testSa : ComputerUtilAbility.getOriginalAndAltCostAbilities(all, ai)) {
|
||||||
ManaCost cost = testSa.getPayCosts().getTotalMana();
|
ManaCost cost = testSa.getPayCosts().getTotalMana();
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public class CounterAi extends SpellAbilityAi {
|
|||||||
if (unlessCost != null && !unlessCost.endsWith(">")) {
|
if (unlessCost != null && !unlessCost.endsWith(">")) {
|
||||||
Player opp = tgtSA.getActivatingPlayer();
|
Player opp = tgtSA.getActivatingPlayer();
|
||||||
|
|
||||||
int usableManaSources = ComputerUtilMana.getAvailableMana(opp, true).size();
|
int usableManaSources = ComputerUtilMana.getAvailableManaSources(opp, true).size();
|
||||||
usableManaSources += opp.getManaPool().totalMana();
|
usableManaSources += opp.getManaPool().totalMana();
|
||||||
|
|
||||||
int toPay = 0;
|
int toPay = 0;
|
||||||
@@ -217,7 +217,7 @@ public class CounterAi extends SpellAbilityAi {
|
|||||||
final Card source = sa.getHostCard();
|
final Card source = sa.getHostCard();
|
||||||
if (unlessCost != null) {
|
if (unlessCost != null) {
|
||||||
// Is this Usable Mana Sources? Or Total Available Mana?
|
// Is this Usable Mana Sources? Or Total Available Mana?
|
||||||
final int usableManaSources = ComputerUtilMana.getAvailableMana(ComputerUtil.getOpponentFor(ai), true).size();
|
final int usableManaSources = ComputerUtilMana.getAvailableManaSources(ComputerUtil.getOpponentFor(ai), true).size();
|
||||||
int toPay = 0;
|
int toPay = 0;
|
||||||
boolean setPayX = false;
|
boolean setPayX = false;
|
||||||
if (unlessCost.equals("X") && source.getSVar(unlessCost).equals("Count$xPaid")) {
|
if (unlessCost.equals("X") && source.getSVar(unlessCost).equals("Count$xPaid")) {
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class ManaEffectAi extends SpellAbilityAi {
|
|||||||
private boolean doManaRitualLogic(Player ai, SpellAbility sa) {
|
private boolean doManaRitualLogic(Player ai, SpellAbility sa) {
|
||||||
final Card host = sa.getHostCard();
|
final Card host = sa.getHostCard();
|
||||||
|
|
||||||
CardCollection manaSources = ComputerUtilMana.getAvailableMana(ai, true);
|
CardCollection manaSources = ComputerUtilMana.getAvailableManaSources(ai, true);
|
||||||
int numManaSrcs = manaSources.size();
|
int numManaSrcs = manaSources.size();
|
||||||
int manaReceived = sa.hasParam("Amount") ? AbilityUtils.calculateAmount(host, sa.getParam("Amount"), sa) : 1;
|
int manaReceived = sa.hasParam("Amount") ? AbilityUtils.calculateAmount(host, sa.getParam("Amount"), sa) : 1;
|
||||||
manaReceived *= sa.getParam("Produced").split(" ").length;
|
manaReceived *= sa.getParam("Produced").split(" ").length;
|
||||||
|
|||||||
@@ -183,14 +183,14 @@ public class PermanentAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
} else if (param.equals("NumManaSources")) {
|
} else if (param.equals("NumManaSources")) {
|
||||||
// Only cast if there are X or more mana sources controlled by the AI
|
// Only cast if there are X or more mana sources controlled by the AI
|
||||||
CardCollection m = ComputerUtilMana.getAvailableMana(ai, true);
|
CardCollection m = ComputerUtilMana.getAvailableManaSources(ai, true);
|
||||||
if (m.size() < Integer.parseInt(value)) {
|
if (m.size() < Integer.parseInt(value)) {
|
||||||
dontCast = true;
|
dontCast = true;
|
||||||
}
|
}
|
||||||
} else if (param.equals("NumManaSourcesNextTurn")) {
|
} else if (param.equals("NumManaSourcesNextTurn")) {
|
||||||
// Only cast if there are X or more mana sources controlled by the AI *or*
|
// Only cast if there are X or more mana sources controlled by the AI *or*
|
||||||
// if there are X-1 mana sources in play but the AI has an extra land in hand
|
// if there are X-1 mana sources in play but the AI has an extra land in hand
|
||||||
CardCollection m = ComputerUtilMana.getAvailableMana(ai, true);
|
CardCollection m = ComputerUtilMana.getAvailableManaSources(ai, true);
|
||||||
int extraMana = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS).size() > 0 ? 1 : 0;
|
int extraMana = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS).size() > 0 ? 1 : 0;
|
||||||
if (card.getName().equals("Illusions of Grandeur")) {
|
if (card.getName().equals("Illusions of Grandeur")) {
|
||||||
// TODO: this is currently hardcoded for specific Illusions-Donate cost reduction spells, need to make this generic.
|
// TODO: this is currently hardcoded for specific Illusions-Donate cost reduction spells, need to make this generic.
|
||||||
|
|||||||
Reference in New Issue
Block a user