mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
Added support for reload rules
This commit is contained in:
parent
70388dbd73
commit
3817469e35
11 changed files with 99 additions and 3 deletions
|
|
@ -61,6 +61,24 @@ 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) {
|
||||
// TODO: Update item resource value when the functionality has been added to the system
|
||||
// this.item.update({ 'system.resource.value': 0 });
|
||||
}
|
||||
return true;
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
|
|||
hasEffect: new fields.BooleanField({ initial: false }),
|
||||
hasSave: new fields.BooleanField({ initial: false }),
|
||||
hasTarget: new fields.BooleanField({ initial: false }),
|
||||
needReload: new fields.BooleanField({ initial: false }),
|
||||
isDirect: new fields.BooleanField({ initial: false }),
|
||||
onSave: new fields.StringField(),
|
||||
source: new fields.SchemaField({
|
||||
|
|
|
|||
|
|
@ -117,6 +117,10 @@ export default class DHWeapon extends AttachableItem {
|
|||
return this.weaponFeatures;
|
||||
}
|
||||
|
||||
get hasReload() {
|
||||
return Boolean(this.weaponFeatures.find(x => x.value === 'reloading'));
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async getDescriptionData() {
|
||||
const baseDescription = this.description;
|
||||
|
|
|
|||
|
|
@ -196,6 +196,13 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
|||
})
|
||||
})
|
||||
}),
|
||||
reload: new fields.StringField({
|
||||
required: true,
|
||||
choices: CONFIG.DH.SETTINGS.reloadChoices,
|
||||
initial: CONFIG.DH.SETTINGS.reloadChoices.button.id,
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.reload.label',
|
||||
hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.reload.hint'
|
||||
}),
|
||||
autoExpireActiveEffects: new fields.BooleanField({
|
||||
required: true,
|
||||
initial: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue