mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Fixed a AI target selecting problem.
This commit is contained in:
parent
cdd6094f59
commit
47ad1ea0ee
2 changed files with 41 additions and 0 deletions
|
@ -576,6 +576,41 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (target.getOriginalTarget() instanceof TargetPlayerOrPlaneswalker) {
|
||||
List<Permanent> targets;
|
||||
TargetPlayerOrPlaneswalker t = ((TargetPlayerOrPlaneswalker) target);
|
||||
if (outcome.isGood()) {
|
||||
targets = threats(abilityControllerId, source.getSourceId(), ((FilterPermanentOrPlayer) t.getFilter()).getPermanentFilter(), game, target.getTargets());
|
||||
} else {
|
||||
targets = threats(randomOpponentId, source.getSourceId(), ((FilterPermanentOrPlayer) t.getFilter()).getPermanentFilter(), game, target.getTargets());
|
||||
}
|
||||
|
||||
if (targets.isEmpty()) {
|
||||
if (outcome.isGood()) {
|
||||
if (target.canTarget(getId(), abilityControllerId, source, game)) {
|
||||
target.addTarget(abilityControllerId, source, game);
|
||||
return true;
|
||||
}
|
||||
} else if (target.canTarget(getId(), randomOpponentId, source, game)) {
|
||||
target.addTarget(randomOpponentId, source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (targets.isEmpty() && target.isRequired(source)) {
|
||||
targets = game.getBattlefield().getActivePermanents(((TargetPlayerOrPlaneswalker) t.getFilter()).getPlaneswalkerFilter(), playerId, game);
|
||||
}
|
||||
for (Permanent permanent : targets) {
|
||||
List<UUID> alreadyTargetted = target.getTargets();
|
||||
if (t.canTarget(abilityControllerId, permanent.getId(), source, game)) {
|
||||
if (alreadyTargetted != null && !alreadyTargetted.contains(permanent.getId())) {
|
||||
target.addTarget(permanent.getId(), source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (outcome.isGood()) {
|
||||
if (target.canTarget(getId(), abilityControllerId, source, game)) {
|
||||
|
@ -753,6 +788,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
return target.isChosen();
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Target wasn't handled. class:" + target.getClass().toString());
|
||||
} //end of chooseTarget method
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import mage.MageObject;
|
|||
import mage.abilities.Ability;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||
import mage.filter.common.FilterPlayerOrPlaneswalker;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -213,6 +214,10 @@ public class TargetPlayerOrPlaneswalker extends TargetImpl {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public FilterPlaneswalkerPermanent getPlaneswalkerFilter() {
|
||||
return filter.getPlaneswalkerFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPlayerOrPlaneswalker copy() {
|
||||
return new TargetPlayerOrPlaneswalker(this);
|
||||
|
|
Loading…
Reference in a new issue