Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#342, #2538] Display race on sheet, add singleton logic to race & background items #2541

Merged
merged 5 commits into from
Nov 6, 2023

Conversation

arbron
Copy link
Collaborator

@arbron arbron commented Oct 31, 2023

Displays race item above background on features tab of character sheet.

Adds a LocalDocumentField to reference a single item on an actor, and replace background & race properties with this new field. This field has a fallback option so that if the item isn't found, then string is displayed (allowing existing hand-typed Race and Background values to continue displaying properly).

Used a mixin for Item5e and Actor5e that forwards socket event handler requests to their data models, allowing each type to add custom socket event handler behavior. This behavior is used in RaceData and BackgroundData to set system.details.race and system.details.background to reference any newly added items, and unset it when they are deleted. This is also used for any item marked with the singleton metadata property to only allow one to be created at a time.

I've also tweaked all of our current socket event handlers to ensure they return false if the parent handler returns false so we can properly prevent items from being created.

module/data/fields.mjs Outdated Show resolved Hide resolved
module/data/fields.mjs Show resolved Hide resolved
module/documents/mixin.mjs Outdated Show resolved Hide resolved
module/documents/mixin.mjs Outdated Show resolved Hide resolved
module/documents/item.mjs Outdated Show resolved Hide resolved
module/documents/item.mjs Outdated Show resolved Hide resolved
module/documents/actor/actor.mjs Outdated Show resolved Hide resolved
module/documents/actor/actor.mjs Outdated Show resolved Hide resolved
module/data/item/background.mjs Outdated Show resolved Hide resolved
module/data/item/race.mjs Outdated Show resolved Hide resolved
@arbron
Copy link
Collaborator Author

arbron commented Nov 6, 2023

@Fyorl I added a bit of data preparation code to ensure that background labels from before the reference was added continue working displaying properly.

module/data/item/race.mjs Outdated Show resolved Hide resolved
module/data/actor/character.mjs Outdated Show resolved Hide resolved
@arbron arbron requested a review from Fyorl November 6, 2023 18:14
@Fyorl Fyorl added the migration The feature involves a system migration label Nov 6, 2023
module/migration.mjs Outdated Show resolved Hide resolved
Copy link
Contributor

@Fyorl Fyorl left a comment

Choose a reason for hiding this comment

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

LGTM, thank you Jeff

@arbron arbron merged commit 59b5363 into foundryvtt:2.4.x Nov 6, 2023
@arbron arbron deleted the types/race-actor branch November 6, 2023 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking changes feature request migration The feature involves a system migration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants