forked from OpenWF/SpaceNinjaServer
fix: selling consumable/gear items (#639)
This commit is contained in:
parent
8ad979ab11
commit
3a1b407a81
@ -1,7 +1,7 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { ISellRequest } from "@/src/types/sellTypes";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { getInventory, addMods, addRecipes, addMiscItems } from "@/src/services/inventoryService";
|
||||
import { getInventory, addMods, addRecipes, addMiscItems, addConsumables } from "@/src/services/inventoryService";
|
||||
|
||||
export const sellController: RequestHandler = async (req, res) => {
|
||||
const payload = JSON.parse(String(req.body)) as ISellRequest;
|
||||
@ -45,6 +45,16 @@ export const sellController: RequestHandler = async (req, res) => {
|
||||
inventory.Melee.pull({ _id: sellItem.String });
|
||||
});
|
||||
}
|
||||
if (payload.Items.Consumables) {
|
||||
const consumablesChanges = [];
|
||||
for (const sellItem of payload.Items.Consumables) {
|
||||
consumablesChanges.push({
|
||||
ItemType: sellItem.String,
|
||||
ItemCount: sellItem.Count * -1
|
||||
});
|
||||
}
|
||||
addConsumables(inventory, consumablesChanges);
|
||||
}
|
||||
if (payload.Items.Recipes) {
|
||||
const recipeChanges = [];
|
||||
for (const sellItem of payload.Items.Recipes) {
|
||||
|
@ -4,6 +4,7 @@ export interface ISellRequest {
|
||||
LongGuns?: ISellItem[];
|
||||
Pistols?: ISellItem[];
|
||||
Melee?: ISellItem[];
|
||||
Consumables?: ISellItem[];
|
||||
Recipes?: ISellItem[];
|
||||
Upgrades?: ISellItem[];
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user