rpg-westreiche/westreiche_website/views/admin_equipment.php
torsten 5f01146d4b Charakterverwalter: Ausrüstungskatalog mit Selektor im Inventar
- data/item_catalog.csv als kuratierbare Master-Liste (481 Gegenstände nach
  OSE-Kernlisten plus Hausrat, Handel und Schatz), Preise in Silbertalern
  (OSE-Goldmünzen 1:1), Art aus WS_ITEM_CATEGORIES, Verfügbarkeit gestaffelt
  (Methaven/Garana/selten)
- tools/build_item_catalog.py erzeugt app/item_catalog_data.php und
  sql/seed_items.sql; item_catalog_sync() spiegelt den Katalog in die neue
  Tabelle item_catalog (Migration 3)
- Selektor-Dialog im Inventar filtert serverseitig nach Art, Verfügbarkeit und
  Suche (GET item_kind/item_avail/item_q) und übernimmt die Auswahl als
  Inventarzeile (POST /characters/{id}/items/from-catalog)
- Admin-Ansicht Ausrüstung listet den Katalog und liest die CSV neu ein
2026-11-21 14:31:29 +01:00

105 lines
4.4 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 $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>