From 381a94a5e4f9ec1a0b8015ed4ae931ebdc184e74 Mon Sep 17 00:00:00 2001 From: Agetian Date: Mon, 10 Dec 2018 18:27:37 +0300 Subject: [PATCH] - Fixed the AI trying to pay for abilities it doesn't control, causing weird side effects and slowdowns. --- forge-ai/src/main/java/forge/ai/AiController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 36bbf6542b8..30230fe9ee6 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -673,16 +673,16 @@ public class AiController { private AiPlayDecision canPlayAndPayFor(final SpellAbility sa) { boolean xCost = sa.getPayCosts().hasXInAnyCostPart(); + if (!sa.canPlay()) { + return AiPlayDecision.CantPlaySa; + } + 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 // 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; } - if (!sa.canPlay()) { - return AiPlayDecision.CantPlaySa; - } - AiPlayDecision canPlay = canPlaySa(sa); // this is the "heaviest" check, which also sets up targets, defines X, etc. if (canPlay != AiPlayDecision.WillPlay) { return canPlay;