* Armory Automaton - fixed infinite AI choose (#5023);

This commit is contained in:
Oleg Agafonov 2019-05-17 22:54:23 +04:00
parent ec9198fb22
commit a0805327d1

View file

@ -88,7 +88,9 @@ class ArmoryAutomatonEffect extends OneShotEffect {
while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.Benefit, "Select and attach a target Equipment?", source, game)) {
Target targetEquipment = new TargetPermanent(currentFilter);
targetEquipment.setRequired(false);
if (player.choose(Outcome.Benefit, targetEquipment, source.getSourceId(), game)) {
if (player.choose(Outcome.Benefit, targetEquipment, source.getSourceId(), game) && targetEquipment.getFirstTarget() != null) {
currentFilter.add(Predicates.not(new PermanentIdPredicate(targetEquipment.getFirstTarget()))); // exclude selected for next time
Permanent aura = game.getPermanent(targetEquipment.getFirstTarget());
if (aura != null) {
Permanent attachedTo = game.getPermanent(aura.getAttachedTo());
@ -96,10 +98,9 @@ class ArmoryAutomatonEffect extends OneShotEffect {
attachedTo.removeAttachment(aura.getId(), game);
}
sourcePermanent.addAttachment(aura.getId(), game);
// exclude selected
currentFilter.add(Predicates.not(new PermanentIdPredicate(aura.getId())));
}
} else {
break;
}
countBattlefield = game.getBattlefield().getAllActivePermanents(currentFilter, game).size();
}