CostTapType: for Crew add Keyword "CARDNAME can't crew a vehicle",

now the cost does check that the creatures does not have this.
This commit is contained in:
Hanmac
2016-09-18 05:01:39 +00:00
parent 4ecf85d505
commit c0f7ea2983
4 changed files with 18 additions and 4 deletions

View File

@@ -433,7 +433,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
totalPower = true;
totalP = type.split("withTotalPowerGE")[1];
type = type.replace("+withTotalPowerGE" + totalP, "");
totap = ComputerUtil.chooseTapTypeAccumulatePower(player, type, source, !cost.canTapSource, Integer.parseInt(totalP), tapped);
totap = ComputerUtil.chooseTapTypeAccumulatePower(player, type, ability, !cost.canTapSource, Integer.parseInt(totalP), tapped);
} else {
totap = ComputerUtil.chooseTapType(player, type, source, !cost.canTapSource, c, tapped);
}

View File

@@ -497,14 +497,19 @@ public class ComputerUtil {
return tapList;
}
public static CardCollection chooseTapTypeAccumulatePower(final Player ai, final String type, final Card activate, final boolean tap, final int amount, final CardCollectionView exclude) {
public static CardCollection chooseTapTypeAccumulatePower(final Player ai, final String type, final SpellAbility sa, final boolean tap, final int amount, final CardCollectionView exclude) {
// Used for Crewing vehicles, ideally we sort by useless creatures. Can't Attack/Defender
int totalPower = 0;
final Card activate = sa.getHostCard();
CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield));
all.removeAll(exclude);
CardCollection typeList =
CardLists.getValidCards(all, type.split(";"), activate.getController(), activate, null);
CardLists.getValidCards(all, type.split(";"), activate.getController(), activate, sa);
if (sa.hasParam("Crew")) {
typeList = CardLists.getNotKeyword(typeList, "CARDNAME can't crew a vehicle");
}
// is this needed?
typeList = CardLists.filter(typeList, Presets.UNTAPPED);

View File

@@ -128,6 +128,10 @@ public class CostTapType extends CostPartWithList {
}
typeList = CardLists.filter(typeList, Presets.UNTAPPED);
if (ability.hasParam("Crew")) {
typeList = CardLists.getNotKeyword(typeList, "CARDNAME can't crew a vehicle");
}
if (sameType) {
for (final Card card : typeList) {
if (CardLists.filter(typeList, new Predicate<Card>() {

View File

@@ -1093,6 +1093,11 @@ public class HumanCostDecision extends CostDecisionMakerBase {
CardCollection typeList = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), type.split(";"), player,
source, ability);
typeList = CardLists.filter(typeList, Presets.UNTAPPED);
if (ability.hasParam("Crew")) {
typeList = CardLists.getNotKeyword(typeList, "CARDNAME can't crew a vehicle");
}
if (c == null && !amount.equals("Any")) {
final String sVar = ability.getSVar(amount);
// Generalize this