Added AI Targeting for TargetActivatedOrTriggeredAbility. Closes #9276.

This commit is contained in:
Alex Vasile 2022-07-17 00:29:39 -04:00
parent f26f56736a
commit 137f02f31b

View file

@ -661,6 +661,9 @@ public class ComputerPlayer extends PlayerImpl implements Player {
// TODO: implemented findBestPlayerTargets
// TODO: add findBest*Targets for all target types
// TODO: Much of this code needs to be re-written to move code into Target.possibleTargets
// A) Having it here makes this function ridiculously long
// B) Each time a new target type is added, people must remember to add it here
if (target.getOriginalTarget() instanceof TargetPermanent) {
FilterPermanent filter = null;
@ -1043,6 +1046,15 @@ public class ComputerPlayer extends PlayerImpl implements Player {
return target.isChosen();
}
if (target.getOriginalTarget() instanceof TargetActivatedOrTriggeredAbility
|| target.getOriginalTarget() instanceof TargetActivatedOrTriggeredAbilityOrLegendarySpell) {
Iterator<UUID> iterator = target.possibleTargets(source.getControllerId(), source, game).iterator();
while (!target.isChosen() && iterator.hasNext()) {
target.addTarget(iterator.next(), source, game);
}
return target.isChosen();
}
if (target.getOriginalTarget() instanceof TargetCardInGraveyardBattlefieldOrStack) {
List<Card> cards = new ArrayList<>();
for (Player player : game.getPlayers().values()) {