mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-16 05:31:07 +01:00
Pass the hope value in the button data; skeleton risk it all dialog to fill out.
This commit is contained in:
parent
7e4422dbf4
commit
d414b464b5
7 changed files with 79 additions and 7 deletions
|
|
@ -614,6 +614,10 @@
|
||||||
"title": "{name} Resource",
|
"title": "{name} Resource",
|
||||||
"rerollDice": "Reroll Dice"
|
"rerollDice": "Reroll Dice"
|
||||||
},
|
},
|
||||||
|
"RiskItAllDialog": {
|
||||||
|
"title": "Risk It All - Clear Stress and Hope",
|
||||||
|
"submit": "Submit"
|
||||||
|
},
|
||||||
"TagTeamSelect": {
|
"TagTeamSelect": {
|
||||||
"title": "Tag Team Roll",
|
"title": "Tag Team Roll",
|
||||||
"leaderTitle": "Initiating Character",
|
"leaderTitle": "Initiating Character",
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
|
||||||
this.actor = actor;
|
this.actor = actor;
|
||||||
this.selectedMove = null;
|
this.selectedMove = null;
|
||||||
this.showRiskItAllButton = false;
|
this.showRiskItAllButton = false;
|
||||||
this.riskItAllButtonLabel = ""
|
this.riskItAllButtonLabel = "";
|
||||||
|
this.riskItAllHope = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
get title() {
|
get title() {
|
||||||
|
|
@ -109,6 +110,7 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
|
||||||
} else {
|
} else {
|
||||||
chatMessage = game.i18n.format('DAGGERHEART.UI.Chat.deathMove.riskItAllSuccess', { hope: config.roll.hope.value })
|
chatMessage = game.i18n.format('DAGGERHEART.UI.Chat.deathMove.riskItAllSuccess', { hope: config.roll.hope.value })
|
||||||
this.showRiskItAllButton = true;
|
this.showRiskItAllButton = true;
|
||||||
|
this.riskItAllHope = config.roll.hope.value;
|
||||||
this.riskItAllButtonLabel = game.i18n.format('DAGGERHEART.UI.Chat.deathMove.riskItAllClearStressAndHitPoints', { hope: 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' : '',
|
open: autoExpandDescription ? 'open' : '',
|
||||||
chevron: autoExpandDescription ? 'fa-chevron-up' : 'fa-chevron-down',
|
chevron: autoExpandDescription ? 'fa-chevron-up' : 'fa-chevron-down',
|
||||||
showRiskItAllButton: this.showRiskItAllButton,
|
showRiskItAllButton: this.showRiskItAllButton,
|
||||||
riskItAllButtonLabel: this.riskItAllButtonLabel
|
riskItAllButtonLabel: this.riskItAllButtonLabel,
|
||||||
|
riskItAllHope: this.riskItAllHope
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
title: game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.title'),
|
title: game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.title'),
|
||||||
|
|
|
||||||
42
module/applications/dialogs/riskItAllDialog.mjs
Normal file
42
module/applications/dialogs/riskItAllDialog.mjs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { abilities } from '../../config/actorConfig.mjs';
|
import { abilities } from '../../config/actorConfig.mjs';
|
||||||
import { emitAsGM, GMUpdateEvent, RefreshType, socketEvent } from '../../systemRegistration/socket.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 {
|
export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLog {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
|
|
@ -82,7 +83,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
element.addEventListener('click', this.groupRollExpandSection)
|
element.addEventListener('click', this.groupRollExpandSection)
|
||||||
);
|
);
|
||||||
html.querySelectorAll('.risk-it-all-button').forEach(element =>
|
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) {
|
async riskItAllClearStressAndHitPoints(event, data) {
|
||||||
console.log("riskItAllClearStressAndHitPoints button hit!", event, message);
|
const hopeValue = event.target.dataset.hope;
|
||||||
|
const config = {
|
||||||
|
hope: hopeValue
|
||||||
|
}
|
||||||
|
await new RiskItAllDialog(data.actor, config).render({ force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -738,7 +738,7 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
|
|
||||||
static migrateData(source) {
|
static migrateData(source) {
|
||||||
if (typeof source.scars === 'object') source.scars = 0;
|
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);
|
return super.migrateData(source);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
templates/dialogs/riskItAllDialog.hbs
Normal file
18
templates/dialogs/riskItAllDialog.hbs
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<div>
|
||||||
|
<header class="dialog-header">
|
||||||
|
<h1>{{title}}</h1>
|
||||||
|
</header>
|
||||||
|
<div class="risk-it-all-container">
|
||||||
|
<span>TODO magic here</span>
|
||||||
|
</div>
|
||||||
|
<footer class="flexrow">
|
||||||
|
<button data-action="close">
|
||||||
|
<span>{{localize "Cancel"}}</span>
|
||||||
|
</button>
|
||||||
|
<button data-action="submit" {{#if (not this.validChoices)}}disabled{{/if}}>
|
||||||
|
<span>
|
||||||
|
{{localize "DAGGERHEART.APPLICATIONS.RiskItAllDialog.submit"}}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{#if this.showRiskItAllButton}}
|
{{#if this.showRiskItAllButton}}
|
||||||
<div>
|
<div>
|
||||||
<button class="risk-it-all-button">
|
<button class="risk-it-all-button" data-hope="{{this.riskItAllHope}}">
|
||||||
<span>
|
<span>
|
||||||
{{this.riskItAllButtonLabel}}
|
{{this.riskItAllButtonLabel}}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue