feat: handle KeyToRemove in EOM upload (#1491)
Reviewed-on: OpenWF/SpaceNinjaServer#1491 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
							
								
									919f12b8f9
								
							
						
					
					
						commit
						7f805a1dcc
					
				@ -538,15 +538,9 @@ export const addItem = async (
 | 
			
		||||
            if (!key) return {};
 | 
			
		||||
            return { QuestKeys: [key] };
 | 
			
		||||
        } else {
 | 
			
		||||
            const key = { ItemType: typeName, ItemCount: quantity };
 | 
			
		||||
 | 
			
		||||
            const index = inventory.LevelKeys.findIndex(levelKey => levelKey.ItemType == typeName);
 | 
			
		||||
            if (index != -1) {
 | 
			
		||||
                inventory.LevelKeys[index].ItemCount += quantity;
 | 
			
		||||
            } else {
 | 
			
		||||
                inventory.LevelKeys.push(key);
 | 
			
		||||
            }
 | 
			
		||||
            return { LevelKeys: [key] };
 | 
			
		||||
            const levelKeyChanges = [{ ItemType: typeName, ItemCount: quantity }];
 | 
			
		||||
            addLevelKeys(inventory, levelKeyChanges);
 | 
			
		||||
            return { LevelKeys: levelKeyChanges };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (typeName in ExportDrones) {
 | 
			
		||||
@ -1240,6 +1234,10 @@ export const addRecipes = (inventory: TInventoryDatabaseDocument, itemsArray: IT
 | 
			
		||||
    applyArrayChanges(inventory.Recipes, itemsArray);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const addLevelKeys = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[]): void => {
 | 
			
		||||
    applyArrayChanges(inventory.LevelKeys, itemsArray);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const addMods = (inventory: TInventoryDatabaseDocument, itemsArray: IRawUpgrade[]): void => {
 | 
			
		||||
    const { RawUpgrades } = inventory;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -22,6 +22,7 @@ import {
 | 
			
		||||
    addFusionTreasures,
 | 
			
		||||
    addGearExpByCategory,
 | 
			
		||||
    addItem,
 | 
			
		||||
    addLevelKeys,
 | 
			
		||||
    addMiscItems,
 | 
			
		||||
    addMissionComplete,
 | 
			
		||||
    addMods,
 | 
			
		||||
@ -77,19 +78,52 @@ export const addMissionInventoryUpdates = async (
 | 
			
		||||
    inventoryUpdates: IMissionInventoryUpdateRequest
 | 
			
		||||
): Promise<IInventoryChanges> => {
 | 
			
		||||
    const inventoryChanges: IInventoryChanges = {};
 | 
			
		||||
    if (
 | 
			
		||||
        inventoryUpdates.EndOfMatchUpload &&
 | 
			
		||||
        inventoryUpdates.Missions &&
 | 
			
		||||
        inventoryUpdates.Missions.Tag in ExportRegions
 | 
			
		||||
    ) {
 | 
			
		||||
        const node = ExportRegions[inventoryUpdates.Missions.Tag];
 | 
			
		||||
        if (node.miscItemFee) {
 | 
			
		||||
            addMiscItems(inventory, [
 | 
			
		||||
                {
 | 
			
		||||
                    ItemType: node.miscItemFee.ItemType,
 | 
			
		||||
                    ItemCount: node.miscItemFee.ItemCount * -1
 | 
			
		||||
                }
 | 
			
		||||
            ]);
 | 
			
		||||
    if (inventoryUpdates.EndOfMatchUpload) {
 | 
			
		||||
        if (inventoryUpdates.Missions && inventoryUpdates.Missions.Tag in ExportRegions) {
 | 
			
		||||
            const node = ExportRegions[inventoryUpdates.Missions.Tag];
 | 
			
		||||
            if (node.miscItemFee) {
 | 
			
		||||
                addMiscItems(inventory, [
 | 
			
		||||
                    {
 | 
			
		||||
                        ItemType: node.miscItemFee.ItemType,
 | 
			
		||||
                        ItemCount: node.miscItemFee.ItemCount * -1
 | 
			
		||||
                    }
 | 
			
		||||
                ]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (inventoryUpdates.KeyToRemove) {
 | 
			
		||||
            if (!inventoryUpdates.KeyOwner || inventory.accountOwnerId.equals(inventoryUpdates.KeyOwner)) {
 | 
			
		||||
                addLevelKeys(inventory, [
 | 
			
		||||
                    {
 | 
			
		||||
                        ItemType: inventoryUpdates.KeyToRemove,
 | 
			
		||||
                        ItemCount: -1
 | 
			
		||||
                    }
 | 
			
		||||
                ]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (
 | 
			
		||||
            inventoryUpdates.MissionFailed &&
 | 
			
		||||
            inventoryUpdates.MissionStatus == "GS_FAILURE" &&
 | 
			
		||||
            inventoryUpdates.ObjectiveReached &&
 | 
			
		||||
            !inventoryUpdates.LockedWeaponGroup
 | 
			
		||||
        ) {
 | 
			
		||||
            const loadout = (await Loadout.findById(inventory.LoadOutPresets, "NORMAL"))!;
 | 
			
		||||
            const config = loadout.NORMAL.id(inventory.CurrentLoadOutIds[0].$oid)!;
 | 
			
		||||
            const SuitId = new Types.ObjectId(config.s!.ItemId.$oid);
 | 
			
		||||
 | 
			
		||||
            inventory.BrandedSuits ??= [];
 | 
			
		||||
            if (!inventory.BrandedSuits.find(x => x.equals(SuitId))) {
 | 
			
		||||
                inventory.BrandedSuits.push(SuitId);
 | 
			
		||||
 | 
			
		||||
                await createMessage(inventory.accountOwnerId, [
 | 
			
		||||
                    {
 | 
			
		||||
                        sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
 | 
			
		||||
                        msg: "/Lotus/Language/G1Quests/BrandedMessage",
 | 
			
		||||
                        sub: "/Lotus/Language/G1Quests/BrandedTitle",
 | 
			
		||||
                        att: ["/Lotus/Types/Recipes/Components/BrandRemovalBlueprint"],
 | 
			
		||||
                        highPriority: true // TOVERIFY: I cannot find any content of this within the last 10 years so I can only assume that highPriority is set (it certainly would make sense), but I just don't know for sure that it is so on live.
 | 
			
		||||
                    }
 | 
			
		||||
                ]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (inventoryUpdates.RewardInfo) {
 | 
			
		||||
@ -110,32 +144,6 @@ export const addMissionInventoryUpdates = async (
 | 
			
		||||
            inventory.NemesisAbandonedRewards = inventoryUpdates.RewardInfo.NemesisAbandonedRewards;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (
 | 
			
		||||
        inventoryUpdates.MissionFailed &&
 | 
			
		||||
        inventoryUpdates.MissionStatus == "GS_FAILURE" &&
 | 
			
		||||
        inventoryUpdates.EndOfMatchUpload &&
 | 
			
		||||
        inventoryUpdates.ObjectiveReached &&
 | 
			
		||||
        !inventoryUpdates.LockedWeaponGroup
 | 
			
		||||
    ) {
 | 
			
		||||
        const loadout = (await Loadout.findById(inventory.LoadOutPresets, "NORMAL"))!;
 | 
			
		||||
        const config = loadout.NORMAL.id(inventory.CurrentLoadOutIds[0].$oid)!;
 | 
			
		||||
        const SuitId = new Types.ObjectId(config.s!.ItemId.$oid);
 | 
			
		||||
 | 
			
		||||
        inventory.BrandedSuits ??= [];
 | 
			
		||||
        if (!inventory.BrandedSuits.find(x => x.equals(SuitId))) {
 | 
			
		||||
            inventory.BrandedSuits.push(SuitId);
 | 
			
		||||
 | 
			
		||||
            await createMessage(inventory.accountOwnerId, [
 | 
			
		||||
                {
 | 
			
		||||
                    sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
 | 
			
		||||
                    msg: "/Lotus/Language/G1Quests/BrandedMessage",
 | 
			
		||||
                    sub: "/Lotus/Language/G1Quests/BrandedTitle",
 | 
			
		||||
                    att: ["/Lotus/Types/Recipes/Components/BrandRemovalBlueprint"],
 | 
			
		||||
                    highPriority: true // TOVERIFY: I cannot find any content of this within the last 10 years so I can only assume that highPriority is set (it certainly would make sense), but I just don't know for sure that it is so on live.
 | 
			
		||||
                }
 | 
			
		||||
            ]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    for (const [key, value] of getEntriesUnsafe(inventoryUpdates)) {
 | 
			
		||||
        if (value === undefined) {
 | 
			
		||||
            logger.error(`Inventory update key ${key} has no value `);
 | 
			
		||||
 | 
			
		||||
@ -49,6 +49,9 @@ export type IMissionInventoryUpdateRequest = {
 | 
			
		||||
    rewardsMultiplier?: number;
 | 
			
		||||
    GoalTag: string;
 | 
			
		||||
    LevelKeyName: string;
 | 
			
		||||
    KeyOwner?: string;
 | 
			
		||||
    KeyRemovalHash?: string;
 | 
			
		||||
    KeyToRemove?: string;
 | 
			
		||||
    ActiveBoosters?: IBooster[];
 | 
			
		||||
    RawUpgrades?: IRawUpgrade[];
 | 
			
		||||
    FusionTreasures?: IFusionTreasure[];
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user