- DiscardAi: find the first opponent that can discard to the effect, don't try to cast on players who have Tamiyo, Collector of Tales-like effect.

This commit is contained in:
Hans Mackowiak
2019-04-16 05:05:13 +00:00
committed by Michael Kamensky
parent 3a9eaf52c6
commit b6f023c57c
8 changed files with 150 additions and 55 deletions

View File

@@ -150,14 +150,17 @@ public class DiscardAi extends SpellAbilityAi {
private boolean discardTargetAI(final Player ai, final SpellAbility sa) {
final TargetRestrictions tgt = sa.getTargetRestrictions();
Player opp = ComputerUtil.getOpponentFor(ai);
if (opp.getCardsIn(ZoneType.Hand).isEmpty() && !ComputerUtil.activateForCost(sa, ai)) {
return false;
}
if (tgt != null) {
if (sa.canTarget(opp)) {
sa.getTargets().add(opp);
return true;
for (Player opp : ai.getOpponents()) {
if (opp.getCardsIn(ZoneType.Hand).isEmpty() && !ComputerUtil.activateForCost(sa, ai)) {
continue;
} else if (!opp.canDiscardBy(sa)) { // e.g. Tamiyo, Collector of Tales
continue;
}
if (tgt != null) {
if (sa.canTarget(opp)) {
sa.getTargets().add(opp);
return true;
}
}
}
return false;