- Added an AI cost preference for discard costs, the SVar is called "DiscardMe". Squee, Goblin Nabob is an example.

This commit is contained in:
Sloth
2011-08-31 10:03:43 +00:00
parent 93e106ad51
commit 7d4800a91e
3 changed files with 26 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ PT:1/1
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Graveyard | OptionalDecider$ You | Execute$ TrigChange | TriggerDescription$ At the beginning of your upkeep, you may return CARDNAME from your graveyard to your hand.
SVar:TrigChange:AB$ChangeZone | Cost$ 0 | Origin$ Graveyard | Destination$ Hand | Defined$ Self
SVar:SacMe:2
SVar:DiscardMe:2
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/squee_goblin_nabob.jpg
SetInfo:MMQ|Rare|http://magiccards.info/scans/en/mm/214.jpg

View File

@@ -867,6 +867,22 @@ public class ComputerUtil {
}
}
}
if (pref.contains("DiscardCost")) { // search for permanents with DiscardMe
for (int ip = 0; ip < 9; ip++) { // priority 0 is the lowest, priority 5 the highest
final int priority = 9 - ip;
CardList SacMeList = typeList.filter(new CardListFilter() {
public boolean addCard(Card c) {
return (!c.getSVar("DiscardMe").equals("") && Integer.parseInt(c.getSVar("DiscardMe")) == priority);
}
});
if (SacMeList.size() != 0) {
SacMeList.shuffle();
return SacMeList.get(0);
}
}
}
return null;
}

View File

@@ -61,9 +61,16 @@ public class CostUtil {
static public boolean checkDiscardCost(Cost cost, Card source){
for(CostPart part : cost.getCostParts()){
if (part instanceof CostDiscard)
if (part instanceof CostDiscard) {
CostDiscard disc = (CostDiscard)part;
String type = disc.getType();
CardList typeList = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer());
typeList = typeList.getValidCards(type.split(","), source.getController(), source);
if (ComputerUtil.getCardPreference(source, "DiscardCost", typeList) == null)
return false;
}
}
return true;
}