also using `/api/modularWeaponCrafting.php` instead of `/custom/addModularEquipment` for modular equipment Reviewed-on: #1752 Reviewed-by: Sainan <sainan@calamity.inc> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
|
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
import { RequestHandler } from "express";
|
|
|
|
export const releasePetController: RequestHandler = async (req, res) => {
|
|
const accountId = await getAccountIdForRequest(req);
|
|
const inventory = await getInventory(accountId, "RegularCredits KubrowPets");
|
|
const payload = getJSONfromString<IReleasePetRequest>(String(req.body));
|
|
|
|
const inventoryChanges = updateCurrency(
|
|
inventory,
|
|
payload.recipeName == "/Lotus/Types/Game/KubrowPet/ReleasePetRecipe" ? 25000 : 0,
|
|
false
|
|
);
|
|
|
|
inventoryChanges.RemovedIdItems = [{ ItemId: { $oid: payload.petId } }];
|
|
inventory.KubrowPets.pull({ _id: payload.petId });
|
|
|
|
await inventory.save();
|
|
res.json({ inventoryChanges }); // Not a mistake; it's "inventoryChanges" here.
|
|
};
|
|
|
|
interface IReleasePetRequest {
|
|
recipeName: "/Lotus/Types/Game/KubrowPet/ReleasePetRecipe" | "webui";
|
|
petId: string;
|
|
}
|