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
This commit is contained in:
torsten 2026-11-21 14:31:29 +01:00
parent b68e92f581
commit 5f01146d4b
17 changed files with 2029 additions and 4 deletions

View file

@ -46,3 +46,60 @@
</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>