PDF: TP-Zeile mit GESAMT statt MAXIMUM, AKTUELL-Feld fuellt die restliche Breite

This commit is contained in:
torsten 2026-11-22 20:28:11 +01:00
parent 1acb99dc51
commit 4f6acf43d9

View file

@ -177,29 +177,28 @@ function character_pdf(array $c, array $extra): string
$y += $boxH + 6; $y += $boxH + 6;
/* ----------------------------------------------------- Trefferpunkte */ /* ----------------------------------------------------- Trefferpunkte */
// Eigene Zeile: berechnetes Maximum, die Einzelwürfe je Stufe und ein // Eigene Zeile: berechnete Gesamtsumme, die Einzelwürfe je Stufe und ein
// leeres Kästchen, in das der Spieler die aktuellen TP einträgt. // großes Kästchen, in das der Spieler die aktuellen TP einträgt.
$hp = hp_breakdown($c); $hp = hp_breakdown($c);
$sectionTitle('Trefferpunkte'); $sectionTitle('Trefferpunkte');
$ensure(50); $ensure(50);
$hpRowH = 30.0; $hpRowH = 30.0;
$maxW = 34.0; $maxW = 34.0;
$curW = 72.0; // Das Feld „Aktuell“ füllt den Rest der Zeile aus und behält mindestens
$pdf->rect($M, $y, $maxW, $hpRowH, $parchment2, $gold, 0.5); // diese Breite; die Würfelzellen davor schrumpfen notfalls.
$pdf->textCenter($M + $maxW / 2, $y + 8, 6.2, 'F1', $soft, 'MAXIMUM'); $curMinW = 96.0;
$pdf->textCenter($M + $maxW / 2, $y + 23, 15, 'F4', $ink, (string) $hp['total']);
$curX = $M + $inner - $curW;
$pdf->rect($curX, $y, $curW, $hpRowH, null, $gold, 0.8);
$pdf->textCenter($curX + $curW / 2, $y + 8, 6.2, 'F1', $soft, 'AKTUELL');
$pdf->line($curX + 8, $y + 13, $curX + $curW - 8, $y + 13, $goldLight, 0.3);
// Würfelzellen: Stufe 0 (1W4), dann eine Zelle je Stufenwurf
$slotCount = 1 + count($hp['rolls']); $slotCount = 1 + count($hp['rolls']);
$cellsX = $M + $maxW + 6; $cellsX = $M + $maxW + 6;
$cellsW = $curX - 6 - $cellsX;
$cellGap = 3.0; $cellGap = 3.0;
$cellW = min(26.0, max(9.0, ($cellsW - ($slotCount - 1) * $cellGap) / max(1, $slotCount))); $cellSpace = ($M + $inner - $curMinW - 6 - $cellsX) - ($slotCount - 1) * $cellGap;
$cellW = min(26.0, max(9.0, $cellSpace / max(1, $slotCount)));
$cellsW = $slotCount * $cellW + ($slotCount - 1) * $cellGap;
$pdf->rect($M, $y, $maxW, $hpRowH, $parchment2, $gold, 0.5);
$pdf->textCenter($M + $maxW / 2, $y + 8, 6.2, 'F1', $soft, 'GESAMT');
$pdf->textCenter($M + $maxW / 2, $y + 23, 15, 'F4', $ink, (string) $hp['total']);
// Würfelzellen: Stufe 0 (1W4), dann eine Zelle je Stufenwurf
$cx = $cellsX; $cx = $cellsX;
$slotValues = array_merge([$hp['base']], $hp['rolls']); $slotValues = array_merge([$hp['base']], $hp['rolls']);
foreach ($slotValues as $slot => $value) { foreach ($slotValues as $slot => $value) {
@ -210,6 +209,12 @@ function character_pdf(array $c, array $extra): string
$pdf->textCenter($cx + $cellW / 2, $y + 25, 12, 'F4', $ink, $value === null ? '' : (string) $value); $pdf->textCenter($cx + $cellW / 2, $y + 25, 12, 'F4', $ink, $value === null ? '' : (string) $value);
$cx += $cellW + $cellGap; $cx += $cellW + $cellGap;
} }
$curX = $cellsX + $cellsW + 6;
$curW = max($curMinW, $M + $inner - $curX);
$pdf->rect($curX, $y, $curW, $hpRowH, null, $gold, 0.8);
$pdf->textCenter($curX + $curW / 2, $y + 8, 6.2, 'F1', $soft, 'AKTUELL');
$pdf->line($curX + 8, $y + 13, $curX + $curW - 8, $y + 13, $goldLight, 0.3);
$y += $hpRowH + 3; $y += $hpRowH + 3;
$pdf->text($M, $y + 7, 6.2, 'F1', $soft, WsPdf::fit( $pdf->text($M, $y + 7, 6.2, 'F1', $soft, WsPdf::fit(
'Stufe 0: 1W' . WS_HP_LEVEL0_DIE . ' · je Stufe 1W' . $hp['die'] . ' · KON ' 'Stufe 0: 1W' . WS_HP_LEVEL0_DIE . ' · je Stufe 1W' . $hp['die'] . ' · KON '