rpg-westreiche/westreiche_website/views/character_sheet.php

295 lines
14 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/** @var array $character */
/** @var array $derived */
/** @var array $skills */
/** @var array $spells */
/** @var array $items */
/** @var array $weapons */
/** @var array $armors */
/** @var array $acInfo */
$base = url('/characters/' . (int) $character['id']);
$monogram = mb_strtoupper(mb_substr((string) $character['name'], 0, 1), 'UTF-8');
$status = (string) $character['status'];
$bonuses = $derived['bonuses'];
$equipped = array_values(array_filter($items, static fn ($item) => (int) $item['equipped'] === 1));
?>
<div class="page-head">
<div>
<p class="muted" style="margin:0; letter-spacing:.16em; text-transform:uppercase; font-size:.72rem;">
Bogen von <?= e((string) $character['owner_name']) ?>
</p>
<h1><?= e((string) $character['name']) ?><?php if ((string) $character['title'] !== ''): ?>
<small class="muted" style="font-size:.55em;">· <?= e((string) $character['title']) ?></small>
<?php endif; ?></h1>
<p class="lede">
<?= e((string) $character['class_name']) ?> · Stufe <?= (int) $character['level'] ?>
· <?= (int) $character['xp'] ?> EP
<?php if ((string) $character['alignment'] !== '' && (string) $character['alignment'] !== '–'): ?>
· <?= e((string) $character['alignment']) ?>
<?php endif; ?>
</p>
</div>
<div class="actions" style="margin:0">
<a class="btn btn-primary" href="<?= e($base . '/edit') ?>">Bearbeiten</a>
<a class="btn" href="<?= e($base . '/pdf') ?>">Als PDF</a>
</div>
</div>
<section class="panel">
<div class="sheet-head">
<div class="stat-row">
<?php foreach (WS_ATTRIBUTES as $field => [$short, $label]): ?>
<div class="stat">
<span class="k"><?= e($short) ?></span>
<span class="v"><?= (int) $character[$field] ?></span>
<span class="b <?= bonus_class((int) $bonuses[$field]) ?>"><?= e(signed($bonuses[$field])) ?></span>
</div>
<?php endforeach; ?>
</div>
<?php $portraitSrc = portrait_url($character); ?>
<?php if ($portraitSrc !== ''): ?>
<img class="portrait-frame" src="<?= e($portraitSrc) ?>" alt="Porträt von <?= e((string) $character['name']) ?>">
<?php else: ?>
<div class="monogram" aria-hidden="true"><?= e($monogram) ?></div>
<?php endif; ?>
</div>
<hr class="divider">
<div class="stat-row">
<div class="stat">
<span class="k">Trefferpunkte</span>
<span class="v"><?= (int) $character['hp_current'] ?> / <?= (int) $character['hp_max'] ?></span>
</div>
<div class="stat">
<span class="k">Rüstungsklasse</span>
<span class="v"><?= (int) $acInfo['total'] ?></span>
<span class="b" style="color:var(--parchment-dim)"><?= $acInfo['manual_active']
? 'manuell gesetzt'
: '10 Basis · Geschick ' . e(signed((int) $acInfo['dexterity'])) . ' · Rüstung ' . e(signed((int) $acInfo['armor'])) ?></span>
</div>
<div class="stat"><span class="k">Angriff</span><span class="v"><?= e(signed((int) $character['attack_bonus'])) ?></span></div>
<div class="stat"><span class="k">Gold</span><span class="v"><?= (int) $character['gold_coins'] ?></span></div>
<div class="stat">
<span class="k">Status</span>
<span class="v" style="font-size:1rem;">
<span class="badge badge-<?= e($status === 'active' ? 'active' : $status) ?>">
<?= e(character_status_label($status)) ?>
</span>
</span>
</div>
</div>
<div class="hp-bar" style="margin-top:1rem;height:9px;border-radius:99px;background:rgba(0,0,0,.55);overflow:hidden;border:1px solid rgba(201,162,39,.25)">
<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>
<?php
$saves = [];
foreach (WS_SAVES as $field => $label) {
if ($character[$field] !== null && $character[$field] !== '') {
$saves[$label] = (int) $character[$field];
}
}
?>
<?php if ($saves !== []): ?>
<hr class="divider">
<h2 style="font-size:1rem;">Rettungswürfe</h2>
<div class="stat-row">
<?php foreach ($saves as $label => $value): ?>
<div class="stat"><span class="k"><?= e($label) ?></span><span class="v"><?= $value ?></span></div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
<section class="panel">
<h2>Bewaffnung</h2>
<?php if ($weapons === []): ?>
<p class="muted">Keine Waffe eingetragen. <a href="<?= e($base . '/edit#bewaffnung') ?>">Waffe wählen</a></p>
<?php else: ?>
<table class="data">
<thead><tr><th>Waffe</th><th class="num">Trefferwurf</th><th class="num">Schaden</th><th>Status</th></tr></thead>
<tbody>
<?php foreach ($weapons as $weapon): ?>
<tr>
<td><?= e((string) $weapon['name']) ?> <span class="muted" style="font-size:.78rem">· <?= e((string) $weapon['category']) ?></span></td>
<td class="num"><b><?= e(signed(weapon_attack_total($character, $weapon))) ?></b></td>
<td class="num"><?= e(weapon_damage_total($character, $weapon)) ?></td>
<td class="muted"><?= (int) $weapon['equipped'] === 1 ? 'geführt' : 'weggelegt' ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</section>
<section class="panel">
<h2>Rüstung</h2>
<?php if ($armors === []): ?>
<p class="muted">Nichts am Körper. <a href="<?= e($base . '/edit#ruestung') ?>">Rüstung wählen</a></p>
<?php else: ?>
<table class="data">
<thead><tr><th>Teil</th><th class="num">RK-Bonus</th><th>Art</th><th>Status</th></tr></thead>
<tbody>
<?php foreach ($armors as $armor): ?>
<tr>
<td><?= e((string) $armor['name']) ?></td>
<td class="num"><?= e(signed((int) $armor['ac_bonus'])) ?></td>
<td class="muted"><?= e((string) $armor['kind']) ?></td>
<td class="muted"><?= (int) $armor['equipped'] === 1 ? 'angelegt' : 'abgelegt' ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p class="muted" style="margin-top:.6rem">
Gesamt: 10 + Geschick <?= e(signed((int) $acInfo['dexterity'])) ?>
+ Rüstung <?= e(signed((int) $acInfo['armor'])) ?> = <b><?= (int) $acInfo['total'] ?></b>
</p>
<?php endif; ?>
</section>
<section class="panel">
<h2>Fertigkeiten</h2>
<?php if ($skills === []): ?>
<p class="muted">Noch keine Fertigkeiten eingetragen. <a href="<?= e($base . '/edit#fertigkeiten') ?>">Ergänzen</a></p>
<?php else: ?>
<?php foreach (skills_grouped($skills) as $group => $groupSkills): ?>
<h3 class="skill-group"><?= e($group) ?></h3>
<table class="data skill-table">
<thead><tr><th>Fertigkeit</th><th>Attribut</th><th class="num">MOD</th><th class="num">Stufe</th><th>Notiz</th></tr></thead>
<tbody>
<?php foreach ($groupSkills as $skill): ?>
<?php $mod = skill_attribute_modifier($character, $skill); ?>
<tr>
<td class="skill-name"><?= e((string) $skill['name']) ?></td>
<td class="muted"><?= e((string) ($skill['attribute'] ?? '')) ?></td>
<td class="num <?= $mod === null ? 'muted' : bonus_class($mod) ?>"><?= $mod === null ? '–' : e(signed($mod)) ?></td>
<td class="num <?= bonus_class((int) $skill['bonus']) ?>"><b><?= e(signed((int) $skill['bonus'])) ?></b></td>
<td class="muted"><?= e((string) $skill['note']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endforeach; ?>
<?php endif; ?>
</section>
<?php foreach (['arkan' => 'Arkane Zauber', 'klerikal' => 'Göttliche Liturgien'] as $school => $label): ?>
<?php if ($spells[$school] !== []): ?>
<section class="panel">
<h2><?= e($label) ?></h2>
<?php
$byGrade = [];
foreach ($spells[$school] as $spell) {
$byGrade[(int) $spell['grade']][] = $spell;
}
ksort($byGrade);
?>
<?php foreach ($byGrade as $grade => $entries): ?>
<div class="grade-block">
<h4>Grad <?= (int) $grade ?></h4>
<div class="pill-list">
<?php foreach ($entries as $entry): ?>
<?php
$note = trim((string) ($entry['note'] ?? ''));
$summary = trim((string) ($entry['summary'] ?? ''));
$classes = trim((string) ($entry['classes'] ?? ''));
$duration = trim((string) ($entry['duration'] ?? ''));
$range = trim((string) ($entry['range_text'] ?? ''));
?>
<button type="button" class="pill pill-detail"
data-spell-detail
data-name="<?= e((string) $entry['name']) ?>"
data-line="<?= e(($school === 'arkan' ? 'Arkan' : 'Klerikal') . ' · Grad ' . (int) $entry['grade']) ?>"
data-classes="<?= e($classes) ?>"
data-duration="<?= e($duration) ?>"
data-range="<?= e($range) ?>"
data-note="<?= e($note) ?>"
data-summary="<?= e($summary) ?>"
data-body="<?= e(trim((string) ($entry['body'] ?? ''))) ?>"
title="Details anzeigen">
<?= e((string) $entry['name']) ?>
</button>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
<p class="muted" style="font-size:.82rem">Namen anklicken für Wirkung, Wirkungsdauer und Reichweite.</p>
</section>
<?php endif; ?>
<?php endforeach; ?>
<section class="panel">
<h2>Inventar</h2>
<?php if ($items === []): ?>
<p class="muted">Nichts im Gepäck. <a href="<?= e($base . '/edit#inventar') ?>">Ausrüstung ergänzen</a></p>
<?php else: ?>
<?php if ($equipped !== []): ?>
<p class="muted" style="margin-bottom:.6rem">Am Körper:
<?= e(implode(', ', array_map(static fn ($item) => (string) $item['name'], $equipped))) ?>
</p>
<?php endif; ?>
<table class="data">
<thead><tr><th>Anzahl</th><th>Gegenstand</th><th>Art</th><th>Wert</th><th>Notiz</th></tr></thead>
<tbody>
<?php foreach ($items as $item): ?>
<tr>
<td><?= (int) $item['qty'] ?>×</td>
<td><?= e((string) $item['name']) ?><?= (int) $item['equipped'] === 1 ? ' <span class="badge" style="font-size:.6rem">angelegt</span>' : '' ?></td>
<td class="muted"><?= e((string) $item['category']) ?></td>
<td class="muted"><?= e((string) $item['value']) ?></td>
<td class="muted"><?= e((string) $item['note']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</section>
<?php
$facts = [];
foreach (['deity' => 'Gottheit', 'age' => 'Alter', 'height' => 'Größe', 'weight' => 'Gewicht'] as $field => $label) {
if ((string) $character[$field] !== '') {
$facts[] = $label . ': ' . $character[$field];
}
}
?>
<?php if ($facts !== [] || (string) $character['appearance'] !== '' || (string) $character['background'] !== '' || (string) $character['notes'] !== ''): ?>
<section class="panel">
<h2>Person &amp; Notizen</h2>
<?php if ($facts !== []): ?>
<p class="muted"><?= e(implode(' · ', $facts)) ?></p>
<?php endif; ?>
<?php foreach (['appearance' => 'Erscheinung', 'background' => 'Hintergrund', 'notes' => 'Notizen'] as $field => $label): ?>
<?php if (trim((string) $character[$field]) !== ''): ?>
<h3><?= e($label) ?></h3>
<p style="white-space:pre-wrap"><?= e((string) $character[$field]) ?></p>
<?php endif; ?>
<?php endforeach; ?>
</section>
<?php endif; ?>
<dialog class="selector spell-detail" id="spell-detail" aria-labelledby="spell-detail-title">
<div class="selector-head">
<h2 id="spell-detail-title" data-spell-field="name">Zauber</h2>
<button class="btn btn-small" type="button" data-dialog-close>Schließen</button>
</div>
<div class="selector-body">
<p class="muted" style="margin-top:0" data-spell-field="line">–</p>
<dl class="detail-list">
<dt>Klassen</dt>
<dd data-spell-field="classes">–</dd>
<dt>Wirkungsdauer</dt>
<dd data-spell-field="duration">–</dd>
<dt>Reichweite</dt>
<dd data-spell-field="range">–</dd>
<dt>Notiz</dt>
<dd data-spell-field="note">–</dd>
</dl>
<p data-spell-field="summary" style="margin-top:0"></p>
<div class="spell-body" data-spell-field="body"></div>
<p class="muted" data-spell-field="empty" hidden>Eigener Eintrag – im Katalog steht keine Beschreibung.</p>
</div>
</dialog>