返回提交历史
Modified
src/services/itemDataService.ts
+24
-13
XFEstudio/XFESpaceNinjaServer
chore: improve getItemCategoryByUniqueName (#2130)
unused function, but might as well make it at least half decent Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2130 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
b7c47b91
代码差异
1 个文件
+24
-13
@@ -1,5 +1,4 @@
1
1
import { IKeyChainRequest } from "@/src/types/requestTypes";
2
import { getIndexAfter } from "@/src/helpers/stringHelpers";
3
2
import {
4
3
dict_de,
5
4
dict_en,
@@ -53,20 +52,32 @@ export const getRecipeByResult = (resultType: string): IRecipe | undefined => {
53
52
return Object.values(ExportRecipes).find(x => x.resultType == resultType);
54
53
};
55
54
56
export const getItemCategoryByUniqueName = (uniqueName: string): string => {
57
//Lotus/Types/Items/MiscItems/PolymerBundle
58
59
let splitWord = "Items/";
60
if (!uniqueName.includes("/Items/")) {
61
splitWord = "/Types/";
55
export const getItemCategoryByUniqueName = (uniqueName: string): string | undefined => {
56
if (uniqueName in ExportCustoms) {
57
return ExportCustoms[uniqueName].productCategory;
62
58
}
63
64
const index = getIndexAfter(uniqueName, splitWord);
65
if (index === -1) {
66
throw new Error(`error parsing item category ${uniqueName}`);
59
if (uniqueName in ExportDrones) {
60
return "Drones";
67
61
}
68
const category = uniqueName.substring(index).split("/")[0];
69
return category;
62
if (uniqueName in ExportKeys) {
63
return "LevelKeys";
64
}
65
if (uniqueName in ExportGear) {
66
return "Consumables";
67
}
68
if (uniqueName in ExportResources) {
69
return ExportResources[uniqueName].productCategory;
70
}
71
if (uniqueName in ExportSentinels) {
72
return ExportSentinels[uniqueName].productCategory;
73
}
74
if (uniqueName in ExportWarframes) {
75
return ExportWarframes[uniqueName].productCategory;
76
}
77
if (uniqueName in ExportWeapons) {
78
return ExportWeapons[uniqueName].productCategory;
79
}
80
return undefined;
70
81
};
71
82
72
83
export const getItemName = (uniqueName: string): string | undefined => {