feat: implement selling of recipes (#328)
This commit is contained in:
parent
be5a271609
commit
1bbdfb030c
@ -1,7 +1,7 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { ISellRequest } from "@/src/types/sellTypes";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { getInventory, addMods } from "@/src/services/inventoryService";
|
||||
import { getInventory, addMods, addRecipes } from "@/src/services/inventoryService";
|
||||
|
||||
export const sellController: RequestHandler = async (req, res) => {
|
||||
const payload: ISellRequest = JSON.parse(req.body.toString());
|
||||
@ -39,8 +39,14 @@ export const sellController: RequestHandler = async (req, res) => {
|
||||
});
|
||||
}
|
||||
if (payload.Items.Recipes) {
|
||||
// TODO
|
||||
// Note: sellItem.String is a uniqueName in this case
|
||||
const recipeChanges = [];
|
||||
for (const sellItem of payload.Items.Recipes) {
|
||||
recipeChanges.push({
|
||||
ItemType: sellItem.String,
|
||||
ItemCount: sellItem.Count * -1
|
||||
});
|
||||
}
|
||||
addRecipes(inventory, recipeChanges);
|
||||
}
|
||||
if (payload.Items.Upgrades) {
|
||||
payload.Items.Upgrades.forEach(sellItem => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user