From 3896a79cfa8b47147c8b27b0c699fd2120f1efe9 Mon Sep 17 00:00:00 2001 From: Agetian Date: Thu, 13 Dec 2018 20:08:01 +0300 Subject: [PATCH] - Improve damage chaining so that the AI doesn't try to chain a spell with restricted targeting to a general use spell (e.g. a spell that targets only attacking creatures to a Lightning Strike outside of combat). --- forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index f147a2015b9..4763a134cf5 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -1070,6 +1070,14 @@ public class DamageDealAi extends DamageAiBase { continue; } else if (tgtSa.canTgtPlaneswalker() && !tgtAb.canTgtPlaneswalker()) { continue; + } else if ((tgtSa.getSAValidTargeting() != null && tgtSa.getSAValidTargeting().contains(".")) + || (tgtAb.getSAValidTargeting() != null && tgtAb.getSAValidTargeting().contains("."))) { + if (!tgtAb.getSAValidTargeting().contains(tgtSa.getSAValidTargeting())) { + // if the targeting has additional conditions, make sure that the chained spell + // contains the same condition specifications (or at least these specs are a part + // of what SA can target, hopefully) + continue; + } } // FIXME: should it also check restrictions for targeting players? ManaCost costSa = sa.getPayCosts() != null ? sa.getPayCosts().getTotalMana() : ManaCost.NO_COST;