diff --git a/src/controllers/api/setEquippedInstrumentController.ts b/src/controllers/api/setEquippedInstrumentController.ts new file mode 100644 index 000000000..0781825ab --- /dev/null +++ b/src/controllers/api/setEquippedInstrumentController.ts @@ -0,0 +1,17 @@ +import { RequestHandler } from "express"; +import { getAccountIdForRequest } from "@/src/services/loginService"; +import { getInventory } from "@/src/services/inventoryService"; +import { getJSONfromString } from "@/src/helpers/stringHelpers"; + +export const setEquippedInstrumentController: RequestHandler = async (req, res) => { + const accountId = await getAccountIdForRequest(req); + const inventory = await getInventory(accountId); + const body = getJSONfromString(String(req.body)) as ISetEquippedInstrumentRequest; + inventory.EquippedInstrument = body.Instrument; + await inventory.save(); + res.end(); +}; + +interface ISetEquippedInstrumentRequest { + Instrument: string; +} diff --git a/src/routes/api.ts b/src/routes/api.ts index 2cc428a73..b6e2613ce 100644 --- a/src/routes/api.ts +++ b/src/routes/api.ts @@ -56,6 +56,7 @@ import { sellController } from "@/src/controllers/api/sellController"; import { setActiveQuestController } from "@/src/controllers/api/setActiveQuestController"; import { setActiveShipController } from "@/src/controllers/api/setActiveShipController"; import { setBootLocationController } from "@/src/controllers/api/setBootLocationController"; +import { setEquippedInstrumentController } from "@/src/controllers/api/setEquippedInstrumentController"; import { setPlacedDecoInfoController } from "@/src/controllers/api/setPlacedDecoInfoController"; import { setShipCustomizationsController } from "@/src/controllers/api/setShipCustomizationsController"; import { setShipFavouriteLoadoutController } from "@/src/controllers/api/setShipFavouriteLoadoutController"; @@ -141,6 +142,7 @@ apiRouter.post("/purchase.php", purchaseController); apiRouter.post("/rerollRandomMod.php", rerollRandomModController); apiRouter.post("/saveLoadout.php", saveLoadoutController); apiRouter.post("/sell.php", sellController); +apiRouter.post("/setEquippedInstrument.php", setEquippedInstrumentController); apiRouter.post("/setPlacedDecoInfo.php", setPlacedDecoInfoController); apiRouter.post("/setShipCustomizations.php", setShipCustomizationsController); apiRouter.post("/setShipFavouriteLoadout.php", setShipFavouriteLoadoutController); diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index 89088da2f..dc9e6ef34 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -250,7 +250,7 @@ export interface IInventoryResponse { CompletedJobChains: ICompletedJobChain[]; SeasonChallengeHistory: ISeasonChallenge[]; MoaPets: IEquipmentDatabase[]; - EquippedInstrument: string; + EquippedInstrument?: string; InvasionChainProgress: IInvasionChainProgress[]; DataKnives: IEquipmentDatabase[]; Motorcycles: IEquipmentDatabase[];