From 082babdc14e879bf52f003701474a7753ea902e3 Mon Sep 17 00:00:00 2001 From: Michael Kamensky Date: Sat, 11 Feb 2023 08:41:00 +0300 Subject: [PATCH] - Improve AI handling for Conduit of Worlds. --- forge-ai/src/main/java/forge/ai/ability/PlayAi.java | 10 +++++++++- .../res/cardsfolder/upcoming/conduit_of_worlds.txt | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/PlayAi.java b/forge-ai/src/main/java/forge/ai/ability/PlayAi.java index c5e182f7b2f..b22b940d668 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PlayAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PlayAi.java @@ -180,13 +180,21 @@ public class PlayAi extends SpellAbilityAi { // Before accepting, see if the spell has a valid number of targets (it should at this point). // Proceeding past this point if the spell is not correctly targeted will result // in "Failed to add to stack" error and the card disappearing from the game completely. + if (!sa.hasParam("WithoutManaCost") && !ComputerUtilCost.canPayCost(spell, ai, true)) { + // if we won't be able to pay the cost, don't choose the card + return false; + } return spell.isTargetNumberValid(); } } return false; } }); - return ComputerUtilCard.getBestAI(tgtCards); + final Card best = ComputerUtilCard.getBestAI(tgtCards); + if (sa.usesTargeting() && !sa.isTargetNumberValid()) { + sa.getTargets().add(best); + } + return best; } private static List getPlayableCards(SpellAbility sa, Player ai) { diff --git a/forge-gui/res/cardsfolder/upcoming/conduit_of_worlds.txt b/forge-gui/res/cardsfolder/upcoming/conduit_of_worlds.txt index f45e4e31ee3..03001c3f7a7 100644 --- a/forge-gui/res/cardsfolder/upcoming/conduit_of_worlds.txt +++ b/forge-gui/res/cardsfolder/upcoming/conduit_of_worlds.txt @@ -2,7 +2,7 @@ Name:Conduit of Worlds ManaCost:2 G G Types:Artifact S:Mode$ Continuous | Affected$ Land.YouOwn | MayPlay$ True | AffectedZone$ Graveyard | Description$ You may play lands from your graveyard. -A:AB$ Play | Cost$ T | ValidSA$ Spell | SorcerySpeed$ True | TgtPrompt$ Choose target nonland permanent card in your graveyard | ConditionCheckSVar$ X | ConditionSVarCompare$ EQ0 | TgtZone$ Graveyard | ValidTgts$ Permanent.nonLand+YouOwn | RememberPlayed$ True | Optional$ True | SubAbility$ DBEffect | SpellDescription$ Choose target nonland permanent card in your graveyard. If you haven't cast a spell this turn, you may cast that card. If you do, you can't cast additional spells this turn. Activate only as a sorcery. +A:AB$ Play | Cost$ T | ValidSA$ Spell | SorcerySpeed$ True | TgtPrompt$ Choose target nonland permanent card in your graveyard | ConditionCheckSVar$ X | ConditionSVarCompare$ EQ0 | TgtZone$ Graveyard | ValidTgts$ Permanent.nonLand+YouOwn | RememberPlayed$ True | Optional$ True | SubAbility$ DBEffect | AILogic$ NeedsChosenCard | SpellDescription$ Choose target nonland permanent card in your graveyard. If you haven't cast a spell this turn, you may cast that card. If you do, you can't cast additional spells this turn. Activate only as a sorcery. SVar:DBEffect:DB$ Effect | Name$ Conduit of Worlds's Effect | ConditionDefined$ Remembered | ConditionPresent$ Card | StaticAbilities$ STCantBeCast | SubAbility$ DBCleanup SVar:STCantBeCast:Mode$ CantBeCast | EffectZone$ Command | ValidCard$ Card | Caster$ You | Description$ You can't cast additional spells this turn. SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True