forked from OpenWF/SpaceNinjaServer
		
	feat: WeaponSkins IsNew flag (#1347)
Reviewed-on: OpenWF/SpaceNinjaServer#1347 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									30ae95bec8
								
							
						
					
					
						commit
						a167216730
					
				@ -586,7 +586,8 @@ const spectreLoadoutsSchema = new Schema<ISpectreLoadout>(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const weaponSkinsSchema = new Schema<IWeaponSkinDatabase>(
 | 
					const weaponSkinsSchema = new Schema<IWeaponSkinDatabase>(
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        ItemType: String
 | 
					        ItemType: String,
 | 
				
			||||||
 | 
					        IsNew: Boolean
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    { id: false }
 | 
					    { id: false }
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
				
			|||||||
@ -938,7 +938,7 @@ export const addSkin = (
 | 
				
			|||||||
    typeName: string,
 | 
					    typeName: string,
 | 
				
			||||||
    inventoryChanges: IInventoryChanges = {}
 | 
					    inventoryChanges: IInventoryChanges = {}
 | 
				
			||||||
): IInventoryChanges => {
 | 
					): IInventoryChanges => {
 | 
				
			||||||
    const index = inventory.WeaponSkins.push({ ItemType: typeName }) - 1;
 | 
					    const index = inventory.WeaponSkins.push({ ItemType: typeName, IsNew: true }) - 1;
 | 
				
			||||||
    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
					    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
				
			||||||
    inventoryChanges.WeaponSkins ??= [];
 | 
					    inventoryChanges.WeaponSkins ??= [];
 | 
				
			||||||
    (inventoryChanges.WeaponSkins as IWeaponSkinClient[]).push(
 | 
					    (inventoryChanges.WeaponSkins as IWeaponSkinClient[]).push(
 | 
				
			||||||
 | 
				
			|||||||
@ -140,6 +140,13 @@ export const handleInventoryItemConfigChange = async (
 | 
				
			|||||||
                inventory.UseAdultOperatorLoadout = equipment as boolean;
 | 
					                inventory.UseAdultOperatorLoadout = equipment as boolean;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            case "WeaponSkins": {
 | 
				
			||||||
 | 
					                const itemEntries = equipment as IItemEntry;
 | 
				
			||||||
 | 
					                for (const [itemId, itemConfigEntries] of Object.entries(itemEntries)) {
 | 
				
			||||||
 | 
					                    inventory.WeaponSkins.id(itemId)!.IsNew = itemConfigEntries.IsNew;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            default: {
 | 
					            default: {
 | 
				
			||||||
                if (equipmentKeys.includes(equipmentName as TEquipmentKey) && equipmentName != "ValidNewLoadoutId") {
 | 
					                if (equipmentKeys.includes(equipmentName as TEquipmentKey) && equipmentName != "ValidNewLoadoutId") {
 | 
				
			||||||
                    logger.debug(`general Item config saved of type ${equipmentName}`, {
 | 
					                    logger.debug(`general Item config saved of type ${equipmentName}`, {
 | 
				
			||||||
 | 
				
			|||||||
@ -1017,6 +1017,7 @@ export interface ITaunt {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export interface IWeaponSkinDatabase {
 | 
					export interface IWeaponSkinDatabase {
 | 
				
			||||||
    ItemType: string;
 | 
					    ItemType: string;
 | 
				
			||||||
 | 
					    IsNew?: boolean;
 | 
				
			||||||
    _id: Types.ObjectId;
 | 
					    _id: Types.ObjectId;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -36,6 +36,7 @@ export interface ISaveLoadoutRequest {
 | 
				
			|||||||
    EquippedGear: string[];
 | 
					    EquippedGear: string[];
 | 
				
			||||||
    EquippedEmotes: string[];
 | 
					    EquippedEmotes: string[];
 | 
				
			||||||
    UseAdultOperatorLoadout: boolean;
 | 
					    UseAdultOperatorLoadout: boolean;
 | 
				
			||||||
 | 
					    WeaponSkins: IItemEntry;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface ISaveLoadoutRequestNoUpgradeVer extends Omit<ISaveLoadoutRequest, "UpgradeVer"> {}
 | 
					export interface ISaveLoadoutRequestNoUpgradeVer extends Omit<ISaveLoadoutRequest, "UpgradeVer"> {}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user