Skip to content

Set unique target players for CharmAi#10053

Draft
kojotak wants to merge 4 commits intoCard-Forge:masterfrom
kojotak:bugfix/9044shadrix
Draft

Set unique target players for CharmAi#10053
kojotak wants to merge 4 commits intoCard-Forge:masterfrom
kojotak:bugfix/9044shadrix

Conversation

@kojotak
Copy link
Contributor

@kojotak kojotak commented Mar 13, 2026

Possible fix for #9044.

AI no longer targets the same player. Same issue as with Shadrix Silverquill can be observed with Chaos Balor. It works, but I'm not sure, whether CharmAi is the right place (and time) to set targets.

image image

@Agetian
Copy link
Contributor

Agetian commented Mar 14, 2026

Are there cards with CharmAi that can legitimately target the same player and you can choose more than one option? If there are, would this break them, especially in 1v1 matches where this behavior would be viable?

if (uniquePlayerTargets == num) {
Player nextPlayer = ai;
for (AbilitySub choosen : chosenList) {
choosen.resetTargets();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmn this is a tricky situation:
I don't think trying to retroactively fix the situation is viable enough (right now it could still perform illegal targeting and chances are this approach just ends up producing dumb plays anyway)

What should happen instead is manually building out the SA chain inside each choices loop so that their API checks can just naturally skip already targeted entries 🪄

Though it looks to me like this might risk CharmEffect.chainAbilities creating an infinite loop, so probably also requires some additional reset logic before finishing 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think trying to retroactively fix the situation is viable enough

You are right. I've discovered some invalid targeting today as well 😞.

I was considering adding new parameter (TargetDifferentPlayer$ True) representing Each mode must target a different player. (as a hint for targeting) but it duplicated the TargetUnique$ True (for each mode).

I will try to take a look at "SA chain", because that's something new for me.

@kojotak
Copy link
Contributor Author

kojotak commented Mar 14, 2026

Are there cards with CharmAi that can legitimately target the same player and you can choose more than one option? If there are, would this break them, especially in 1v1 matches where this behavior would be viable?

I was worried about it too, therefore the proposed change checks for TargetUnique$ True and ValidTgts Player/Opponent. So for example Primal Command is unaffected (even if AI will choose the two modes with ValidTgts$ Player - they are not TargetUnique)


I tried to check charms with CanRepeatModes$ True but those are not supported yet (for example Verdant Confluence)

// TODO unused for now, the AI doesn't know how to effectively handle repeated choices
boolean allowRepeat = sa.hasParam("CanRepeatModes");

@kojotak kojotak marked this pull request as draft March 16, 2026 09:56
@kojotak kojotak force-pushed the bugfix/9044shadrix branch from 657e6c8 to 7b2511c Compare March 16, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants