Feature/253 weapon attack action (#290)

* Step #1

* Add Attack to Weapon & Override settings to Roll
This commit is contained in:
Dapoulp 2025-07-07 20:50:48 +02:00 committed by GitHub
parent 52be430eff
commit 7d7fb88035
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 168 additions and 91 deletions

View file

@ -42,6 +42,10 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
return this.parent.actor;
}
get actionsList() {
return this.actions;
}
/**
* Obtain a data object used to evaluate any dice rolls associated with this Item Type
* @param {object} [options] - Options which modify the getRollData method.

View file

@ -11,7 +11,7 @@ export default class DHWeapon extends BaseDataItem {
hasDescription: true,
isQuantifiable: true,
isInventoryItem: true,
hasInitialAction: true
// hasInitialAction: true
});
}
@ -25,19 +25,8 @@ export default class DHWeapon extends BaseDataItem {
//SETTINGS
secondary: new fields.BooleanField({ initial: false }),
trait: new fields.StringField({ required: true, choices: CONFIG.DH.ACTOR.abilities, initial: 'agility' }),
range: new fields.StringField({ required: true, choices: CONFIG.DH.GENERAL.range, initial: 'melee' }),
burden: new fields.StringField({ required: true, choices: CONFIG.DH.GENERAL.burden, initial: 'oneHanded' }),
//DAMAGE
damage: new fields.SchemaField({
dice: new fields.StringField({ choices: CONFIG.DH.GENERAL.diceTypes, initial: 'd6' }),
bonus: new fields.NumberField({ nullable: true, initial: null }),
type: new fields.StringField({
required: true,
choices: CONFIG.DH.GENERAL.damageTypes,
initial: 'physical'
})
}),
features: new fields.ArrayField(
new fields.SchemaField({
value: new fields.StringField({
@ -49,10 +38,42 @@ export default class DHWeapon extends BaseDataItem {
actionIds: new fields.ArrayField(new fields.StringField({ required: true }))
})
),
attack: new ActionField({
initial: {
name: 'Attack',
img: 'icons/skills/melee/blood-slash-foam-red.webp',
_id: foundry.utils.randomID(),
systemPath: 'attack',
type: 'attack',
range: 'melee',
target: {
type: 'any',
amount: 1
},
roll: {
trait: 'agility',
type: 'weapon'
},
damage: {
parts: [
{
value: {
multiplier: 'prof',
dice: "d8"
}
}
]
}
}
}),
actions: new fields.ArrayField(new ActionField())
};
}
get actionsList() {
return [this.attack, ...this.actions];
}
async _preUpdate(changes, options, user) {
const allowed = await super._preUpdate(changes, options, user);
if (allowed === false) return false;