mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Added an AI cost preference for discard costs, the SVar is called "DiscardMe". Squee, Goblin Nabob is an example.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user