forked from External/mage
Added missing target handling of TargetDefender to ComputerPlayer.
This commit is contained in:
parent
e33fd30544
commit
1c120c5f41
1 changed files with 22 additions and 0 deletions
|
|
@ -542,6 +542,28 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
//if (!target.isRequired())
|
||||
return false;
|
||||
}
|
||||
if (target instanceof TargetDefender) {
|
||||
// TODO: Improve, now planeswalker is always chosen if it exits
|
||||
List<Permanent> targets ;
|
||||
targets = game.getBattlefield().getActivePermanents(new FilterPlaneswalkerPermanent(), opponentId, game);
|
||||
if (targets != null && !targets.isEmpty()) {
|
||||
for (Permanent planeswalker: targets) {
|
||||
if (target.canTarget(planeswalker.getId(), source, game)) {
|
||||
target.addTarget(planeswalker.getId(), source, game);
|
||||
}
|
||||
if (target.isChosen()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!target.isChosen()) {
|
||||
if (target.canTarget(opponentId, source, game)) {
|
||||
target.addTarget(opponentId, source, game);
|
||||
}
|
||||
}
|
||||
return target.isChosen();
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Target wasn't handled. class:" + target.getClass().toString());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue