Trefferwuerfe: Rechenkette anzeigen, Bearbeitung im Overlay mit einem Feld je Wurf

This commit is contained in:
torsten 2026-11-22 19:12:26 +01:00
parent 27a267893e
commit f9126675b2
5 changed files with 205 additions and 67 deletions

View file

@ -497,6 +497,23 @@ function hp_max_for(array $character): int
return hp_breakdown($character)['total'];
}
/**
* Kurze Rechenkette für das Formular: „3 + 4 + 7 + 8 = 25“.
* Fehlende Würfe erscheinen als „–“; der Konstitutionsbonus steckt im Ergebnis.
*/
function hp_rolls_sum(array $character): string
{
$info = hp_breakdown($character);
if ($info['manual']) {
return 'noch keine Würfe erfasst';
}
$parts = [$info['base'] === null ? '–' : (string) $info['base']];
foreach ($info['rolls'] as $value) {
$parts[] = $value === null ? '–' : (string) $value;
}
return implode(' + ', $parts) . ' = ' . (int) $info['total'];
}
/**
* Kompakte Klartextkette der Würfe für Bogen und PDF:
* „1W4 3 · W8 7 5 2 · KON +1“ (fehlende Würfe erscheinen als „–“).