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

feat: VariantFusion (#3655)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3655 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

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

代码差异

1 个文件 +11 -14
Modified src/controllers/api/artifactsController.ts +11 -14
@@ -1,13 +1,10 @@
1 1 import { getJSONfromString } from "../../helpers/stringHelpers.ts";
2 2 import { getAccountForRequest } from "../../services/loginService.ts";
3 3 import type { RequestHandler } from "express";
4 import type {
5 IInventoryClient,
6 IUpgradeClient,
7 IUpgradeFromClient
8 } from "../../types/inventoryTypes/inventoryTypes.ts";
4 import type { IUpgradeClient, IUpgradeFromClient } from "../../types/inventoryTypes/inventoryTypes.ts";
9 5 import {
10 6 addFusionPoints,
7 addMiscItem,
11 8 addMods,
12 9 CurrencyType,
13 10 getInventory,
@@ -33,11 +30,16 @@ export const artifactsController: RequestHandler = async (req, res) => {
33 30 version_compare(account.BuildLabel, gameToBuildVersion["18.18.0"]) >= 0
34 31 ) {
35 32 const safeUpgradeFingerprint = UpgradeFingerprint || '{"lvl":0}';
36 const parsedUpgradeFingerprint = JSON.parse(safeUpgradeFingerprint) as { lvl: number };
33 const parsedUpgradeFingerprint = JSON.parse(safeUpgradeFingerprint) as { lvl: number; variant?: number };
37 34 parsedUpgradeFingerprint.lvl += LevelDiff;
35 if (artifactsData.VariantFusion !== undefined) {
36 parsedUpgradeFingerprint.variant = artifactsData.VariantFusion;
37 addMiscItem(inventory, "/Lotus/Types/Items/MiscItems/FoilModUnlocker", -1);
38 }
38 39 const stringifiedUpgradeFingerprint = JSON.stringify(parsedUpgradeFingerprint);
39 40
40 let itemIndex = Upgrades.findIndex(upgrade => upgrade._id.equals(fromOid(ItemId)));
41 const itemId = fromOid(ItemId);
42 let itemIndex = Upgrades.findIndex(upgrade => upgrade._id.equals(itemId));
41 43
42 44 if (itemIndex !== -1) {
43 45 Upgrades[itemIndex].UpgradeFingerprint = stringifiedUpgradeFingerprint;
@@ -65,13 +67,7 @@ export const artifactsController: RequestHandler = async (req, res) => {
65 67 ]);
66 68 }
67 69
68 const changedInventory = (await inventory.save()).toJSON<IInventoryClient>();
69 const itemId =
70 changedInventory.Upgrades[itemIndex].ItemId.$oid ?? changedInventory.Upgrades[itemIndex].ItemId.$id;
71
72 if (!itemId) {
73 throw new Error("Item Id not found in upgradeMod");
74 }
70 await inventory.save();
75 71
76 72 res.send(itemId);
77 73 } else {
@@ -140,4 +136,5 @@ interface IArtifactsRequest {
140 136 LegendaryFusion?: boolean;
141 137 Fingerprint?: string;
142 138 Consumed?: IUpgradeFromClient[];
139 VariantFusion?: number;
143 140 }