commit 69fb4c4751c7167c18edbd96ee810ec036ce771c
parent d1627a80cc086428be88a79c165970f03dae32e4
Author: anon <anon@example.com>
Date: Mon, 9 Nov 2026 22:54:05 +0000
Filter admin item catalog by original item class
Diffstat:
4 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/TODO.md b/TODO.md
@@ -190,6 +190,8 @@ research separately. More screenshots and test cases do not count as new gamepla
training-boss sources; Leets can drop useful Low-Tech gloves. CellAO's examples
provide no compatible starter rows. This completes the requested acquisition
visibility/content extension, not recovery of the full historical loot table.
+ November 9: catalog category filtering uses the original `item_class` values,
+ combines with text/source filters before pagination, and survives sorting.
November 5: [the finite terminal inventory](docs/early-shop-stock.md) lists
all 190 placements in training grounds 950/952/954 and basic shops
1180/1183/1186. The four empty training terminals now carry seven original QL1
diff --git a/server/item_catalog.go b/server/item_catalog.go
@@ -8,6 +8,8 @@ import (
"strings"
)
+var itemClassNames = map[uint32]string{0: "Miscellaneous", 1: "Weapon", 2: "Armor", 3: "Implant", 4: "NPC", 5: "Spirit", 6: "Utility", 7: "Tower"}
+
func itemCatalogProperties(w io.Writer, item ownedItem, definition *gamedata.Item) {
fmt.Fprint(w, "<h2>Catalog properties</h2>")
fmt.Fprintf(w, "<table><tr><th scope='row'>Template</th><td>%d</td></tr><tr><th scope='row'>Template QL</th><td>%d</td></tr><tr><th scope='row'>Attribute QL</th><td>%d</td></tr><tr><th scope='row'>Native object type</th><td>%d</td></tr><tr><th scope='row'>Resource type</th><td>%d</td></tr>", definition.ID, *definition.Quality, item.Quality, definition.HeaderWords[0], definition.RecordType)
@@ -59,7 +61,7 @@ func itemCatalogStatMeaning(item ownedItem, stat, value uint32) string {
case 74:
return "Base price"
case 76:
- return map[uint32]string{0: "Miscellaneous", 1: "Weapon", 2: "Armor", 3: "Implant", 4: "NPC", 5: "Spirit", 6: "Utility", 7: "Tower"}[value]
+ return itemClassNames[value]
case 88, 298:
// Placement bits are local to the weapon, clothing or implant page.
class := item.templateStat(76)
diff --git a/server/item_pages.go b/server/item_pages.go
@@ -119,9 +119,17 @@ func (server *server) itemCatalogPage(w http.ResponseWriter, r *http.Request) {
catalog := strings.ToLower(strings.TrimSpace(r.FormValue("catalog")))
sources := server.itemSources()
sourceFilter := r.FormValue("source")
+ categoryFilter := r.FormValue("category")
+ categories := make(map[uint32]bool)
var matches []*gamedata.Item
for _, definition := range gamedata.ItemTemplates {
+ if definition.Quality != nil {
+ categories[itemStat(definition, 76)] = true
+ }
if definition.Quality != nil && (catalog == "" || strings.Contains(strings.ToLower(adminName(definition.Name)), catalog) || strconv.FormatUint(uint64(definition.ID), 10) == catalog) {
+ if categoryFilter != "" && categoryFilter != strconv.FormatUint(uint64(itemStat(definition, 76)), 10) {
+ continue
+ }
available := sources[itemFamily(definition.ID)]
buyable := slices.ContainsFunc(available, func(source itemSource) bool { return source.kind == "Shop" })
lootable := slices.ContainsFunc(available, func(source itemSource) bool { return source.kind == "Loot" })
@@ -151,6 +159,18 @@ func (server *server) itemCatalogPage(w http.ResponseWriter, r *http.Request) {
}
fmt.Fprintf(w, "<option value='%s'%s>%s</option>", option.value, selected, option.label)
}
+ fmt.Fprint(w, "</select></label> <label>Category <select name='category'><option value=''>All</option>")
+ for _, category := range slices.Sorted(maps.Keys(categories)) {
+ name := itemClassNames[category]
+ if name == "" {
+ name = fmt.Sprintf("Unknown class %d", category)
+ }
+ selected := ""
+ if categoryFilter == strconv.FormatUint(uint64(category), 10) {
+ selected = " selected"
+ }
+ fmt.Fprintf(w, "<option value='%d'%s>%s</option>", category, selected, html.EscapeString(name))
+ }
fmt.Fprint(w, "</select></label> <button>Filter</button> <a href='admin/items/catalog'>Clear filter</a></form>")
fmt.Fprint(w, "<p>Loot chances are per independent roll at the sources listed on each item page. They apply to the offered QLs, not every QL in the family. No configured drop means no current server rule; it does not establish historical loot eligibility.</p>")
var entries []adminTableRow
diff --git a/server/item_sources_test.go b/server/item_sources_test.go
@@ -89,6 +89,31 @@ func TestItemCatalogLootFilterIncludesShopAndLootOnlyFamilies(t *testing.T) {
}
}
+func TestItemCatalogCategoryCombinesWithNameAndSource(t *testing.T) {
+ handler := adminTestHandler(newTestServer(t))
+ for _, scenario := range []struct {
+ template, category, source, label string
+ found bool
+ }{
+ {"123742", "1", "loot", "Weapon", true},
+ {"123742", "2", "loot", "Armor", false},
+ {"70562", "2", "shops", "Armor", true},
+ {"85595", "2", "loot", "Armor", true},
+ {"136626", "0", "loot", "Miscellaneous", true},
+ {"95577", "0", "loot", "Miscellaneous", false},
+ } {
+ page := httptest.NewRecorder()
+ handler.ServeHTTP(page, httptest.NewRequest("GET", "/admin/items/catalog?catalog="+scenario.template+"&category="+scenario.category+"&source="+scenario.source, nil))
+
+ if page.Code != 200 || strings.Contains(page.Body.String(), "value='"+scenario.template+"'>Create") != scenario.found {
+ t.Fatal("combined category/name/source filter returned the wrong item", scenario)
+ }
+ if !strings.Contains(page.Body.String(), "<option value='"+scenario.category+"' selected>"+scenario.label+"</option>") || !strings.Contains(page.Body.String(), "category="+scenario.category+"&") {
+ t.Fatal("category selection or sorting link lost the active filter", scenario)
+ }
+ }
+}
+
func TestShopSourceMapUsesOutdoorEntrancesAndLocationLinks(t *testing.T) {
world := newTestServer(t)
machines := gamedata.ShopMachines