- Fixed AI casting charms with less than minimum options and removed RemAiDeck for Kolaghan's Command

This commit is contained in:
excessum
2015-08-15 14:06:56 +00:00
parent de9a0f79b7
commit 27f76c9ee8
2 changed files with 27 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ public class CharmAi extends SpellAbilityAi {
// reset the chosen list. Otherwise it will be locked in forever
sa.setChosenList(null);
List<AbilitySub> chosenList = chooseOptionsAi(sa, ai, timingRight, num, min, false);
List<AbilitySub> chosenList = min > 1 ? chooseMultipleOptionsAi(sa, ai, min) : chooseOptionsAi(sa, ai, timingRight, num, min, false);
if (chosenList.isEmpty()) {
return false;
@@ -92,6 +92,32 @@ public class CharmAi extends SpellAbilityAi {
return chosenList;
}
//Extension of chooseOptionsAi specific to multi-option charms (eg. Cryptic Command, DTK commands)
private List<AbilitySub> chooseMultipleOptionsAi(SpellAbility sa, final Player ai, int min) {
if (sa.getChosenList() != null) {
return sa.getChosenList();
}
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
List<AbilitySub> chosenList = new ArrayList<AbilitySub>();
// select first n playable options
AiController aic = ((PlayerControllerAi) ai.getController()).getAi();
for (AbilitySub sub : choices) {
sub.setActivatingPlayer(ai);
if (AiPlayDecision.WillPlay == aic.canPlaySa(sub)) {
chosenList.add(sub);
if (chosenList.size() == min) {
break;
}
}
}
if (chosenList.size() != min) {
return new ArrayList<AbilitySub>();
} else {
return chosenList;
}
}
@Override
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> opponents) {
return Aggregates.random(opponents);