diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index ce649c488f7..077b151457f 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -1145,15 +1145,14 @@ public class AiController { } CardCollection landsWannaPlay = ComputerUtilAbility.getAvailableLandsToPlay(game, player); - CardCollection playBeforeLand = CardLists.filter(player.getCardsIn(ZoneType.Hand), new Predicate() { - @Override - public boolean apply(Card card) { - return "true".equalsIgnoreCase(card.getSVar("PlayBeforeLandDrop")); - } - }); + CardCollection playBeforeLand = CardLists.filter( + player.getCardsIn(ZoneType.Hand), CardPredicates.hasSVar("PlayBeforeLandDrop") + ); if (!playBeforeLand.isEmpty()) { - SpellAbility wantToPlayBeforeLand = chooseSpellAbilityToPlayFromList(ComputerUtilAbility.getSpellAbilities(playBeforeLand, player), false); + SpellAbility wantToPlayBeforeLand = chooseSpellAbilityToPlayFromList( + ComputerUtilAbility.getSpellAbilities(playBeforeLand, player), false + ); if (wantToPlayBeforeLand != null) { return singleSpellAbilityList(wantToPlayBeforeLand); } @@ -1163,18 +1162,28 @@ public class AiController { landsWannaPlay = filterLandsToPlay(landsWannaPlay); Log.debug("Computer " + game.getPhaseHandler().getPhase().nameForUi); if (landsWannaPlay != null && !landsWannaPlay.isEmpty() && player.canPlayLand(null)) { + // TODO search for other land it might want to play? Card land = chooseBestLandToPlay(landsWannaPlay); if (ComputerUtil.getDamageFromETB(player, land) < player.getLife() || !player.canLoseLife() || player.cantLoseForZeroOrLessLife() ) { if (!game.getPhaseHandler().is(PhaseType.MAIN1) || !isSafeToHoldLandDropForMain2(land)) { - - // TODO fix logic for mayPlay land - LandAbility la = new LandAbility(land); final List abilities = Lists.newArrayList(); + + LandAbility la = new LandAbility(land, player, null); if (la.canPlay()) { abilities.add(la); } - return abilities; + + // add mayPlay option + for (CardPlayOption o : land.mayPlay(player)) { + la = new LandAbility(land, player, o.getAbility()); + if (la.canPlay()) { + abilities.add(la); + } + } + if (!abilities.isEmpty()) { + return abilities; + } } } }