rpg-westreiche/westreiche_website/views/admin_equipment.php

106 lines
4.4 KiB
PHP
Raw Normal View History

<?php
/** @var array $weapons */
/** @var array $armors */
?>
<div class="page-head">
<div>
<h1>Waffen &amp; Rüstungen</h1>
<p class="lede">Der Katalog füllt die Auswahllisten im Bogen. Werte sind Startpunkte – im Bogen bleibt jeder Eintrag änderbar.</p>
</div>
<a class="btn btn-ghost" href="<?= e(url('/admin/users')) ?>">Zurück</a>
</div>
<section class="panel">
<h2>Waffen</h2>
<table class="data">
<thead><tr><th>Name</th><th>Schaden</th><th class="num">Bonus</th><th>Art</th><th>Gewicht</th><th>Preis</th></tr></thead>
<tbody>
<?php foreach ($weapons as $weapon): ?>
<tr>
<td><?= e((string) $weapon['name']) ?></td>
<td><?= e((string) $weapon['damage']) ?></td>
<td class="num"><?= e(signed((int) $weapon['attack_bonus'])) ?></td>
<td class="muted"><?= e((string) $weapon['category']) ?></td>
<td class="muted"><?= e((string) $weapon['weight']) ?></td>
<td class="muted"><?= e((string) $weapon['value']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
<section class="panel">
<h2>Rüstungen &amp; Schilde</h2>
<table class="data">
<thead><tr><th>Name</th><th class="num">RK-Bonus</th><th>Art</th><th>Gewicht</th><th>Preis</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"><?= e((string) $armor['weight']) ?></td>
<td class="muted"><?= e((string) $armor['value']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
<?php
/**
* Ausrüstungskatalog (Selektor im Inventar).
*
* @var list<array<string,mixed>> $itemCatalog
* @var int $itemCatalogCount
* @var array{kind:string,needle:string,limit:int} $itemFilters
*/
$availabilityShort = ['methaven' => 'Methaven', 'garana' => 'Garana', 'selten' => 'selten'];
?>
<section class="panel">
<h2>Ausrüstungskatalog</h2>
<p class="muted">
Quelle ist <code>data/item_catalog.csv</code> (dort kuratieren, dann
<code>python3 tools/build_item_catalog.py</code>). Preise in Silbertalern;
OSE-Goldmünzen sind 1:1 übernommen.
</p>
<form method="post" action="<?= e($base . '/admin/equipment/items/sync') ?>" class="inline-form" style="margin-bottom:.8rem">
<?= csrf_field() ?>
<button class="btn btn-small" type="submit">Katalog aus der CSV neu einlesen</button>
<span class="muted"><?= (int) $itemCatalogCount ?> Gegenstände im Filter, <?= count($itemCatalog) ?> gelistet.</span>
</form>
<form method="get" action="<?= e($base . '/admin/equipment') ?>" class="selector-filters">
<label class="field">
<span>Suche</span>
<input type="search" name="q" value="<?= e($itemFilters['needle']) ?>" placeholder="Name oder Notiz …">
</label>
<label class="field">
<span>Art</span>
<select name="kind">
<option value="">Alle Arten</option>
<?php foreach (WS_ITEM_CATEGORIES as $category): ?>
<option value="<?= e($category) ?>"<?= $itemFilters['kind'] === $category ? ' selected' : '' ?>><?= e($category) ?></option>
<?php endforeach; ?>
</select>
</label>
<button class="btn btn-small" type="submit">Filtern</button>
</form>
<table class="data">
<thead><tr><th>Name</th><th>Art</th><th class="num">Preis</th><th>Gewicht</th><th>Verfügbarkeit</th><th>Notiz</th></tr></thead>
<tbody>
<?php foreach ($itemCatalog as $entry): ?>
<tr>
<td><?= e((string) $entry['name']) ?></td>
<td class="muted"><?= e((string) $entry['kind']) ?></td>
<td class="num"><?= e(item_cost_label($entry['cost'])) ?></td>
<td class="muted"><?= e(item_weight_label($entry['weight'])) ?></td>
<td class="muted"><?= e($availabilityShort[(string) $entry['availability']] ?? (string) $entry['availability']) ?></td>
<td class="muted"><?= e((string) $entry['note']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>