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

XFESpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/XFESpaceNinjaServer

fix: match ability recipes by name (#3788)

In the latest data, the paths were changed, so a full match isn't possible anymore. Closes #3783 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3788 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

7bef3f07
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

2 个文件 +20 -11
Modified src/controllers/api/upgradesController.ts +20 -7
@@ -5,7 +5,6 @@ import type { ArtifactPolarity, IAbilityOverride } from "../../types/inventoryTy
5 5 import type { IInventoryClient, IMiscItem } from "../../types/inventoryTypes/inventoryTypes.ts";
6 6 import { getAccountForRequest } from "../../services/loginService.ts";
7 7 import { addMiscItems, addMods, addRecipes, getInventory, updateCurrency } from "../../services/inventoryService.ts";
8 import { getRecipeByResult } from "../../services/itemDataService.ts";
9 8 import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
10 9 import { addInfestedFoundryXP, applyCheatsToInfestedFoundry } from "../../services/infestedFoundryService.ts";
11 10 import { sendWsBroadcastTo } from "../../services/wsService.ts";
@@ -13,6 +12,7 @@ import type { IEquipmentDatabase } from "../../types/equipmentTypes.ts";
13 12 import { EquipmentFeatures } from "../../types/equipmentTypes.ts";
14 13 import { Types } from "mongoose";
15 14 import gameToBuildVersion from "../../constants/gameToBuildVersion.ts";
15 import { ExportRecipes } from "warframe-public-export-plus";
16 16
17 17 export const upgradesController: RequestHandler = async (req, res) => {
18 18 const account = await getAccountForRequest(req);
@@ -195,14 +195,27 @@ export const upgradesController: RequestHandler = async (req, res) => {
195 195 Index: operation.PolarizeSlot
196 196 };
197 197
198 const recipe = getRecipeByResult(operation.UpgradeRequirement)!;
199 for (const ingredient of recipe.ingredients) {
200 totalPercentagePointsConsumed += ingredient.ItemCount / 10;
201 if (!inventory.infiniteHelminthMaterials) {
202 inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType)!.Count -=
203 ingredient.ItemCount;
198 const abilityName = operation.UpgradeRequirement.split("/").pop();
199 let recipeFound = false;
200 for (const recipe of Object.values(ExportRecipes)) {
201 if (recipe.resultType.endsWith(`/${abilityName}`)) {
202 recipeFound = true;
203 for (const ingredient of recipe.ingredients) {
204 totalPercentagePointsConsumed += ingredient.ItemCount / 10;
205 if (!inventory.infiniteHelminthMaterials) {
206 inventory.InfestedFoundry!.Resources!.find(
207 x => x.ItemType == ingredient.ItemType
208 )!.Count -= ingredient.ItemCount;
209 }
210 }
211 break;
204 212 }
205 213 }
214 if (!recipeFound) {
215 console.warn(
216 `could not find recipe for ${operation.UpgradeRequirement}; helminth resources won't be charged`
217 );
218 }
206 219 }
207 220
208 221 for (const entry of operation.PolarityRemap) {
Modified src/services/itemDataService.ts +0 -4
@@ -1071,10 +1071,6 @@ export const getSyndicate = (tag: string, buildLabel: string | undefined): ISynd
1071 1071 return ExportSyndicates[tag];
1072 1072 };
1073 1073
1074 export const getRecipeByResult = (resultType: string): IRecipe | undefined => {
1075 return Object.values(ExportRecipes).find(x => x.resultType == resultType);
1076 };
1077
1078 1074 export const getItemCategoryByUniqueName = (uniqueName: string): string | undefined => {
1079 1075 if (uniqueName in ExportCustoms) {
1080 1076 return ExportCustoms[uniqueName].productCategory;