forked from OpenWF/SpaceNinjaServer
		
	chore: properly type equipment in IInventoryChanges
This commit is contained in:
		
							parent
							
								
									fb8d176fbe
								
							
						
					
					
						commit
						5bf981ee61
					
				@ -234,7 +234,7 @@ export const addItem = async (
 | 
				
			|||||||
                InventoryChanges: {
 | 
					                InventoryChanges: {
 | 
				
			||||||
                    Ships: [
 | 
					                    Ships: [
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            ItemId: { $oid: oid },
 | 
					                            ItemId: { $oid: oid.toString() },
 | 
				
			||||||
                            ItemType: typeName
 | 
					                            ItemType: typeName
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    ]
 | 
					                    ]
 | 
				
			||||||
@ -499,7 +499,7 @@ export const addItem = async (
 | 
				
			|||||||
                    const horseIndex = inventory.Horses.push({ ItemType: typeName });
 | 
					                    const horseIndex = inventory.Horses.push({ ItemType: typeName });
 | 
				
			||||||
                    return {
 | 
					                    return {
 | 
				
			||||||
                        InventoryChanges: {
 | 
					                        InventoryChanges: {
 | 
				
			||||||
                            Horses: inventory.Horses[horseIndex - 1].toJSON()
 | 
					                            Horses: [inventory.Horses[horseIndex - 1].toJSON<IEquipmentClient>()]
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@ -572,9 +572,7 @@ export const addSentinel = (
 | 
				
			|||||||
    addMods(inventory, modsToGive);
 | 
					    addMods(inventory, modsToGive);
 | 
				
			||||||
    const sentinelIndex = inventory.Sentinels.push({ ItemType: sentinelName, Configs: configs, XP: 0 }) - 1;
 | 
					    const sentinelIndex = inventory.Sentinels.push({ ItemType: sentinelName, Configs: configs, XP: 0 }) - 1;
 | 
				
			||||||
    inventoryChanges.Sentinels ??= [];
 | 
					    inventoryChanges.Sentinels ??= [];
 | 
				
			||||||
    (inventoryChanges.Sentinels as IEquipmentClient[]).push(
 | 
					    inventoryChanges.Sentinels.push(inventory.Sentinels[sentinelIndex].toJSON<IEquipmentClient>());
 | 
				
			||||||
        inventory.Sentinels[sentinelIndex].toJSON<IEquipmentClient>()
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -586,9 +584,7 @@ export const addSentinelWeapon = (
 | 
				
			|||||||
): void => {
 | 
					): void => {
 | 
				
			||||||
    const index = inventory.SentinelWeapons.push({ ItemType: typeName, XP: 0 }) - 1;
 | 
					    const index = inventory.SentinelWeapons.push({ ItemType: typeName, XP: 0 }) - 1;
 | 
				
			||||||
    inventoryChanges.SentinelWeapons ??= [];
 | 
					    inventoryChanges.SentinelWeapons ??= [];
 | 
				
			||||||
    (inventoryChanges.SentinelWeapons as IEquipmentClient[]).push(
 | 
					    inventoryChanges.SentinelWeapons.push(inventory.SentinelWeapons[index].toJSON<IEquipmentClient>());
 | 
				
			||||||
        inventory.SentinelWeapons[index].toJSON<IEquipmentClient>()
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const addPowerSuit = (
 | 
					export const addPowerSuit = (
 | 
				
			||||||
@ -604,7 +600,7 @@ export const addPowerSuit = (
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
 | 
					    const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
 | 
				
			||||||
    inventoryChanges.Suits ??= [];
 | 
					    inventoryChanges.Suits ??= [];
 | 
				
			||||||
    (inventoryChanges.Suits as IEquipmentClient[]).push(inventory.Suits[suitIndex].toJSON<IEquipmentClient>());
 | 
					    inventoryChanges.Suits.push(inventory.Suits[suitIndex].toJSON<IEquipmentClient>());
 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -621,7 +617,7 @@ export const addMechSuit = (
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    const suitIndex = inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
 | 
					    const suitIndex = inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
 | 
				
			||||||
    inventoryChanges.MechSuits ??= [];
 | 
					    inventoryChanges.MechSuits ??= [];
 | 
				
			||||||
    (inventoryChanges.MechSuits as IEquipmentClient[]).push(inventory.MechSuits[suitIndex].toJSON<IEquipmentClient>());
 | 
					    inventoryChanges.MechSuits.push(inventory.MechSuits[suitIndex].toJSON<IEquipmentClient>());
 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -642,9 +638,7 @@ export const addSpecialItem = (
 | 
				
			|||||||
            XP: 0
 | 
					            XP: 0
 | 
				
			||||||
        }) - 1;
 | 
					        }) - 1;
 | 
				
			||||||
    inventoryChanges.SpecialItems ??= [];
 | 
					    inventoryChanges.SpecialItems ??= [];
 | 
				
			||||||
    (inventoryChanges.SpecialItems as IEquipmentClient[]).push(
 | 
					    inventoryChanges.SpecialItems.push(inventory.SpecialItems[specialItemIndex].toJSON<IEquipmentClient>());
 | 
				
			||||||
        inventory.SpecialItems[specialItemIndex].toJSON<IEquipmentClient>()
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const addSpaceSuit = (
 | 
					export const addSpaceSuit = (
 | 
				
			||||||
@ -654,9 +648,7 @@ export const addSpaceSuit = (
 | 
				
			|||||||
): IInventoryChanges => {
 | 
					): IInventoryChanges => {
 | 
				
			||||||
    const suitIndex = inventory.SpaceSuits.push({ ItemType: spacesuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
 | 
					    const suitIndex = inventory.SpaceSuits.push({ ItemType: spacesuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
 | 
				
			||||||
    inventoryChanges.SpaceSuits ??= [];
 | 
					    inventoryChanges.SpaceSuits ??= [];
 | 
				
			||||||
    (inventoryChanges.SpaceSuits as IEquipmentClient[]).push(
 | 
					    inventoryChanges.SpaceSuits.push(inventory.SpaceSuits[suitIndex].toJSON<IEquipmentClient>());
 | 
				
			||||||
        inventory.SpaceSuits[suitIndex].toJSON<IEquipmentClient>()
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -798,7 +790,7 @@ export const addEquipment = (
 | 
				
			|||||||
        }) - 1;
 | 
					        }) - 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inventoryChanges[category] ??= [];
 | 
					    inventoryChanges[category] ??= [];
 | 
				
			||||||
    (inventoryChanges[category] as IEquipmentClient[]).push(inventory[category][index].toJSON<IEquipmentClient>());
 | 
					    inventoryChanges[category].push(inventory[category][index].toJSON<IEquipmentClient>());
 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -838,7 +830,7 @@ const addCrewShip = (
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    const index = inventory.CrewShips.push({ ItemType: typeName }) - 1;
 | 
					    const index = inventory.CrewShips.push({ ItemType: typeName }) - 1;
 | 
				
			||||||
    inventoryChanges.CrewShips ??= [];
 | 
					    inventoryChanges.CrewShips ??= [];
 | 
				
			||||||
    (inventoryChanges.CrewShips as IEquipmentClient[]).push(inventory.CrewShips[index].toJSON<IEquipmentClient>());
 | 
					    inventoryChanges.CrewShips.push(inventory.CrewShips[index].toJSON<IEquipmentClient>());
 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -852,9 +844,7 @@ const addCrewShipHarness = (
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    const index = inventory.CrewShipHarnesses.push({ ItemType: typeName }) - 1;
 | 
					    const index = inventory.CrewShipHarnesses.push({ ItemType: typeName }) - 1;
 | 
				
			||||||
    inventoryChanges.CrewShipHarnesses ??= [];
 | 
					    inventoryChanges.CrewShipHarnesses ??= [];
 | 
				
			||||||
    (inventoryChanges.CrewShipHarnesses as IEquipmentClient[]).push(
 | 
					    inventoryChanges.CrewShipHarnesses.push(inventory.CrewShipHarnesses[index].toJSON<IEquipmentClient>());
 | 
				
			||||||
        inventory.CrewShipHarnesses[index].toJSON<IEquipmentClient>()
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -868,7 +858,7 @@ const addMotorcycle = (
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    const index = inventory.Motorcycles.push({ ItemType: typeName }) - 1;
 | 
					    const index = inventory.Motorcycles.push({ ItemType: typeName }) - 1;
 | 
				
			||||||
    inventoryChanges.Motorcycles ??= [];
 | 
					    inventoryChanges.Motorcycles ??= [];
 | 
				
			||||||
    (inventoryChanges.Motorcycles as IEquipmentClient[]).push(inventory.Motorcycles[index].toJSON<IEquipmentClient>());
 | 
					    inventoryChanges.Motorcycles.push(inventory.Motorcycles[index].toJSON<IEquipmentClient>());
 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
import { IInfestedFoundryClient } from "./inventoryTypes/inventoryTypes";
 | 
					import { IEquipmentClient } from "./inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
 | 
					import { IInfestedFoundryClient, TEquipmentKey } from "./inventoryTypes/inventoryTypes";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IPurchaseRequest {
 | 
					export interface IPurchaseRequest {
 | 
				
			||||||
    PurchaseParams: IPurchaseParams;
 | 
					    PurchaseParams: IPurchaseParams;
 | 
				
			||||||
@ -29,6 +30,8 @@ export interface ICurrencyChanges {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export type IInventoryChanges = {
 | 
					export type IInventoryChanges = {
 | 
				
			||||||
    [_ in SlotNames]?: IBinChanges;
 | 
					    [_ in SlotNames]?: IBinChanges;
 | 
				
			||||||
 | 
					} & {
 | 
				
			||||||
 | 
					    [_ in TEquipmentKey]?: IEquipmentClient[];
 | 
				
			||||||
} & ICurrencyChanges & { InfestedFoundry?: IInfestedFoundryClient } & Record<
 | 
					} & ICurrencyChanges & { InfestedFoundry?: IInfestedFoundryClient } & Record<
 | 
				
			||||||
        string,
 | 
					        string,
 | 
				
			||||||
        IBinChanges | number | object[] | IInfestedFoundryClient
 | 
					        IBinChanges | number | object[] | IInfestedFoundryClient
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user