mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
[Feature] Reload Check (#2051)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
This commit is contained in:
parent
8d68166e4c
commit
26bcc2dddc
22 changed files with 223 additions and 14 deletions
|
|
@ -52,6 +52,10 @@ export default class DHAttackAction extends DHDamageAction {
|
|||
}
|
||||
|
||||
async use(event, options) {
|
||||
if (this.item?.system.needsReload) {
|
||||
return ui.notifications.error(_loc('DAGGERHEART.UI.Notifications.reloadRequired', { weapon: this.item.name }));
|
||||
}
|
||||
|
||||
const result = await super.use(event, options);
|
||||
|
||||
if (result?.message?.system.action?.roll?.type === 'attack') {
|
||||
|
|
@ -62,6 +66,23 @@ export default class DHAttackAction extends DHDamageAction {
|
|||
return result;
|
||||
}
|
||||
|
||||
async handleReload(options = { awaitRoll: false }) {
|
||||
const roll = await new Roll('1d6').evaluate();
|
||||
if (game.modules.get('dice-so-nice')?.active) {
|
||||
if (options.awaitRoll)
|
||||
await game.dice3d.showForRoll(roll, game.user, true);
|
||||
else
|
||||
game.dice3d.showForRoll(roll, game.user, true);
|
||||
}
|
||||
|
||||
const needsToReload = roll.total === 1;
|
||||
if (needsToReload) {
|
||||
this.item.update({ 'system.resource.value': 0 });
|
||||
}
|
||||
|
||||
return needsToReload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a localized label array for this item subtype.
|
||||
* @returns {(string | { value: string, icons: string[] })[]} An array of localized strings and damage label objects.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue