Merge branch 'countersMove' into 'master'

CountersMoveAI: Improve logic for Ozolith

See merge request core-developers/forge!4568
This commit is contained in:
Michael Kamensky
2021-04-22 05:03:54 +00:00

View File

@@ -372,54 +372,57 @@ public class CountersMoveAi extends SpellAbilityAi {
} }
} }
List<Card> aiList = CardLists.filterControlledBy(tgtCards, ai); Card lki = CardUtil.getLKICopy(src);
if (!aiList.isEmpty()) { lki.clearCounters();
List<Card> best = CardLists.filter(aiList, new Predicate<Card>() { // go for opponent when value implies debuff
if (ComputerUtilCard.evaluateCreature(src) > ComputerUtilCard.evaluateCreature(lki)) {
List<Card> aiList = CardLists.filterControlledBy(tgtCards, ai);
if (!aiList.isEmpty()) {
List<Card> best = CardLists.filter(aiList, new Predicate<Card>() {
@Override @Override
public boolean apply(Card card) { public boolean apply(Card card) {
// gain from useless // gain from useless
if (ComputerUtilCard.isUselessCreature(ai, card)) { 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)) {
return false; return false;
} }
if (!card.canReceiveCounters(cType)) { // source would leave the game
if (card.hasSVar("EndOfTurnLeavePlay")) {
return false; 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; 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 // move counter to opponents creature but only if you can not steal them
// them // try to move to something useless or something that would leave play
// try to move to something useless or something that would leave
// play
List<Card> oppList = CardLists.filterControlledBy(tgtCards, ai.getOpponents()); List<Card> oppList = CardLists.filterControlledBy(tgtCards, ai.getOpponents());
if (!oppList.isEmpty()) { if (!oppList.isEmpty()) {
List<Card> best = CardLists.filter(oppList, new Predicate<Card>() { List<Card> best = CardLists.filter(oppList, new Predicate<Card>() {
@@ -441,7 +444,7 @@ public class CountersMoveAi extends SpellAbilityAi {
}); });
if (best.isEmpty()) { if (best.isEmpty()) {
best = aiList; best = oppList;
} }
Card card = ComputerUtilCard.getBestCreatureAI(best); 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 // or for source -> multiple defined
@Override @Override
protected Card chooseSingleCard(Player ai, SpellAbility sa, Iterable<Card> options, boolean isOptional, protected Card chooseSingleCard(Player ai, SpellAbility sa, Iterable<Card> options, boolean isOptional,