* Improve logic / avoid cheating

* Fix Aggregates.random on FCollection disaster

* Fix finding wrong SA

Co-authored-by: tool4EvEr <tool4EvEr@192.168.0.59>
This commit is contained in:
tool4ever
2022-11-18 20:37:34 +01:00
committed by GitHub
parent f610e1ae40
commit 8eca58e9e4
11 changed files with 33 additions and 20 deletions

View File

@@ -2282,23 +2282,31 @@ public class ComputerUtil {
if (goodChoices.isEmpty()) {
goodChoices = validCards;
}
final CardCollection dChoices = new CardCollection();
if (sa.hasParam("DiscardValid")) {
final String validString = sa.getParam("DiscardValid");
if (validString.contains("Creature") && !validString.contains("nonCreature")) {
final Card c = ComputerUtilCard.getBestCreatureAI(goodChoices);
if (c != null) {
dChoices.add(c);
if (min == 1 && max == 1) {
if (sa.hasParam("DiscardValid")) {
final String validString = sa.getParam("DiscardValid");
if (validString.contains("Creature") && !validString.contains("nonCreature")) {
final Card c = ComputerUtilCard.getBestCreatureAI(goodChoices);
if (c != null) {
return new CardCollection(c);
}
}
}
}
// not enough good choices, need to fill the rest
int minDiff = min - goodChoices.size();
if (minDiff > 0) {
goodChoices.addAll(Aggregates.random(CardLists.filter(validCards, Predicates.not(Predicates.in(goodChoices))), minDiff));
return goodChoices;
}
Collections.sort(goodChoices, CardLists.TextLenComparator);
CardLists.sortByCmcDesc(goodChoices);
dChoices.add(goodChoices.get(0));
return Aggregates.random(goodChoices, min, new CardCollection());
return new CardCollection(Aggregates.random(goodChoices, max));
}
public static CardCollection getCardsToDiscardFromFriend(Player aiChooser, Player p, SpellAbility sa, CardCollection validCards, int min, int max) {