mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Fixed the AI trying to pay for abilities it doesn't control, causing weird side effects and slowdowns.
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user