Compare commits
	
		
			1 Commits
		
	
	
		
			ca13c3fc81
			...
			ba349a11f1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| ba349a11f1 | 
@ -2,11 +2,7 @@ import type { RequestHandler } from "express";
 | 
				
			|||||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
					import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
				
			||||||
import { getAccountForRequest } from "../../services/loginService.ts";
 | 
					import { getAccountForRequest } from "../../services/loginService.ts";
 | 
				
			||||||
import type { IMissionInventoryUpdateRequest } from "../../types/requestTypes.ts";
 | 
					import type { IMissionInventoryUpdateRequest } from "../../types/requestTypes.ts";
 | 
				
			||||||
import {
 | 
					import { addMissionInventoryUpdates, addMissionRewards } from "../../services/missionInventoryUpdateService.ts";
 | 
				
			||||||
    addMissionInventoryUpdates,
 | 
					 | 
				
			||||||
    addMissionRewards,
 | 
					 | 
				
			||||||
    handleConservation
 | 
					 | 
				
			||||||
} from "../../services/missionInventoryUpdateService.ts";
 | 
					 | 
				
			||||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
					import { getInventory } from "../../services/inventoryService.ts";
 | 
				
			||||||
import { getInventoryResponse } from "./inventoryController.ts";
 | 
					import { getInventoryResponse } from "./inventoryController.ts";
 | 
				
			||||||
import { logger } from "../../utils/logger.ts";
 | 
					import { logger } from "../../utils/logger.ts";
 | 
				
			||||||
@ -98,7 +94,6 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
 | 
				
			|||||||
        SyndicateXPItemReward,
 | 
					        SyndicateXPItemReward,
 | 
				
			||||||
        ConquestCompletedMissionsCount
 | 
					        ConquestCompletedMissionsCount
 | 
				
			||||||
    } = await addMissionRewards(account, inventory, missionReport, firstCompletion);
 | 
					    } = await addMissionRewards(account, inventory, missionReport, firstCompletion);
 | 
				
			||||||
    handleConservation(inventory, missionReport, AffiliationMods); // Conservation reports have GS_SUCCESS
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (missionReport.EndOfMatchUpload) {
 | 
					    if (missionReport.EndOfMatchUpload) {
 | 
				
			||||||
        inventory.RewardSeed = generateRewardSeed();
 | 
					        inventory.RewardSeed = generateRewardSeed();
 | 
				
			||||||
@ -116,16 +111,8 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
 | 
				
			|||||||
        AffiliationMods,
 | 
					        AffiliationMods,
 | 
				
			||||||
        ConquestCompletedMissionsCount
 | 
					        ConquestCompletedMissionsCount
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    if (
 | 
					    if (missionReport.RJ) {
 | 
				
			||||||
        missionReport.BMI ||
 | 
					        logger.debug(`railjack interstitial request, sending only deltas`, deltas);
 | 
				
			||||||
        missionReport.TNT ||
 | 
					 | 
				
			||||||
        missionReport.SSC ||
 | 
					 | 
				
			||||||
        missionReport.RJ ||
 | 
					 | 
				
			||||||
        missionReport.SS ||
 | 
					 | 
				
			||||||
        missionReport.CMI ||
 | 
					 | 
				
			||||||
        missionReport.EJC
 | 
					 | 
				
			||||||
    ) {
 | 
					 | 
				
			||||||
        logger.debug(`interstitial request, sending only deltas`, deltas);
 | 
					 | 
				
			||||||
        res.json(deltas);
 | 
					        res.json(deltas);
 | 
				
			||||||
    } else if (missionReport.RewardInfo) {
 | 
					    } else if (missionReport.RewardInfo) {
 | 
				
			||||||
        logger.debug(`classic mission completion, sending everything`);
 | 
					        logger.debug(`classic mission completion, sending everything`);
 | 
				
			||||||
 | 
				
			|||||||
@ -517,6 +517,46 @@ export const addMissionInventoryUpdates = async (
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            case "CapturedAnimals": {
 | 
				
			||||||
 | 
					                for (const capturedAnimal of value) {
 | 
				
			||||||
 | 
					                    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
				
			||||||
 | 
					                    const meta = ExportAnimals[capturedAnimal.AnimalType]?.conservation;
 | 
				
			||||||
 | 
					                    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
				
			||||||
 | 
					                    if (meta) {
 | 
				
			||||||
 | 
					                        if (capturedAnimal.NumTags) {
 | 
				
			||||||
 | 
					                            addMiscItems(inventory, [
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    ItemType: meta.itemReward,
 | 
				
			||||||
 | 
					                                    ItemCount: capturedAnimal.NumTags
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            ]);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if (capturedAnimal.NumExtraRewards) {
 | 
				
			||||||
 | 
					                            if (meta.woundedAnimalReward) {
 | 
				
			||||||
 | 
					                                addMiscItems(inventory, [
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        ItemType: meta.woundedAnimalReward,
 | 
				
			||||||
 | 
					                                        ItemCount: capturedAnimal.NumExtraRewards
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                ]);
 | 
				
			||||||
 | 
					                            } else {
 | 
				
			||||||
 | 
					                                logger.warn(
 | 
				
			||||||
 | 
					                                    `client attempted to claim unknown extra rewards for conservation of ${capturedAnimal.AnimalType}`
 | 
				
			||||||
 | 
					                                );
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if (meta.standingReward) {
 | 
				
			||||||
 | 
					                            const syndicateTag =
 | 
				
			||||||
 | 
					                                inventoryUpdates.Missions!.Tag == "SolNode129" ? "SolarisSyndicate" : "CetusSyndicate";
 | 
				
			||||||
 | 
					                            logger.debug(`adding ${meta.standingReward} standing to ${syndicateTag} for conservation`);
 | 
				
			||||||
 | 
					                            addStanding(inventory, syndicateTag, meta.standingReward);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        logger.warn(`ignoring conservation of unknown AnimalType: ${capturedAnimal.AnimalType}`);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            case "KubrowPetEggs": {
 | 
					            case "KubrowPetEggs": {
 | 
				
			||||||
                for (const egg of value) {
 | 
					                for (const egg of value) {
 | 
				
			||||||
                    inventory.KubrowPetEggs.push({
 | 
					                    inventory.KubrowPetEggs.push({
 | 
				
			||||||
@ -921,7 +961,7 @@ interface AddMissionRewardsReturnType {
 | 
				
			|||||||
    MissionRewards: IMissionReward[];
 | 
					    MissionRewards: IMissionReward[];
 | 
				
			||||||
    inventoryChanges?: IInventoryChanges;
 | 
					    inventoryChanges?: IInventoryChanges;
 | 
				
			||||||
    credits?: IMissionCredits;
 | 
					    credits?: IMissionCredits;
 | 
				
			||||||
    AffiliationMods: IAffiliationMods[];
 | 
					    AffiliationMods?: IAffiliationMods[];
 | 
				
			||||||
    SyndicateXPItemReward?: number;
 | 
					    SyndicateXPItemReward?: number;
 | 
				
			||||||
    ConquestCompletedMissionsCount?: number;
 | 
					    ConquestCompletedMissionsCount?: number;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1097,12 +1137,10 @@ export const addMissionRewards = async (
 | 
				
			|||||||
    }: IMissionInventoryUpdateRequest,
 | 
					    }: IMissionInventoryUpdateRequest,
 | 
				
			||||||
    firstCompletion: boolean
 | 
					    firstCompletion: boolean
 | 
				
			||||||
): Promise<AddMissionRewardsReturnType> => {
 | 
					): Promise<AddMissionRewardsReturnType> => {
 | 
				
			||||||
    AffiliationMods ??= [];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (!rewardInfo) {
 | 
					    if (!rewardInfo) {
 | 
				
			||||||
        //TODO: if there is a case where you can have credits collected during a mission but no rewardInfo, add credits needs to be handled earlier
 | 
					        //TODO: if there is a case where you can have credits collected during a mission but no rewardInfo, add credits needs to be handled earlier
 | 
				
			||||||
        logger.debug(`Mission ${missions!.Tag} did not have Reward Info `);
 | 
					        logger.debug(`Mission ${missions!.Tag} did not have Reward Info `);
 | 
				
			||||||
        return { MissionRewards: [], AffiliationMods };
 | 
					        return { MissionRewards: [] };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //TODO: check double reward merging
 | 
					    //TODO: check double reward merging
 | 
				
			||||||
@ -1412,6 +1450,8 @@ export const addMissionRewards = async (
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AffiliationMods ??= [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (rewardInfo.JobStage != undefined && rewardInfo.jobId) {
 | 
					    if (rewardInfo.JobStage != undefined && rewardInfo.jobId) {
 | 
				
			||||||
        // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | 
					        // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | 
				
			||||||
        const [jobType, unkIndex, hubNode, syndicateMissionId] = rewardInfo.jobId.split("_");
 | 
					        const [jobType, unkIndex, hubNode, syndicateMissionId] = rewardInfo.jobId.split("_");
 | 
				
			||||||
@ -2212,54 +2252,6 @@ function getRandomMissionDrops(
 | 
				
			|||||||
    return drops;
 | 
					    return drops;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const handleConservation = (
 | 
					 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					 | 
				
			||||||
    missionReport: IMissionInventoryUpdateRequest,
 | 
					 | 
				
			||||||
    AffiliationMods: IAffiliationMods[]
 | 
					 | 
				
			||||||
): void => {
 | 
					 | 
				
			||||||
    if (missionReport.CapturedAnimals) {
 | 
					 | 
				
			||||||
        for (const capturedAnimal of missionReport.CapturedAnimals) {
 | 
					 | 
				
			||||||
            // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
					 | 
				
			||||||
            const meta = ExportAnimals[capturedAnimal.AnimalType]?.conservation;
 | 
					 | 
				
			||||||
            // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
					 | 
				
			||||||
            if (meta) {
 | 
					 | 
				
			||||||
                if (capturedAnimal.NumTags) {
 | 
					 | 
				
			||||||
                    addMiscItems(inventory, [
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            ItemType: meta.itemReward,
 | 
					 | 
				
			||||||
                            ItemCount: capturedAnimal.NumTags * capturedAnimal.Count
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    ]);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (capturedAnimal.NumExtraRewards) {
 | 
					 | 
				
			||||||
                    if (meta.woundedAnimalReward) {
 | 
					 | 
				
			||||||
                        addMiscItems(inventory, [
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                ItemType: meta.woundedAnimalReward,
 | 
					 | 
				
			||||||
                                ItemCount: capturedAnimal.NumExtraRewards * capturedAnimal.Count
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        ]);
 | 
					 | 
				
			||||||
                    } else {
 | 
					 | 
				
			||||||
                        logger.warn(
 | 
					 | 
				
			||||||
                            `client attempted to claim unknown extra rewards for conservation of ${capturedAnimal.AnimalType}`
 | 
					 | 
				
			||||||
                        );
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (meta.standingReward) {
 | 
					 | 
				
			||||||
                    addStanding(
 | 
					 | 
				
			||||||
                        inventory,
 | 
					 | 
				
			||||||
                        missionReport.Missions!.Tag == "SolNode129" ? "SolarisSyndicate" : "CetusSyndicate",
 | 
					 | 
				
			||||||
                        [2, 1.5, 1][capturedAnimal.CaptureRating] * meta.standingReward * capturedAnimal.Count,
 | 
					 | 
				
			||||||
                        AffiliationMods
 | 
					 | 
				
			||||||
                    );
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                logger.warn(`ignoring conservation of unknown AnimalType: ${capturedAnimal.AnimalType}`);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const corruptedMods = [
 | 
					const corruptedMods = [
 | 
				
			||||||
    "/Lotus/StoreItems/Upgrades/Mods/Melee/DualStat/CorruptedHeavyDamageChargeSpeedMod", // Corrupt Charge
 | 
					    "/Lotus/StoreItems/Upgrades/Mods/Melee/DualStat/CorruptedHeavyDamageChargeSpeedMod", // Corrupt Charge
 | 
				
			||||||
    "/Lotus/StoreItems/Upgrades/Mods/Pistol/DualStat/CorruptedCritDamagePistol", // Hollow Point
 | 
					    "/Lotus/StoreItems/Upgrades/Mods/Pistol/DualStat/CorruptedCritDamagePistol", // Hollow Point
 | 
				
			||||||
 | 
				
			|||||||
@ -2803,7 +2803,7 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        const activeStartDay = day - ghoulsCycleDay + 17;
 | 
					        const activeStartDay = day - ghoulsCycleDay + 17;
 | 
				
			||||||
        const activeEndDay = activeStartDay + 5;
 | 
					        const activeEndDay = activeStartDay + 5;
 | 
				
			||||||
        const dayWithFraction = (timeMs - EPOCH) / unixTimesInMs.day;
 | 
					        const dayWithFraction = (timeMs - EPOCH) / 86400000;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const progress = (dayWithFraction - activeStartDay) / (activeEndDay - activeStartDay);
 | 
					        const progress = (dayWithFraction - activeStartDay) / (activeEndDay - activeStartDay);
 | 
				
			||||||
        const healthPct = 1 - Math.min(Math.max(progress, 0), 1);
 | 
					        const healthPct = 1 - Math.min(Math.max(progress, 0), 1);
 | 
				
			||||||
@ -2814,14 +2814,22 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
 | 
				
			|||||||
                $date: {
 | 
					                $date: {
 | 
				
			||||||
                    $numberLong: config.worldState?.ghoulEmergenceOverride
 | 
					                    $numberLong: config.worldState?.ghoulEmergenceOverride
 | 
				
			||||||
                        ? "1753204900185"
 | 
					                        ? "1753204900185"
 | 
				
			||||||
                        : (EPOCH + activeStartDay * unixTimesInMs.day).toString()
 | 
					                        : Date.UTC(
 | 
				
			||||||
 | 
					                              date.getUTCFullYear(),
 | 
				
			||||||
 | 
					                              date.getUTCMonth(),
 | 
				
			||||||
 | 
					                              date.getUTCDate() + activeStartDay
 | 
				
			||||||
 | 
					                          ).toString()
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            Expiry: {
 | 
					            Expiry: {
 | 
				
			||||||
                $date: {
 | 
					                $date: {
 | 
				
			||||||
                    $numberLong: config.worldState?.ghoulEmergenceOverride
 | 
					                    $numberLong: config.worldState?.ghoulEmergenceOverride
 | 
				
			||||||
                        ? "2000000000000"
 | 
					                        ? "2000000000000"
 | 
				
			||||||
                        : (EPOCH + activeEndDay * unixTimesInMs.day).toString()
 | 
					                        : Date.UTC(
 | 
				
			||||||
 | 
					                              date.getUTCFullYear(),
 | 
				
			||||||
 | 
					                              date.getUTCMonth(),
 | 
				
			||||||
 | 
					                              date.getUTCDate() + activeEndDay
 | 
				
			||||||
 | 
					                          ).toString()
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            HealthPct: config.worldState?.ghoulEmergenceOverride ? 1 : healthPct,
 | 
					            HealthPct: config.worldState?.ghoulEmergenceOverride ? 1 : healthPct,
 | 
				
			||||||
 | 
				
			|||||||
@ -45,15 +45,6 @@ export type IMissionInventoryUpdateRequest = {
 | 
				
			|||||||
    EmailItems?: ITypeCount[];
 | 
					    EmailItems?: ITypeCount[];
 | 
				
			||||||
    ShipDecorations?: ITypeCount[];
 | 
					    ShipDecorations?: ITypeCount[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // flags for interstitial requests
 | 
					 | 
				
			||||||
    BMI?: boolean;
 | 
					 | 
				
			||||||
    TNT?: boolean; // Conservation; definitely need to include AffiliationMods in this case, so a normal 'inventory sync' would not work here.
 | 
					 | 
				
			||||||
    SSC?: boolean; // K-Drive race?
 | 
					 | 
				
			||||||
    RJ?: boolean; // Railjack. InventoryJson should only be returned when going back to dojo.
 | 
					 | 
				
			||||||
    SS?: boolean;
 | 
					 | 
				
			||||||
    CMI?: boolean;
 | 
					 | 
				
			||||||
    EJC?: boolean;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    SyndicateId?: string;
 | 
					    SyndicateId?: string;
 | 
				
			||||||
    SortieId?: string;
 | 
					    SortieId?: string;
 | 
				
			||||||
    CalendarProgress?: { challenge: string }[];
 | 
					    CalendarProgress?: { challenge: string }[];
 | 
				
			||||||
@ -158,6 +149,7 @@ export type IMissionInventoryUpdateRequest = {
 | 
				
			|||||||
        MultiProgress: unknown[];
 | 
					        MultiProgress: unknown[];
 | 
				
			||||||
    }[];
 | 
					    }[];
 | 
				
			||||||
    InvasionProgress?: IInvasionProgressClient[];
 | 
					    InvasionProgress?: IInvasionProgressClient[];
 | 
				
			||||||
 | 
					    RJ?: boolean;
 | 
				
			||||||
    ConquestMissionsCompleted?: number;
 | 
					    ConquestMissionsCompleted?: number;
 | 
				
			||||||
    duviriSuitSelection?: string;
 | 
					    duviriSuitSelection?: string;
 | 
				
			||||||
    duviriPistolSelection?: string;
 | 
					    duviriPistolSelection?: string;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user