diff --git a/res/cardsfolder/a/austere_command.txt b/res/cardsfolder/a/austere_command.txt index 664c155fabd..6144db7c047 100644 --- a/res/cardsfolder/a/austere_command.txt +++ b/res/cardsfolder/a/austere_command.txt @@ -7,7 +7,6 @@ SVar:DestroyArtifacts:DB$ DestroyAll | ValidCards$ Artifact | SpellDescription$ SVar:DestroyEnchs:DB$ DestroyAll | ValidCards$ Enchantment | SpellDescription$ Destroy all enchantments. SVar:DestroyLE3:DB$ DestroyAll | ValidCards$ Creature.cmcLE3 | SpellDescription$ Destroy all creatures with converted mana cost 3 or less. SVar:DestroyGE4:DB$ DestroyAll | ValidCards$ Creature.cmcGE4 | SpellDescription$ Destroy all creatures with converted mana cost 4 or greater. -SVar:RemAIDeck:True SVar:Rarity:Rare SVar:Picture:http://www.wizards.com/global/images/magic/general/austere_command.jpg SetInfo:COM|Rare|http://magiccards.info/scans/en/cmd/8.jpg diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java index 241fbf917ae..61a7985528e 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java @@ -142,6 +142,7 @@ public final class AbilityFactoryCharm { final Card source = sa.getSourceCard(); //this resets all previous choices sa.setSubAbility(null); + sa.setActivatingPlayer(AllZone.getComputerPlayer()); final int num = Integer.parseInt(params.containsKey("CharmNum") ? params.get("CharmNum") : "1"); final String[] saChoices = params.get("Choices").split(","); @@ -156,13 +157,13 @@ public final class AbilityFactoryCharm { for (SpellAbility sub : choices) { if (sub.doTrigger(false)) { chosen = (AbilitySub) sub; + choices.remove(sub); break; } } if (chosen == null) { return false; } - choices.remove(chosen); // walk down the SpellAbility tree and add to the child // Ability_Sub diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java index 2a7cac24a61..0b76da9b1ed 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java @@ -680,11 +680,7 @@ public class AbilityFactoryDestroy { @Override public String getStackDescription() { - if (this.params.containsKey("SpellDescription")) { - return af.getHostCard().getName() + " - " + this.params.get("SpellDescription"); - } else { - return AbilityFactoryDestroy.destroyAllStackDescription(af, this, this.noRegen); - } + return AbilityFactoryDestroy.destroyAllStackDescription(af, this, this.noRegen); } @Override @@ -699,8 +695,7 @@ public class AbilityFactoryDestroy { @Override public boolean doTrigger(final boolean mandatory) { - // TODO Auto-generated method stub - return false; + return AbilityFactoryDestroy.destroyAllTriggerAI(af, this, mandatory); } }; @@ -726,26 +721,35 @@ public class AbilityFactoryDestroy { final StringBuilder sb = new StringBuilder(); final String name = af.getHostCard().getName(); final HashMap params = af.getMapParams(); - - final String conditionDesc = params.get("ConditionDescription"); - if (conditionDesc != null) { - sb.append(conditionDesc).append(" "); - } - - ArrayList tgtCards; - - final Target tgt = sa.getTarget(); - if (tgt != null) { - tgtCards = tgt.getTargetCards(); + if (!(sa instanceof AbilitySub)) { + sb.append(sa.getSourceCard().getName()).append(" - "); } else { - tgtCards = new ArrayList(); - tgtCards.add(sa.getSourceCard()); + sb.append(" "); } - sb.append(name).append(" - Destroy permanents."); + if (params.containsKey("SpellDescription")) { + sb.append(params.get("SpellDescription")); + } else { + final String conditionDesc = params.get("ConditionDescription"); + if (conditionDesc != null) { + sb.append(conditionDesc).append(" "); + } - if (noRegen) { - sb.append(" They can't be regenerated"); + ArrayList tgtCards; + + final Target tgt = sa.getTarget(); + if (tgt != null) { + tgtCards = tgt.getTargetCards(); + } else { + tgtCards = new ArrayList(); + tgtCards.add(sa.getSourceCard()); + } + + sb.append(name).append(" - Destroy permanents."); + + if (noRegen) { + sb.append(" They can't be regenerated"); + } } final AbilitySub abSub = sa.getSubAbility(); @@ -756,6 +760,73 @@ public class AbilityFactoryDestroy { return sb.toString(); } + /** + *

+ * destroyAllCanPlayAI. + *

+ * + * @param af + * a {@link forge.card.abilityfactory.AbilityFactory} object. + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. + * @param noRegen + * a boolean. + * @return a boolean. + */ + private static boolean destroyAllTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) { + final Card source = sa.getSourceCard(); + final HashMap params = af.getMapParams(); + final Target tgt = sa.getTarget(); + String valid = ""; + if (params.containsKey("ValidCards")) { + valid = params.get("ValidCards"); + } + CardList humanlist = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList computerlist = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + if (sa.getTarget() != null) { + tgt.resetTargets(); + sa.getTarget().addTarget(AllZone.getHumanPlayer()); + computerlist.clear(); + } + if (mandatory) { + return true; + } + humanlist = humanlist.getValidCards(valid.split(","), source.getController(), source); + computerlist = computerlist.getValidCards(valid.split(","), source.getController(), source); + humanlist = humanlist.filter(new CardListFilter() { + @Override + public boolean addCard(final Card c) { + return !(c.hasKeyword("Indestructible") || c.getSVar("SacMe").length() > 0); + } + }); + if (humanlist.isEmpty()) { + return false; + } + computerlist = computerlist.filter(new CardListFilter() { + @Override + public boolean addCard(final Card c) { + return !(c.hasKeyword("Indestructible") || c.getSVar("SacMe").length() > 0); + } + }); + // if only creatures are affected evaluate both lists and pass only if + // human creatures are more valuable + if ((humanlist.getNotType("Creature").size() == 0) && (computerlist.getNotType("Creature").size() == 0)) { + if (CardFactoryUtil.evaluateCreatureList(computerlist) >= CardFactoryUtil.evaluateCreatureList(humanlist)) { + return false; + } + } // otherwise evaluate both lists by CMC and pass only if human + // permanents are more valuable + else if (CardFactoryUtil.evaluatePermanentList(computerlist) >= CardFactoryUtil.evaluatePermanentList(humanlist)) { + return false; + } + + final AbilitySub subAb = sa.getSubAbility(); + if (subAb != null && !subAb.chkAIDrawback()) { + return false; + } + return true; + } + /** *

* destroyAllCanPlayAI.