From cbcb845c416e67c4393edec8c8b15a1725321d2f Mon Sep 17 00:00:00 2001 From: Sainan Date: Fri, 7 Jun 2024 14:27:55 +0200 Subject: [PATCH] fix: being unable to add Grimoire --- .../custom/getItemListsController.ts | 15 +++++++++++++-- src/helpers/customHelpers/addItemHelpers.ts | 7 +------ src/services/itemDataService.ts | 17 +++++++++-------- static/webui/script.js | 3 +-- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/controllers/custom/getItemListsController.ts b/src/controllers/custom/getItemListsController.ts index ac987565..bbcd8b06 100644 --- a/src/controllers/custom/getItemListsController.ts +++ b/src/controllers/custom/getItemListsController.ts @@ -1,7 +1,8 @@ import { RequestHandler } from "express"; -import { MinItem, MinWeapon, warframes, weapons, items, getEnglishString } from "@/src/services/itemDataService"; +import { MinItem, MinWeapon, warframes, items, getEnglishString } from "@/src/services/itemDataService"; import badItems from "@/static/json/exclude-mods.json"; import ExportArcanes from "@/node_modules/warframe-public-export-plus/ExportArcanes.json"; +import ExportWeapons from "@/node_modules/warframe-public-export-plus/ExportWeapons.json"; interface ListedItem { uniqueName: string; @@ -29,7 +30,17 @@ const getItemListsController: RequestHandler = (_req, res) => { } res.json({ warframes: reduceItems(warframes), - weapons: reduceItems(weapons.filter(item => item.productCategory != "OperatorAmps" && item.totalDamage != 0)), + weapons: Object.entries(ExportWeapons) + .filter( + ([_uniqueName, weapon]: [string, any]) => + weapon.productCategory !== "OperatorAmps" && weapon.totalDamage !== 0 + ) + .map(([uniqueName, weapon]: [string, any]) => { + return { + uniqueName, + name: getEnglishString(weapon.name) + }; + }), miscitems: reduceItems( items.filter( item => diff --git a/src/helpers/customHelpers/addItemHelpers.ts b/src/helpers/customHelpers/addItemHelpers.ts index 2b1f464d..5ce2378f 100644 --- a/src/helpers/customHelpers/addItemHelpers.ts +++ b/src/helpers/customHelpers/addItemHelpers.ts @@ -1,5 +1,4 @@ import { isString } from "@/src/helpers/general"; -import { items } from "@/src/services/itemDataService"; export enum ItemType { Powersuit = "Powersuit", @@ -22,13 +21,9 @@ interface IAddItemRequest { type: ItemType; InternalName: string; } -export const isInternalItemName = (internalName: string): boolean => { - const item = items.find(i => i.uniqueName === internalName); - return Boolean(item); -}; const parseInternalItemName = (internalName: unknown): string => { - if (!isString(internalName) || !isInternalItemName(internalName)) { + if (!isString(internalName)) { throw new Error("incorrect internal name"); } diff --git a/src/services/itemDataService.ts b/src/services/itemDataService.ts index 55ebf31c..5b78bff1 100644 --- a/src/services/itemDataService.ts +++ b/src/services/itemDataService.ts @@ -4,6 +4,7 @@ import Items, { Buildable, Category, MinimalItem, Warframe, Weapon } from "warfr import badItems from "@/static/json/exclude-mods.json"; import dict_en from "@/node_modules/warframe-public-export-plus/dict.en.json"; import ExportWarframes from "@/node_modules/warframe-public-export-plus/ExportWarframes.json"; +import ExportWeapons from "@/node_modules/warframe-public-export-plus/ExportWeapons.json"; export type MinWarframe = Omit; export type MinWeapon = Omit; @@ -19,13 +20,13 @@ export const warframes: MinWarframe[] = Array.from(new Items({ category: ["Warfr return next; }); -export const weapons: MinWeapon[] = Array.from( - new Items({ category: ["Primary", "Secondary", "Melee"] }) as Weapon[] -).map(item => { - const next = { ...item }; - delete next.patchlogs; - return next; -}); +const weapons: MinWeapon[] = Array.from(new Items({ category: ["Primary", "Secondary", "Melee"] }) as Weapon[]).map( + item => { + const next = { ...item }; + delete next.patchlogs; + return next; + } +); export type WeaponTypeInternal = "LongGuns" | "Pistols" | "Melee"; @@ -36,7 +37,7 @@ export const items: MinItem[] = Array.from(new Items({ category: ["All"] }) as M }); export const getWeaponType = (weaponName: string) => { - const weaponInfo = weapons.find(i => i.uniqueName === weaponName); + const weaponInfo = (ExportWeapons as PublicExportPlus.IGenericExport)[weaponName]; if (!weaponInfo) { throw new Error(`unknown weapon ${weaponName}`); diff --git a/static/webui/script.js b/static/webui/script.js index a50e0ab6..6d1e0a52 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -95,8 +95,7 @@ window.itemListPromise = new Promise(resolve => { "/Lotus/Weapons/Tenno/Rifle/LotusRifle": { name: "Rifle" }, "/Lotus/Weapons/Tenno/Shotgun/LotusShotgun": { name: "Shotgun" }, // Missing in data sources - "/Lotus/Upgrades/CosmeticEnhancers/Peculiars/CyoteMod": { name: "Traumatic Peculiar" }, - "/Lotus/Weapons/Tenno/Grimoire/TnGrimoire": { name: "Grimoire" } + "/Lotus/Upgrades/CosmeticEnhancers/Peculiars/CyoteMod": { name: "Traumatic Peculiar" } }; for (const [type, items] of Object.entries(data)) { if (type != "badItems") {