- Improved the AI of AF TwoPiles.

This commit is contained in:
Sloth
2012-02-16 18:21:38 +00:00
parent cc658ee7e5
commit fc1511bde3
4 changed files with 37 additions and 6 deletions

View File

@@ -5,7 +5,6 @@ Text:no text
A:SP$ TwoPiles | Cost$ 4 W | Defined$ You | Separator$ You | Chooser$ Opponent | ChosenPile$ DBReturn | UnchosenPile$ DBExile | ValidCards$ Creature | Zone$ Graveyard | SpellDescription$ Separate all creature cards in your graveyard into two piles. Exile the pile of an opponent's choice and return the other to the battlefield.
SVar:DBReturn:DB$ ChangeZone | Defined$ Remembered | Origin$ Library | Destination$ Battlefield
SVar:DBExile:DB$ ChangeZone | Defined$ Remembered | Origin$ Library | Destination$ Exile
SVar:RemAIDeck:True
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/death_or_glory.jpg
SetInfo:INV|Rare|http://magiccards.info/scans/en/in/13.jpg

View File

@@ -4,7 +4,6 @@ Types:Sorcery
Text:no text
A:SP$ TwoPiles | Cost$ 1 B | ValidTgts$ Player | TgtPrompt$ Select target player | Separator$ You | ChosenPile$ DBDestroy | ValidCards$ Creature | Zone$ Battlefield | SpellDescription$ Separate all creatures target player controls into two piles. Destroy all creatures in the pile of that player's choice. They can't be regenerated.
SVar:DBDestroy:DB$ Destroy | Defined$ Remembered | NoRegen$ True
SVar:RemAIDeck:True
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/do_or_die.jpg
SetInfo:INV|Rare|http://magiccards.info/scans/en/in/102.jpg

View File

@@ -5,7 +5,7 @@ Text:no text
Loyalty:3
A:AB$ Discard | Cost$ AddCounter<1/LOYALTY> | NumCards$ 1 | Mode$ TgtChoose | Defined$ Each | Planeswalker$ True | SpellDescription$ Each player discards a card.
A:AB$ Sacrifice | Cost$ SubCounter<2/LOYALTY> | ValidTgts$ Player | SacValid$ Creature | SacMessage$ Creature | Planeswalker$ True | SpellDescription$ Target player sacrifices a creature.
A:AB$ TwoPiles | Cost$ SubCounter<6/LOYALTY> | ValidTgts$ Player | TgtPrompt$ Select target player | Separator$ You | ChosenPile$ DBSacAll | ValidCards$ Permanent | Planeswalker$ True | Ultimate$ True | SpellDescription$ Separate all permanents target player controls into two piles. That player sacrifices all permanents in the pile of his or her choice.
A:AB$ TwoPiles | Cost$ SubCounter<6/LOYALTY> | ValidTgts$ Player | TgtPrompt$ Select target player | Separator$ You | ChosenPile$ DBSacAll | ValidCards$ Permanent | Zone$ Battlefield | Planeswalker$ True | Ultimate$ True | SpellDescription$ Separate all permanents target player controls into two piles. That player sacrifices all permanents in the pile of his or her choice.
SVar:DBSacAll:DB$ SacrificeAll | ValidCards$ Permanent | Defined$ Remembered | SubAbility$ Cleanup
SVar:Cleanup:DB$ Cleanup | ClearRemembered$ True
SVar:RemAIDeck:True

View File

@@ -26,9 +26,7 @@ import javax.swing.JOptionPane;
import forge.AllZone;
import forge.Card;
import forge.CardList;
import forge.CardUtil;
import forge.Constant;
import forge.Constant.Zone;
import forge.GameActionUtil;
import forge.Player;
import forge.card.cardfactory.CardFactoryUtil;
@@ -607,7 +605,42 @@ public final class AbilityFactoryClash {
}
private static boolean twoPilesCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
return AbilityFactoryClash.twoPilesTriggerAI(af, sa, false);
final HashMap<String, String> params = af.getMapParams();
final Card card = af.getHostCard();
Constant.Zone zone = null;
if (params.containsKey("Zone")) {
zone = Constant.Zone.smartValueOf(params.get("Zone"));
}
String valid = "";
if (params.containsKey("ValidCards")) {
valid = params.get("ValidCards");
}
ArrayList<Player> tgtPlayers;
final Target tgt = sa.getTarget();
if (tgt != null) {
tgt.resetTargets();
if (tgt.canTgtPlayer()) {
tgt.addTarget(AllZone.getHumanPlayer());
}
tgtPlayers = tgt.getTargetPlayers();
} else {
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
}
final Player p = tgtPlayers.get(0);
CardList pool = new CardList();
if (params.containsKey("DefinedCards")) {
pool = new CardList(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("DefinedCards"), sa));
} else {
pool = p.getCardsIn(zone);
}
pool = pool.getValidCards(valid, card.getController(), card);
int size = pool.size();
return size > 2;
}
private static boolean twoPilesTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {