add rollable action to sheet

This commit is contained in:
jalensailin
2025-07-18 22:48:02 -04:00
parent cca2438b1d
commit 189394a460
6 changed files with 89 additions and 51 deletions
+4 -10
View File
@@ -17,6 +17,7 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
position: { width: 750, height: 770 },
actions: {
itemAction: DeltaGreenActorSheet._onItemAction,
roll: DeltaGreenActorSheet._onRoll,
},
});
@@ -589,7 +590,6 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
if (!this.options.editable) return;
// Rollable abilities - bind to everything with the 'Rollable' class
html.find(".rollable").click(this._onRoll.bind(this));
html.find(".rollable").contextmenu(this._onRoll.bind(this)); // this is for right-click, which triggers the roll modifier dialogue for most rolls
html.find(".toggle-untrained").click(() =>
@@ -1269,16 +1269,10 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
* @async
* @private
*/
async _onRoll(event) {
event.preventDefault();
const element = event.currentTarget;
const { dataset } = element;
if (event && event.which === 2) {
// probably don't want rolls to trigger from a middle mouse click so just kill it here
return;
}
static async _onRoll(event, target) {
if (target.classList.contains("not-rollable") || event.which === 3) return;
const { dataset } = target;
const item = this.actor.items.get(dataset.iid);
const rollOptions = {
rollType: dataset.rolltype,
@@ -4,6 +4,7 @@
<div>
<div class="physical-stats-outer-grid-3col">
<label class="rollable resource-label"
data-action="roll"
data-rolltype="stat"
data-key="{{key}}"
data-tooltip="{{localize (concat 'DG.Attributes.Tooltip.' key)}}"
@@ -16,6 +17,7 @@
value="{{statistic.value}}"
data-dtype="Number" />
<span class="rollable"
data-action="roll"
data-rolltype="stat"
data-key="{{key}}"
title="{{localize 'DG.Tooltip.x5AttributeLabel'}}">({{numberFormat statistic.x5 decimals=0 sign=false}}% <i class="fas fa-dice"></i>)</span>
@@ -1,68 +1,95 @@
<div class="item-controls skill-util-buttons">
<a class="item-control typed-skill-add action-pill"><i class="fas fa-plus"></i>{{localize 'DG.Skills.AddTypedOrCustomSkill'}}</a>
<a class="item-control special-training-action action-pill" data-action="Create"><i class="fas fa-plus"></i>{{localize 'DG.SpecialTraining.Dialog.CreateSpecialTraining'}}</a>
{{#if_eq actorType "agent"}}
<a class="item-control special-training-action action-pill"
data-action="Create"><i class="fas fa-plus"></i>{{localize 'DG.SpecialTraining.Dialog.CreateSpecialTraining'}}</a>
{{#if_eq actorType "agent" }}
<a class="item-control apply-skill-improvements action-pill">{{localize 'DG.Skills.ApplySkillImprovements'}}<i class="fas fa-dice"></i></a>
{{/if_eq}}
</div>
<div class="grid-2col">
{{#each actor.system.sortedCustomSkills as |skill|}}
{{#if_eq type "typeSkill"}}
{{#each actor.system.sortedCustomSkills as |skill| }}
{{#if_eq type "typeSkill" }}
<div class="item flexrow flex-group-left flex-thin-border">
<div class="flexrow">
<label data-tooltip="{{localize (concat 'DG.TypeSkills.Tooltip.' skill.group)}}">
{{localize (concat 'DG.TypeSkills.' skill.group)}} ({{skill.label}})
</label>
<label class="{{if_gt skill.proficiency 0 'rollable' 'not-rollable'}} skill-label" data-key="{{skill.key}}" data-rolltype="skill" data-roll="d100" data-target="{{skill.proficiency}}" data-label="{{skill.label}}"
{{#if skill.proficiency}}data-tooltip="{{localize 'DG.Tooltip.SkillLabel'}}"{{/if}}
{{#unless skill.proficiency}}data-tooltip="{{localize 'DG.Tooltip.CannotRollSkillLabel'}}"{{/unless}}
>
<label class="{{if_gt skill.proficiency 0 'rollable' 'not-rollable'}} skill-label"
data-action="roll"
data-key="{{skill.key}}"
data-rolltype="skill"
data-roll="d100"
data-target="{{skill.proficiency}}"
data-label="{{skill.label}}"
{{#if skill.proficiency }}
data-tooltip="{{localize 'DG.Tooltip.SkillLabel' }}"
{{/if }}
{{#unless skill.proficiency }}
data-tooltip="{{localize 'DG.Tooltip.CannotRollSkillLabel' }}"
{{/unless}}>
<i class="fas fa-dice"></i>
</label>
<input class="percentile-skill-input" type="text" name="system.typedSkills.{{skill.key}}.proficiency" value="{{skill.proficiency}}" data-dtype="Number"/>
{{#if_eq skill.actorType "agent"}}
<input class="checkbox-skill-input" type="checkbox" name="system.typedSkills.{{skill.key}}.failure" {{checked skill.failure}} data-dtype="Boolean" {{#if skill.cannotBeImprovedByFailure}} disabled {{/if}} />
<input class="percentile-skill-input"
type="text"
name="system.typedSkills.{{skill.key}}.proficiency"
value="{{skill.proficiency}}"
data-dtype="Number" />
{{#if_eq skill.actorType "agent" }}
<input class="checkbox-skill-input"
type="checkbox"
name="system.typedSkills.{{skill.key}}.failure"
{{checked skill.failure}}
data-dtype="Boolean"
{{#if skill.cannotBeImprovedByFailure }}
disabled
{{/if }} />
{{/if_eq}}
</div>
<div class="item-controls skill-and-training-controls">
<a class="item-control typed-skill-edit" title="Edit Skill"><i class="fas fa-edit" data-typedskill="{{skill.key}}" ></i></a>
<a class="item-control typed-skill-delete" title="Delete Skill"><i class="fas fa-trash" data-typedskill="{{skill.key}}" ></i></a>
<a class="item-control typed-skill-edit" title="Edit Skill"><i class="fas fa-edit" data-typedskill="{{skill.key}}"></i></a>
<a class="item-control typed-skill-delete" title="Delete Skill"><i class="fas fa-trash" data-typedskill="{{skill.key}}"></i></a>
</div>
</div>
{{/if_eq}}
{{#if_eq type "training"}}
{{#if_eq type "training" }}
<div class="item flexrow flex-group-left flex-thin-border special-training-box">
<div class="flexrow">
{{#if_not_eq (localize (concat 'DG.Attributes.' skill.key)) (concat "DG.Attributes." skill.key)}}
<label data-tooltip="{{localize (concat 'DG.Attributes.Tooltip.' skill.key)}}">
{{skill.name}} ({{localize (concat 'DG.Attributes.' skill.key)}}, {{skill.targetNumber}}%)
</label>
{{else}}
{{#if_not_eq (localize (concat 'DG.Skills.' skill.key)) (concat "DG.Skills." skill.key)}}
<label data-tooltip="{{localize (concat 'DG.Skills.Tooltip.' skill.key)}}">
{{skill.name}} ({{localize (concat 'DG.Skills.' skill.key)}}, {{skill.targetNumber}}%)
<div class="item flexrow flex-group-left flex-thin-border special-training-box">
<div class="flexrow">
{{#if_not_eq (localize (concat 'DG.Attributes.' skill.key)) (concat "DG.Attributes." skill.key) }}
<label data-tooltip="{{localize (concat 'DG.Attributes.Tooltip.' skill.key)}}">
{{skill.name}} ({{localize (concat 'DG.Attributes.' skill.key)}}, {{skill.targetNumber}}%)
</label>
{{else}}
<label>
{{skill.name}} ({{skill.attribute}}, {{skill.targetNumber}}%)
</label>
{{#if_not_eq (localize (concat 'DG.Skills.' skill.key)) (concat "DG.Skills." skill.key) }}
<label data-tooltip="{{localize (concat 'DG.Skills.Tooltip.' skill.key)}}">
{{skill.name}} ({{localize (concat 'DG.Skills.' skill.key)}}, {{skill.targetNumber}}%)
</label>
{{else}}
<label>{{skill.name}} ({{skill.attribute}}, {{skill.targetNumber}}%)</label>
{{/if_not_eq}}
{{/if_not_eq}}
{{/if_not_eq}}
<label class="{{if_gt skill.targetNumber 0 'rollable' 'not-rollable'}}" data-key="{{skill.key}}" data-name="{{skill.name}}" data-rolltype="special-training">
<i class="fas fa-dice"></i>
</label>
<div class="item-controls skill-and-training-controls">
<a class="item-control special-training-action" data-action="Edit" data-id="{{skill.id}}" title="Edit Training"><i class="fas fa-edit"></i></a>
<a class="item-control special-training-delete" title="Delete Training" data-id="{{skill.id}}" ><i class="fas fa-trash"></i></a>
<label class="{{if_gt skill.targetNumber 0 'rollable' 'not-rollable'}}"
data-action="roll"
data-key="{{skill.key}}"
data-name="{{skill.name}}"
data-rolltype="special-training">
<i class="fas fa-dice"></i>
</label>
<div class="item-controls skill-and-training-controls">
<a class="item-control special-training-action"
data-action="Edit"
data-id="{{skill.id}}"
title="Edit Training"><i class="fas fa-edit"></i></a>
<a class="item-control special-training-delete"
title="Delete Training"
data-id="{{skill.id}}"><i class="fas fa-trash"></i></a>
</div>
</div>
</div>
</div>
{{/if_eq}}
+18 -5
View File
@@ -46,6 +46,7 @@
<span>
<h4 style="word-wrap: break-word; display: inline;" class="item-name">{{item.name}}</h4>
<span class="rollable"
data-action="roll"
data-iid="{{item._id}}"
data-rolltype="weapon"
data-key="{{item.system.skill}}"
@@ -73,7 +74,10 @@
{{/if}}
{{#unless item.system.isLethal}}
<span class="rollable" data-rolltype="damage" data-iid="{{item._id}}">
<span class="rollable"
data-action="roll"
data-rolltype="damage"
data-iid="{{item._id}}">
{{toUpperCase item.system.damage}}
{{#if_eq item.system.skill 'unarmed_combat' }}
{{actor.system.statistics.str.meleeDamageBonusFormula}}
@@ -87,6 +91,7 @@
{{#if item.system.isLethal }}
<span class="rollable"
data-action="roll"
data-rolltype="lethality"
data-iid="{{item._id}}"
title="{{localize 'DG.ItemWindow.Weapons.LethalityTooltip'}}">
@@ -347,10 +352,18 @@
<div>
<div class="horizontal-bar-section-divider">
<span>{{localize 'DG.Gear.Rituals'}} <a class="rollable"
data-key="ritual"
data-rolltype="skill"
title="Ritual activation"><i class="fa-solid fa-dice" data-gear-type="ritual"></i></a></span>
<span>
{{localize 'DG.Gear.Rituals'}}
<a class="rollable"
data-action="roll"
data-key="ritual"
data-rolltype="skill"
title="Ritual activation">
<i class="fa-solid fa-dice" data-gear-type="ritual">
</i>
</a>
</span>
</div>
<ol class="items-list">
+1
View File
@@ -72,6 +72,7 @@
<div class="resource-outer-grid-1col">
<label for="system.san.value"
class="resource-label rollable"
data-action="roll"
data-rolltype="sanity"
data-tooltip="{{localize 'DG.Attributes.Tooltip.SAN'}}">
{{localize 'DG.Attributes.SAN' }} <i class="fas fa-dice"></i>
+1
View File
@@ -8,6 +8,7 @@
{{#each actor.system.sortedSkills as |skill key| }}
<div class="flexrow flex-group-left flex-thin-border">
<label class="{{if_gt skill.targetProficiency 0 'rollable' 'not-rollable'}} skill-label"
data-action="roll"
data-key="{{skill.key}}"
data-rolltype="skill"
for="system.skills.{{skill.key}}.value"