fix: add missing item finding functionality to CharacterModel (#2685)#2737
Open
rinickolous wants to merge 3 commits into
Open
fix: add missing item finding functionality to CharacterModel (#2685)#2737rinickolous wants to merge 3 commits into
rinickolous wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the broken global item-finding helpers (GURPS.findSkill, GURPS.findAdDisad, GURPS.findAttack, etc.) by routing lookups through CharacterModel (and a small adapter) instead of calling methods directly on the Actor document, addressing #2685.
Changes:
- Added
src/module/util/find-item.tsto resolve anActordocument to aCharacterModeland providefindSkill/findSpell/findSkillSpell/findAdDisad/findAttackhelpers. - Implemented skill/spell lookup methods on
CharacterModel(regex-based, best-level selection per list). - Updated
src/module/gurps.jsto expose these helpers on theGURPSglobal and use them in OTF “test-exists” handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/module/util/find-item.ts | New adapter/helper module that resolves Actor→CharacterModel and exposes item-finding functions used by GURPS.*. |
| src/module/gurps.js | Wires the new helpers into the GURPS global API and replaces removed in-file implementations. |
| src/module/actor/data/character.ts | Adds CharacterModel lookup methods for skills/spells (and a shared regex builder) used by the new global helpers. |
Comments suppressed due to low confidence (1)
src/module/util/find-item.ts:26
- New item-finding behavior is introduced via
find-item.tsand the newCharacterModellookup methods, but there are no unit tests covering the key cases that caused #2685 (passing an Actor document vsactor.system, and handlingnull/undefinedactor inputs). Adding a small Vitest suite for these helpers would help prevent regressions in global APIs likeGURPS.findSkill/findAttack.
export function findSkill(actor: CharacterOrActor, name: string): Item.OfType<ItemType.Skill> | null {
return resolveCharacterModel(actor)?.findSkill(name) ?? null
}
/* ---------------------------------------- */
export function findSpell(actor: CharacterOrActor, name: string): Item.OfType<ItemType.Spell> | null {
return resolveCharacterModel(actor)?.findSpell(name) ?? null
}
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
mjeffw
requested changes
May 29, 2026
| return item | ||
| } | ||
|
|
||
| GURPS.findAdDisad = findAdDisad |
Collaborator
There was a problem hiding this comment.
Module utils should add these methods to the GURPS global in its init() method.
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.
Fixes #2685