XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

fix: being unable to add Grimoire (#285)

Co-authored-by: Sainan <Sainan@users.noreply.github.com>

e660e20c
Sainan <sainan@calamity.gg>
提交于

代码差异

6 个文件 +36 -37
Modified package-lock.json +4 -4
@@ -13,7 +13,7 @@
13 13 "express": "^5.0.0-beta.3",
14 14 "mongoose": "^8.1.1",
15 15 "warframe-items": "^1.1262.74",
16 "warframe-public-export-plus": "^0.1.0",
16 "warframe-public-export-plus": "^0.2.2",
17 17 "warframe-riven-info": "^0.1.0",
18 18 "winston": "^3.11.0",
19 19 "winston-daily-rotate-file": "^4.7.1"
@@ -3895,9 +3895,9 @@
3895 3895 }
3896 3896 },
3897 3897 "node_modules/warframe-public-export-plus": {
3898 "version": "0.1.0",
3899 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.1.0.tgz",
3900 "integrity": "sha512-a76Be2pwPjKrin67zMux5L9U6zt9bhEtyy723tM2czGGcOZYWp1XdCZY684q3zPytWS0SmEia0C/h/4EiadBnQ=="
3898 "version": "0.2.2",
3899 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.2.2.tgz",
3900 "integrity": "sha512-PAsiyiRDqXcsUwZTweihwrSksd+GT3USrbHwS/TrJUC3TqLS0Ng24OfefFKPWOmPfMxDbdkg2zV39uq72iZ/Yg=="
3901 3901 },
3902 3902 "node_modules/warframe-riven-info": {
3903 3903 "version": "0.1.0",
Modified package.json +1 -1
@@ -17,7 +17,7 @@
17 17 "express": "^5.0.0-beta.3",
18 18 "mongoose": "^8.1.1",
19 19 "warframe-items": "^1.1262.74",
20 "warframe-public-export-plus": "^0.1.0",
20 "warframe-public-export-plus": "^0.2.2",
21 21 "warframe-riven-info": "^0.1.0",
22 22 "winston": "^3.11.0",
23 23 "winston-daily-rotate-file": "^4.7.1"
Modified src/controllers/custom/getItemListsController.ts +12 -5
@@ -1,7 +1,7 @@
1 1 import { RequestHandler } from "express";
2 import { MinItem, MinWeapon, warframes, weapons, items, getEnglishString } from "@/src/services/itemDataService";
2 import { MinItem, MinWeapon, warframes, items, getEnglishString } from "@/src/services/itemDataService";
3 3 import badItems from "@/static/json/exclude-mods.json";
4 import ExportArcanes from "@/node_modules/warframe-public-export-plus/ExportArcanes.json";
4 import { ExportArcanes, ExportWeapons } from "warframe-public-export-plus";
5 5
6 6 interface ListedItem {
7 7 uniqueName: string;
@@ -21,15 +21,22 @@ function reduceItems(items: MinItem[]): ListedItem[] {
21 21
22 22 const getItemListsController: RequestHandler = (_req, res) => {
23 23 const mods = reduceItems(items.filter(item => item.category == "Mods"));
24 for (const arcane of ExportArcanes) {
24 for (const [uniqueName, arcane] of Object.entries(ExportArcanes)) {
25 25 mods.push({
26 uniqueName: arcane.uniqueName,
26 uniqueName: uniqueName,
27 27 name: getEnglishString(arcane.name)
28 28 });
29 29 }
30 30 res.json({
31 31 warframes: reduceItems(warframes),
32 weapons: reduceItems(weapons.filter(item => item.productCategory != "OperatorAmps" && item.totalDamage != 0)),
32 weapons: Object.entries(ExportWeapons)
33 .filter(([_uniqueName, weapon]) => weapon.productCategory !== "OperatorAmps" && weapon.totalDamage !== 0)
34 .map(([uniqueName, weapon]) => {
35 return {
36 uniqueName,
37 name: getEnglishString(weapon.name)
38 };
39 }),
33 40 miscitems: reduceItems(
34 41 items.filter(
35 42 item =>
Modified src/helpers/customHelpers/addItemHelpers.ts +1 -6
@@ -1,5 +1,4 @@
1 1 import { isString } from "@/src/helpers/general";
2 import { items } from "@/src/services/itemDataService";
3 2
4 3 export enum ItemType {
5 4 Powersuit = "Powersuit",
@@ -22,13 +21,9 @@ interface IAddItemRequest {
22 21 type: ItemType;
23 22 InternalName: string;
24 23 }
25 export const isInternalItemName = (internalName: string): boolean => {
26 const item = items.find(i => i.uniqueName === internalName);
27 return Boolean(item);
28 };
29 24
30 25 const parseInternalItemName = (internalName: unknown): string => {
31 if (!isString(internalName) || !isInternalItemName(internalName)) {
26 if (!isString(internalName)) {
32 27 throw new Error("incorrect internal name");
33 28 }
34 29
Modified src/services/itemDataService.ts +17 -19
@@ -2,8 +2,7 @@ import { getIndexAfter } from "@/src/helpers/stringHelpers";
2 2 import { logger } from "@/src/utils/logger";
3 3 import Items, { Buildable, Category, MinimalItem, Warframe, Weapon } from "warframe-items";
4 4 import badItems from "@/static/json/exclude-mods.json";
5 import dict_en from "@/node_modules/warframe-public-export-plus/dict.en.json";
6 import exportSuits from "@/node_modules/warframe-public-export-plus/ExportWarframes.json";
5 import { dict_en, ExportWarframes, ExportWeapons, IPowersuit } from "warframe-public-export-plus";
7 6
8 7 export type MinWarframe = Omit<Warframe, "patchlogs">;
9 8 export type MinWeapon = Omit<Weapon, "patchlogs">;
@@ -19,15 +18,15 @@ export const warframes: MinWarframe[] = Array.from(new Items({ category: ["Warfr
19 18 return next;
20 19 });
21 20
22 export const weapons: MinWeapon[] = Array.from(
23 new Items({ category: ["Primary", "Secondary", "Melee"] }) as Weapon[]
24 ).map(item => {
25 const next = { ...item };
26 delete next.patchlogs;
27 return next;
28 });
29
30 export type WeaponTypeInternal = "LongGuns" | "Pistols" | "Melee";
21 export type WeaponTypeInternal =
22 | "LongGuns"
23 | "Pistols"
24 | "Melee"
25 | "SpaceMelee"
26 | "SpaceGuns"
27 | "SentinelWeapons"
28 | "OperatorAmps"
29 | "SpecialItems";
31 30
32 31 export const items: MinItem[] = Array.from(new Items({ category: ["All"] }) as MinimalItem[]).map(item => {
33 32 const next = { ...item };
@@ -35,8 +34,8 @@ export const items: MinItem[] = Array.from(new Items({ category: ["All"] }) as M
35 34 return next;
36 35 });
37 36
38 export const getWeaponType = (weaponName: string) => {
39 const weaponInfo = weapons.find(i => i.uniqueName === weaponName);
37 export const getWeaponType = (weaponName: string): WeaponTypeInternal => {
38 const weaponInfo = ExportWeapons[weaponName];
40 39
41 40 if (!weaponInfo) {
42 41 throw new Error(`unknown weapon ${weaponName}`);
@@ -47,7 +46,7 @@ export const getWeaponType = (weaponName: string) => {
47 46 throw new Error(`${weaponName} doesn't quack like a weapon`);
48 47 }
49 48
50 const weaponType = weaponInfo.productCategory as WeaponTypeInternal;
49 const weaponType = weaponInfo.productCategory;
51 50
52 51 if (!weaponType) {
53 52 logger.error(`unknown weapon category for item ${weaponName}`);
@@ -136,9 +135,8 @@ export const getItemCategoryByUniqueName = (uniqueName: string) => {
136 135 return category;
137 136 };
138 137
139 export const getSuitByUniqueName = (uniqueName: string) => {
140 const suit = exportSuits.find(suit => suit.uniqueName === uniqueName);
141 return suit;
138 export const getSuitByUniqueName = (uniqueName: string): IPowersuit | undefined => {
139 return ExportWarframes[uniqueName];
142 140 };
143 141
144 142 export const getItemByUniqueName = (uniqueName: string) => {
@@ -151,6 +149,6 @@ export const getItemByName = (name: string) => {
151 149 return item;
152 150 };
153 151
154 export const getEnglishString = (key: string) => {
155 return dict_en[key as keyof typeof dict_en] ?? key;
152 export const getEnglishString = (key: string): string => {
153 return dict_en[key] ?? key;
156 154 };
Modified static/webui/script.js +1 -2
@@ -95,8 +95,7 @@ window.itemListPromise = new Promise(resolve => {
95 95 "/Lotus/Weapons/Tenno/Rifle/LotusRifle": { name: "Rifle" },
96 96 "/Lotus/Weapons/Tenno/Shotgun/LotusShotgun": { name: "Shotgun" },
97 97 // Missing in data sources
98 "/Lotus/Upgrades/CosmeticEnhancers/Peculiars/CyoteMod": { name: "Traumatic Peculiar" },
99 "/Lotus/Weapons/Tenno/Grimoire/TnGrimoire": { name: "Grimoire" }
98 "/Lotus/Upgrades/CosmeticEnhancers/Peculiars/CyoteMod": { name: "Traumatic Peculiar" }
100 99 };
101 100 for (const [type, items] of Object.entries(data)) {
102 101 if (type != "badItems") {