DestroyAI: better logic for Pongify also Update for X

This commit is contained in:
Hans Mackowiak
2020-12-25 23:23:06 +01:00
parent 60bf6dde9d
commit d8f010d54a
6 changed files with 214 additions and 167 deletions

View File

@@ -65,6 +65,16 @@ public class CostDiscard extends CostPartWithList {
public int paymentOrder() { return 10; }
@Override
public Integer getMaxAmountX(SpellAbility ability, Player payer) {
final Card source = ability.getHostCard();
String type = this.getType();
CardCollectionView handList = payer.canDiscardBy(ability) ? payer.getCardsIn(ZoneType.Hand) : CardCollection.EMPTY;
handList = CardLists.getValidCards(handList, type.split(";"), payer, source, ability);
return handList.size();
}
/*
* (non-Javadoc)
*

View File

@@ -1391,7 +1391,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
return false;
}
return getTargets().size() < getTargetRestrictions().getMaxTargets(hostCard, this);
return getTargets().size() < getMaxTargets();
}
public boolean isZeroTargets() {
@@ -1405,6 +1405,14 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
return getTargetRestrictions().isMaxTargetsChosen(hostCard, this);
}
public int getMinTargets() {
return getTargetRestrictions().getMinTargets(getHostCard(), this);
}
public int getMaxTargets() {
return getTargetRestrictions().getMaxTargets(getHostCard(), this);
}
public boolean isTargetNumberValid() {
if (!this.usesTargeting()) {
return getTargets().isEmpty();
@@ -1413,7 +1421,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
if (!isMinTargetChosen()) {
return false;
}
int maxTargets = getTargetRestrictions().getMaxTargets(hostCard, this);
int maxTargets = getMaxTargets();
if (maxTargets == 0 && getPayCosts().hasSpecificCostType(CostRemoveCounter.class)
&& hasSVar(getParam("TargetMax"))