Charakterverwalter: Stufe aus Erfahrungspunkten und Klasse ableiten (WS_XP_TABLES)

This commit is contained in:
torsten 2026-11-21 10:15:56 +01:00
parent f21b714d82
commit b4d4c53dd4
8 changed files with 138 additions and 11 deletions

View file

@ -27,12 +27,22 @@
</select>
</label>
<label class="field">
<span>Stufe</span>
<input type="number" name="level" min="1" max="20" value="<?= (int) $values['level'] ?>">
<span>Stufe (aus EP)</span>
<input type="text" value="<?= (int) $values['level'] ?>" readonly
title="Wird aus Erfahrungspunkten und Klasse abgeleitet">
<?php $xpProgress = xp_progress((string) $values['class_name'], (int) $values['xp']); ?>
<small class="muted">
<?= $xpProgress['next'] === null
? 'höchste Stufe erreicht'
: 'ab ' . number_format((int) $xpProgress['next'], 0, ',', '.') . ' EP Stufe ' . ((int) $xpProgress['level'] + 1) ?>
</small>
</label>
<label class="field">
<span>Erfahrungspunkte</span>
<input type="number" name="xp" min="0" value="<?= (int) $values['xp'] ?>">
<small class="muted">
<?= number_format((int) $values['xp'], 0, ',', '.') ?> EP gesammelt
</small>
</label>
<label class="field">
<span>Gesinnung</span>

View file

@ -23,7 +23,7 @@ $equipped = array_values(array_filter($items, static fn ($item) => (int) $item['
<?php endif; ?></h1>
<p class="lede">
<?= e((string) $character['class_name']) ?> · Stufe <?= (int) $character['level'] ?>
· <?= (int) $character['xp'] ?> EP
· <?= number_format((int) $character['xp'], 0, ',', '.') ?> EP<?php $xpProgress = xp_progress((string) $character['class_name'], (int) $character['xp']); ?><?php if ($xpProgress['next'] !== null): ?> (noch <?= number_format((int) $xpProgress['missing'], 0, ',', '.') ?> EP bis Stufe <?= (int) $xpProgress['level'] + 1 ?>)<?php endif; ?>
<?php if ((string) $character['alignment'] !== '' && (string) $character['alignment'] !== '–'): ?>
· <?= e((string) $character['alignment']) ?>
<?php endif; ?>
@ -84,6 +84,9 @@ $equipped = array_values(array_filter($items, static fn ($item) => (int) $item['
<span style="display:block;height:100%;width:<?= (int) round($derived['hp_ratio'] * 100) ?>%;
background: linear-gradient(90deg, <?= $derived['hp_state'] === 'healthy' ? 'var(--moss), var(--gold-bright)' : 'var(--blood), var(--ember)' ?>);"></span>
</div>
<div class="xp-bar" title="Erfahrung bis zur nächsten Stufe">
<span style="width:<?= (int) round($xpProgress['ratio'] * 100) ?>%"></span>
</div>
<?php
$saves = [];