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
|
|
@ -66,7 +66,7 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
|||
context.hasBaseDamage = !!this.action.parent.damage;
|
||||
context.getRealIndex = this.getRealIndex.bind(this);
|
||||
context.disableOption = this.disableOption.bind(this);
|
||||
context.isNPC = this.action.actor.type !== 'character';
|
||||
context.isNPC = this.action.actor && this.action.actor.type !== 'character';
|
||||
return context;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,13 +90,11 @@ export default function DHItemMixin(Base) {
|
|||
}
|
||||
|
||||
static async addAction() {
|
||||
const actionType = await DHItemSheetV2.selectActionType(),
|
||||
actionIndexes = this.document.system.actions.map(x => x._id.split('-')[2]).sort((a, b) => a - b);
|
||||
const actionType = await DHItemSheetV2.selectActionType();
|
||||
try {
|
||||
const cls = actionsTypes[actionType?.type] ?? actionsTypes.attack,
|
||||
action = new cls(
|
||||
{
|
||||
// id: `${this.document.id}-Action-${actionIndexes.length > 0 ? actionIndexes[0] + 1 : 1}`
|
||||
_id: foundry.utils.randomID(),
|
||||
type: actionType.type,
|
||||
name: game.i18n.localize(SYSTEM.ACTIONS.actionTypes[actionType.type].name),
|
||||
|
|
@ -107,9 +105,7 @@ export default function DHItemMixin(Base) {
|
|||
}
|
||||
);
|
||||
await this.document.update({ 'system.actions': [...this.document.system.actions, action] });
|
||||
await new DHActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render(
|
||||
true
|
||||
);
|
||||
await new DHActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render(true);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue