diff --git a/src/controllers/api/missionInventoryUpdateController.ts b/src/controllers/api/missionInventoryUpdateController.ts index 4dc5bd66..1a8e6318 100644 --- a/src/controllers/api/missionInventoryUpdateController.ts +++ b/src/controllers/api/missionInventoryUpdateController.ts @@ -55,7 +55,8 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res) const inventory = await getInventory(accountId); const inventoryUpdates = await addMissionInventoryUpdates(inventory, missionReport); - if (missionReport.MissionStatus !== "GS_SUCCESS") { + // skip mission rewards if not GS_SUCCESS and not a bounty (by presence of jobId, as there's a reward every stage but only the last stage has GS_SUCCESS) + if (missionReport.MissionStatus !== "GS_SUCCESS" && !missionReport.RewardInfo?.jobId) { await inventory.save(); const inventoryResponse = await getInventoryResponse(inventory, true); res.json({ diff --git a/src/services/missionInventoryUpdateService.ts b/src/services/missionInventoryUpdateService.ts index 9ca788af..376656c6 100644 --- a/src/services/missionInventoryUpdateService.ts +++ b/src/services/missionInventoryUpdateService.ts @@ -50,6 +50,7 @@ import conservationAnimals from "@/static/fixed_responses/conservationAnimals.js import { getInfNodes } from "@/src/helpers/nemesisHelpers"; import { Loadout } from "../models/inventoryModels/loadoutModel"; import { ILoadoutConfigDatabase } from "../types/saveLoadoutTypes"; +import { getWorldState } from "./worldStateService"; const getRotations = (rotationCount: number, tierOverride: number | undefined): number[] => { if (rotationCount === 0) return [0]; @@ -806,13 +807,23 @@ function getRandomMissionDrops(RewardInfo: IRewardInfo, tierOverride: number | u const drops: IMissionReward[] = []; if (RewardInfo.node in ExportRegions) { const region = ExportRegions[RewardInfo.node]; - const rewardManifests: string[] = + let rewardManifests: string[] = RewardInfo.periodicMissionTag == "EliteAlert" || RewardInfo.periodicMissionTag == "EliteAlertB" ? ["/Lotus/Types/Game/MissionDecks/EliteAlertMissionRewards/EliteAlertMissionRewards"] : region.rewardManifests; let rotations: number[] = []; - if (RewardInfo.VaultsCracked) { + if (RewardInfo.jobId) { + if (RewardInfo.JobTier! >= 0) { + const id = RewardInfo.jobId.split("_")[3]; + const syndicateInfo = getWorldState().SyndicateMissions.find(x => x._id.$oid == id); + if (syndicateInfo) { + const jobInfo = syndicateInfo.Jobs![RewardInfo.JobTier!]; + rewardManifests = [jobInfo.rewards]; + rotations = [RewardInfo.JobStage!]; + } + } + } else if (RewardInfo.VaultsCracked) { // For Spy missions, e.g. 3 vaults cracked = A, B, C for (let i = 0; i != RewardInfo.VaultsCracked; ++i) { rotations.push(i); @@ -821,6 +832,9 @@ function getRandomMissionDrops(RewardInfo: IRewardInfo, tierOverride: number | u const rotationCount = RewardInfo.rewardQualifications?.length || 0; rotations = getRotations(rotationCount, tierOverride); } + if (rewardManifests.length != 0) { + logger.debug(`generating random mission rewards`, { rewardManifests, rotations }); + } rewardManifests .map(name => ExportRewards[name]) .forEach(table => { diff --git a/src/types/requestTypes.ts b/src/types/requestTypes.ts index 1f00fa45..6e732f83 100644 --- a/src/types/requestTypes.ts +++ b/src/types/requestTypes.ts @@ -145,10 +145,10 @@ export interface IRewardInfo { periodicMissionTag?: string; // for bounties, only EOM_AFK and node are given from above, plus: - JobTier?: string; + JobTier?: number; jobId?: string; - JobStage?: string; - Q?: boolean; // always false? + JobStage?: number; + Q?: boolean; // likely indicates that the bonus objective for this stage was completed CheckpointCounter?: number; // starts at 1, is incremented with each job stage upload, and does not reset when starting a new job } diff --git a/src/types/worldStateTypes.ts b/src/types/worldStateTypes.ts index a90f2134..a3b6efac 100644 --- a/src/types/worldStateTypes.ts +++ b/src/types/worldStateTypes.ts @@ -5,7 +5,7 @@ export interface IWorldState { BuildLabel: string; Time: number; Goals: IGoal[]; - SyndicateMissions: ISyndicateMission[]; + SyndicateMissions: ISyndicateMissionInfo[]; GlobalUpgrades: IGlobalUpgrade[]; Sorties: ISortie[]; LiteSorties: ILiteSortie[]; @@ -39,13 +39,24 @@ export interface IGoal { Node: string; } -export interface ISyndicateMission { +export interface ISyndicateMissionInfo { _id: IOid; Activation: IMongoDate; Expiry: IMongoDate; Tag: string; Seed: number; Nodes: string[]; + Jobs?: { + jobType?: string; + rewards: string; + masteryReq: number; + minEnemyLevel: number; + maxEnemyLevel: number; + xpAmounts: number[]; + endless?: boolean; + locationTag?: string; + isVault?: boolean; + }[]; } export interface IGlobalUpgrade {