improve some types
This commit is contained in:
		
							parent
							
								
									e7245bbb68
								
							
						
					
					
						commit
						5101366ff2
					
				
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -5,3 +5,6 @@
 | 
				
			|||||||
/static/data/*.bin
 | 
					/static/data/*.bin
 | 
				
			||||||
yarn.lock
 | 
					yarn.lock
 | 
				
			||||||
/tmp
 | 
					/tmp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# JetBrains/webstorm configs
 | 
				
			||||||
 | 
					.idea/
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,12 @@
 | 
				
			|||||||
import { Inventory } from "@/src/models/inventoryModel";
 | 
					import { Inventory } from "@/src/models/inventoryModel";
 | 
				
			||||||
import { RequestHandler } from "express";
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
import util from "util";
 | 
					import util from "util";
 | 
				
			||||||
import { EquipmentCategories, ISaveLoadoutRequest } from "@/src/types/saveLoadoutTypes";
 | 
					import {
 | 
				
			||||||
 | 
					    EquipmentCategories,
 | 
				
			||||||
 | 
					    ISaveLoadoutEntry,
 | 
				
			||||||
 | 
					    ISaveLoadoutLoadoutEntry,
 | 
				
			||||||
 | 
					    ISaveLoadoutRequest
 | 
				
			||||||
 | 
					} from "@/src/types/saveLoadoutTypes";
 | 
				
			||||||
import { isObject } from "@/src/helpers/general";
 | 
					import { isObject } from "@/src/helpers/general";
 | 
				
			||||||
import { ISuitResponse } from "@/src/types/inventoryTypes/SuitTypes";
 | 
					import { ISuitResponse } from "@/src/types/inventoryTypes/SuitTypes";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -9,8 +14,11 @@ export const isObjectEmpty = (obj: Record<string, unknown>) => {
 | 
				
			|||||||
    return obj && Object.keys(obj).length === 0 && obj.constructor === Object;
 | 
					    return obj && Object.keys(obj).length === 0 && obj.constructor === Object;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type EquipmentChangeEntry = number | ISaveLoadoutEntry | ISaveLoadoutLoadoutEntry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const handleInventoryItemConfigChange = (equipmentChanges: ISaveLoadoutRequest) => {
 | 
					export const handleInventoryItemConfigChange = (equipmentChanges: ISaveLoadoutRequest) => {
 | 
				
			||||||
    for (const [equipmentName, equipment] of Object.entries(equipmentChanges)) {
 | 
					    for (const [equipmentName, eqp] of Object.entries(equipmentChanges)) {
 | 
				
			||||||
 | 
					        const equipment = eqp as EquipmentChangeEntry;
 | 
				
			||||||
        //console.log(equipmentName);
 | 
					        //console.log(equipmentName);
 | 
				
			||||||
        if (!isObjectEmpty(equipment)) {
 | 
					        if (!isObjectEmpty(equipment)) {
 | 
				
			||||||
            // non-empty is a change in loadout(or suit...)
 | 
					            // non-empty is a change in loadout(or suit...)
 | 
				
			||||||
 | 
				
			|||||||
@ -1,30 +1,37 @@
 | 
				
			|||||||
export interface ISaveLoadoutRequest {
 | 
					export interface ISaveLoadoutRequest {
 | 
				
			||||||
    LoadOuts: { [key: string]: LoadOut };
 | 
					    LoadOuts: ISaveLoadoutLoadoutEntry;
 | 
				
			||||||
    LongGuns: { [key: string]: Config };
 | 
					    LongGuns: ISaveLoadoutEntry;
 | 
				
			||||||
    OperatorAmps: { [key: string]: Config };
 | 
					    OperatorAmps: ISaveLoadoutEntry;
 | 
				
			||||||
    Pistols: { [key: string]: Config };
 | 
					    Pistols: ISaveLoadoutEntry;
 | 
				
			||||||
    Suits: { [key: string]: Config };
 | 
					    Suits: ISaveLoadoutEntry;
 | 
				
			||||||
    Melee: {};
 | 
					    Melee: ISaveLoadoutEntry;
 | 
				
			||||||
    Sentinels: {};
 | 
					    Sentinels: ISaveLoadoutEntry;
 | 
				
			||||||
    SentinelWeapons: {};
 | 
					    SentinelWeapons: ISaveLoadoutEntry;
 | 
				
			||||||
    KubrowPets: {};
 | 
					    KubrowPets: ISaveLoadoutEntry;
 | 
				
			||||||
    SpaceSuits: {};
 | 
					    SpaceSuits: ISaveLoadoutEntry;
 | 
				
			||||||
    SpaceGuns: {};
 | 
					    SpaceGuns: ISaveLoadoutEntry;
 | 
				
			||||||
    SpaceMelee: {};
 | 
					    SpaceMelee: ISaveLoadoutEntry;
 | 
				
			||||||
    Scoops: {};
 | 
					    Scoops: ISaveLoadoutEntry;
 | 
				
			||||||
    SpecialItems: {};
 | 
					    SpecialItems: ISaveLoadoutEntry;
 | 
				
			||||||
    MoaPets: {};
 | 
					    MoaPets: ISaveLoadoutEntry;
 | 
				
			||||||
    Hoverboards: {};
 | 
					    Hoverboards: ISaveLoadoutEntry;
 | 
				
			||||||
    DataKnives: {};
 | 
					    DataKnives: ISaveLoadoutEntry;
 | 
				
			||||||
    MechSuits: {};
 | 
					    MechSuits: ISaveLoadoutEntry;
 | 
				
			||||||
    CrewShipHarnesses: {};
 | 
					    CrewShipHarnesses: ISaveLoadoutEntry;
 | 
				
			||||||
    Horses: {};
 | 
					    Horses: ISaveLoadoutEntry;
 | 
				
			||||||
    DrifterMelee: {};
 | 
					    DrifterMelee: ISaveLoadoutEntry;
 | 
				
			||||||
    UpgradeVer: number;
 | 
					    UpgradeVer: number;
 | 
				
			||||||
    OperatorLoadOuts: {};
 | 
					    OperatorLoadOuts: ISaveLoadoutEntry;
 | 
				
			||||||
    AdultOperatorLoadOuts: {};
 | 
					    AdultOperatorLoadOuts: ISaveLoadoutEntry;
 | 
				
			||||||
    KahlLoadOuts: {};
 | 
					    KahlLoadOuts: ISaveLoadoutEntry;
 | 
				
			||||||
    CrewShips: {};
 | 
					    CrewShips: ISaveLoadoutEntry;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface ISaveLoadoutEntry {
 | 
				
			||||||
 | 
					    [key: string]: Config;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					export interface ISaveLoadoutLoadoutEntry {
 | 
				
			||||||
 | 
					    [key: string]: LoadOut;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface Config {
 | 
					export interface Config {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user