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);
|
||||
|
||||
@@ -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: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:RemAIDeck:True
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user