diff --git a/module/helpers/index.mjs b/module/helpers/index.mjs index a05a4c6..a0e362b 100644 --- a/module/helpers/index.mjs +++ b/module/helpers/index.mjs @@ -5,10 +5,11 @@ import { objectValue } from "./objectValue.mjs"; import { toFriendlyDuration } from "./toFriendlyDuration.mjs"; export default { - "dotdungeon-schemaOptions": schemaOptions, - "dotdungeon-array": createArray, - "dotdungeon-toFriendlyDuration": toFriendlyDuration, - "dotdungeon-objectValue": objectValue, - "dotdungeon-stringify": v => JSON.stringify(v, null, ` `), - "dotdungeon-expanded": detailsExpanded, + "dd-schemaOptions": schemaOptions, + "dd-array": createArray, + "dd-toFriendlyDuration": toFriendlyDuration, + "dd-objectValue": objectValue, + "dd-expanded": detailsExpanded, + "dd-stringify": v => JSON.stringify(v, null, ` `), + "dd-negate": v => !v, }; \ No newline at end of file diff --git a/module/sheets/GenericActorSheet.mjs b/module/sheets/GenericActorSheet.mjs index ccaa195..3e75940 100644 --- a/module/sheets/GenericActorSheet.mjs +++ b/module/sheets/GenericActorSheet.mjs @@ -21,25 +21,42 @@ export class GenericActorSheet extends ActorSheet { ctx.meta = { expanded: this._expanded, + idp: this.actor.uuid, }; return ctx; }; activateListeners(html) { + super.activateListeners(html); + if (this.document.isEmbedded) return; if (!this.isEditable) return; console.debug(`.dungeon | Generic sheet adding listeners`); - html.find(`.roll`).on(`click`, this._handleRoll); - html.find(`summary`).on(`click`, this._handleSummaryToggle); + html.find(`summary`).on(`click`, this._handleSummaryToggle.bind(this)); + html.find(`.roll`).on(`click`, this._handleRoll.bind(this)); }; + async _handleRoll($e) { + let data = $e.target.dataset; + if (!data.roll) return; + console.debug(`.dungeon | Attempting to roll with formula "${data.roll}"`); + + game.i18n + + let roll = new Roll(data.roll); + await roll.evaluate(); + await roll.toMessage({ + speaker: ChatMessage.getSpeaker({ actor: this.actor }), + }); + }; _handleSummaryToggle($e) { let data = $e.target.dataset; let open = $e.target.parentNode.open; console.debug(`.dungeon | Collapse ID: ${data.collapseId} (open: ${open})`); + /* This seeming inversion of logic is due to the fact that this handler gets called before the element is updated to include/reflect the @@ -51,12 +68,5 @@ export class GenericActorSheet extends ActorSheet { } else { this._expanded.delete(data.collapseId); }; - } - - - _handleRoll($e) { - let data = $e.target.dataset; - if (!data.roll) return; - console.debug(`.dungeon | Attempting to roll ${data.roll}`); }; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/module/sheets/PlayerSheet.mjs b/module/sheets/PlayerSheet.mjs index bbeaba0..63e4d30 100644 --- a/module/sheets/PlayerSheet.mjs +++ b/module/sheets/PlayerSheet.mjs @@ -22,9 +22,6 @@ export class PlayerSheet extends GenericActorSheet { /* Toggles the expanded state for the detail elements in the sheet. */ - html.find(`summary`).on(`click`, ($e) => { - - }); }; #syncValue() { @@ -47,12 +44,12 @@ export class PlayerSheet extends GenericActorSheet { canChangeGroup: ctx.settings.playersCanChangeGroup || ctx.isGM, }; - ctx.meta.idp = this.actor.uuid; - console.groupCollapsed(`PlayerSheet.getData`); console.log(`ctx`, ctx); console.log(`actor`, actor); console.groupEnd(); return ctx; }; + + }; \ No newline at end of file diff --git a/module/sheets/SyncVariations/AbstractSyncSheet.mjs b/module/sheets/SyncVariations/AbstractSyncSheet.mjs index 15cfd8d..7837cfc 100644 --- a/module/sheets/SyncVariations/AbstractSyncSheet.mjs +++ b/module/sheets/SyncVariations/AbstractSyncSheet.mjs @@ -1,6 +1,6 @@ -import { GenericSheet } from "../GenericSheet.mjs"; +import { GenericActorSheet } from "../GenericActorSheet.mjs"; -export class AbstractSyncSheet extends GenericSheet { +export class AbstractSyncSheet extends GenericActorSheet { static get defaultOptions() { let opts = mergeObject( super.defaultOptions, diff --git a/templates/actors/char-sheet-mvp/panels/aspect.pc.hbs b/templates/actors/char-sheet-mvp/panels/aspect.pc.hbs index 2846c75..913a545 100644 --- a/templates/actors/char-sheet-mvp/panels/aspect.pc.hbs +++ b/templates/actors/char-sheet-mvp/panels/aspect.pc.hbs @@ -19,7 +19,7 @@ {{localize "dotdungeon.actor.pc.aspect.duration"}} {{#if system.aspect.deactivateAfter}} - ({{dotdungeon-toFriendlyDuration system.aspect.deactivateAfter}}) + ({{dd-toFriendlyDuration system.aspect.deactivateAfter}}) {{/if}} dotdungeon.panel class="weapons" title="dotdungeon.actor.pc.panel.weapons"}} -
+
{{localize "dotdungeon.actor.pc.weapon.mainHand"}} @@ -24,7 +24,7 @@ {{#select system.weapon.offHand.damage}} - {{#each (dotdungeon-array "slashing" "piercing" "smashing" "gun" "neon" "shadow" "solar")}} + {{#each (dd-array "slashing" "piercing" "smashing" "gun" "neon" "shadow" "solar")}} diff --git a/templates/actors/char-sheet-mvp/partials/dice_choice.hbs b/templates/actors/char-sheet-mvp/partials/dice_choice.hbs index 4c73c9c..af61d4b 100644 --- a/templates/actors/char-sheet-mvp/partials/dice_choice.hbs +++ b/templates/actors/char-sheet-mvp/partials/dice_choice.hbs @@ -1,7 +1,7 @@