返回提交历史
Modified
src/controllers/api/releasePetController.ts
+5
-2
XFEstudio/SpaceNinjaServer
fix: free up inventory slot when consigning pet (#3940)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3940 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
1ddfd078
代码差异
1 个文件
+5
-2
@@ -1,12 +1,13 @@
1
1
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
2
import { getInventory, updateCurrency } from "../../services/inventoryService.ts";
2
import { freeUpSlot, getInventory, updateCurrency } from "../../services/inventoryService.ts";
3
3
import { getAccountIdForRequest } from "../../services/loginService.ts";
4
4
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
5
5
import type { RequestHandler } from "express";
6
import { InventorySlot } from "../../types/inventoryTypes/inventoryTypes.ts";
6
7
7
8
export const releasePetController: RequestHandler = async (req, res) => {
8
9
const accountId = await getAccountIdForRequest(req);
9
const inventory = await getInventory(accountId, "RegularCredits KubrowPets PendingRecipes");
10
const inventory = await getInventory(accountId, "RegularCredits KubrowPets PendingRecipes SentinelBin");
10
11
const payload = getJSONfromString<IReleasePetRequest>(String(req.body));
11
12
12
13
const cost = payload.recipeName == "/Lotus/Types/Game/KubrowPet/ReleasePetRecipe" ? 25000 : 0;
@@ -15,6 +16,8 @@ export const releasePetController: RequestHandler = async (req, res) => {
15
16
inventoryChanges.RemovedIdItems = [{ ItemId: { $oid: payload.petId } }];
16
17
inventory.KubrowPets.pull({ _id: payload.petId });
17
18
inventory.PendingRecipes.pull({ KubrowPet: payload.petId });
19
inventoryChanges[InventorySlot.SENTINELS] = { count: -1, platinum: 0, Slots: 1 };
20
freeUpSlot(inventory, InventorySlot.SENTINELS);
18
21
19
22
await inventory.save();
20
23
res.json({