Implement installation of Focus Lenses
Should work correctly, hopefully.
This commit is contained in:
		
							parent
							
								
									07c2fbcadf
								
							
						
					
					
						commit
						44a302b93a
					
				@ -1,7 +1,7 @@
 | 
				
			|||||||
import { RequestHandler } from "express";
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
import { getInventory, addMiscItems, addEquipment } from "@/src/services/inventoryService";
 | 
					import { getInventory, addMiscItems, addEquipment } from "@/src/services/inventoryService";
 | 
				
			||||||
import { IMiscItem, TFocusPolarity } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
					import { IMiscItem, TFocusPolarity, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
import { logger } from "@/src/utils/logger";
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
import { ExportFocusUpgrades } from "warframe-public-export-plus";
 | 
					import { ExportFocusUpgrades } from "warframe-public-export-plus";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -14,6 +14,16 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
            logger.debug(req.body.toString());
 | 
					            logger.debug(req.body.toString());
 | 
				
			||||||
            res.end();
 | 
					            res.end();
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					        case FocusOperation.InstallLens: {
 | 
				
			||||||
 | 
					            const request = JSON.parse(String(req.body)) as ILensInstallRequest;
 | 
				
			||||||
 | 
					            const inventory = await getInventory(accountId);
 | 
				
			||||||
 | 
					            for (const item of inventory[request.ItemCategory]) {
 | 
				
			||||||
 | 
					                if (item._id.toString() == request.ItemId) {
 | 
				
			||||||
 | 
					                    item.FocusLens = request.LensType;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        case FocusOperation.UnlockWay: {
 | 
					        case FocusOperation.UnlockWay: {
 | 
				
			||||||
            const focusType = (JSON.parse(String(req.body)) as IWayRequest).FocusType;
 | 
					            const focusType = (JSON.parse(String(req.body)) as IWayRequest).FocusType;
 | 
				
			||||||
            const focusPolarity = focusTypeToPolarity(focusType);
 | 
					            const focusPolarity = focusTypeToPolarity(focusType);
 | 
				
			||||||
@ -144,6 +154,7 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum FocusOperation {
 | 
					enum FocusOperation {
 | 
				
			||||||
 | 
					    InstallLens = "1",
 | 
				
			||||||
    UnlockWay = "2",
 | 
					    UnlockWay = "2",
 | 
				
			||||||
    UnlockUpgrade = "3",
 | 
					    UnlockUpgrade = "3",
 | 
				
			||||||
    LevelUpUpgrade = "4",
 | 
					    LevelUpUpgrade = "4",
 | 
				
			||||||
@ -186,6 +197,12 @@ interface ISentTrainingAmplifierRequest {
 | 
				
			|||||||
    StartingWeaponType: string;
 | 
					    StartingWeaponType: string;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface ILensInstallRequest {
 | 
				
			||||||
 | 
					    LensType: string;
 | 
				
			||||||
 | 
					    ItemCategory: TEquipmentKey;
 | 
				
			||||||
 | 
					    ItemId: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Works for ways & upgrades
 | 
					// Works for ways & upgrades
 | 
				
			||||||
const focusTypeToPolarity = (type: string): TFocusPolarity => {
 | 
					const focusTypeToPolarity = (type: string): TFocusPolarity => {
 | 
				
			||||||
    return ("AP_" + type.substr(1).split("/")[3].toUpperCase()) as TFocusPolarity;
 | 
					    return ("AP_" + type.substr(1).split("/")[3].toUpperCase()) as TFocusPolarity;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user