forked from OpenWF/SpaceNinjaServer
		
	add warning for other loadouts with skins
This commit is contained in:
		
							parent
							
								
									6fa80dab38
								
							
						
					
					
						commit
						a83d96289f
					
				@ -5,7 +5,7 @@ import { Inventory } from "../../models/inventoryModels/inventoryModel.ts";
 | 
			
		||||
import { config } from "../../services/configService.ts";
 | 
			
		||||
import allDialogue from "../../../static/fixed_responses/allDialogue.json" with { type: "json" };
 | 
			
		||||
import type { ILoadoutDatabase } from "../../types/saveLoadoutTypes.ts";
 | 
			
		||||
import type { IInventoryClient, IShipInventory } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import type { IInventoryClient, IShipInventory, IWeaponSkinClient } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import { equipmentKeys } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import type { IPolarity } from "../../types/inventoryTypes/commonInventoryTypes.ts";
 | 
			
		||||
import { ArtifactPolarity } from "../../types/inventoryTypes/commonInventoryTypes.ts";
 | 
			
		||||
@ -333,43 +333,28 @@ export const getInventoryResponse = async (
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const skinLookupTable: Record<number, string> = {};
 | 
			
		||||
    for (const key of Object.keys(ExportCustoms)) {
 | 
			
		||||
        skinLookupTable[catBreadHash(key)] = key;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (const key of equipmentKeys) {
 | 
			
		||||
        if (key in inventoryResponse) {
 | 
			
		||||
            for (const equipment of inventoryResponse[key]) {
 | 
			
		||||
                for (const config of equipment.Configs) {
 | 
			
		||||
                    if (config.Skins) {
 | 
			
		||||
                        for (let i = 0; i < config.Skins.length; i++) {
 | 
			
		||||
                            const skinId: string = config.Skins[i];
 | 
			
		||||
                            if (skinId.substring(0, 16) === "ca70ca70ca70ca70") {
 | 
			
		||||
                                const skinItemType = skinLookupTable[parseInt(skinId.substring(16), 16)];
 | 
			
		||||
                                const inventoryItem = inventoryResponse.WeaponSkins.find(
 | 
			
		||||
                                    x => x.ItemType == skinItemType
 | 
			
		||||
                                );
 | 
			
		||||
 | 
			
		||||
                                if (inventoryItem) {
 | 
			
		||||
                                    config.Skins[i] = inventoryItem.ItemId.$oid;
 | 
			
		||||
                                } else {
 | 
			
		||||
                                    config.Skins[i] = skinItemType;
 | 
			
		||||
                                    if (!ExportCustoms[skinItemType].alwaysAvailable) {
 | 
			
		||||
                                        logger.warn(
 | 
			
		||||
                                            `Get ${skinItemType} or you may loose your appearance on ${equipment.ItemType}`
 | 
			
		||||
                                        );
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                equipment.Configs.forEach(config => {
 | 
			
		||||
                    if (config.Skins) processSkins(config.Skins, inventoryResponse.WeaponSkins, equipment.ItemType);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (const key of ["AdultOperatorLoadOuts", "OperatorLoadOuts", "KahlLoadOuts"] as const) {
 | 
			
		||||
        if (key in inventoryResponse) {
 | 
			
		||||
            inventoryResponse[key].forEach(loadOut => {
 | 
			
		||||
                if (loadOut.Skins) processSkins(loadOut.Skins, inventoryResponse.WeaponSkins, key);
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (inventoryResponse.LotusCustomization?.Skins) {
 | 
			
		||||
        processSkins(inventoryResponse.LotusCustomization.Skins, inventoryResponse.WeaponSkins, "LotusCustomization");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (typeof config.spoofMasteryRank === "number" && config.spoofMasteryRank >= 0) {
 | 
			
		||||
        inventoryResponse.PlayerLevel = config.spoofMasteryRank;
 | 
			
		||||
        if (!xpBasedLevelCapDisabled) {
 | 
			
		||||
@ -499,3 +484,26 @@ const getExpRequiredForMr = (rank: number): number => {
 | 
			
		||||
    }
 | 
			
		||||
    return 2_250_000 + 147_500 * (rank - 30);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const skinLookupTable: Record<number, string> = {};
 | 
			
		||||
for (const key of Object.keys(ExportCustoms)) {
 | 
			
		||||
    skinLookupTable[catBreadHash(key)] = key;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const processSkins = (skins: string[], weaponSKins: IWeaponSkinClient[], contextName: string): void => {
 | 
			
		||||
    skins.forEach((skinId, i) => {
 | 
			
		||||
        if (skinId.startsWith("ca70ca70ca70ca70")) {
 | 
			
		||||
            const skinItemType = skinLookupTable[parseInt(skinId.slice(16), 16)];
 | 
			
		||||
            const inventoryItem = weaponSKins.find(x => x.ItemType === skinItemType);
 | 
			
		||||
 | 
			
		||||
            if (inventoryItem) {
 | 
			
		||||
                skins[i] = inventoryItem.ItemId.$oid;
 | 
			
		||||
            } else {
 | 
			
		||||
                skins[i] = skinItemType;
 | 
			
		||||
                if (!ExportCustoms[skinItemType].alwaysAvailable) {
 | 
			
		||||
                    logger.warn(`Get ${skinItemType} or you may loose your appearance on ${contextName}`);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user