Selektor auch für Waffen und Rüstung, fest auf die jeweilige Art vorgefiltert
This commit is contained in:
parent
a121b8c202
commit
c0756971cf
5 changed files with 247 additions and 40 deletions
|
|
@ -299,6 +299,32 @@ function page_handle(string $method, string $path): void
|
|||
}
|
||||
redirect('/characters/' . $character['id'] . '/edit#inventar');
|
||||
}
|
||||
if (preg_match('#^/characters/(\d+)/weapons/from-catalog$#', $path, $m) === 1) {
|
||||
require_post();
|
||||
$character = character_require((int) $m[1], $user);
|
||||
$entry = item_catalog_find(post_int('catalog_id', 0));
|
||||
if ($entry === null) {
|
||||
flash('error', 'Diesen Eintrag kennt der Katalog nicht.');
|
||||
} elseif (character_weapon_add_from_catalog((int) $character['id'], (int) $entry['id'])) {
|
||||
flash('success', '„' . (string) $entry['name'] . '“ in die Bewaffnung übernommen.');
|
||||
} else {
|
||||
flash('error', 'Der Eintrag ist keine Waffe.');
|
||||
}
|
||||
redirect('/characters/' . $character['id'] . '/edit#bewaffnung');
|
||||
}
|
||||
if (preg_match('#^/characters/(\d+)/armors/from-catalog$#', $path, $m) === 1) {
|
||||
require_post();
|
||||
$character = character_require((int) $m[1], $user);
|
||||
$entry = item_catalog_find(post_int('catalog_id', 0));
|
||||
if ($entry === null) {
|
||||
flash('error', 'Diesen Eintrag kennt der Katalog nicht.');
|
||||
} elseif (character_armor_add_from_catalog((int) $character['id'], (int) $entry['id'])) {
|
||||
flash('success', '„' . (string) $entry['name'] . '“ in die Rüstung übernommen.');
|
||||
} else {
|
||||
flash('error', 'Der Eintrag ist weder Rüstung noch Schild.');
|
||||
}
|
||||
redirect('/characters/' . $character['id'] . '/edit#ruestung');
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ Admin */
|
||||
if ($path === '/admin/users') {
|
||||
|
|
@ -598,17 +624,15 @@ function page_character_edit(string $method, int $id, array $user): void
|
|||
$character = character_require($id, $user);
|
||||
$armors = character_armors((int) $character['id']);
|
||||
item_catalog_sync();
|
||||
$itemFilters = [
|
||||
'kind' => query_string('item_kind'),
|
||||
'availability' => query_string('item_avail'),
|
||||
'needle' => query_string('item_q'),
|
||||
$charPath = '/characters/' . (int) $character['id'];
|
||||
$selectors = [
|
||||
'item' => item_selector_config('item', 'Ausrüstung aus dem Katalog', $charPath . '/items/from-catalog', 'inventar'),
|
||||
'weapon' => item_selector_config('weapon', 'Waffe aus dem Katalog', $charPath . '/weapons/from-catalog', 'bewaffnung', ['Waffe']),
|
||||
'armor' => item_selector_config('armor', 'Rüstung aus dem Katalog', $charPath . '/armors/from-catalog', 'ruestung', ['Rüstung', 'Schild']),
|
||||
];
|
||||
render_page('character_edit', [
|
||||
'character' => $character,
|
||||
'itemFilters' => $itemFilters,
|
||||
'itemCatalog' => item_catalog_search($itemFilters),
|
||||
'itemCatalogCount' => item_catalog_count($itemFilters),
|
||||
'itemSelectorOpen' => $itemFilters['kind'] !== '' || $itemFilters['availability'] !== '' || $itemFilters['needle'] !== '',
|
||||
'selectors' => $selectors,
|
||||
'weapons' => character_weapons((int) $character['id']),
|
||||
'armors' => $armors,
|
||||
'weaponCatalog' => weapons_catalog(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue