mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Armory Automaton - fixed infinite AI choose, added selects target cancel (#5023);
This commit is contained in:
parent
2b4a01410b
commit
3d70dadc22
1 changed files with 22 additions and 7 deletions
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldOrAttacksSourceTriggeredAbility;
|
||||
|
@ -11,16 +9,22 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterArtifactPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardIdPredicate;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.filter.predicate.permanent.AttachedToPredicate;
|
||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author spjspj
|
||||
*/
|
||||
public final class ArmoryAutomaton extends CardImpl {
|
||||
|
@ -73,9 +77,17 @@ class ArmoryAutomatonEffect extends OneShotEffect {
|
|||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && sourcePermanent != null) {
|
||||
int countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game).size() - sourcePermanent.getAttachments().size();
|
||||
while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.Benefit, "Attach a target Equipment?", source, game)) {
|
||||
Target targetEquipment = new TargetPermanent(filter);
|
||||
|
||||
// dynamic filter (can't selects own attaches and can't selects twice)
|
||||
FilterPermanent currentFilter = filter.copy();
|
||||
FilterPermanent filterSourceId = new FilterPermanent();
|
||||
filterSourceId.add(new CardIdPredicate(this.getId()));
|
||||
currentFilter.add(Predicates.not(new AttachedToPredicate(filterSourceId)));
|
||||
|
||||
int countBattlefield = game.getBattlefield().getAllActivePermanents(currentFilter, game).size();
|
||||
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)) {
|
||||
Permanent aura = game.getPermanent(targetEquipment.getFirstTarget());
|
||||
if (aura != null) {
|
||||
|
@ -84,9 +96,12 @@ class ArmoryAutomatonEffect extends OneShotEffect {
|
|||
attachedTo.removeAttachment(aura.getId(), game);
|
||||
}
|
||||
sourcePermanent.addAttachment(aura.getId(), game);
|
||||
|
||||
// exclude selected
|
||||
currentFilter.add(Predicates.not(new PermanentIdPredicate(aura.getId())));
|
||||
}
|
||||
}
|
||||
countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game).size() - sourcePermanent.getAttachments().size();
|
||||
countBattlefield = game.getBattlefield().getAllActivePermanents(currentFilter, game).size();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue