Pass the hope value in the button data; skeleton risk it all dialog to fill out.

This commit is contained in:
Chris Ryan 2026-01-15 23:39:44 +10:00
parent 7e4422dbf4
commit d414b464b5
7 changed files with 79 additions and 7 deletions

View file

@ -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'),

View file

@ -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();
}
}

View file

@ -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 });
}