vagabond-rpg-foundryvtt/module/data/item/ancestry.mjs
Cal Corum 06e0dc01c0 Complete P2-P5: Perks, Feature Choices, Ancestry Traits, Caster Progression
- P2: Perks with changes[] arrays create Active Effects on drop/delete
- P3: Feature choice UI for Fighting Style (auto-grants Situational
  Awareness + selected training perk, ignoring prerequisites)
- P4: Ancestry traits apply Active Effects (Dwarf Darksight/Tough working)
- P5: Caster progression accumulates mana from class progression table

Key patterns:
- Manual UUID construction: Compendium.${pack.collection}.Item.${entry._id}
- ignorePrereqs flag for specific choices bypassing all prerequisites
- Mode 5 (OVERRIDE) for boolean senses like darkvision
- Form data merging with direct DOM reading for reliable selection capture

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 14:23:44 -06:00

76 lines
1.9 KiB
JavaScript

/**
* Ancestry Item Data Model
*
* Defines the data schema for character ancestries (races) in Vagabond RPG.
* Examples: Human, Dwarf, Elf, Halfling, Draken, Goblin, Orc
*
* Ancestries provide:
* - Being type classification
* - Size category
* - Racial traits (abilities/features)
*
* @extends VagabondItemBase
*/
import VagabondItemBase from "./base-item.mjs";
export default class AncestryData extends VagabondItemBase {
/**
* Define the schema for ancestry items.
*
* @returns {Object} The schema definition
*/
static defineSchema() {
const fields = foundry.data.fields;
const baseSchema = super.defineSchema();
return {
...baseSchema,
// Being type (Humanlike, Fae, Cryptid, etc.)
beingType: new fields.StringField({
required: true,
initial: "humanlike",
}),
// Size category
size: new fields.StringField({
required: true,
initial: "medium",
}),
// Racial traits - abilities granted by this ancestry
traits: new fields.ArrayField(
new fields.SchemaField({
name: new fields.StringField({ required: true }),
description: new fields.HTMLField({ required: true }),
// Mechanical effects as Active Effect changes
changes: new fields.ArrayField(
new fields.SchemaField({
key: new fields.StringField({ required: true }),
mode: new fields.NumberField({ integer: true, initial: 2 }),
value: new fields.StringField({ required: true }),
}),
{ initial: [] }
),
}),
{ initial: [] }
),
};
}
/**
* Get chat card data for displaying ancestry information.
*
* @returns {Object} Chat card data
*/
getChatData() {
const data = super.getChatData();
data.beingType = this.beingType;
data.size = this.size;
data.traits = this.traits;
return data;
}
}