- Fixed the AI trying to pay for abilities it doesn't control, causing weird side effects and slowdowns.

This commit is contained in:
Agetian
2018-12-10 18:27:37 +03:00
parent 348f60a1eb
commit 381a94a5e4

View File

@@ -673,16 +673,16 @@ public class AiController {
private AiPlayDecision canPlayAndPayFor(final SpellAbility sa) { private AiPlayDecision canPlayAndPayFor(final SpellAbility sa) {
boolean xCost = sa.getPayCosts().hasXInAnyCostPart(); boolean xCost = sa.getPayCosts().hasXInAnyCostPart();
if (!sa.canPlay()) {
return AiPlayDecision.CantPlaySa;
}
if (!xCost && !ComputerUtilCost.canPayCost(sa, player)) { if (!xCost && !ComputerUtilCost.canPayCost(sa, player)) {
// for most costs, it's OK to check if they can be paid early in order to avoid running a heavy API check // for most costs, it's OK to check if they can be paid early in order to avoid running a heavy API check
// when the AI won't even be able to play the spell in the first place (even if it could afford it) // when the AI won't even be able to play the spell in the first place (even if it could afford it)
return AiPlayDecision.CantAfford; return AiPlayDecision.CantAfford;
} }
if (!sa.canPlay()) {
return AiPlayDecision.CantPlaySa;
}
AiPlayDecision canPlay = canPlaySa(sa); // this is the "heaviest" check, which also sets up targets, defines X, etc. AiPlayDecision canPlay = canPlaySa(sa); // this is the "heaviest" check, which also sets up targets, defines X, etc.
if (canPlay != AiPlayDecision.WillPlay) { if (canPlay != AiPlayDecision.WillPlay) {
return canPlay; return canPlay;