From e25c7dac4aaefa7cd6709788b50fed4683d7017a Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Wed, 21 Apr 2021 22:32:37 +0200 Subject: [PATCH] Improve logic for Ozolith --- .../java/forge/ai/ability/CountersMoveAi.java | 79 ++++++++++--------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java index 105e248f346..3c931b7df66 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java @@ -372,54 +372,57 @@ public class CountersMoveAi extends SpellAbilityAi { } } - List aiList = CardLists.filterControlledBy(tgtCards, ai); - if (!aiList.isEmpty()) { - List best = CardLists.filter(aiList, new Predicate() { + Card lki = CardUtil.getLKICopy(src); + lki.clearCounters(); + // go for opponent when value implies debuff + if (ComputerUtilCard.evaluateCreature(src) > ComputerUtilCard.evaluateCreature(lki)) { + List aiList = CardLists.filterControlledBy(tgtCards, ai); + if (!aiList.isEmpty()) { + List best = CardLists.filter(aiList, new Predicate() { - @Override - public boolean apply(Card card) { - // gain from useless - if (ComputerUtilCard.isUselessCreature(ai, card)) { - return false; - } - - // source would leave the game - if (card.hasSVar("EndOfTurnLeavePlay")) { - return false; - } - - if (cType != null) { - if (cType.is(CounterEnumType.P1P1) && card.hasKeyword(Keyword.UNDYING)) { - return false; - } - if (cType.is(CounterEnumType.M1M1) && card.hasKeyword(Keyword.PERSIST)) { + @Override + public boolean apply(Card card) { + // gain from useless + if (ComputerUtilCard.isUselessCreature(ai, card)) { return false; } - if (!card.canReceiveCounters(cType)) { + // source would leave the game + if (card.hasSVar("EndOfTurnLeavePlay")) { return false; } + + if (cType != null) { + if (cType.is(CounterEnumType.P1P1) && card.hasKeyword(Keyword.UNDYING)) { + return false; + } + if (cType.is(CounterEnumType.M1M1)) { + return false; + } + + if (!card.canReceiveCounters(cType)) { + return false; + } + } + return true; } + }); + + if (best.isEmpty()) { + best = aiList; + } + + Card card = ComputerUtilCard.getBestCreatureAI(best); + + if (card != null) { + sa.getTargets().add(card); return true; } - }); - - if (best.isEmpty()) { - best = aiList; - } - - Card card = ComputerUtilCard.getBestCreatureAI(best); - - if (card != null) { - sa.getTargets().add(card); - return true; } } - // move counter to opponents creature but only if you can not steal - // them - // try to move to something useless or something that would leave - // play + // move counter to opponents creature but only if you can not steal them + // try to move to something useless or something that would leave play List oppList = CardLists.filterControlledBy(tgtCards, ai.getOpponents()); if (!oppList.isEmpty()) { List best = CardLists.filter(oppList, new Predicate() { @@ -441,7 +444,7 @@ public class CountersMoveAi extends SpellAbilityAi { }); if (best.isEmpty()) { - best = aiList; + best = oppList; } Card card = ComputerUtilCard.getBestCreatureAI(best); @@ -455,7 +458,7 @@ public class CountersMoveAi extends SpellAbilityAi { } } - // used for multiple sources -> defied + // used for multiple sources -> defined // or for source -> multiple defined @Override protected Card chooseSingleCard(Player ai, SpellAbility sa, Iterable options, boolean isOptional,