- Sanity check not to kill own stuff preemptively if certain valid targeting options exist after a standard check (e.g. Searing Blaze)

This commit is contained in:
Agetian
2023-10-27 21:52:10 +03:00
parent 4c6d9be8e7
commit 92ecb8eb23

View File

@@ -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<GameEntity> 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);
}