Check if card for PlayEffect is worth it

This commit is contained in:
tool4EvEr
2021-05-05 21:14:15 +02:00
parent 122baba999
commit d6e7d1ffee
4 changed files with 11 additions and 7 deletions

View File

@@ -280,7 +280,7 @@ public class ComputerUtil {
SpellAbility newSA = sa.copyWithNoManaCost();
newSA.setActivatingPlayer(ai);
if (!CostPayment.canPayAdditionalCosts(newSA.getPayCosts(), newSA) || !ComputerUtilMana.payManaCost(ai, newSA)) {
if (!CostPayment.canPayAdditionalCosts(newSA.getPayCosts(), newSA) || !ComputerUtilMana.canPayManaCost(newSA, ai, 0)) {
return false;
}

View File

@@ -29,6 +29,7 @@ import forge.game.cost.Cost;
import forge.game.keyword.Keyword;
import forge.game.player.Player;
import forge.game.player.PlayerActionConfirmMode;
import forge.game.ability.effects.PlayEffect;
import forge.game.spellability.Spell;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.SpellAbilityPredicates;
@@ -163,9 +164,9 @@ public class PlayAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/
@Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
// as called from PlayEffect:173
return true;
public boolean confirmAction(Player ai, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
// as called from PlayEffect
return chooseSingleCard(ai, sa, new CardCollection(((PlayEffect)(sa.getApi().getSpellEffect())).getTgtCard()), true, ai, null) != null;
}
/* (non-Javadoc)

View File

@@ -55,7 +55,7 @@ public abstract class SpellAbilityEffect {
public abstract void resolve(SpellAbility sa);
protected String getStackDescription(final SpellAbility sa) {
// Unless overriden, let the spell description also be the stack description
// Unless overridden, let the spell description also be the stack description
return sa.getDescription();
}
@@ -218,7 +218,6 @@ public abstract class SpellAbilityEffect {
: AbilityUtils.getDefinedSpellAbilities(sa.getHostCard(), sa.getParam(definedParam), sa);
}
// Targets of card or player type
protected final static List<GameEntity> getTargetEntities(final SpellAbility sa) { return getEntities(false, "Defined", sa); }
protected final static List<GameEntity> getTargetEntities(final SpellAbility sa, final String definedParam) { return getEntities(false, definedParam, sa); }

View File

@@ -40,6 +40,10 @@ import forge.util.Lang;
import forge.util.Localizer;
public class PlayEffect extends SpellAbilityEffect {
private Card tgtCard;
public Card getTgtCard() { return tgtCard; }
@Override
protected String getStackDescription(final SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
@@ -181,7 +185,7 @@ public class PlayEffect extends SpellAbilityEffect {
final CardCollection saidNoTo = new CardCollection();
while (tgtCards.size() > saidNoTo.size() && saidNoTo.size() < amount && amount > 0) {
activator.getController().tempShowCards(showCards);
Card tgtCard = controller.getController().chooseSingleEntityForEffect(tgtCards, sa, Localizer.getInstance().getMessage("lblSelectCardToPlay"), null);
tgtCard = controller.getController().chooseSingleEntityForEffect(tgtCards, sa, Localizer.getInstance().getMessage("lblSelectCardToPlay"), null);
activator.getController().endTempShowCards();
if (tgtCard == null) {
break;