mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 19:51:08 +01:00
Auto add Attack action to newly created weapon
This commit is contained in:
parent
22075e7490
commit
1bd2bbd02d
3 changed files with 21 additions and 7 deletions
|
|
@ -51,6 +51,24 @@ export default class DHWeapon extends BaseDataItem {
|
|||
};
|
||||
}
|
||||
|
||||
async _preCreate(data, options, user) {
|
||||
const actionType = 'attack',
|
||||
cls = actionsTypes.attack,
|
||||
action = new cls(
|
||||
{
|
||||
_id: foundry.utils.randomID(),
|
||||
type: actionType,
|
||||
name: game.i18n.localize(SYSTEM.ACTIONS.actionTypes[actionType].name),
|
||||
...cls.getSourceConfig(this.parent)
|
||||
},
|
||||
{
|
||||
parent: this.parent
|
||||
}
|
||||
);
|
||||
this.updateSource({actions: [action]});
|
||||
return super._preCreate(data, options, user);
|
||||
}
|
||||
|
||||
async _preUpdate(changes, options, user) {
|
||||
const allowed = await super._preUpdate(changes, options, user);
|
||||
if (allowed === false) return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue