- A somewhat more comprehensive anti-cheating solution for Cavern of Souls AI.

This commit is contained in:
Agetian
2017-08-14 05:15:30 +00:00
parent 74b12606ef
commit 9997b4a2de

View File

@@ -219,27 +219,32 @@ public class ComputerUtilMana {
} }
} }
SpellAbility paymentChoice = ma;
// Exception: when paying generic mana with Cavern of Souls, prefer the colored mana producing ability // Exception: when paying generic mana with Cavern of Souls, prefer the colored mana producing ability
// to attempt to make the spell uncounterable when possible. // to attempt to make the spell uncounterable when possible.
if ((toPay == ManaCostShard.GENERIC || toPay == ManaCostShard.X) if (ComputerUtilAbility.getAbilitySourceName(ma).equals("Cavern of Souls")
&& ComputerUtilAbility.getAbilitySourceName(ma).equals("Cavern of Souls")
&& sa.getHostCard().getType().getCreatureTypes().contains(ma.getHostCard().getChosenType())) { && sa.getHostCard().getType().getCreatureTypes().contains(ma.getHostCard().getChosenType())) {
for (SpellAbility ab : saList) { if (toPay == ManaCostShard.COLORLESS && cost.getUnpaidShards().contains(ManaCostShard.GENERIC)) {
if (ab.isManaAbility() && ab.getManaPart().isAnyMana() && ab.hasParam("AddsNoCounter")) { // Deprioritize Cavern of Souls, try to pay generic mana with it instead to use the NoCounter ability
if (canPayShardWithSpellAbility(toPay, ai, ma, sa, checkCosts)) { continue;
return ab; } else if (toPay == ManaCostShard.GENERIC || toPay == ManaCostShard.X) {
for (SpellAbility ab : saList) {
if (ab.isManaAbility() && ab.getManaPart().isAnyMana() && ab.hasParam("AddsNoCounter")) {
paymentChoice = ab;
break;
} }
} }
} }
} }
final String typeRes = cost.getSourceRestriction(); final String typeRes = cost.getSourceRestriction();
if (StringUtils.isNotBlank(typeRes) && !ma.getHostCard().getType().hasStringType(typeRes)) { if (StringUtils.isNotBlank(typeRes) && !paymentChoice.getHostCard().getType().hasStringType(typeRes)) {
continue; continue;
} }
if (canPayShardWithSpellAbility(toPay, ai, ma, sa, checkCosts)) { if (canPayShardWithSpellAbility(toPay, ai, paymentChoice, sa, checkCosts)) {
return ma; return paymentChoice;
} }
} }
return null; return null;