feat: implement entitling of weapons

This commit is contained in:
Sainan 2024-06-16 20:08:38 +02:00
parent b22618d43d
commit 5fc3b748a1
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
interface INameWeaponRequest {
ItemName: string;
}
export const nameWeaponController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
const body = getJSONfromString(req.body.toString()) as INameWeaponRequest;
const item = inventory[req.query.Category as string as TEquipmentKey].find(
item => item._id.toString() == (req.query.ItemId as string)
)!;
item.ItemName = body.ItemName;
await inventory.save();
res.json({
InventoryChanges: await updateCurrency(15, true, accountId)
});
};

View File

@ -55,6 +55,7 @@ import { getGuildDojoController } from "@/src/controllers/api/getGuildDojoContro
import { syndicateSacrificeController } from "../controllers/api/syndicateSacrificeController";
import { startDojoRecipeController } from "@/src/controllers/api/startDojoRecipeController";
import { queueDojoComponentDestructionController } from "@/src/controllers/api/queueDojoComponentDestructionController";
import { nameWeaponController } from "@/src/controllers/api/nameWeaponController";
const apiRouter = express.Router();
@ -120,5 +121,6 @@ apiRouter.post("/upgrades.php", upgradesController);
apiRouter.post("/guildTech.php", guildTechController);
apiRouter.post("/syndicateSacrifice.php", syndicateSacrificeController);
apiRouter.post("/startDojoRecipe.php", startDojoRecipeController);
apiRouter.post("/nameWeapon.php", nameWeaponController);
export { apiRouter };