From ca27992621b7410b65537a867dcadffe5f648e2e Mon Sep 17 00:00:00 2001 From: torsten Date: Sun, 22 Nov 2026 19:20:36 +0100 Subject: [PATCH] Trefferpunkte: Konstitutionsbonus als eigener Summand in der Rechenkette --- westreiche_website/app/rules.php | 9 +++++++-- westreiche_website/assets/app.js | 6 +++++- westreiche_website/views/_fields.php | 13 ++++++++++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/westreiche_website/app/rules.php b/westreiche_website/app/rules.php index a960fb7..ba27e4d 100644 --- a/westreiche_website/app/rules.php +++ b/westreiche_website/app/rules.php @@ -511,7 +511,12 @@ function hp_rolls_sum(array $character): string foreach ($info['rolls'] as $value) { $parts[] = $value === null ? '–' : (string) $value; } - return implode(' + ', $parts) . ' = ' . (int) $info['total']; + $chain = implode(' + ', $parts); + if ((int) $info['con'] !== 0) { + // Konstitutionsbonus als eigener Summand, damit die Kette aufgeht. + $chain .= ((int) $info['con'] > 0 ? ' + ' : ' − ') . abs((int) $info['con']) . ' KON'; + } + return $chain . ' = ' . (int) $info['total']; } /** @@ -527,6 +532,6 @@ function hp_rolls_label(array $character): string $parts = ['1W' . WS_HP_LEVEL0_DIE . ' ' . ($info['base'] ?? '–')]; $levelDice = implode(' ', array_map(static fn (?int $v): string => $v === null ? '–' : (string) $v, $info['rolls'])); $parts[] = 'W' . $info['die'] . ' ' . ($levelDice === '' ? '–' : $levelDice); - $parts[] = 'KON ' . signed((int) $info['con']); + $parts[] = 'KON ' . str_replace('-', '−', signed((int) $info['con'])); return implode(' · ', $parts); } diff --git a/westreiche_website/assets/app.js b/westreiche_website/assets/app.js index 4b91433..4d5b417 100644 --- a/westreiche_website/assets/app.js +++ b/westreiche_website/assets/app.js @@ -91,7 +91,11 @@ sum += value; return value > 0 ? String(value) : '–'; }); - return { text: parts.join(' + ') + ' = ' + Math.max(1, sum + con), sum: sum }; + let chain = parts.join(' + '); + if (con !== 0) { + chain += (con > 0 ? ' + ' : ' − ') + Math.abs(con) + ' KON'; + } + return { text: chain + ' = ' + Math.max(1, sum + con), sum: sum }; }; const paint = function (list) { const info = chainText(list); diff --git a/westreiche_website/views/_fields.php b/westreiche_website/views/_fields.php index ad09526..030f728 100644 --- a/westreiche_website/views/_fields.php +++ b/westreiche_website/views/_fields.php @@ -81,9 +81,16 @@ $hpSlotValue = static fn (int $slot): string => ((int) ($hpRolls[$slot] ?? 0)) > bearbeiten - +