From 7e0780ea5180cc451d450724f05bbde640bd3e74 Mon Sep 17 00:00:00 2001 From: npc0-hue Date: Wed, 23 Sep 2026 16:12:33 +0800 Subject: [PATCH] Fix SCUM gift catalog visibility --- plugins/examples/scum-server-plugin/features/page.ts | 3 +-- .../scum-server-plugin/features/scum-catalog-zh.ts | 11 +++++++++-- plugins/tests/scum-catalog.test.ts | 9 +++++++++ plugins/tests/scum-feature-module.test.ts | 4 ++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/plugins/examples/scum-server-plugin/features/page.ts b/plugins/examples/scum-server-plugin/features/page.ts index 746504b..71013d6 100644 --- a/plugins/examples/scum-server-plugin/features/page.ts +++ b/plugins/examples/scum-server-plugin/features/page.ts @@ -40,7 +40,6 @@ const scumMapBaseLayers: ReadonlyArray = [["ter const scumMapVehicleFilters: ReadonlyArray = [["all", "全部载具"], ["land", "陆地载具"], ["water", "水上载具"], ["air", "飞行类载具"], ["other", "其他载具"]]; const scumFlightVehicleKeys = new Set(["kinglet_duster", "kinglet_mariner", "kinglet_scout"]); const scumGiftCatalogCategories: ReadonlyArray = [["all", "全部目录"], ["hunting", "狩猎"], ["food", "食物"], ["metabolism", "代谢"], ["medical", "医疗"], ["weapons", "武器"], ["crafting", "制作"], ["gear", "装备"], ["fishing", "钓鱼"], ["building", "建筑"], ["tools", "工具"], ["farming", "农业"], ["misc", "其他"], ["vehicle", "载具"], ["animal", "动物"], ["zombie", "丧尸"], ["armed-npc", "NPC"]]; -const scumCatalogPickLimit = 48; const scumMapSize = 4096; const scumSurfaceRefreshMs = 15000; const scumMapZoomMin = 1; @@ -1430,7 +1429,7 @@ function catalogMatches(query: string, kind: string, target: CatalogPickTarget): return scumCatalogEntries.filter((entry) => { const matchesKind = kind === "all" || scumGiftCatalogFilterKey(entry) === kind; return matchesKind && (!search || scumCatalogSearchText(entry).includes(search)); - }).slice(0, scumCatalogPickLimit); + }); } function appendCatalogItem(items: GiftItemDraft[], code: string): GiftItemDraft[] { diff --git a/plugins/examples/scum-server-plugin/features/scum-catalog-zh.ts b/plugins/examples/scum-server-plugin/features/scum-catalog-zh.ts index e9fb869..779b468 100644 --- a/plugins/examples/scum-server-plugin/features/scum-catalog-zh.ts +++ b/plugins/examples/scum-server-plugin/features/scum-catalog-zh.ts @@ -57,7 +57,7 @@ const wordNames: Record = { }; const additionalWordNames: Record = { - activated: "活性炭", alcohol: "酒精", alcoholic: "酒精类", anti: "抗", antibiotic: "抗生素", antimalaria: "抗疟疾", antiparasitic: "抗寄生虫", antipsychotic: "抗精神病", ammunition: "弹药", attachment: "配件", back: "后部", body: "身体", boots: "靴子", box: "盒", bucket: "桶", camp: "营地", charcoal: "木炭", clothes: "服装", component: "组件", crafted: "制作的", crafting: "制作", dirty: "脏污", door: "车门", electrodes: "电极", farming: "农业", feet: "脚部", front: "前部", gear: "装备", gloves: "手套", hiking: "徒步", hood: "引擎盖", inventory: "背包栏", item: "物品", legs: "腿部", light: "轻型", normal: "普通", other: "其他", parts: "零件", rear: "后部", rubber: "橡胶", security: "安全", seat: "座椅", side: "侧面", single: "单发", skin: "皮肤", spare: "备用", standing: "立式", steel: "钢制", tactical: "战术", top: "顶部", trap: "陷阱", underwear: "内衣", weapon: "武器", wheel: "车轮" + activated: "活性炭", alcohol: "酒精", alcoholic: "酒精类", anti: "抗", antibiotic: "抗生素", antimalaria: "抗疟疾", antiparasitic: "抗寄生虫", antipsychotic: "抗精神病", ammunition: "弹药", attachment: "配件", back: "后部", big: "大", body: "身体", boots: "靴子", box: "盒", bucket: "桶", camp: "营地", charcoal: "木炭", clothes: "服装", component: "组件", crafted: "制作的", crafting: "制作", dirty: "脏污", door: "车门", electrodes: "电极", farming: "农业", feet: "脚部", front: "前部", gear: "装备", gloves: "手套", hiking: "徒步", hood: "引擎盖", inventory: "背包栏", item: "物品", legs: "腿部", light: "轻型", military: "军用", normal: "普通", other: "其他", parts: "零件", rear: "后部", rubber: "橡胶", security: "安全", seat: "座椅", side: "侧面", single: "单发", skin: "皮肤", spare: "备用", standing: "立式", steel: "钢制", tactical: "战术", top: "顶部", trap: "陷阱", underwear: "内衣", weapon: "武器", wheel: "车轮" }; const phraseNames: Array = [ @@ -94,7 +94,14 @@ export function scumCatalogNameZh(entry: ScumCatalogEntry): string { export function scumCatalogDisplayName(entry: ScumCatalogEntry): string { return scumCatalogNameZh(entry); } export function scumCatalogSearchText(entry: ScumCatalogEntry): string { - return [scumCatalogNameZh(entry), entry.name, entry.code, entry.command].join(" ").toLowerCase(); + const codeWords = entry.code.replace(/[_-]+/g, " "); + const aliases = [ + /(?:big|large).*backpack|backpack.*(?:big|large)/i.test(codeWords) ? "大背包" : "", + /military.*backpack|backpack.*military/i.test(codeWords) ? "军用背包" : "", + /military.*helmet|helmet.*military/i.test(codeWords) ? "军用头盔" : "" + ].filter(Boolean); + const source = [scumCatalogNameZh(entry), entry.name, entry.code, codeWords, entry.command, ...aliases].join(" ").toLowerCase(); + return source + " " + source.replace(/[\s._-]+/g, ""); } function usableName(entry: ScumCatalogEntry): string { diff --git a/plugins/tests/scum-catalog.test.ts b/plugins/tests/scum-catalog.test.ts index 864e304..ccb2974 100644 --- a/plugins/tests/scum-catalog.test.ts +++ b/plugins/tests/scum-catalog.test.ts @@ -10,6 +10,15 @@ const pluginRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../examples const catalogSource = readFileSync(join(pluginRoot, "features/scum-catalog.ts"), "utf8"); describe("scum catalog icons", () => { + it("includes the backpack and military helmet entries users expect", () => { + const byCode = new Map(scumCatalogEntries.map((entry) => [entry.code, entry])); + expect(byCode.get("Improvised_Backpack_Big")).toMatchObject({ kind: "item" }); + expect(byCode.get("Military_Backpack_01_01")).toMatchObject({ kind: "item" }); + expect(byCode.get("Military_Helmet_01_01")).toMatchObject({ kind: "item" }); + expect(byCode.get("Improvised_Backpack_Big")?.icon).toContain("backpacks/"); + expect(byCode.get("Military_Helmet_01_01")?.icon).toContain("head armor/"); + }); + it("resolves icons on demand instead of importing each icon as its own module", () => { expect(catalogSource).not.toContain("import.meta.glob"); expect(scumCatalogIconUrl("npcs/zombie11.webp")).toContain("zombie11.webp"); diff --git a/plugins/tests/scum-feature-module.test.ts b/plugins/tests/scum-feature-module.test.ts index 2478968..859f6f8 100644 --- a/plugins/tests/scum-feature-module.test.ts +++ b/plugins/tests/scum-feature-module.test.ts @@ -346,9 +346,13 @@ describe("SCUM plugin feature module", () => { it("shows Chinese catalog names and searches through the translated name", () => { const aloe = scumCatalogEntries.find((item) => item.code === "Aloe_Vera")!; const vehicle = scumCatalogEntries.find((item) => item.code === "BPC_Laika")!; + const bigBackpack = scumCatalogEntries.find((item) => item.code === "Improvised_Backpack_Big")!; + const militaryHelmet = scumCatalogEntries.find((item) => item.code === "Military_Helmet_01_01")!; expect(scumCatalogDisplayName(aloe)).toBe("芦荟"); expect(scumCatalogDisplayName(vehicle)).toBe("莱卡"); expect(scumCatalogSearchText(aloe)).toContain("芦荟"); + expect(scumCatalogSearchText(bigBackpack)).toContain("大背包"); + expect(scumCatalogSearchText(militaryHelmet)).toContain("军用头盔"); }); it("uses catalog spawn commands for mixed gift contents", async () => {