- 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 // reset the chosen list. Otherwise it will be locked in forever
sa.setChosenList(null); 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()) { if (chosenList.isEmpty()) {
return false; return false;
@@ -92,6 +92,32 @@ public class CharmAi extends SpellAbilityAi {
return chosenList; 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 @Override
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> opponents) { public Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> opponents) {
return Aggregates.random(opponents); return Aggregates.random(opponents);

View File

@@ -6,6 +6,5 @@ SVar:DBReturn:DB$ ChangeZone | Origin$ Graveyard | Destination$ Hand | ValidTgts
SVar:DBDiscard:DB$ Discard | ValidTgts$ Player | TgtPrompt$ Choose a player | NumCards$ 1 | Mode$ TgtChoose | SpellDescription$ Target player discards a card. SVar:DBDiscard:DB$ Discard | ValidTgts$ Player | TgtPrompt$ Choose a player | NumCards$ 1 | Mode$ TgtChoose | SpellDescription$ Target player discards a card.
SVar:DBDestroy:DB$ Destroy | ValidTgts$ Artifact | TgtPrompt$ Select target artifact | SpellDescription$ Destroy target artifact. SVar:DBDestroy:DB$ Destroy | ValidTgts$ Artifact | TgtPrompt$ Select target artifact | SpellDescription$ Destroy target artifact.
SVar:DBDamage:DB$ DealDamage | ValidTgts$ Creature,Player | TgtPrompt$ Select target creature or player | NumDmg$ 2 | SpellDescription$ CARDNAME deals 2 damage to target creature or player. SVar:DBDamage:DB$ DealDamage | ValidTgts$ Creature,Player | TgtPrompt$ Select target creature or player | NumDmg$ 2 | SpellDescription$ CARDNAME deals 2 damage to target creature or player.
SVar:RemAIDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/kolaghans_command.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/kolaghans_command.jpg
Oracle:Choose two -\n• Return target creature card from your graveyard to your hand.\n• Target player discards a card.\n• Destroy target artifact.\n• Kolaghan's Command deals 2 damage to target creature or player. Oracle:Choose two -\n• Return target creature card from your graveyard to your hand.\n• Target player discards a card.\n• Destroy target artifact.\n• Kolaghan's Command deals 2 damage to target creature or player.