subtract platinum
All checks were successful
Build / build (push) Successful in 47s
Build / build (pull_request) Successful in 1m56s

This commit is contained in:
Sainan 2025-05-29 11:18:50 +02:00
parent a92d56d941
commit c577ef3bf2

View File

@ -1,16 +1,20 @@
import { getJSONfromString } from "@/src/helpers/stringHelpers"; import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { getInventory } from "@/src/services/inventoryService"; import { getInventory, updateCurrency } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService"; import { getAccountIdForRequest } from "@/src/services/loginService";
import { RequestHandler } from "express"; import { RequestHandler } from "express";
export const renamePetController: RequestHandler = async (req, res) => { export const renamePetController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req); const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId, "KubrowPets"); const inventory = await getInventory(accountId, "KubrowPets PremiumCredits PremiumCreditsFree");
const data = getJSONfromString<IRenamePetRequest>(String(req.body)); const data = getJSONfromString<IRenamePetRequest>(String(req.body));
const details = inventory.KubrowPets.id(data.petId)!.Details!; const details = inventory.KubrowPets.id(data.petId)!.Details!;
details.Name = data.name; details.Name = data.name;
const currencyChanges = updateCurrency(inventory, 15, true);
await inventory.save(); await inventory.save();
res.json(data); res.json({
...data,
inventoryChanges: currencyChanges
});
}; };
interface IRenamePetRequest { interface IRenamePetRequest {