返回提交历史
Modified
src/controllers/api/inventorySlotsController.ts
+10
-3
Modified
src/types/requestTypes.ts
+0
-3
XFEstudio/SpaceNinjaServer
fix: purchasing SuitBin slots (#1026)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1026
9893fa95
代码差异
2 个文件
+10
-6
@@ -3,6 +3,7 @@ import { getInventory, updateCurrency } from "@/src/services/inventoryService";
3
3
import { RequestHandler } from "express";
4
4
import { updateSlots } from "@/src/services/inventoryService";
5
5
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
6
import { logger } from "@/src/utils/logger";
6
7
7
8
/*
8
9
loadout slots are additionally purchased slots only
@@ -20,14 +21,20 @@ import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
20
21
21
22
export const inventorySlotsController: RequestHandler = async (req, res) => {
22
23
const accountId = await getAccountIdForRequest(req);
23
//const body = JSON.parse(req.body as string) as IInventorySlotsRequest;
24
const body = JSON.parse(req.body as string) as IInventorySlotsRequest;
24
25
25
//TODO: check which slot was purchased because pvpBonus is also possible
26
if (body.Bin != InventorySlot.SUITS && body.Bin != InventorySlot.PVE_LOADOUTS) {
27
logger.warn(`unexpected slot purchase of type ${body.Bin}, account may be overcharged`);
28
}
26
29
27
30
const inventory = await getInventory(accountId);
28
31
const currencyChanges = updateCurrency(inventory, 20, true);
29
updateSlots(inventory, InventorySlot.PVE_LOADOUTS, 1, 1);
32
updateSlots(inventory, body.Bin, 1, 1);
30
33
await inventory.save();
31
34
32
35
res.json({ InventoryChanges: currencyChanges });
33
36
};
37
38
interface IInventorySlotsRequest {
39
Bin: InventorySlot;
40
}
@@ -121,9 +121,6 @@ export interface IRewardInfo {
121
121
122
122
export type IMissionStatus = "GS_SUCCESS" | "GS_FAILURE" | "GS_DUMPED" | "GS_QUIT" | "GS_INTERRUPTED";
123
123
124
export interface IInventorySlotsRequest {
125
Bin: "PveBonusLoadoutBin";
126
}
127
124
export interface IUpdateGlyphRequest {
128
125
AvatarImageType: string;
129
126
AvatarImage: string;