diff --git a/lang/en.json b/lang/en.json index b28a3c93..c9160405 100755 --- a/lang/en.json +++ b/lang/en.json @@ -614,6 +614,10 @@ "title": "{name} Resource", "rerollDice": "Reroll Dice" }, + "RiskItAllDialog": { + "title": "Risk It All - Clear Stress and Hope", + "submit": "Submit" + }, "TagTeamSelect": { "title": "Tag Team Roll", "leaderTitle": "Initiating Character", diff --git a/module/applications/dialogs/deathMove.mjs b/module/applications/dialogs/deathMove.mjs index 0996fc27..ea7a18eb 100644 --- a/module/applications/dialogs/deathMove.mjs +++ b/module/applications/dialogs/deathMove.mjs @@ -9,7 +9,8 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV this.actor = actor; this.selectedMove = null; this.showRiskItAllButton = false; - this.riskItAllButtonLabel = "" + this.riskItAllButtonLabel = ""; + this.riskItAllHope = 0; } get title() { @@ -109,6 +110,7 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV } else { chatMessage = game.i18n.format('DAGGERHEART.UI.Chat.deathMove.riskItAllSuccess', { hope: config.roll.hope.value }) this.showRiskItAllButton = true; + this.riskItAllHope = config.roll.hope.value; this.riskItAllButtonLabel = game.i18n.format('DAGGERHEART.UI.Chat.deathMove.riskItAllClearStressAndHitPoints', { hope: config.roll.hope.value }) } } @@ -185,7 +187,8 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV open: autoExpandDescription ? 'open' : '', chevron: autoExpandDescription ? 'fa-chevron-up' : 'fa-chevron-down', showRiskItAllButton: this.showRiskItAllButton, - riskItAllButtonLabel: this.riskItAllButtonLabel + riskItAllButtonLabel: this.riskItAllButtonLabel, + riskItAllHope: this.riskItAllHope } ), title: game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.title'), diff --git a/module/applications/dialogs/riskItAllDialog.mjs b/module/applications/dialogs/riskItAllDialog.mjs new file mode 100644 index 00000000..5a114d3a --- /dev/null +++ b/module/applications/dialogs/riskItAllDialog.mjs @@ -0,0 +1,42 @@ +const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api; +export default class RiskItAllDialog extends HandlebarsApplicationMixin(ApplicationV2) { + constructor(actor, config) { + super({}); + + this.actor = actor; + this.validChoices = null; + this.config = config; + } + + get title() { + return game.i18n.format('DAGGERHEART.APPLICATIONS.RiskItAllDialog.title', { actor: this.actor.name }); + } + + static DEFAULT_OPTIONS = { + classes: ['daggerheart', 'dh-style', 'dialog', 'views', 'risk-it-all'], + position: { width: 'auto', height: 'auto' }, + window: { icon: 'fa-solid fa-skull' }, + actions: { + submit: this.submit + } + }; + + static PARTS = { + application: { + id: 'risk-it-all', + template: 'systems/daggerheart/templates/dialogs/riskItAllDialog.hbs' + } + }; + + async _prepareContext(_options) { + const context = await super._prepareContext(_options); + context.RiskItAllDialog = this.RiskItAllDialog; + context.title = game.i18n.localize('DAGGERHEART.APPLICATIONS.RiskItAllDialog.submit'); + + return context; + } + + static async submit() { + this.close(); + } +} diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index d3e30dab..febb6155 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -1,5 +1,6 @@ import { abilities } from '../../config/actorConfig.mjs'; import { emitAsGM, GMUpdateEvent, RefreshType, socketEvent } from '../../systemRegistration/socket.mjs'; +import RiskItAllDialog from '../dialogs/riskItAllDialog.mjs'; export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLog { constructor(options) { @@ -82,7 +83,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo element.addEventListener('click', this.groupRollExpandSection) ); html.querySelectorAll('.risk-it-all-button').forEach(element => - element.addEventListener('click', event => this.riskItAllClearStressAndHitPoints(event, message)) + element.addEventListener('click', event => this.riskItAllClearStressAndHitPoints(event, data)) ); }; @@ -375,8 +376,12 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo } - async riskItAllClearStressAndHitPoints(event, message) { - console.log("riskItAllClearStressAndHitPoints button hit!", event, message); + async riskItAllClearStressAndHitPoints(event, data) { + const hopeValue = event.target.dataset.hope; + const config = { + hope: hopeValue + } + await new RiskItAllDialog(data.actor, config).render({ force: true }); } diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index d36a4b08..a7f99ca8 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -738,7 +738,7 @@ export default class DhCharacter extends BaseDataActor { static migrateData(source) { if (typeof source.scars === 'object') source.scars = 0; - if (source.resources.hope.max) source.scars = Math.max(6 - source.resources.hope.max, 0); + if (source.resources?.hope?.max) source.scars = Math.max(6 - source.resources.hope.max, 0); return super.migrateData(source); } diff --git a/templates/dialogs/riskItAllDialog.hbs b/templates/dialogs/riskItAllDialog.hbs new file mode 100644 index 00000000..0bf78e6b --- /dev/null +++ b/templates/dialogs/riskItAllDialog.hbs @@ -0,0 +1,18 @@ +
+
+

{{title}}

+
+
+ TODO magic here +
+ +
\ No newline at end of file diff --git a/templates/ui/chat/deathMove.hbs b/templates/ui/chat/deathMove.hbs index f73b32cd..b36ee590 100644 --- a/templates/ui/chat/deathMove.hbs +++ b/templates/ui/chat/deathMove.hbs @@ -19,7 +19,7 @@ {{#if this.showRiskItAllButton}}
-