chore: use SubdocumentArray.id in some more places
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build / build (18) (push) Successful in 42s
				
			
		
			
				
	
				Build / build (22) (push) Successful in 1m14s
				
			
		
			
				
	
				Build / build (20) (push) Successful in 1m5s
				
			
		
			
				
	
				Build / build (18) (pull_request) Successful in 41s
				
			
		
			
				
	
				Build / build (20) (pull_request) Successful in 1m14s
				
			
		
			
				
	
				Build / build (22) (pull_request) Successful in 1m7s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build / build (18) (push) Successful in 42s
				
			Build / build (22) (push) Successful in 1m14s
				
			Build / build (20) (push) Successful in 1m5s
				
			Build / build (18) (pull_request) Successful in 41s
				
			Build / build (20) (pull_request) Successful in 1m14s
				
			Build / build (22) (pull_request) Successful in 1m7s
				
			This commit is contained in:
		
							parent
							
								
									01f04c287a
								
							
						
					
					
						commit
						535dae40e6
					
				@ -17,7 +17,7 @@ export const evolveWeaponController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
            recipe.ingredients.map(x => ({ ItemType: x.ItemType, ItemCount: x.ItemCount * -1 }))
 | 
					            recipe.ingredients.map(x => ({ ItemType: x.ItemType, ItemCount: x.ItemCount * -1 }))
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!;
 | 
					        const item = inventory[payload.Category].id(req.query.ItemId as string)!;
 | 
				
			||||||
        item.Features ??= 0;
 | 
					        item.Features ??= 0;
 | 
				
			||||||
        item.Features |= EquipmentFeatures.INCARNON_GENESIS;
 | 
					        item.Features |= EquipmentFeatures.INCARNON_GENESIS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -39,7 +39,7 @@ export const evolveWeaponController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!;
 | 
					        const item = inventory[payload.Category].id(req.query.ItemId as string)!;
 | 
				
			||||||
        item.Features! &= ~EquipmentFeatures.INCARNON_GENESIS;
 | 
					        item.Features! &= ~EquipmentFeatures.INCARNON_GENESIS;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        throw new Error(`unexpected evolve weapon action: ${payload.Action}`);
 | 
					        throw new Error(`unexpected evolve weapon action: ${payload.Action}`);
 | 
				
			||||||
 | 
				
			|||||||
@ -18,8 +18,8 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
        case FocusOperation.InstallLens: {
 | 
					        case FocusOperation.InstallLens: {
 | 
				
			||||||
            const request = JSON.parse(String(req.body)) as ILensInstallRequest;
 | 
					            const request = JSON.parse(String(req.body)) as ILensInstallRequest;
 | 
				
			||||||
            const inventory = await getInventory(accountId);
 | 
					            const inventory = await getInventory(accountId);
 | 
				
			||||||
            for (const item of inventory[request.Category]) {
 | 
					            const item = inventory[request.Category].id(request.WeaponId);
 | 
				
			||||||
                if (item._id.toString() == request.WeaponId) {
 | 
					            if (item) {
 | 
				
			||||||
                item.FocusLens = request.LensType;
 | 
					                item.FocusLens = request.LensType;
 | 
				
			||||||
                addMiscItems(inventory, [
 | 
					                addMiscItems(inventory, [
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
@ -27,8 +27,6 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
                        ItemCount: -1
 | 
					                        ItemCount: -1
 | 
				
			||||||
                    } satisfies IMiscItem
 | 
					                    } satisfies IMiscItem
 | 
				
			||||||
                ]);
 | 
					                ]);
 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            await inventory.save();
 | 
					            await inventory.save();
 | 
				
			||||||
            res.json({
 | 
					            res.json({
 | 
				
			||||||
 | 
				
			|||||||
@ -28,7 +28,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
            // shard installation
 | 
					            // shard installation
 | 
				
			||||||
            const request = getJSONfromString<IShardInstallRequest>(String(req.body));
 | 
					            const request = getJSONfromString<IShardInstallRequest>(String(req.body));
 | 
				
			||||||
            const inventory = await getInventory(accountId);
 | 
					            const inventory = await getInventory(accountId);
 | 
				
			||||||
            const suit = inventory.Suits.find(suit => suit._id.toString() == request.SuitId.$oid)!;
 | 
					            const suit = inventory.Suits.id(request.SuitId.$oid)!;
 | 
				
			||||||
            if (!suit.ArchonCrystalUpgrades || suit.ArchonCrystalUpgrades.length != 5) {
 | 
					            if (!suit.ArchonCrystalUpgrades || suit.ArchonCrystalUpgrades.length != 5) {
 | 
				
			||||||
                suit.ArchonCrystalUpgrades = [{}, {}, {}, {}, {}];
 | 
					                suit.ArchonCrystalUpgrades = [{}, {}, {}, {}, {}];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -56,7 +56,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
            // shard removal
 | 
					            // shard removal
 | 
				
			||||||
            const request = getJSONfromString<IShardUninstallRequest>(String(req.body));
 | 
					            const request = getJSONfromString<IShardUninstallRequest>(String(req.body));
 | 
				
			||||||
            const inventory = await getInventory(accountId);
 | 
					            const inventory = await getInventory(accountId);
 | 
				
			||||||
            const suit = inventory.Suits.find(suit => suit._id.toString() == request.SuitId.$oid)!;
 | 
					            const suit = inventory.Suits.id(request.SuitId.$oid)!;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const miscItemChanges: IMiscItem[] = [];
 | 
					            const miscItemChanges: IMiscItem[] = [];
 | 
				
			||||||
            if (suit.ArchonCrystalUpgrades![request.Slot].Color) {
 | 
					            if (suit.ArchonCrystalUpgrades![request.Slot].Color) {
 | 
				
			||||||
 | 
				
			|||||||
@ -12,9 +12,7 @@ export const nameWeaponController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
    const accountId = await getAccountIdForRequest(req);
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
    const inventory = await getInventory(accountId);
 | 
					    const inventory = await getInventory(accountId);
 | 
				
			||||||
    const body = getJSONfromString<INameWeaponRequest>(String(req.body));
 | 
					    const body = getJSONfromString<INameWeaponRequest>(String(req.body));
 | 
				
			||||||
    const item = inventory[req.query.Category as string as TEquipmentKey].find(
 | 
					    const item = inventory[req.query.Category as string as TEquipmentKey].id(req.query.ItemId as string)!;
 | 
				
			||||||
        item => item._id.toString() == (req.query.ItemId as string)
 | 
					 | 
				
			||||||
    )!;
 | 
					 | 
				
			||||||
    if (body.ItemName != "") {
 | 
					    if (body.ItemName != "") {
 | 
				
			||||||
        item.ItemName = body.ItemName;
 | 
					        item.ItemName = body.ItemName;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
 | 
				
			|||||||
@ -9,9 +9,7 @@ export const setWeaponSkillTreeController: RequestHandler = async (req, res) =>
 | 
				
			|||||||
    const inventory = await getInventory(accountId);
 | 
					    const inventory = await getInventory(accountId);
 | 
				
			||||||
    const payload = getJSONfromString<ISetWeaponSkillTreeRequest>(String(req.body));
 | 
					    const payload = getJSONfromString<ISetWeaponSkillTreeRequest>(String(req.body));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const item = inventory[req.query.Category as WeaponTypeInternal].find(
 | 
					    const item = inventory[req.query.Category as WeaponTypeInternal].id(req.query.ItemId as string)!;
 | 
				
			||||||
        item => item._id.toString() == (req.query.ItemId as string)
 | 
					 | 
				
			||||||
    )!;
 | 
					 | 
				
			||||||
    item.SkillTree = payload.SkillTree;
 | 
					    item.SkillTree = payload.SkillTree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await inventory.save();
 | 
					    await inventory.save();
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,7 @@ import { getInventory } from "@/src/services/inventoryService";
 | 
				
			|||||||
export const popArchonCrystalUpgradeController: RequestHandler = async (req, res) => {
 | 
					export const popArchonCrystalUpgradeController: RequestHandler = async (req, res) => {
 | 
				
			||||||
    const accountId = await getAccountIdForRequest(req);
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
    const inventory = await getInventory(accountId);
 | 
					    const inventory = await getInventory(accountId);
 | 
				
			||||||
    const suit = inventory.Suits.find(suit => suit._id.toString() == (req.query.oid as string));
 | 
					    const suit = inventory.Suits.id(req.query.oid as string);
 | 
				
			||||||
    if (suit && suit.ArchonCrystalUpgrades) {
 | 
					    if (suit && suit.ArchonCrystalUpgrades) {
 | 
				
			||||||
        suit.ArchonCrystalUpgrades = suit.ArchonCrystalUpgrades.filter(
 | 
					        suit.ArchonCrystalUpgrades = suit.ArchonCrystalUpgrades.filter(
 | 
				
			||||||
            x => x.UpgradeType != (req.query.type as string)
 | 
					            x => x.UpgradeType != (req.query.type as string)
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,7 @@ import { getInventory } from "@/src/services/inventoryService";
 | 
				
			|||||||
export const pushArchonCrystalUpgradeController: RequestHandler = async (req, res) => {
 | 
					export const pushArchonCrystalUpgradeController: RequestHandler = async (req, res) => {
 | 
				
			||||||
    const accountId = await getAccountIdForRequest(req);
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
    const inventory = await getInventory(accountId);
 | 
					    const inventory = await getInventory(accountId);
 | 
				
			||||||
    const suit = inventory.Suits.find(suit => suit._id.toString() == (req.query.oid as string));
 | 
					    const suit = inventory.Suits.id(req.query.oid as string);
 | 
				
			||||||
    if (suit) {
 | 
					    if (suit) {
 | 
				
			||||||
        suit.ArchonCrystalUpgrades ??= [];
 | 
					        suit.ArchonCrystalUpgrades ??= [];
 | 
				
			||||||
        const count = (req.query.count as number | undefined) ?? 1;
 | 
					        const count = (req.query.count as number | undefined) ?? 1;
 | 
				
			||||||
 | 
				
			|||||||
@ -84,9 +84,7 @@ export const handleInventoryItemConfigChange = async (
 | 
				
			|||||||
                            continue;
 | 
					                            continue;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        const oldLoadoutConfig = loadout[loadoutSlot].find(
 | 
					                        const oldLoadoutConfig = loadout[loadoutSlot].id(loadoutId);
 | 
				
			||||||
                            loadout => loadout._id.toString() === loadoutId
 | 
					 | 
				
			||||||
                        );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        const { ItemId, ...loadoutConfigItemIdRemoved } = loadoutConfig;
 | 
					                        const { ItemId, ...loadoutConfigItemIdRemoved } = loadoutConfig;
 | 
				
			||||||
                        const loadoutConfigDatabase: ILoadoutConfigDatabase = {
 | 
					                        const loadoutConfigDatabase: ILoadoutConfigDatabase = {
 | 
				
			||||||
 | 
				
			|||||||
@ -61,19 +61,17 @@ export const handleSetShipDecorations = async (
 | 
				
			|||||||
    if (placedDecoration.MoveId) {
 | 
					    if (placedDecoration.MoveId) {
 | 
				
			||||||
        //moved within the same room
 | 
					        //moved within the same room
 | 
				
			||||||
        if (placedDecoration.OldRoom === placedDecoration.Room) {
 | 
					        if (placedDecoration.OldRoom === placedDecoration.Room) {
 | 
				
			||||||
            const existingDecorationIndex = roomToPlaceIn.PlacedDecos.findIndex(
 | 
					            const existingDecoration = roomToPlaceIn.PlacedDecos.id(placedDecoration.MoveId);
 | 
				
			||||||
                deco => deco._id.toString() === placedDecoration.MoveId
 | 
					 | 
				
			||||||
            );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (existingDecorationIndex === -1) {
 | 
					            if (!existingDecoration) {
 | 
				
			||||||
                throw new Error("decoration to be moved not found");
 | 
					                throw new Error("decoration to be moved not found");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            roomToPlaceIn.PlacedDecos[existingDecorationIndex].Pos = placedDecoration.Pos;
 | 
					            existingDecoration.Pos = placedDecoration.Pos;
 | 
				
			||||||
            roomToPlaceIn.PlacedDecos[existingDecorationIndex].Rot = placedDecoration.Rot;
 | 
					            existingDecoration.Rot = placedDecoration.Rot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (placedDecoration.Scale) {
 | 
					            if (placedDecoration.Scale) {
 | 
				
			||||||
                roomToPlaceIn.PlacedDecos[existingDecorationIndex].Scale = placedDecoration.Scale;
 | 
					                existingDecoration.Scale = placedDecoration.Scale;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            await personalRooms.save();
 | 
					            await personalRooms.save();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user