mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
* Initial * Added Character-Settings * Finalized Character-Settings * Hide CharacterSetup if any part is done manually * Fixed class/subclass drag-drop * Fixed relinking of Features from items created on Character * Adding features on CharacterItems now adds them on the Character and relinks * Made suggested items inactive in the Class sheet if rendered from inside a Character * Added hope to CharacterSetting * add style to textarea element, add spellcasting and domain class into char sheet and move rest buttons to another place * Fixed characterCreation experience description --------- Co-authored-by: moliloo <dev.murilobrito@gmail.com>
48 lines
1.7 KiB
JavaScript
48 lines
1.7 KiB
JavaScript
import BaseDataItem from './base.mjs';
|
|
import { ActionField, ActionsField } from '../fields/actionField.mjs';
|
|
|
|
export default class DHFeature extends BaseDataItem {
|
|
/** @inheritDoc */
|
|
static get metadata() {
|
|
return foundry.utils.mergeObject(super.metadata, {
|
|
label: 'TYPES.Item.feature',
|
|
type: 'feature',
|
|
hasDescription: true,
|
|
hasResource: true,
|
|
hasActions: true
|
|
});
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
static defineSchema() {
|
|
const fields = foundry.data.fields;
|
|
return {
|
|
...super.defineSchema(),
|
|
originItemType: new fields.StringField({
|
|
choices: CONFIG.DH.ITEM.featureTypes,
|
|
nullable: true,
|
|
initial: null
|
|
}),
|
|
originId: new fields.StringField({ nullable: true, initial: null }),
|
|
identifier: new fields.StringField()
|
|
};
|
|
}
|
|
|
|
get spellcastingModifier() {
|
|
let traitValue = 0;
|
|
if (this.actor && this.originId && ['class', 'subclass'].includes(this.originItemType)) {
|
|
if (this.originItemType === 'subclass') {
|
|
traitValue =
|
|
this.actor.system.traits[this.actor.items.get(this.originId).system.spellcastingTrait]?.value ?? 0;
|
|
} else {
|
|
const subclass =
|
|
this.actor.system.multiclass.value?.id === this.originId
|
|
? this.actor.system.multiclass.subclass
|
|
: this.actor.system.class.subclass;
|
|
traitValue = this.actor.system.traits[subclass.system.spellcastingTrait]?.value ?? 0;
|
|
}
|
|
}
|
|
|
|
return traitValue;
|
|
}
|
|
}
|