Skip to content

Commit

Permalink
Roll defaults in NPC sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
Mezryss committed Jul 16, 2023
1 parent b91cc12 commit 029ea30
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 12 additions & 0 deletions module/actor/sheets/NPCSheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default class NPCSheet extends DnMActorSheet {
// Unbind listener from DnMActorSheet
html.find('[data-action=roll]').off('click');
html.find('[data-action=roll]').on('click', this.roll.bind(this));
html.find('[data-action=roll-default]').on('click', this.rollDefault.bind(this));

if (!this.isEditable) {
return;
Expand Down Expand Up @@ -78,4 +79,15 @@ export default class NPCSheet extends DnMActorSheet {
fixedFocus: this.system.skill.value,
});
}

/**
* Event Handler; Called when the user clicks to roll for the NPC's default attribute & skill.
*/
rollDefault() {
DicePrompt.promptForRoll({
actor: this.actor,
fixedTargetNumber: this.system.attribute.default,
fixedFocus: this.system.skill.default,
});
}
}
10 changes: 8 additions & 2 deletions templates/actor/npc-sheet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
</label>

<label class="flex flex-col">
<span class="text-center text-purple-800 font-semibold uppercase border-0 border-t-1 border-purple-600 border-solid">{{ localize "Labels.Default" }}</span>
<span class="text-center text-purple-800 font-semibold uppercase border-0 border-t-1 border-purple-600 border-solid">
<a data-action="roll-default"><i class="fas fa-dice-d20"></i></a>
<span>{{ localize "Labels.Default" }}</span>
</span>
{{#if editable}}
<input type="number" min="0" name="system.attribute.default" value="{{ system.attribute.default }}" class="!bg-none !rounded-none !border-0 !text-center !text-3xl !font-semibold !h-[unset]" />
{{else}}
Expand All @@ -54,7 +57,10 @@
</label>

<label class="flex flex-col">
<span class="text-center text-purple-800 font-semibold uppercase border-0 border-t-1 border-l-2 border-purple-600 border-solid">{{ localize "Labels.Default" }}</span>
<span class="text-center text-purple-800 font-semibold uppercase border-0 border-t-1 border-l-2 border-purple-600 border-solid">
<a data-action="roll-default"><i class="fas fa-dice-d20"></i></a>
<span>{{ localize "Labels.Default" }}</span>
</span>
{{#if editable}}
<input type="number" min="0" name="system.skill.default" value="{{ system.skill.default }}" class="!bg-none !rounded-none !border-0 !text-center !text-3xl !font-semibold !h-[unset] !border-l-2 !border-purple-600" />
{{else}}
Expand Down

0 comments on commit 029ea30

Please sign in to comment.