saveLoadout and misc. #99
							
								
								
									
										5
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -4,4 +4,7 @@
 | 
			
		||||
/.env
 | 
			
		||||
/static/data/*.bin
 | 
			
		||||
yarn.lock
 | 
			
		||||
/tmp
 | 
			
		||||
/tmp
 | 
			
		||||
 | 
			
		||||
# JetBrains/webstorm configs
 | 
			
		||||
.idea/
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,12 @@
 | 
			
		||||
import { Inventory } from "@/src/models/inventoryModel";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
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 { 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;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
type EquipmentChangeEntry = number | ISaveLoadoutEntry | ISaveLoadoutLoadoutEntry;
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
        if (!isObjectEmpty(equipment)) {
 | 
			
		||||
            // non-empty is a change in loadout(or suit...)
 | 
			
		||||
 | 
			
		||||
@ -1,30 +1,37 @@
 | 
			
		||||
export interface ISaveLoadoutRequest {
 | 
			
		||||
    LoadOuts: { [key: string]: LoadOut };
 | 
			
		||||
    LongGuns: { [key: string]: Config };
 | 
			
		||||
    OperatorAmps: { [key: string]: Config };
 | 
			
		||||
    Pistols: { [key: string]: Config };
 | 
			
		||||
    Suits: { [key: string]: Config };
 | 
			
		||||
    Melee: {};
 | 
			
		||||
    Sentinels: {};
 | 
			
		||||
    SentinelWeapons: {};
 | 
			
		||||
    KubrowPets: {};
 | 
			
		||||
    SpaceSuits: {};
 | 
			
		||||
    SpaceGuns: {};
 | 
			
		||||
    SpaceMelee: {};
 | 
			
		||||
    Scoops: {};
 | 
			
		||||
    SpecialItems: {};
 | 
			
		||||
    MoaPets: {};
 | 
			
		||||
    Hoverboards: {};
 | 
			
		||||
    DataKnives: {};
 | 
			
		||||
    MechSuits: {};
 | 
			
		||||
    CrewShipHarnesses: {};
 | 
			
		||||
    Horses: {};
 | 
			
		||||
    DrifterMelee: {};
 | 
			
		||||
    LoadOuts: ISaveLoadoutLoadoutEntry;
 | 
			
		||||
    LongGuns: ISaveLoadoutEntry;
 | 
			
		||||
    OperatorAmps: ISaveLoadoutEntry;
 | 
			
		||||
    Pistols: ISaveLoadoutEntry;
 | 
			
		||||
    Suits: ISaveLoadoutEntry;
 | 
			
		||||
    Melee: ISaveLoadoutEntry;
 | 
			
		||||
    Sentinels: ISaveLoadoutEntry;
 | 
			
		||||
    SentinelWeapons: ISaveLoadoutEntry;
 | 
			
		||||
    KubrowPets: ISaveLoadoutEntry;
 | 
			
		||||
    SpaceSuits: ISaveLoadoutEntry;
 | 
			
		||||
    SpaceGuns: ISaveLoadoutEntry;
 | 
			
		||||
    SpaceMelee: ISaveLoadoutEntry;
 | 
			
		||||
    Scoops: ISaveLoadoutEntry;
 | 
			
		||||
    SpecialItems: ISaveLoadoutEntry;
 | 
			
		||||
    MoaPets: ISaveLoadoutEntry;
 | 
			
		||||
    Hoverboards: ISaveLoadoutEntry;
 | 
			
		||||
    DataKnives: ISaveLoadoutEntry;
 | 
			
		||||
    MechSuits: ISaveLoadoutEntry;
 | 
			
		||||
    CrewShipHarnesses: ISaveLoadoutEntry;
 | 
			
		||||
    Horses: ISaveLoadoutEntry;
 | 
			
		||||
    DrifterMelee: ISaveLoadoutEntry;
 | 
			
		||||
    UpgradeVer: number;
 | 
			
		||||
    OperatorLoadOuts: {};
 | 
			
		||||
    AdultOperatorLoadOuts: {};
 | 
			
		||||
    KahlLoadOuts: {};
 | 
			
		||||
    CrewShips: {};
 | 
			
		||||
    OperatorLoadOuts: ISaveLoadoutEntry;
 | 
			
		||||
    AdultOperatorLoadOuts: ISaveLoadoutEntry;
 | 
			
		||||
    KahlLoadOuts: ISaveLoadoutEntry;
 | 
			
		||||
    CrewShips: ISaveLoadoutEntry;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ISaveLoadoutEntry {
 | 
			
		||||
    [key: string]: Config;
 | 
			
		||||
}
 | 
			
		||||
export interface ISaveLoadoutLoadoutEntry {
 | 
			
		||||
    [key: string]: LoadOut;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface Config {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user