Skip to content

Conversation

@roth-michael
Copy link
Contributor

So far, just modifying the schema and making any required code changes so that everything works as it already did. uuid.item ?? uuid is awful each time it comes up, rest assured it's a temporary measure, since everywhere it's used we'll be needing new explicit logic to handle the level aspect of things (in a follow-up PR).

@roth-michael roth-michael marked this pull request as draft December 30, 2025 19:37
@roth-michael roth-michael marked this pull request as ready for review December 30, 2025 19:53
Copy link
Contributor

@aaclayton aaclayton left a comment

Choose a reason for hiding this comment

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

Looking good. A couple requests!

Comment on lines 130 to 137
return {
uuid,
name: talent.name,
img: talent.img,
description: await CONFIG.ux.TextEditor.enrichHTML(talent.system.description),
tags: talent.getTags(),
item: await talent.renderInline({showRemove: this.isEditable})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm missing something, but i think we shouldn't need to do all this work and call talent.renderInline(). Don't we only care about the inline render now and we can ignore the other stuff like manual description enrichment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point - cleaned this up both here and in CrucibleActorDetailsItemSheet.

const data = CONFIG.ux.TextEditor.getDragEventData(event);
const talents = this.document.system.talents;
if ( (data.type !== "Item") || talents.has(data.uuid) ) return;
const hasLeveledTalents = this.document.type === "archetype";
Copy link
Contributor

Choose a reason for hiding this comment

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

For the very short term, can we leave a // TODO [issue number here] anywhere that we have to logically condition on whether we have leveled talents or not so we can identify all the places that we need to circle back to later?

Comment on lines 212 to 234
const grantingTalents = cls.grantingTalents[component];
if ( grantingTalents.some(({uuid}) => talents.has(uuid)) ) continue;
const minTalent = grantingTalents.reduce((currMin, t) => (currMin.tier < t.tier) ? currMin : t).uuid;
requisiteTalents.push(minTalent);
if ( grantingTalents.some(({uuid}) => talents.some(t => t.item === uuid)) ) continue;
const minTalent = grantingTalents.reduce((currMin, t) => (currMin.tier < t.tier) ? currMin : t);
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be a worthwhile helper method on the spellcraft component class, something like:

const reqTalent = await cls.getGrantingTalent(component);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added - I do think it probably makes sense to create some base spellcraft component class they all inherit from, but probably not in this PR.

let deleteItemIds = new Set();
for ( const uuid of (existing?.talents || []) ) {
const talentId = foundry.utils.parseUuid(uuid)?.documentId;
const talentId = foundry.utils.parseUuid(uuid.item ?? uuid)?.documentId;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's tag places where we have to do this with a // TODO [issue number here]

if ( source.details?.archetype ) crucible.api.models.CrucibleArchetypeItem.migrateData(source.details.archetype);
/** @deprecated since 0.7.3 */
if ( source.details?.taxonomy ) crucible.api.models.CrucibleArchetypeItem.migrateData(source.details.taxonomy);
if ( source.details?.taxonomy ) crucible.api.models.CrucibleTaxonomyItem.migrateData(source.details.taxonomy);
Copy link
Contributor

Choose a reason for hiding this comment

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

oops!

Comment on lines +23 to +26
talents: new fields.ArrayField(new fields.SchemaField({
item: new fields.DocumentUUIDField({type: "Item"}),
level: new fields.NumberField({required: true, nullable: true, integer: true, initial: null})
})),
Copy link
Contributor

Choose a reason for hiding this comment

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

We could consider using a TypedObjectField here where the keys are the talent UUIDs and the values are the required levels (or maybe better a schema field if we anticipate other potential metadata). This would have the side effect of avoiding duplicates in the array since the UUID keys would be unique.

Suggested change
talents: new fields.ArrayField(new fields.SchemaField({
item: new fields.DocumentUUIDField({type: "Item"}),
level: new fields.NumberField({required: true, nullable: true, integer: true, initial: null})
})),
talents: new fields.TypedObjectField(new fields.SchemaField({
level: new fields.NumberField({required: true, nullable: true, integer: true, initial: null})
}), {validateKey: itemUuidField.validate}),

@aaclayton aaclayton added the pr:pending Issues that are currently being worked on as part of a pull request. label Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:pending Issues that are currently being worked on as part of a pull request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants