返回提交历史
Modified
src/controllers/api/giveStartingGearController.ts
+19
-1
Modified
src/routes/api.ts
+3
-2
Modified
src/services/inventoryService.ts
+4
-3
XFEstudio/SpaceNinjaServer
feat: get endpoint for giveStartingGear (#2997)
Closes #2995 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2997 Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
8ceab34f
代码差异
3 个文件
+26
-6
@@ -4,7 +4,7 @@ import { getAccountIdForRequest } from "../../services/loginService.ts";
4
4
import type { TPartialStartingGear } from "../../types/inventoryTypes/inventoryTypes.ts";
5
5
import type { RequestHandler } from "express";
6
6
7
export const giveStartingGearController: RequestHandler = async (req, res) => {
7
export const giveStartingGearPostController: RequestHandler = async (req, res) => {
8
8
const accountId = await getAccountIdForRequest(req);
9
9
const startingGear = getJSONfromString<TPartialStartingGear>(String(req.body));
10
10
const inventory = await getInventory(accountId);
@@ -14,3 +14,21 @@ export const giveStartingGearController: RequestHandler = async (req, res) => {
14
14
15
15
res.send(inventoryChanges);
16
16
};
17
18
export const giveStartingGearGetController: RequestHandler = async (req, res) => {
19
const accountId = await getAccountIdForRequest(req);
20
const inventory = await getInventory(accountId);
21
22
const inventoryChanges = await addStartingGear(inventory, {
23
Suits: [
24
{
25
ItemType: String(req.query.warframeName),
26
ItemId: { $oid: "0" },
27
Configs: []
28
}
29
]
30
});
31
await inventory.save();
32
33
res.send(inventoryChanges); // Not sure if this is even needed
34
};
@@ -80,7 +80,7 @@ import { giveKeyChainTriggeredItemsController } from "../controllers/api/giveKey
80
80
import { giveKeyChainTriggeredMessageController } from "../controllers/api/giveKeyChainTriggeredMessageController.ts";
81
81
import { giveQuestKeyRewardController } from "../controllers/api/giveQuestKeyRewardController.ts";
82
82
import { giveShipDecoAndLoreFragmentController } from "../controllers/api/giveShipDecoAndLoreFragmentController.ts";
83
import { giveStartingGearController } from "../controllers/api/giveStartingGearController.ts";
83
import { giveStartingGearGetController, giveStartingGearPostController } from "../controllers/api/giveStartingGearController.ts";
84
84
import { guildTechController } from "../controllers/api/guildTechController.ts";
85
85
import { hostSessionController } from "../controllers/api/hostSessionController.ts";
86
86
import { hubBlessingController } from "../controllers/api/hubBlessingController.ts";
@@ -208,6 +208,7 @@ apiRouter.get("/getNewRewardSeed.php", getNewRewardSeedController);
208
208
apiRouter.get("/getPastWeeklyChallenges.php", getPastWeeklyChallengesController)
209
209
apiRouter.get("/getShip.php", getShipController);
210
210
apiRouter.get("/getShipDecos.php", (_req, res) => { res.end(); }); // needed to log in on U22.8
211
apiRouter.get("/giveStartingGear.php", giveStartingGearGetController);
211
212
apiRouter.get("/getVendorInfo.php", getVendorInfoController);
212
213
apiRouter.get("/hub", hubController);
213
214
apiRouter.get("/hubInstances", hubInstancesController);
@@ -297,7 +298,7 @@ apiRouter.post("/giveKeyChainTriggeredItems.php", giveKeyChainTriggeredItemsCont
297
298
apiRouter.post("/giveKeyChainTriggeredMessage.php", giveKeyChainTriggeredMessageController);
298
299
apiRouter.post("/giveQuestKeyReward.php", giveQuestKeyRewardController);
299
300
apiRouter.post("/giveShipDecoAndLoreFragment.php", giveShipDecoAndLoreFragmentController);
300
apiRouter.post("/giveStartingGear.php", giveStartingGearController);
301
apiRouter.post("/giveStartingGear.php", giveStartingGearPostController);
301
302
apiRouter.post("/guildTech.php", guildTechController);
302
303
apiRouter.post("/hostSession.php", hostSessionController);
303
304
apiRouter.post("/hubBlessing.php", hubBlessingController);
@@ -137,18 +137,19 @@ export const createInventory = async (
137
137
138
138
export const addStartingGear = async (
139
139
inventory: TInventoryDatabaseDocument,
140
startingGear?: TPartialStartingGear
140
startingGear?: Partial<TPartialStartingGear>
141
141
): Promise<IInventoryChanges> => {
142
142
if (inventory.ReceivedStartingGear) {
143
143
throw new Error(`account has already received starting gear`);
144
144
}
145
145
inventory.ReceivedStartingGear = true;
146
146
147
const { LongGuns, Pistols, Suits, Melee } = startingGear || {
147
const { LongGuns, Pistols, Suits, Melee } = {
148
148
LongGuns: [{ ItemType: "/Lotus/Weapons/Tenno/Rifle/Rifle" }],
149
149
Pistols: [{ ItemType: "/Lotus/Weapons/Tenno/Pistol/Pistol" }],
150
150
Suits: [{ ItemType: "/Lotus/Powersuits/Excalibur/Excalibur" }],
151
Melee: [{ ItemType: "/Lotus/Weapons/Tenno/Melee/LongSword/LongSword" }]
151
Melee: [{ ItemType: "/Lotus/Weapons/Tenno/Melee/LongSword/LongSword" }],
152
...startingGear
152
153
};
153
154
154
155
//TODO: properly merge weapon bin changes it is currently static here