feat: changing equipped shawzin/instrument (#762)
This commit is contained in:
		
							parent
							
								
									e8e918ff0c
								
							
						
					
					
						commit
						25459503d1
					
				
							
								
								
									
										17
									
								
								src/controllers/api/setEquippedInstrumentController.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/controllers/api/setEquippedInstrumentController.ts
									
									
									
									
									
										Normal file
									
								
							@ -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;
 | 
			
		||||
}
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
@ -250,7 +250,7 @@ export interface IInventoryResponse {
 | 
			
		||||
    CompletedJobChains: ICompletedJobChain[];
 | 
			
		||||
    SeasonChallengeHistory: ISeasonChallenge[];
 | 
			
		||||
    MoaPets: IEquipmentDatabase[];
 | 
			
		||||
    EquippedInstrument: string;
 | 
			
		||||
    EquippedInstrument?: string;
 | 
			
		||||
    InvasionChainProgress: IInvasionChainProgress[];
 | 
			
		||||
    DataKnives: IEquipmentDatabase[];
 | 
			
		||||
    Motorcycles: IEquipmentDatabase[];
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user