Added Actions and effects

This commit is contained in:
WBHarry 2025-06-15 02:50:29 +02:00
parent 6adbb4e49b
commit 4a596179d8
11 changed files with 182 additions and 58 deletions

View file

@ -55,6 +55,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
static defineSchema() {
return {
_id: new fields.DocumentIdField(),
systemPath: new fields.StringField({ required: true, initial: 'actions' }),
type: new fields.StringField({ initial: undefined, readonly: true, required: true }),
name: new fields.StringField({ initial: undefined }),
img: new fields.FilePathField({ initial: undefined, categories: ['IMAGE'], base64: false }),
@ -93,7 +94,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
prepareData() {}
get index() {
return this.parent.actions.indexOf(this);
return foundry.utils.getProperty(this.parent, this.systemPath).indexOf(this);
}
get item() {
@ -202,7 +203,7 @@ export class DHAttackAction extends DHBaseAction {
static getRollType() {
return 'weapon';
}
get chatTitle() {
return game.i18n.format('DAGGERHEART.Chat.AttackRoll.Title', {
attack: this.item.name

View file

@ -1,6 +1,15 @@
import ActionField from '../fields/actionField.mjs';
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
import BaseDataItem from './base.mjs';
const featureSchema = () => {
return new foundry.data.fields.SchemaField({
name: new foundry.data.fields.StringField({ required: true }),
effects: new foundry.data.fields.ArrayField(new ForeignDocumentUUIDField({ type: 'ActiveEffect' })),
actions: new foundry.data.fields.ArrayField(new ActionField())
});
};
export default class DHSubclass extends BaseDataItem {
/** @inheritDoc */
static get metadata() {
@ -22,9 +31,9 @@ export default class DHSubclass extends BaseDataItem {
nullable: true,
initial: null
}),
foundationFeature: new ForeignDocumentUUIDField({ type: 'Item' }),
specializationFeature: new ForeignDocumentUUIDField({ type: 'Item' }),
masteryFeature: new ForeignDocumentUUIDField({ type: 'Item' }),
foundationFeature: featureSchema(),
specializationFeature: featureSchema(),
masteryFeature: featureSchema(),
featureState: new fields.NumberField({ required: true, initial: 1, min: 1 }),
isMulticlass: new fields.BooleanField({ initial: false })
};