diff --git a/lang/en.json b/lang/en.json index ccf03029..c2b2fabb 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2660,12 +2660,15 @@ }, "deathMove": { "title": "Death Move", - "gainScar": "You gained a scar", - "avoidScar": "You have avoided a new scar", + "gainScar": "You gained a scar.", + "avoidScar": "You have avoided a new scar.", "journeysEnd": "You have {scars} Scars and have crossed out your last Hope slot. Your character's journey ends.", - "riskItAllCritical": "Critical Rolled, clearing all marked Stress and Hit Points", + "riskItAllCritical": "Critical Rolled, clearing all marked Stress and Hit Points.", "riskItAllFailure": "The fear die rolled higher. You have crossed through the veil of death.", - "blazeOfGlory": "Blaze of Glory Effect Added!" + "blazeOfGlory": "Blaze of Glory Effect Added!", + "riskItAllClearStressAndHitPoints": "Clear {hope} Stress Or Hit Points.", + "riskItAllSuccessWithEnoughHope": "Hope roll value is more than the marked Stress and Hit Points, clearing both.", + "riskItAllSuccess": "The hope die rolled higher, clear up to {hope} Stress Or Hit Points." }, "dicePool": { "title": "Dice Pool" diff --git a/module/applications/dialogs/deathMove.mjs b/module/applications/dialogs/deathMove.mjs index f6ab33a9..0996fc27 100644 --- a/module/applications/dialogs/deathMove.mjs +++ b/module/applications/dialogs/deathMove.mjs @@ -8,6 +8,8 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV this.actor = actor; this.selectedMove = null; + this.showRiskItAllButton = false; + this.riskItAllButtonLabel = "" } get title() { @@ -98,16 +100,17 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV } if (config.roll.result.duality == 1) { - console.log('Need to clear up Stress and HP up to hope value'); - console.log('Hope rolled', config.roll.hope.value); if ( config.roll.hope.value >= this.actor.system.resources.hitPoints.value + this.actor.system.resources.stress.value ) { config.resourceUpdates.addResources(clearAllStressAndHitpointsUpdates); - chatMessage = 'Hope roll value is more than the marked Stress and Hit Points, clearing both.'; + chatMessage = game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.riskItAllSuccessWithEnoughHope'); + } else { + chatMessage = game.i18n.format('DAGGERHEART.UI.Chat.deathMove.riskItAllSuccess', { hope: config.roll.hope.value }) + this.showRiskItAllButton = true; + this.riskItAllButtonLabel = game.i18n.format('DAGGERHEART.UI.Chat.deathMove.riskItAllClearStressAndHitPoints', { hope: config.roll.hope.value }) } - chatMessage = 'TODO - need to clear Stress and/or Hit Points up to: ' + config.roll.hope.value; } if (config.roll.result.duality == -1) { @@ -180,7 +183,9 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV description: game.i18n.localize(this.selectedMove.description), result: result, open: autoExpandDescription ? 'open' : '', - chevron: autoExpandDescription ? 'fa-chevron-up' : 'fa-chevron-down' + chevron: autoExpandDescription ? 'fa-chevron-up' : 'fa-chevron-down', + showRiskItAllButton: this.showRiskItAllButton, + riskItAllButtonLabel: this.riskItAllButtonLabel } ), title: game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.title'), diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index 79cbe304..0919f0c5 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -728,9 +728,8 @@ export default class CharacterSheet extends DHBaseActorSheet { if (!result) return; /* This could be avoided by baking config.costs into config.resourceUpdates. Didn't feel like messing with it at the time */ - const costResources = result.costs - .filter(x => x.enabled) - .map(cost => ({ ...cost, value: -cost.value, total: -cost.total })); + const costResources = result.costs?.filter(x => x.enabled) + .map(cost => ({ ...cost, value: -cost.value, total: -cost.total })) || {}; config.resourceUpdates.addResources(costResources); await config.resourceUpdates.updateResources(); } diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index 20dfea8d..d3e30dab 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -81,6 +81,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo html.querySelectorAll('.group-roll-header-expand-section').forEach(element => element.addEventListener('click', this.groupRollExpandSection) ); + html.querySelectorAll('.risk-it-all-button').forEach(element => + element.addEventListener('click', event => this.riskItAllClearStressAndHitPoints(event, message)) + ); }; setupHooks() { @@ -370,4 +373,11 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo }); event.target.closest('.group-roll-section').querySelector('.group-roll-content').classList.toggle('closed'); } + + + async riskItAllClearStressAndHitPoints(event, message) { + console.log("riskItAllClearStressAndHitPoints button hit!", event, message); + } + + } diff --git a/styles/less/ui/chat/deathmoves.less b/styles/less/ui/chat/deathmoves.less index 9060e644..175b8753 100644 --- a/styles/less/ui/chat/deathmoves.less +++ b/styles/less/ui/chat/deathmoves.less @@ -32,6 +32,10 @@ .result { color: @dark; } + + .risk-it-all-button { + color: @dark; + } } } @@ -137,5 +141,12 @@ padding: 8px; font-weight: bold; } + + .risk-it-all-button { + width: -webkit-fill-available; + margin: 0 8px; + font-weight: 600; + height: 40px; + } } } diff --git a/templates/ui/chat/deathMove.hbs b/templates/ui/chat/deathMove.hbs index 3cca5fc7..f73b32cd 100644 --- a/templates/ui/chat/deathMove.hbs +++ b/templates/ui/chat/deathMove.hbs @@ -17,4 +17,15 @@