Skip to content

Improve Typescript definition for OngoingEffect impls#2269

Open
Frugghi wants to merge 4 commits intomainfrom
ongoing-effects-ts
Open

Improve Typescript definition for OngoingEffect impls#2269
Frugghi wants to merge 4 commits intomainfrom
ongoing-effects-ts

Conversation

@Frugghi
Copy link
Copy Markdown
Collaborator

@Frugghi Frugghi commented Mar 5, 2026

No description provided.

@Frugghi Frugghi marked this pull request as ready for review March 5, 2026 00:58
@Frugghi Frugghi force-pushed the ongoing-effects-ts branch from 2c8c8a8 to 398d8c9 Compare March 7, 2026 01:10
VJubert
VJubert previously approved these changes Mar 17, 2026
title: 'This unit gains Raid 1 for each damage on him',
ongoingEffect: AbilityHelper.ongoingEffects.gainKeyword(
(target) => ({ keyword: KeywordName.Raid, amount: target.damage })
(target: this) => ({ keyword: KeywordName.Raid, amount: target.damage })
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If at all possible I'd prefer to make it so that this type annotation isn't mandator. I think that should be doable, since we've done something similar for the templating on GameSystems attached to abilities. If we make IOngoingEffectGenerator a generic and then e.g. for IConstantAbilityProps we change the property to something like this:

ongoingEffect: IOngoingEffectGenerator<TSource> | IOngoingEffectGenerator<TSource>[];

everything should flow through naturally. I haven't dug all the way down on that rabbit hole though, so I may be missing something

Copy link
Copy Markdown
Collaborator 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 this is possible. The problem is that ongoing effects are not always targeting the source (e.g. they could target a player or other cards) so using TSource wouldn't be correct.

I've updated the implementation to infer that modifyStats is only applied to units because it's true, but the same cannot be done for gainKeyword.

@Frugghi Frugghi requested a review from AMMayberry1 March 21, 2026 00:21
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