diff --git a/src/main/java/forge/card/ability/effects/EncodeEffect.java b/src/main/java/forge/card/ability/effects/EncodeEffect.java index f8f57be27fb..39f72e203a4 100644 --- a/src/main/java/forge/card/ability/effects/EncodeEffect.java +++ b/src/main/java/forge/card/ability/effects/EncodeEffect.java @@ -35,8 +35,8 @@ public class EncodeEffect extends SpellAbilityEffect { choices = CardLists.getValidCards(choices, "Creature.YouCtrl", host.getController(), host); // if no creatures on battlefield, cannot encoded - if (choices.size() == 0) { - + if (choices.isEmpty()) { + return; } // Handle choice of whether or not to encoded @@ -46,8 +46,6 @@ public class EncodeEffect extends SpellAbilityEffect { if (!player.getController().confirmAction(sa, null, sb.toString())) { return; } - // Note: AI will always choose to encode - // TODO add better AI choice here // move host card to exile Card movedCard = Singletons.getModel().getGame().getAction().moveTo(ZoneType.Exile, host); diff --git a/src/main/java/forge/game/ai/AiController.java b/src/main/java/forge/game/ai/AiController.java index 9245a14eca6..ac386890e3e 100644 --- a/src/main/java/forge/game/ai/AiController.java +++ b/src/main/java/forge/game/ai/AiController.java @@ -45,6 +45,7 @@ import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellPermanent; import forge.game.GameActionUtil; import forge.game.GameState; +import forge.game.phase.CombatUtil; import forge.game.phase.PhaseType; import forge.game.player.AIPlayer; import forge.game.player.Player; @@ -661,20 +662,17 @@ public class AiController { case Encode: if (logic == null) { - // Base Logic is choose "best" - choice = ComputerUtilCard.getBestAI(options); - } else if ("WorstCard".equals(logic)) { - choice = ComputerUtilCard.getWorstAI(options); - } else if (logic.equals("BestBlocker")) { - if (!CardLists.filter(options, Presets.UNTAPPED).isEmpty()) { - options = CardLists.filter(options, Presets.UNTAPPED); + List attackers = CardLists.filter(options, new Predicate() { + @Override + public boolean apply(final Card c) { + return CombatUtil.canAttackNextTurn(c); + } + }); + if (attackers.isEmpty()) { + choice = ComputerUtilCard.getBestAI(options); + } else { + choice = ComputerUtilCard.getBestAI(attackers); } - choice = ComputerUtilCard.getBestCreatureAI(options); - } else if (logic.equals("Clone")) { - if (!CardLists.getValidCards(options, "Permanent.YouDontCtrl,Permanent.nonLegendary", host.getController(), host).isEmpty()) { - options = CardLists.getValidCards(options, "Permanent.YouDontCtrl,Permanent.nonLegendary", host.getController(), host); - } - choice = ComputerUtilCard.getBestAI(options); } return choice;