Fix AI for Forge of Heroes and similar counter-boon pump wrappers#10620
Open
Madwand99 wants to merge 1 commit intoCard-Forge:masterfrom
Open
Fix AI for Forge of Heroes and similar counter-boon pump wrappers#10620Madwand99 wants to merge 1 commit intoCard-Forge:masterfrom
Madwand99 wants to merge 1 commit intoCard-Forge:masterfrom
Conversation
tool4ever
reviewed
May 7, 2026
|
|
||
| private static boolean isDefinedByParentTarget(AbilitySub ab) { | ||
| final String defined = ab.getParam("Defined"); | ||
| return "ParentTarget".equals(defined) || "Targeted".equals(defined) || "ThisTargetedCard".equals(defined); |
Contributor
There was a problem hiding this comment.
no duplicated methods please
tool4ever
reviewed
May 7, 2026
| } | ||
|
|
||
| if (counterBoon) { | ||
| CardCollection counterBoonTargets = getCounterBoonTargets(ai, sa); |
Contributor
There was a problem hiding this comment.
not a fan of attempting all this lookahead logic
a better solution could be just refactoring the script without Pump effect so the top API logic might fit better 🤔
tool4ever
reviewed
May 7, 2026
| */ | ||
| public AiAbilityDecision chkDrawbackWithSubs(Player aiPlayer, AbilitySub ab) { | ||
| final AbilitySub subAb = ab.getSubAbility(); | ||
| if (!ab.metConditions() || isDefinedByParentTarget(ab)) { |
Contributor
There was a problem hiding this comment.
can cause negative side effects with way too generic assumption:
lots of conditions might only be true after putting it on the stack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes an AI targeting issue where Forge of Heroes could target an opponent’s commander instead of the AI’s own commander.
Forge of Heroes is scripted as a Pump ability with PutCounter sub-abilities that apply to the parent target. Since the top-level ability has no normal pump stats or keyword effect, PumpAi could fall through to generic target selection and choose the “best” legal commander overall, including an opponent’s commander.
This PR teaches PumpAi to recognize beneficial counter sub-abilities attached to the pump target, then restrict those target choices to valid permanents controlled by the AI’s team. It currently treats +1/+1, loyalty, and keyword counters as beneficial, while avoiding hostile or arbitrary counters such as stun, corruption, oil, and -1/-1.
It also updates sub-ability drawback handling so inactive conditional sub-abilities and parent-targeted sub-abilities are not evaluated as independent drawback decisions.
Cards that benefit from this general handling include:
Added a regression test confirming that Forge of Heroes targets the AI’s own commander even when the opponent’s commander is also legal and stronger.
Tested with:
mvn -pl forge-gui-desktop -am -Dtest=forge.ai.ability.PumpAiTest -Dsurefire.failIfNoSpecifiedTests=false test
Fixes #9641