Fix issue #89: Traits and items are mixed up
All checks were successful
Test / test (push) Successful in 2s

This commit is contained in:
Gitea OpenCode Agent
2026-10-15 21:36:44 +00:00
parent 98aa3be078
commit f8dae95563
7 changed files with 586 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
const { numberOr, asText, plainText, stringList } = require('./foundry-fields');
const { isFoundryGearType } = require('./item-foundry');
// D&D 5e keeps an actor's background, species, class and subclass as a reference to an
// embedded item: `system.details.background` and friends hold that item's id, and the
@@ -169,8 +170,11 @@ function foundryActorToCharacter(foundryActor) {
armorClass: numberOr(attributes.ac?.value ?? attributes.ac, 10),
speed: numberOr(movement.walk ?? movement.value, 30),
proficiencies: foundryProficiencies || asText(savedDragonrollFields.proficiencies),
// What the character carries: gear, and gear only (Syndria98/dragonroll#89). A feat
// is a trait — its tab shows it — and a race is the species; standing them in the
// inventory next to the longswords is how traits and items got mixed up.
inventory: items
.filter((item) => !['class', 'subclass', 'background', 'spell'].includes(item.type))
.filter((item) => isFoundryGearType(item.type))
.map((item) => ({
name: asText(item.name).trim(),
quantity: numberOr(item.system?.quantity, 1),