From a4c14c6be1ef090bd556236c3cdd672be579945d Mon Sep 17 00:00:00 2001 From: Agetian Date: Thu, 28 Sep 2017 04:41:38 +0000 Subject: [PATCH] - Some improvements to the Splice AI: do not reconsider the SA unless at least something was chosen for splice to save processing time; reset the targets on the main SA because it'll need to be retargeted anyway. --- forge-ai/src/main/java/forge/ai/ComputerUtil.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 2c6b491aa72..0cb88edfd60 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -76,10 +76,15 @@ public class ComputerUtil { if (sa.isSpell() && !source.isCopiedSpell()) { if (source.getType().hasStringType("Arcane")) { sa = AbilityUtils.addSpliceEffects(sa); - AiPlayDecision postSpliceDecision = ((PlayerControllerAi)ai.getController()).getAi().canPlaySa(sa); - if (postSpliceDecision != AiPlayDecision.WillPlay) { - // for whatever reason the AI doesn't want to play the thing with the subs at this time - return false; + if (sa.getSplicedCards() != null && !sa.getSplicedCards().isEmpty() && ai.getController().isAI()) { + // we need to reconsider and retarget the SA after additional SAs have been added onto it via splice, + // otherwise the AI will fail to add the card to stack and that'll knock it out of the game + sa.resetTargets(); + if (((PlayerControllerAi) ai.getController()).getAi().canPlaySa(sa) != AiPlayDecision.WillPlay) { + // for whatever reason the AI doesn't want to play the thing with the spliced subs anymore, + // proceeding past this point may result in an illegal play + return false; + } } }