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: update slots where addEquipment is used (#1207)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1207

c3a9b42f
Sainan <sainan@calamity.inc>
提交于

代码差异

4 个文件 +45 -5
Modified src/controllers/api/focusController.ts +3 -2
@@ -1,7 +1,7 @@
1 1 import { RequestHandler } from "express";
2 2 import { getAccountIdForRequest } from "@/src/services/loginService";
3 import { getInventory, addMiscItems, addEquipment } from "@/src/services/inventoryService";
4 import { IMiscItem, TFocusPolarity, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
3 import { getInventory, addMiscItems, addEquipment, occupySlot } from "@/src/services/inventoryService";
4 import { IMiscItem, TFocusPolarity, TEquipmentKey, InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
5 5 import { logger } from "@/src/utils/logger";
6 6 import { ExportFocusUpgrades } from "warframe-public-export-plus";
7 7 import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
@@ -105,6 +105,7 @@ export const focusController: RequestHandler = async (req, res) => {
105 105 ];
106 106 const inventory = await getInventory(accountId);
107 107 const inventoryChanges = addEquipment(inventory, "OperatorAmps", request.StartingWeaponType, parts);
108 occupySlot(inventory, InventorySlot.AMPS, false);
108 109 await inventory.save();
109 110 res.json((inventoryChanges.OperatorAmps as IEquipmentClient[])[0]);
110 111 break;
Modified src/controllers/api/modularWeaponCraftingController.ts +8 -2
@@ -7,9 +7,12 @@ import {
7 7 updateCurrency,
8 8 addEquipment,
9 9 addMiscItems,
10 applyDefaultUpgrades
10 applyDefaultUpgrades,
11 occupySlot,
12 productCategoryToInventoryBin
11 13 } from "@/src/services/inventoryService";
12 14 import { ExportWeapons } from "warframe-public-export-plus";
15 import { IInventoryChanges } from "@/src/types/purchaseTypes";
13 16
14 17 const modularWeaponTypes: Record<string, TEquipmentKey> = {
15 18 "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary": "LongGuns",
@@ -47,7 +50,10 @@ export const modularWeaponCraftingController: RequestHandler = async (req, res)
47 50 const configs = applyDefaultUpgrades(inventory, ExportWeapons[data.Parts[0]]?.defaultUpgrades);
48 51
49 52 // Give weapon
50 const inventoryChanges = addEquipment(inventory, category, data.WeaponType, data.Parts, {}, { Configs: configs });
53 const inventoryChanges: IInventoryChanges = {
54 ...addEquipment(inventory, category, data.WeaponType, data.Parts, {}, { Configs: configs }),
55 ...occupySlot(inventory, productCategoryToInventoryBin(category)!, false)
56 };
51 57
52 58 // Remove credits & parts
53 59 const miscItemChanges = [];
Modified src/services/inventoryService.ts +32 -0
@@ -172,6 +172,38 @@ export const getInventory = async (
172 172 return inventory;
173 173 };
174 174
175 export const productCategoryToInventoryBin = (productCategory: string): InventorySlot | undefined => {
176 switch (productCategory) {
177 case "Suits":
178 return InventorySlot.SUITS;
179 case "Pistols":
180 case "LongGuns":
181 case "Melee":
182 return InventorySlot.WEAPONS;
183 case "Sentinels":
184 case "SentinelWeapons":
185 case "KubrowPets":
186 case "MoaPets":
187 return InventorySlot.SENTINELS;
188 case "SpaceSuits":
189 case "Hoverboards":
190 return InventorySlot.SPACESUITS;
191 case "SpaceGuns":
192 case "SpaceMelee":
193 return InventorySlot.SPACEWEAPONS;
194 case "OperatorAmps":
195 return InventorySlot.AMPS;
196 case "CrewShipWeapons":
197 case "CrewShipWeaponSkins":
198 return InventorySlot.RJ_COMPONENT_AND_ARMAMENTS;
199 case "MechSuits":
200 return InventorySlot.MECHSUITS;
201 case "CrewMembers":
202 return InventorySlot.CREWMEMBERS;
203 }
204 return undefined;
205 };
206
175 207 export const occupySlot = (
176 208 inventory: TInventoryDatabaseDocument,
177 209 bin: InventorySlot,
Modified src/types/inventoryTypes/inventoryTypes.ts +2 -1
@@ -459,7 +459,8 @@ export enum InventorySlot {
459 459 PVE_LOADOUTS = "PveBonusLoadoutBin",
460 460 SENTINELS = "SentinelBin",
461 461 AMPS = "OperatorAmpBin",
462 RJ_COMPONENT_AND_ARMAMENTS = "CrewShipSalvageBin"
462 RJ_COMPONENT_AND_ARMAMENTS = "CrewShipSalvageBin",
463 CREWMEMBERS = "CrewMemberBin"
463 464 }
464 465
465 466 export interface ISlots {