merge EndOfMatchUpload conditions
This commit is contained in:
		
							parent
							
								
									b93a4a6dae
								
							
						
					
					
						commit
						cb89e31c15
					
				@ -77,11 +77,8 @@ export const addMissionInventoryUpdates = async (
 | 
			
		||||
    inventoryUpdates: IMissionInventoryUpdateRequest
 | 
			
		||||
): Promise<IInventoryChanges> => {
 | 
			
		||||
    const inventoryChanges: IInventoryChanges = {};
 | 
			
		||||
    if (
 | 
			
		||||
        inventoryUpdates.EndOfMatchUpload &&
 | 
			
		||||
        inventoryUpdates.Missions &&
 | 
			
		||||
        inventoryUpdates.Missions.Tag in ExportRegions
 | 
			
		||||
    ) {
 | 
			
		||||
    if (inventoryUpdates.EndOfMatchUpload) {
 | 
			
		||||
        if (inventoryUpdates.Missions && inventoryUpdates.Missions.Tag in ExportRegions) {
 | 
			
		||||
            const node = ExportRegions[inventoryUpdates.Missions.Tag];
 | 
			
		||||
            if (node.miscItemFee) {
 | 
			
		||||
                addMiscItems(inventory, [
 | 
			
		||||
@ -92,28 +89,9 @@ export const addMissionInventoryUpdates = async (
 | 
			
		||||
                ]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    if (inventoryUpdates.RewardInfo) {
 | 
			
		||||
        if (inventoryUpdates.RewardInfo.periodicMissionTag) {
 | 
			
		||||
            const tag = inventoryUpdates.RewardInfo.periodicMissionTag;
 | 
			
		||||
            const existingCompletion = inventory.PeriodicMissionCompletions.find(completion => completion.tag === tag);
 | 
			
		||||
 | 
			
		||||
            if (existingCompletion) {
 | 
			
		||||
                existingCompletion.date = new Date();
 | 
			
		||||
            } else {
 | 
			
		||||
                inventory.PeriodicMissionCompletions.push({
 | 
			
		||||
                    tag: tag,
 | 
			
		||||
                    date: new Date()
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (inventoryUpdates.RewardInfo.NemesisAbandonedRewards) {
 | 
			
		||||
            inventory.NemesisAbandonedRewards = inventoryUpdates.RewardInfo.NemesisAbandonedRewards;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
        if (
 | 
			
		||||
            inventoryUpdates.MissionFailed &&
 | 
			
		||||
            inventoryUpdates.MissionStatus == "GS_FAILURE" &&
 | 
			
		||||
        inventoryUpdates.EndOfMatchUpload &&
 | 
			
		||||
            inventoryUpdates.ObjectiveReached &&
 | 
			
		||||
            !inventoryUpdates.LockedWeaponGroup
 | 
			
		||||
        ) {
 | 
			
		||||
@ -136,6 +114,25 @@ export const addMissionInventoryUpdates = async (
 | 
			
		||||
                ]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (inventoryUpdates.RewardInfo) {
 | 
			
		||||
        if (inventoryUpdates.RewardInfo.periodicMissionTag) {
 | 
			
		||||
            const tag = inventoryUpdates.RewardInfo.periodicMissionTag;
 | 
			
		||||
            const existingCompletion = inventory.PeriodicMissionCompletions.find(completion => completion.tag === tag);
 | 
			
		||||
 | 
			
		||||
            if (existingCompletion) {
 | 
			
		||||
                existingCompletion.date = new Date();
 | 
			
		||||
            } else {
 | 
			
		||||
                inventory.PeriodicMissionCompletions.push({
 | 
			
		||||
                    tag: tag,
 | 
			
		||||
                    date: new Date()
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (inventoryUpdates.RewardInfo.NemesisAbandonedRewards) {
 | 
			
		||||
            inventory.NemesisAbandonedRewards = inventoryUpdates.RewardInfo.NemesisAbandonedRewards;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    for (const [key, value] of getEntriesUnsafe(inventoryUpdates)) {
 | 
			
		||||
        if (value === undefined) {
 | 
			
		||||
            logger.error(`Inventory update key ${key} has no value `);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user