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: Installation of Focus Lenses (#550)

59679c3d
Vampire Kitten <95658710+VampireKitten@users.noreply.github.com>
提交于

代码差异

1 个文件 +30 -1
Modified src/controllers/api/focusController.ts +30 -1
@@ -1,7 +1,7 @@
1 1 import { RequestHandler } from "express";
2 2 import { getAccountIdForRequest } from "@/src/services/loginService";
3 3 import { getInventory, addMiscItems, addEquipment } from "@/src/services/inventoryService";
4 import { IMiscItem, TFocusPolarity } from "@/src/types/inventoryTypes/inventoryTypes";
4 import { IMiscItem, TFocusPolarity, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
5 5 import { logger } from "@/src/utils/logger";
6 6 import { ExportFocusUpgrades } from "warframe-public-export-plus";
7 7
@@ -14,6 +14,28 @@ export const focusController: RequestHandler = async (req, res) => {
14 14 logger.debug(req.body.toString());
15 15 res.end();
16 16 break;
17 case FocusOperation.InstallLens: {
18 const request = JSON.parse(String(req.body)) as ILensInstallRequest;
19 const inventory = await getInventory(accountId);
20 for (const item of inventory[request.Category]) {
21 if (item._id.toString() == request.WeaponId) {
22 item.FocusLens = request.LensType;
23 addMiscItems(inventory, [
24 {
25 ItemType: request.LensType,
26 ItemCount: -1
27 } satisfies IMiscItem
28 ]);
29 break;
30 }
31 }
32 await inventory.save();
33 res.json({
34 weaponId: request.WeaponId,
35 lensType: request.LensType
36 });
37 break;
38 }
17 39 case FocusOperation.UnlockWay: {
18 40 const focusType = (JSON.parse(String(req.body)) as IWayRequest).FocusType;
19 41 const focusPolarity = focusTypeToPolarity(focusType);
@@ -144,6 +166,7 @@ export const focusController: RequestHandler = async (req, res) => {
144 166 };
145 167
146 168 enum FocusOperation {
169 InstallLens = "1",
147 170 UnlockWay = "2",
148 171 UnlockUpgrade = "3",
149 172 LevelUpUpgrade = "4",
@@ -186,6 +209,12 @@ interface ISentTrainingAmplifierRequest {
186 209 StartingWeaponType: string;
187 210 }
188 211
212 interface ILensInstallRequest {
213 LensType: string;
214 Category: TEquipmentKey;
215 WeaponId: string;
216 }
217
189 218 // Works for ways & upgrades
190 219 const focusTypeToPolarity = (type: string): TFocusPolarity => {
191 220 return ("AP_" + type.substr(1).split("/")[3].toUpperCase()) as TFocusPolarity;