mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Fixed AI casting charms with less than minimum options and removed RemAiDeck for Kolaghan's Command
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user