From 7cc777d7a372c7c0500f05e842e697fcb9e82505 Mon Sep 17 00:00:00 2001 From: TheLastScrub <67403321+TheLastScrub@users.noreply.github.com> Date: Fri, 28 Jun 2024 21:51:52 -0700 Subject: [PATCH] add automation for exhaustion penalty to skill, stat, and san tests --- css/deltagreen.css | 16 ++++++++++ lang/ca.json | 1 + lang/de.json | 1 + lang/en.json | 1 + lang/es.json | 1 + lang/fr.json | 1 + lang/ja.json | 1 + lang/pt-BR.json | 1 + module/actor/actor.js | 5 +++ module/roll/roll.js | 55 +++++++++++++++++++++++++++++--- template.json | 3 +- templates/actor/actor-sheet.html | 14 +++++--- 12 files changed, 91 insertions(+), 9 deletions(-) diff --git a/css/deltagreen.css b/css/deltagreen.css index b3d4d3a..eb34b14 100644 --- a/css/deltagreen.css +++ b/css/deltagreen.css @@ -671,6 +671,22 @@ div .exhausted-section { margin-bottom: 10px; } +.exhausted-section input { + width: 75px; + text-align: center; + border: 1px solid rgb(122, 121, 113); + border-radius: 3px; + height: 100%; + margin-left: 10px; + min-height: 23px; + color: rgb(139, 0, 0); + background-color: rgba(0, 0, 0, 0.05); +} + +.resource .exhaustion-label { + vertical-align: middle; +} + .bonds-section-header { /* border-top: 1px solid #AAA; */ width: 100%; diff --git a/lang/ca.json b/lang/ca.json index b58c8d9..972eee1 100644 --- a/lang/ca.json +++ b/lang/ca.json @@ -97,6 +97,7 @@ "DG.Physical.Wounds": "Ferides", "DG.Physical.FirstAidLabel": "Primers auxilis ja aplicats: ", "DG.Physical.Exhausted": "Exhausted:", + "DG.Physical.ExhaustionPenalty": "Penalty:", "DG.Generic.AddButtonLabel": "Afegir", diff --git a/lang/de.json b/lang/de.json index c44a334..d1a77e6 100644 --- a/lang/de.json +++ b/lang/de.json @@ -112,6 +112,7 @@ "DG.Physical.Wounds": "Verletzungen", "DG.Physical.FirstAidLabel": "Erste Hilfe bereits geleistet: ", "DG.Physical.Exhausted": "Exhausted:", + "DG.Physical.ExhaustionPenalty": "Penalty:", "DG.Generic.AddButtonLabel": "Hinzufügen", diff --git a/lang/en.json b/lang/en.json index 44eb616..7241a58 100644 --- a/lang/en.json +++ b/lang/en.json @@ -113,6 +113,7 @@ "DG.Physical.Wounds": "Wounds", "DG.Physical.FirstAidLabel": "First Aid Has Already Been Attempted: ", "DG.Physical.Exhausted": "Exhausted:", + "DG.Physical.ExhaustionPenalty": "Penalty:", "DG.Generic.AddButtonLabel": "Add", diff --git a/lang/es.json b/lang/es.json index 3aa0bf1..78c50e8 100644 --- a/lang/es.json +++ b/lang/es.json @@ -97,6 +97,7 @@ "DG.Physical.Wounds": "Heridas", "DG.Physical.FirstAidLabel": "Los Primeros Auxilios ya han sido aplicados: ", "DG.Physical.Exhausted": "Exhausted:", + "DG.Physical.ExhaustionPenalty": "Penalty:", "DG.Generic.AddButtonLabel": "Añadir", diff --git a/lang/fr.json b/lang/fr.json index 2cd0029..da3aa1e 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -103,6 +103,7 @@ "DG.Physical.Wounds": "Blessures", "DG.Physical.FirstAidLabel": "Les premiers secours ont déjà été tentés: ", "DG.Physical.Exhausted": "Exhausted:", + "DG.Physical.ExhaustionPenalty": "Penalty:", "DG.Generic.AddButtonLabel": "Ajout", diff --git a/lang/ja.json b/lang/ja.json index 352c052..020a5e8 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -97,6 +97,7 @@ "DG.Physical.Wounds": "傷", "DG.Physical.FirstAidLabel": "応急処置は既に施された", "DG.Physical.Exhausted": "疲れ果てた:", + "DG.Physical.ExhaustionPenalty": "Penalty:", "DG.Generic.AddButtonLabel": "加える", diff --git a/lang/pt-BR.json b/lang/pt-BR.json index cbc7673..8da5a8b 100644 --- a/lang/pt-BR.json +++ b/lang/pt-BR.json @@ -88,6 +88,7 @@ "DG.Physical.Wounds": "Ferimentos", "DG.Physical.FirstAidLabel": "Primeiros socorros já foi tentado: ", "DG.Physical.Exhausted": "Exhausted:", + "DG.Physical.ExhaustionPenalty": "Penalty:", "DG.Generic.AddButtonLabel": "Adicionar", "DG.Mental.BreakingPoint": "Ponto de Ruptura: ", "DG.Mental.Reset": "Resetar", diff --git a/module/actor/actor.js b/module/actor/actor.js index bf96c97..6c44405 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -265,6 +265,11 @@ export default class DeltaGreenActor extends Actor { system.statistics.str.meleeDamageBonus = bonus; system.statistics.str.meleeDamageBonusFormula = sbonus; + if (system.physical.exhaustedPenalty > 0) { + system.physical.exhaustedPenalty = + -1 * Math.abs(system.physical.exhaustedPenalty); + } + console.log(agent); } diff --git a/module/roll/roll.js b/module/roll/roll.js index 597e3de..7072fa2 100644 --- a/module/roll/roll.js +++ b/module/roll/roll.js @@ -267,10 +267,36 @@ export class DGPercentileRoll extends DGRoll { this.effectiveTarget }`; } - if (this.modifier) { - label += ` (${this.target}${DGUtils.formatStringWithLeadingPlus( - this.modifier, - )}%)`; + + let isExhausted = false; + let exhaustedCheckPenalty = -20; + + try { + // I suspect (but am not entirely certain) that being tired doesn't make you less lucky) + if (this.type !== "luck") { + isExhausted = this.actor.system.physical.exhausted; + exhaustedCheckPenalty = this.actor.system.physical.exhaustedPenalty; + exhaustedCheckPenalty = -1 * Math.abs(exhaustedCheckPenalty); + } + } catch { + isExhausted = false; + exhaustedCheckPenalty = -20; + } + + if (this.modifier || isExhausted) { + label += ` (${this.target}`; + + if (this.modifier) { + label += ` ${DGUtils.formatStringWithLeadingPlus(this.modifier)}%`; + } + + if (isExhausted) { + label += ` ${DGUtils.formatStringWithLeadingPlus( + exhaustedCheckPenalty, + )}%`; + } + + label += `)`; } let resultString = ""; @@ -425,18 +451,39 @@ export class DGPercentileRoll extends DGRoll { * Actual target for the roll accounting for modifier if present. * Floored to 1 if a negative modifier would bring it below 1. * Capped at 99 unless it is an inhuman stat test. + * Also worth noting, per page 47 of the Agent's Handbook, Exhaustion penalties + * affect not only skill and stat tests, but SAN tests as well... * * @returns {null|integer} */ get effectiveTarget() { let target = 1; + let isExhausted = false; + let exhaustedCheckPenalty = -20; + + try { + // I suspect (but am not entirely certain) that being tired doesn't make you less lucky) + if (this.type !== "luck") { + isExhausted = this.actor.system.physical.exhausted; + exhaustedCheckPenalty = this.actor.system.physical.exhaustedPenalty; + exhaustedCheckPenalty = -1 * Math.abs(exhaustedCheckPenalty); + } + } catch { + isExhausted = false; + exhaustedCheckPenalty = -20; + } + if (!this.target || Number.isNaN(this.target)) { return null; } target = parseInt(this.target); + if (isExhausted) { + target += exhaustedCheckPenalty; + } + if (this.modifier && !Number.isNaN(this.modifier)) { const modifier = parseInt(this.modifier); diff --git a/template.json b/template.json index eb12c1c..611042d 100644 --- a/template.json +++ b/template.json @@ -487,7 +487,8 @@ "description": "(Physical description of agent)", "wounds": "", "firstAidAttempted": false, - "exhausted": false + "exhausted": false, + "exhaustedPenalty": -20 }, "biography": { "profession": "", diff --git a/templates/actor/actor-sheet.html b/templates/actor/actor-sheet.html index 844ab09..c482281 100644 --- a/templates/actor/actor-sheet.html +++ b/templates/actor/actor-sheet.html @@ -172,10 +172,16 @@
- - + + + + + {{#if actor.system.physical.exhausted }} + + + + + {{/if}}