Trefferpunkte: Konstitutionsbonus als eigener Summand in der Rechenkette

This commit is contained in:
torsten 2026-11-22 19:20:36 +01:00
parent 38ad53254c
commit ca27992621
3 changed files with 22 additions and 6 deletions

View file

@ -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);
}

View file

@ -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);

View file

@ -81,9 +81,16 @@ $hpSlotValue = static fn (int $slot): string => ((int) ($hpRolls[$slot] ?? 0)) >
<small class="muted">bearbeiten</small>
</button>
<small class="muted">
<?= $hp['complete']
? ((int) $hp['con'] === 0 ? '' : 'Konstitutionsbonus ' . e(signed((int) $hp['con'])) . ' eingerechnet')
: 'fehlende Würfe zählen nicht mit' ?>
<?php
$hints = [];
if ((int) $hp['con'] !== 0) {
$hints[] = 'KON ' . signed((int) $hp['con']) . ' einmal eingerechnet';
}
if (!$hp['complete']) {
$hints[] = 'fehlende Würfe zählen nicht mit';
}
echo e(implode(' · ', $hints));
?>
</small>
</div>
<label class="field">