- Add getTotalSlots() method to base-item.mjs as unified interface - Add slotsWhenEquipped field to weapon, armor, and equipment schemas - Implement getTotalSlots() in each item type respecting equipped state - Update actor slot calculation to use getTotalSlots() uniformly - Add _onUpdate hook to sync equipment effects with equipped state - Update backpack with slotsWhenEquipped: 0 and +2 slot bonus effect Backpack now correctly: - Costs 1 slot when unequipped, 0 when equipped - Grants +2 max item slots via Active Effect when equipped 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
79 lines
1.9 KiB
JavaScript
79 lines
1.9 KiB
JavaScript
/**
|
|
* Base Item Data Model
|
|
*
|
|
* Provides shared data fields and methods for all item types in Vagabond RPG.
|
|
* This is an abstract base class - use specific item data models for actual items.
|
|
*
|
|
* @extends foundry.abstract.TypeDataModel
|
|
*/
|
|
export default class VagabondItemBase extends foundry.abstract.TypeDataModel {
|
|
/**
|
|
* Define the base schema shared by all items.
|
|
* Subclasses should call super.defineSchema() and extend the result.
|
|
*
|
|
* @returns {Object} The schema definition
|
|
*/
|
|
static defineSchema() {
|
|
const fields = foundry.data.fields;
|
|
return {
|
|
// Rich text description
|
|
description: new fields.HTMLField({ required: false, blank: true }),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Prepare base data for the item.
|
|
* Called before derived data calculation.
|
|
*/
|
|
prepareBaseData() {
|
|
// Base preparation - subclasses can override
|
|
}
|
|
|
|
/**
|
|
* Prepare derived data for the item.
|
|
* Called after base data and before render.
|
|
*/
|
|
prepareDerivedData() {
|
|
// Derived data calculation - subclasses should override
|
|
}
|
|
|
|
/**
|
|
* Get the roll data for this item for use in Roll formulas.
|
|
*
|
|
* @returns {Object} Roll data object with item's values
|
|
*/
|
|
getRollData() {
|
|
const data = { ...this };
|
|
|
|
// Include parent actor's roll data if available
|
|
if (this.parent?.actor) {
|
|
data.actor = this.parent.actor.getRollData();
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
/**
|
|
* Get a chat card data object for this item.
|
|
* Override in subclasses for type-specific chat output.
|
|
*
|
|
* @returns {Object} Chat card data
|
|
*/
|
|
getChatData() {
|
|
return {
|
|
description: this.description,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Calculate the total inventory slot cost for this item.
|
|
* Override in subclasses that have inventory slots (weapons, armor, equipment).
|
|
* Items without inventory presence (features, classes, ancestries) return 0.
|
|
*
|
|
* @returns {number} Total slots used
|
|
*/
|
|
getTotalSlots() {
|
|
return 0;
|
|
}
|
|
}
|