mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Added some missing functions to AF DestroyAll (namely a proper stack description and doTriggerAI).
- The AI can now use Austere Command.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -680,12 +680,8 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
@@ -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,7 +721,15 @@ public class AbilityFactoryDestroy {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final String name = af.getHostCard().getName();
|
||||
final HashMap<String, String> params = af.getMapParams();
|
||||
if (!(sa instanceof AbilitySub)) {
|
||||
sb.append(sa.getSourceCard().getName()).append(" - ");
|
||||
} else {
|
||||
sb.append(" ");
|
||||
}
|
||||
|
||||
if (params.containsKey("SpellDescription")) {
|
||||
sb.append(params.get("SpellDescription"));
|
||||
} else {
|
||||
final String conditionDesc = params.get("ConditionDescription");
|
||||
if (conditionDesc != null) {
|
||||
sb.append(conditionDesc).append(" ");
|
||||
@@ -747,6 +750,7 @@ public class AbilityFactoryDestroy {
|
||||
if (noRegen) {
|
||||
sb.append(" They can't be regenerated");
|
||||
}
|
||||
}
|
||||
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
@@ -756,6 +760,73 @@ public class AbilityFactoryDestroy {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* destroyAllCanPlayAI.
|
||||
* </p>
|
||||
*
|
||||
* @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<String, String> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* destroyAllCanPlayAI.
|
||||
|
||||
Reference in New Issue
Block a user