Reduce FailedToTarget scenario

This commit is contained in:
tool4EvEr
2021-06-03 10:14:16 +02:00
parent 3b594d239c
commit 196b48cbd3
7 changed files with 8 additions and 9 deletions

View File

@@ -313,7 +313,6 @@ public class AiController {
// need to set TriggeredObject
exSA.setTriggeringObject(AbilityKey.Card, card);
// for trigger test, need to ignore the conditions
SpellAbilityCondition cons = exSA.getConditions();
if (cons != null) {

View File

@@ -193,7 +193,7 @@ public abstract class SpellAbilityAi {
* Handles the AI decision to play a triggered SpellAbility
*/
protected boolean doTriggerAINoCost(final Player aiPlayer, final SpellAbility sa, final boolean mandatory) {
if (canPlayWithoutRestrict(aiPlayer, sa)) {
if (canPlayWithoutRestrict(aiPlayer, sa) && (!mandatory || sa.isTargetNumberValid())) {
return true;
}

View File

@@ -400,7 +400,6 @@ public class PumpAi extends PumpAiBase {
if (ComputerUtilCard.shouldPumpCard(ai, sa, card, defense, attack, keywords, false)) {
return true;
} else if (containsUsefulKeyword(ai, keywords, card, sa, attack)) {
Card pumped = ComputerUtilCard.getPumpedCreature(ai, sa, card, 0, 0, keywords);
if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS, ai)
|| game.getPhaseHandler().is(PhaseType.COMBAT_BEGIN, ai)) {

View File

@@ -44,7 +44,6 @@ public abstract class PumpAiBase extends SpellAbilityAi {
return false;
}
public boolean grantsUsefulExtraBlockOpts(final Player ai, final SpellAbility sa, final Card card, List<String> keywords) {
PhaseHandler ph = ai.getGame().getPhaseHandler();
Card pumped = ComputerUtilCard.getPumpedCreature(ai, sa, card, 0, 0, keywords);
@@ -506,7 +505,6 @@ public abstract class PumpAiBase extends SpellAbilityAi {
else {
final boolean addsKeywords = !keywords.isEmpty();
if (addsKeywords) {
// If the keyword can prevent a creature from attacking, see if there's some kind of viable prioritization
if (keywords.contains("CARDNAME can't attack.") || keywords.contains("CARDNAME can't attack or block.")
|| keywords.contains("HIDDEN CARDNAME can't attack.") || keywords.contains("HIDDEN CARDNAME can't attack or block.")) {

View File

@@ -151,6 +151,12 @@ public class PumpAllAi extends PumpAiBase {
return true;
}
@Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
// important to call canPlay first so targets are added if needed
return canPlayAI(ai, sa) || mandatory;
}
boolean pumpAgainstRemoval(Player ai, SpellAbility sa, List<Card> comp) {
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa, true);
for (final Card c : comp) {

View File

@@ -39,6 +39,4 @@ public class TapOrUntapAi extends TapAiBase {
return randomReturn;
}
}

View File

@@ -244,7 +244,6 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
* @return a boolean.
*/
public final boolean areMet(final SpellAbility sa) {
Player activator = sa.getActivatingPlayer();
if (activator == null) {
activator = sa.getHostCard().getController();