From 92ecb8eb2317a80f6448bc9749da628baed51f03 Mon Sep 17 00:00:00 2001 From: Agetian Date: Fri, 27 Oct 2023 21:52:10 +0300 Subject: [PATCH] - Sanity check not to kill own stuff preemptively if certain valid targeting options exist after a standard check (e.g. Searing Blaze) --- .../main/java/forge/ai/ability/DamageDealAi.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 e3959fbcf1e..9c4f48cfd5b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -749,8 +749,22 @@ public class DamageDealAi extends DamageAiBase { } // fell through all the choices, no targets left? - if (tcs.size() < tgt.getMinTargets(source, sa) || tcs.size() == 0) { + int minTgts = tgt.getMinTargets(source, sa); + if (tcs.size() < minTgts || tcs.size() == 0) { if (mandatory) { + // Sanity check: if there are any legal non-owned targets after the check (which may happen for complex cards like Searing Blaze), + // choose a random opponent's target before forcing targeting of own stuff + List allTgtEntities = sa.getTargetRestrictions().getAllCandidates(sa, true); + for (GameEntity ent : allTgtEntities) { + if ((ent instanceof Player && ((Player)ent).isOpponentOf(ai)) + || (ent instanceof Card && ((Card)ent).getController().isOpponentOf(ai))) { + tcs.add(ent); + } + if (tcs.size() == minTgts) { + return true; + } + } + // If the trigger is mandatory, gotta choose my own stuff now return damageChooseRequiredTargets(ai, sa, tgt, dmg); }