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

chore: use MongooseDocumentArray.id instead of .find where possible (#813)

16c2b8f8
Sainan <sainan@calamity.inc>
提交于

代码差异

5 个文件 +9 -9
Modified src/controllers/api/arcaneCommonController.ts +1 -1
@@ -8,7 +8,7 @@ export const arcaneCommonController: RequestHandler = async (req, res) => {
8 8 const accountId = await getAccountIdForRequest(req);
9 9 const json = getJSONfromString(String(req.body)) as IArcaneCommonRequest;
10 10 const inventory = await getInventory(accountId);
11 const upgrade = inventory.Upgrades.find(x => x._id!.toString() == json.arcane.ItemId.$oid);
11 const upgrade = inventory.Upgrades.id(json.arcane.ItemId.$oid);
12 12 if (json.newRank == -1) {
13 13 // Break down request?
14 14 if (!upgrade || !upgrade.UpgradeFingerprint) {
Modified src/controllers/api/infestedFoundryController.ts +2 -2
@@ -229,7 +229,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
229 229 resource.Count -= ingredient.ItemCount;
230 230 }
231 231 }
232 const suit = inventory.Suits.find(x => x._id.toString() == request.SuitId.$oid)!;
232 const suit = inventory.Suits.id(request.SuitId.$oid)!;
233 233 inventory.Suits.pull(suit);
234 234 const consumedSuit: IConsumedSuit = { s: suit.ItemType };
235 235 if (suit.Configs && suit.Configs[0] && suit.Configs[0].pricol) {
@@ -285,7 +285,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
285 285 case "u": {
286 286 const request = getJSONfromString(String(req.body)) as IHelminthInvigorationRequest;
287 287 const inventory = await getInventory(accountId);
288 const suit = inventory.Suits.find(x => x._id.toString() == request.SuitId.$oid)!;
288 const suit = inventory.Suits.id(request.SuitId.$oid)!;
289 289 const upgradesExpiry = new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000);
290 290 suit.OffensiveUpgrade = request.OffensiveUpgradeType;
291 291 suit.DefensiveUpgrade = request.DefensiveUpgradeType;
Modified src/controllers/api/startRecipeController.ts +4 -4
@@ -64,19 +64,19 @@ export const startRecipeController: RequestHandler = async (req, res) => {
64 64 break;
65 65 }
66 66 if (type == "/Lotus/Types/Game/PowerSuits/PlayerPowerSuit") {
67 const item = inventory.Suits.find(x => x._id.toString() == oid)!;
67 const item = inventory.Suits.id(oid)!;
68 68 spectreLoadout.Suits = item.ItemType;
69 69 } else if (type == "/Lotus/Weapons/Tenno/Pistol/LotusPistol") {
70 const item = inventory.Pistols.find(x => x._id.toString() == oid)!;
70 const item = inventory.Pistols.id(oid)!;
71 71 spectreLoadout.Pistols = item.ItemType;
72 72 spectreLoadout.PistolsModularParts = item.ModularParts;
73 73 } else if (type == "/Lotus/Weapons/Tenno/LotusLongGun") {
74 const item = inventory.LongGuns.find(x => x._id.toString() == oid)!;
74 const item = inventory.LongGuns.id(oid)!;
75 75 spectreLoadout.LongGuns = item.ItemType;
76 76 spectreLoadout.LongGunsModularParts = item.ModularParts;
77 77 } else {
78 78 console.assert(type == "/Lotus/Types/Game/LotusMeleeWeapon");
79 const item = inventory.Melee.find(x => x._id.toString() == oid)!;
79 const item = inventory.Melee.id(oid)!;
80 80 spectreLoadout.Melee = item.ItemType;
81 81 spectreLoadout.MeleeModularParts = item.ModularParts;
82 82 }
Modified src/controllers/api/upgradesController.ts +1 -1
@@ -35,7 +35,7 @@ export const upgradesController: RequestHandler = async (req, res) => {
35 35
36 36 if (operation.OperationType == "UOT_ABILITY_OVERRIDE") {
37 37 console.assert(payload.ItemCategory == "Suits");
38 const suit = inventory.Suits.find(x => x._id.toString() == payload.ItemId.$oid)!;
38 const suit = inventory.Suits.id(payload.ItemId.$oid)!;
39 39
40 40 let newAbilityOverride: IAbilityOverride | undefined;
41 41 let totalPercentagePointsConsumed = 0;
Modified src/services/shipCustomizationsService.ts +1 -1
@@ -157,7 +157,7 @@ export const handleSetPlacedDecoInfo = async (accountId: string, req: ISetPlaced
157 157 throw new Error("room not found");
158 158 }
159 159
160 const placedDeco = room.PlacedDecos?.find(x => x._id.toString() == req.DecoId);
160 const placedDeco = room.PlacedDecos?.id(req.DecoId);
161 161 if (!placedDeco) {
162 162 throw new Error("deco not found");
163 163 }