forked from OpenWF/SpaceNinjaServer
		
	fix: being unable to add Grimoire (#285)
Co-authored-by: Sainan <Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									d123458957
								
							
						
					
					
						commit
						e660e20c87
					
				
							
								
								
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@ -13,7 +13,7 @@
 | 
			
		||||
        "express": "^5.0.0-beta.3",
 | 
			
		||||
        "mongoose": "^8.1.1",
 | 
			
		||||
        "warframe-items": "^1.1262.74",
 | 
			
		||||
        "warframe-public-export-plus": "^0.1.0",
 | 
			
		||||
        "warframe-public-export-plus": "^0.2.2",
 | 
			
		||||
        "warframe-riven-info": "^0.1.0",
 | 
			
		||||
        "winston": "^3.11.0",
 | 
			
		||||
        "winston-daily-rotate-file": "^4.7.1"
 | 
			
		||||
@ -3895,9 +3895,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/warframe-public-export-plus": {
 | 
			
		||||
      "version": "0.1.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.1.0.tgz",
 | 
			
		||||
      "integrity": "sha512-a76Be2pwPjKrin67zMux5L9U6zt9bhEtyy723tM2czGGcOZYWp1XdCZY684q3zPytWS0SmEia0C/h/4EiadBnQ=="
 | 
			
		||||
      "version": "0.2.2",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.2.2.tgz",
 | 
			
		||||
      "integrity": "sha512-PAsiyiRDqXcsUwZTweihwrSksd+GT3USrbHwS/TrJUC3TqLS0Ng24OfefFKPWOmPfMxDbdkg2zV39uq72iZ/Yg=="
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/warframe-riven-info": {
 | 
			
		||||
      "version": "0.1.0",
 | 
			
		||||
 | 
			
		||||
@ -17,7 +17,7 @@
 | 
			
		||||
    "express": "^5.0.0-beta.3",
 | 
			
		||||
    "mongoose": "^8.1.1",
 | 
			
		||||
    "warframe-items": "^1.1262.74",
 | 
			
		||||
    "warframe-public-export-plus": "^0.1.0",
 | 
			
		||||
    "warframe-public-export-plus": "^0.2.2",
 | 
			
		||||
    "warframe-riven-info": "^0.1.0",
 | 
			
		||||
    "winston": "^3.11.0",
 | 
			
		||||
    "winston-daily-rotate-file": "^4.7.1"
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
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 { ExportArcanes, ExportWeapons } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
interface ListedItem {
 | 
			
		||||
    uniqueName: string;
 | 
			
		||||
@ -21,15 +21,22 @@ function reduceItems(items: MinItem[]): ListedItem[] {
 | 
			
		||||
 | 
			
		||||
const getItemListsController: RequestHandler = (_req, res) => {
 | 
			
		||||
    const mods = reduceItems(items.filter(item => item.category == "Mods"));
 | 
			
		||||
    for (const arcane of ExportArcanes) {
 | 
			
		||||
    for (const [uniqueName, arcane] of Object.entries(ExportArcanes)) {
 | 
			
		||||
        mods.push({
 | 
			
		||||
            uniqueName: arcane.uniqueName,
 | 
			
		||||
            uniqueName: uniqueName,
 | 
			
		||||
            name: getEnglishString(arcane.name)
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    res.json({
 | 
			
		||||
        warframes: reduceItems(warframes),
 | 
			
		||||
        weapons: reduceItems(weapons.filter(item => item.productCategory != "OperatorAmps" && item.totalDamage != 0)),
 | 
			
		||||
        weapons: Object.entries(ExportWeapons)
 | 
			
		||||
            .filter(([_uniqueName, weapon]) => weapon.productCategory !== "OperatorAmps" && weapon.totalDamage !== 0)
 | 
			
		||||
            .map(([uniqueName, weapon]) => {
 | 
			
		||||
                return {
 | 
			
		||||
                    uniqueName,
 | 
			
		||||
                    name: getEnglishString(weapon.name)
 | 
			
		||||
                };
 | 
			
		||||
            }),
 | 
			
		||||
        miscitems: reduceItems(
 | 
			
		||||
            items.filter(
 | 
			
		||||
                item =>
 | 
			
		||||
 | 
			
		||||
@ -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");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,8 +2,7 @@ import { getIndexAfter } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import Items, { Buildable, Category, MinimalItem, Warframe, Weapon } from "warframe-items";
 | 
			
		||||
import badItems from "@/static/json/exclude-mods.json";
 | 
			
		||||
import dict_en from "@/node_modules/warframe-public-export-plus/dict.en.json";
 | 
			
		||||
import exportSuits from "@/node_modules/warframe-public-export-plus/ExportWarframes.json";
 | 
			
		||||
import { dict_en, ExportWarframes, ExportWeapons, IPowersuit } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export type MinWarframe = Omit<Warframe, "patchlogs">;
 | 
			
		||||
export type MinWeapon = Omit<Weapon, "patchlogs">;
 | 
			
		||||
@ -19,15 +18,15 @@ 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;
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
export type WeaponTypeInternal = "LongGuns" | "Pistols" | "Melee";
 | 
			
		||||
export type WeaponTypeInternal =
 | 
			
		||||
    | "LongGuns"
 | 
			
		||||
    | "Pistols"
 | 
			
		||||
    | "Melee"
 | 
			
		||||
    | "SpaceMelee"
 | 
			
		||||
    | "SpaceGuns"
 | 
			
		||||
    | "SentinelWeapons"
 | 
			
		||||
    | "OperatorAmps"
 | 
			
		||||
    | "SpecialItems";
 | 
			
		||||
 | 
			
		||||
export const items: MinItem[] = Array.from(new Items({ category: ["All"] }) as MinimalItem[]).map(item => {
 | 
			
		||||
    const next = { ...item };
 | 
			
		||||
@ -35,8 +34,8 @@ export const items: MinItem[] = Array.from(new Items({ category: ["All"] }) as M
 | 
			
		||||
    return next;
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
export const getWeaponType = (weaponName: string) => {
 | 
			
		||||
    const weaponInfo = weapons.find(i => i.uniqueName === weaponName);
 | 
			
		||||
export const getWeaponType = (weaponName: string): WeaponTypeInternal => {
 | 
			
		||||
    const weaponInfo = ExportWeapons[weaponName];
 | 
			
		||||
 | 
			
		||||
    if (!weaponInfo) {
 | 
			
		||||
        throw new Error(`unknown weapon ${weaponName}`);
 | 
			
		||||
@ -47,7 +46,7 @@ export const getWeaponType = (weaponName: string) => {
 | 
			
		||||
        throw new Error(`${weaponName} doesn't quack like a weapon`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const weaponType = weaponInfo.productCategory as WeaponTypeInternal;
 | 
			
		||||
    const weaponType = weaponInfo.productCategory;
 | 
			
		||||
 | 
			
		||||
    if (!weaponType) {
 | 
			
		||||
        logger.error(`unknown weapon category for item ${weaponName}`);
 | 
			
		||||
@ -136,9 +135,8 @@ export const getItemCategoryByUniqueName = (uniqueName: string) => {
 | 
			
		||||
    return category;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getSuitByUniqueName = (uniqueName: string) => {
 | 
			
		||||
    const suit = exportSuits.find(suit => suit.uniqueName === uniqueName);
 | 
			
		||||
    return suit;
 | 
			
		||||
export const getSuitByUniqueName = (uniqueName: string): IPowersuit | undefined => {
 | 
			
		||||
    return ExportWarframes[uniqueName];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getItemByUniqueName = (uniqueName: string) => {
 | 
			
		||||
@ -151,6 +149,6 @@ export const getItemByName = (name: string) => {
 | 
			
		||||
    return item;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getEnglishString = (key: string) => {
 | 
			
		||||
    return dict_en[key as keyof typeof dict_en] ?? key;
 | 
			
		||||
export const getEnglishString = (key: string): string => {
 | 
			
		||||
    return dict_en[key] ?? key;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -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") {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user