- 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

@@ -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,8 +61,15 @@ public class CostUtil {
static public boolean checkDiscardCost(Cost cost, Card source){
for(CostPart part : cost.getCostParts()){
if (part instanceof CostDiscard)
return false;
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;
}