Compare commits
	
		
			3 Commits
		
	
	
		
			ba349a11f1
			...
			ca13c3fc81
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| ca13c3fc81 | |||
| d2aff211c6 | |||
| 791ae389d8 | 
@ -8,8 +8,8 @@ export const giveKeyChainTriggeredMessageController: RequestHandler = async (req
 | 
				
			|||||||
    const accountId = await getAccountIdForRequest(req);
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
    const keyChainInfo = JSON.parse((req.body as Buffer).toString()) as IKeyChainRequest;
 | 
					    const keyChainInfo = JSON.parse((req.body as Buffer).toString()) as IKeyChainRequest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const inventory = await getInventory(accountId, "QuestKeys");
 | 
					    const inventory = await getInventory(accountId, "QuestKeys accountOwnerId");
 | 
				
			||||||
    await giveKeyChainMessage(inventory, accountId, keyChainInfo);
 | 
					    await giveKeyChainMessage(inventory, keyChainInfo);
 | 
				
			||||||
    await inventory.save();
 | 
					    await inventory.save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    res.send(1);
 | 
					    res.send(1);
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,11 @@ 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 { addMissionInventoryUpdates, addMissionRewards } from "../../services/missionInventoryUpdateService.ts";
 | 
					import {
 | 
				
			||||||
 | 
					    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";
 | 
				
			||||||
@ -94,6 +98,7 @@ 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();
 | 
				
			||||||
@ -111,8 +116,16 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
 | 
				
			|||||||
        AffiliationMods,
 | 
					        AffiliationMods,
 | 
				
			||||||
        ConquestCompletedMissionsCount
 | 
					        ConquestCompletedMissionsCount
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    if (missionReport.RJ) {
 | 
					    if (
 | 
				
			||||||
        logger.debug(`railjack interstitial request, sending only deltas`, deltas);
 | 
					        missionReport.BMI ||
 | 
				
			||||||
 | 
					        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`);
 | 
				
			||||||
 | 
				
			|||||||
@ -102,8 +102,16 @@ export const manageQuestsController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
                    questKey.Completed = false;
 | 
					                    questKey.Completed = false;
 | 
				
			||||||
                    questKey.CompletionDate = undefined;
 | 
					                    questKey.CompletionDate = undefined;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                const run = questKey.Progress[0]?.c ?? 0;
 | 
				
			||||||
 | 
					                const stage = questKey.Progress.map(p => p.c).lastIndexOf(run);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (run > 0) {
 | 
				
			||||||
 | 
					                    questKey.Progress[stage].c = run - 1;
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
                    questKey.Progress.pop();
 | 
					                    questKey.Progress.pop();
 | 
				
			||||||
                const stage = questKey.Progress.length - 1;
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (stage > 0) {
 | 
					                if (stage > 0) {
 | 
				
			||||||
                    await giveKeyChainStageTriggered(inventory, {
 | 
					                    await giveKeyChainStageTriggered(inventory, {
 | 
				
			||||||
                        KeyChain: questKey.ItemType,
 | 
					                        KeyChain: questKey.ItemType,
 | 
				
			||||||
@ -123,28 +131,28 @@ export const manageQuestsController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                if (!questKey.Progress) break;
 | 
					                if (!questKey.Progress) break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                const currentStage = questKey.Progress.length;
 | 
					                const run = questKey.Progress[0]?.c ?? 0;
 | 
				
			||||||
 | 
					                const currentStage = questKey.Progress.map(p => p.c).lastIndexOf(run);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (currentStage + 1 == questManifest.chainStages?.length) {
 | 
					                if (currentStage + 1 == questManifest.chainStages?.length) {
 | 
				
			||||||
                    logger.debug(`Trying to complete last stage with nextStage, calling completeQuest instead`);
 | 
					                    logger.debug(`Trying to complete last stage with nextStage, calling completeQuest instead`);
 | 
				
			||||||
                    await completeQuest(inventory, questKey.ItemType);
 | 
					                    await completeQuest(inventory, questKey.ItemType);
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    const progress = {
 | 
					                    if (run > 0) {
 | 
				
			||||||
                        c: 0,
 | 
					                        questKey.Progress[currentStage + 1].c = run;
 | 
				
			||||||
                        i: false,
 | 
					                    } else {
 | 
				
			||||||
                        m: false,
 | 
					                        questKey.Progress.push({ c: run, i: false, m: false, b: [] });
 | 
				
			||||||
                        b: []
 | 
					                    }
 | 
				
			||||||
                    };
 | 
					 | 
				
			||||||
                    questKey.Progress.push(progress);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    await giveKeyChainStageTriggered(inventory, {
 | 
					                    await giveKeyChainStageTriggered(inventory, {
 | 
				
			||||||
                        KeyChain: questKey.ItemType,
 | 
					                        KeyChain: questKey.ItemType,
 | 
				
			||||||
                        ChainStage: currentStage
 | 
					                        ChainStage: currentStage + 1
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (currentStage > 0) {
 | 
					                    if (currentStage > 0) {
 | 
				
			||||||
                        await giveKeyChainMissionReward(inventory, {
 | 
					                        await giveKeyChainMissionReward(inventory, {
 | 
				
			||||||
                            KeyChain: questKey.ItemType,
 | 
					                            KeyChain: questKey.ItemType,
 | 
				
			||||||
                            ChainStage: currentStage - 1
 | 
					                            ChainStage: currentStage
 | 
				
			||||||
                        });
 | 
					                        });
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
				
			|||||||
@ -517,46 +517,6 @@ 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({
 | 
				
			||||||
@ -961,7 +921,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;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1137,10 +1097,12 @@ 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: [] };
 | 
					        return { MissionRewards: [], AffiliationMods };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //TODO: check double reward merging
 | 
					    //TODO: check double reward merging
 | 
				
			||||||
@ -1450,8 +1412,6 @@ 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("_");
 | 
				
			||||||
@ -2252,6 +2212,54 @@ 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
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,6 @@ import { addItem, addItems, addKeyChainItems, setupKahlSyndicate } from "./inven
 | 
				
			|||||||
import { fromStoreItem, getKeyChainMessage, getLevelKeyRewards } from "./itemDataService.ts";
 | 
					import { fromStoreItem, getKeyChainMessage, getLevelKeyRewards } from "./itemDataService.ts";
 | 
				
			||||||
import type { IQuestKeyClient, IQuestKeyDatabase, IQuestStage } from "../types/inventoryTypes/inventoryTypes.ts";
 | 
					import type { IQuestKeyClient, IQuestKeyDatabase, IQuestStage } from "../types/inventoryTypes/inventoryTypes.ts";
 | 
				
			||||||
import { logger } from "../utils/logger.ts";
 | 
					import { logger } from "../utils/logger.ts";
 | 
				
			||||||
import type { Types } from "mongoose";
 | 
					 | 
				
			||||||
import { ExportKeys } from "warframe-public-export-plus";
 | 
					import { ExportKeys } from "warframe-public-export-plus";
 | 
				
			||||||
import { addFixedLevelRewards } from "./missionInventoryUpdateService.ts";
 | 
					import { addFixedLevelRewards } from "./missionInventoryUpdateService.ts";
 | 
				
			||||||
import type { IInventoryChanges } from "../types/purchaseTypes.ts";
 | 
					import type { IInventoryChanges } from "../types/purchaseTypes.ts";
 | 
				
			||||||
@ -44,7 +43,12 @@ export const updateQuestKey = async (
 | 
				
			|||||||
        inventory.QuestKeys[questKeyIndex].CompletionDate = new Date();
 | 
					        inventory.QuestKeys[questKeyIndex].CompletionDate = new Date();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const questKey = questKeyUpdate[0].ItemType;
 | 
					        const questKey = questKeyUpdate[0].ItemType;
 | 
				
			||||||
        await handleQuestCompletion(inventory, questKey, inventoryChanges);
 | 
					        await handleQuestCompletion(
 | 
				
			||||||
 | 
					            inventory,
 | 
				
			||||||
 | 
					            questKey,
 | 
				
			||||||
 | 
					            inventoryChanges,
 | 
				
			||||||
 | 
					            (questKeyUpdate[0].Progress?.[0]?.c ?? 0) > 0
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -52,7 +56,7 @@ export const updateQuestKey = async (
 | 
				
			|||||||
export const updateQuestStage = (
 | 
					export const updateQuestStage = (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
    { KeyChain, ChainStage }: IKeyChainRequest,
 | 
					    { KeyChain, ChainStage }: IKeyChainRequest,
 | 
				
			||||||
    questStageUpdate: IQuestStage
 | 
					    questStageUpdate: Partial<IQuestStage>
 | 
				
			||||||
): void => {
 | 
					): void => {
 | 
				
			||||||
    const quest = inventory.QuestKeys.find(quest => quest.ItemType === KeyChain);
 | 
					    const quest = inventory.QuestKeys.find(quest => quest.ItemType === KeyChain);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -68,14 +72,22 @@ export const updateQuestStage = (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
					    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
				
			||||||
    if (!questStage) {
 | 
					    if (!questStage) {
 | 
				
			||||||
        const questStageIndex = quest.Progress.push(questStageUpdate) - 1;
 | 
					        const questStageIndex =
 | 
				
			||||||
 | 
					            quest.Progress.push({
 | 
				
			||||||
 | 
					                c: questStageUpdate.c ?? 0,
 | 
				
			||||||
 | 
					                i: questStageUpdate.i ?? false,
 | 
				
			||||||
 | 
					                m: questStageUpdate.m ?? false,
 | 
				
			||||||
 | 
					                b: questStageUpdate.b ?? []
 | 
				
			||||||
 | 
					            }) - 1;
 | 
				
			||||||
        if (questStageIndex !== ChainStage) {
 | 
					        if (questStageIndex !== ChainStage) {
 | 
				
			||||||
            throw new Error(`Quest stage index mismatch: ${questStageIndex} !== ${ChainStage}`);
 | 
					            throw new Error(`Quest stage index mismatch: ${questStageIndex} !== ${ChainStage}`);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Object.assign(questStage, questStageUpdate);
 | 
					    for (const [key, value] of Object.entries(questStageUpdate) as [keyof IQuestStage, number | boolean | any[]][]) {
 | 
				
			||||||
 | 
					        (questStage[key] as any) = value;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const addQuestKey = (
 | 
					export const addQuestKey = (
 | 
				
			||||||
@ -112,58 +124,53 @@ export const completeQuest = async (inventory: TInventoryDatabaseDocument, quest
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const chainStageTotal = chainStages.length;
 | 
					    const chainStageTotal = chainStages.length;
 | 
				
			||||||
 | 
					    let existingQuestKey = inventory.QuestKeys.find(qk => qk.ItemType === questKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const existingQuestKey = inventory.QuestKeys.find(qk => qk.ItemType === questKey);
 | 
					    if (!existingQuestKey) {
 | 
				
			||||||
 | 
					        const completedQuestKey: IQuestKeyDatabase = {
 | 
				
			||||||
    const startingStage = Math.max((existingQuestKey?.Progress?.length ?? 0) - 1, 0);
 | 
					            ItemType: questKey,
 | 
				
			||||||
 | 
					            Completed: false,
 | 
				
			||||||
    if (existingQuestKey?.Completed) {
 | 
					            unlock: true,
 | 
				
			||||||
 | 
					            Progress: Array.from({ length: chainStageTotal }, () => ({
 | 
				
			||||||
 | 
					                c: 0,
 | 
				
			||||||
 | 
					                i: false,
 | 
				
			||||||
 | 
					                m: false,
 | 
				
			||||||
 | 
					                b: []
 | 
				
			||||||
 | 
					            }))
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        addQuestKey(inventory, completedQuestKey);
 | 
				
			||||||
 | 
					        existingQuestKey = inventory.QuestKeys.find(qk => qk.ItemType === questKey)!;
 | 
				
			||||||
 | 
					    } else if (existingQuestKey.Completed) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (existingQuestKey) {
 | 
					
 | 
				
			||||||
    existingQuestKey.Progress = existingQuestKey.Progress ?? [];
 | 
					    existingQuestKey.Progress = existingQuestKey.Progress ?? [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const existingProgressLength = existingQuestKey.Progress.length;
 | 
					    const run = existingQuestKey.Progress[0]?.c ?? 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const existingProgressLength = existingQuestKey.Progress.length;
 | 
				
			||||||
    if (existingProgressLength < chainStageTotal) {
 | 
					    if (existingProgressLength < chainStageTotal) {
 | 
				
			||||||
        const missingProgress: IQuestStage[] = Array.from(
 | 
					        const missingProgress: IQuestStage[] = Array.from(
 | 
				
			||||||
            { length: chainStageTotal - existingProgressLength },
 | 
					            { length: chainStageTotal - existingProgressLength },
 | 
				
			||||||
                () =>
 | 
					            () => ({ c: run, i: false, m: false, b: [] }) as IQuestStage
 | 
				
			||||||
                    ({
 | 
					 | 
				
			||||||
                        c: 0,
 | 
					 | 
				
			||||||
                        i: false,
 | 
					 | 
				
			||||||
                        m: false,
 | 
					 | 
				
			||||||
                        b: []
 | 
					 | 
				
			||||||
                    }) as IQuestStage
 | 
					 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					 | 
				
			||||||
        existingQuestKey.Progress.push(...missingProgress);
 | 
					        existingQuestKey.Progress.push(...missingProgress);
 | 
				
			||||||
            existingQuestKey.CompletionDate = new Date();
 | 
					 | 
				
			||||||
            existingQuestKey.Completed = true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        const completedQuestKey: IQuestKeyDatabase = {
 | 
					 | 
				
			||||||
            ItemType: questKey,
 | 
					 | 
				
			||||||
            Completed: true,
 | 
					 | 
				
			||||||
            unlock: true,
 | 
					 | 
				
			||||||
            Progress: Array(chainStageTotal).fill({
 | 
					 | 
				
			||||||
                c: 0,
 | 
					 | 
				
			||||||
                i: false,
 | 
					 | 
				
			||||||
                m: false,
 | 
					 | 
				
			||||||
                b: []
 | 
					 | 
				
			||||||
            } satisfies IQuestStage),
 | 
					 | 
				
			||||||
            CompletionDate: new Date()
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
        addQuestKey(inventory, completedQuestKey);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (let i = startingStage; i < chainStageTotal; i++) {
 | 
					    for (let i = 0; i < chainStageTotal; i++) {
 | 
				
			||||||
 | 
					        const stage = existingQuestKey.Progress[i];
 | 
				
			||||||
 | 
					        if (stage.c < run) {
 | 
				
			||||||
 | 
					            stage.c = run;
 | 
				
			||||||
            await giveKeyChainStageTriggered(inventory, { KeyChain: questKey, ChainStage: i });
 | 
					            await giveKeyChainStageTriggered(inventory, { KeyChain: questKey, ChainStage: i });
 | 
				
			||||||
 | 
					 | 
				
			||||||
            await giveKeyChainMissionReward(inventory, { KeyChain: questKey, ChainStage: i });
 | 
					            await giveKeyChainMissionReward(inventory, { KeyChain: questKey, ChainStage: i });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await handleQuestCompletion(inventory, questKey);
 | 
					    if (existingQuestKey.Progress.every(p => p.c == run)) {
 | 
				
			||||||
 | 
					        existingQuestKey.Completed = true;
 | 
				
			||||||
 | 
					        existingQuestKey.CompletionDate = new Date();
 | 
				
			||||||
 | 
					        await handleQuestCompletion(inventory, questKey, undefined, run > 0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const getQuestCompletionItems = (questKey: string): ITypeCount[] | undefined => {
 | 
					const getQuestCompletionItems = (questKey: string): ITypeCount[] | undefined => {
 | 
				
			||||||
@ -214,28 +221,35 @@ const doesQuestCompletionFinishSet = (
 | 
				
			|||||||
const handleQuestCompletion = async (
 | 
					const handleQuestCompletion = async (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
    questKey: string,
 | 
					    questKey: string,
 | 
				
			||||||
    inventoryChanges: IInventoryChanges = {}
 | 
					    inventoryChanges: IInventoryChanges = {},
 | 
				
			||||||
 | 
					    isRerun: boolean = false
 | 
				
			||||||
): Promise<void> => {
 | 
					): Promise<void> => {
 | 
				
			||||||
    logger.debug(`completed quest ${questKey}`);
 | 
					    logger.debug(`completed quest ${questKey}`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (inventory.ActiveQuest == questKey) inventory.ActiveQuest = "";
 | 
				
			||||||
    if (questKey == "/Lotus/Types/Keys/OrokinMoonQuest/OrokinMoonQuestKeyChain") {
 | 
					    if (questKey == "/Lotus/Types/Keys/OrokinMoonQuest/OrokinMoonQuestKeyChain") {
 | 
				
			||||||
 | 
					        const att = isRerun
 | 
				
			||||||
 | 
					            ? []
 | 
				
			||||||
 | 
					            : [
 | 
				
			||||||
 | 
					                  "/Lotus/Weapons/Tenno/Melee/Swords/StalkerTwo/StalkerTwoSmallSword",
 | 
				
			||||||
 | 
					                  "/Lotus/Upgrades/Skins/Sigils/ScarSigil"
 | 
				
			||||||
 | 
					              ];
 | 
				
			||||||
        await createMessage(inventory.accountOwnerId, [
 | 
					        await createMessage(inventory.accountOwnerId, [
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                sndr: "/Lotus/Language/Bosses/Ordis",
 | 
					                sndr: "/Lotus/Language/Bosses/Ordis",
 | 
				
			||||||
                msg: "/Lotus/Language/G1Quests/SecondDreamFinishInboxMessage",
 | 
					                msg: "/Lotus/Language/G1Quests/SecondDreamFinishInboxMessage",
 | 
				
			||||||
                att: [
 | 
					                att,
 | 
				
			||||||
                    "/Lotus/Weapons/Tenno/Melee/Swords/StalkerTwo/StalkerTwoSmallSword",
 | 
					 | 
				
			||||||
                    "/Lotus/Upgrades/Skins/Sigils/ScarSigil"
 | 
					 | 
				
			||||||
                ],
 | 
					 | 
				
			||||||
                sub: "/Lotus/Language/G1Quests/SecondDreamFinishInboxTitle",
 | 
					                sub: "/Lotus/Language/G1Quests/SecondDreamFinishInboxTitle",
 | 
				
			||||||
                icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
 | 
					                icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
 | 
				
			||||||
                highPriority: true
 | 
					                highPriority: true
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
    } else if (questKey == "/Lotus/Types/Keys/NewWarQuest/NewWarQuestKeyChain") {
 | 
					    } else if (questKey == "/Lotus/Types/Keys/NewWarQuest/NewWarQuestKeyChain" && !isRerun) {
 | 
				
			||||||
        setupKahlSyndicate(inventory);
 | 
					        setupKahlSyndicate(inventory);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (isRerun) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Whispers in the Walls is unlocked once The New War + Heart of Deimos are completed.
 | 
					    // Whispers in the Walls is unlocked once The New War + Heart of Deimos are completed.
 | 
				
			||||||
    if (
 | 
					    if (
 | 
				
			||||||
        doesQuestCompletionFinishSet(inventory, questKey, [
 | 
					        doesQuestCompletionFinishSet(inventory, questKey, [
 | 
				
			||||||
@ -279,21 +293,24 @@ const handleQuestCompletion = async (
 | 
				
			|||||||
    if (questCompletionItems) {
 | 
					    if (questCompletionItems) {
 | 
				
			||||||
        await addItems(inventory, questCompletionItems, inventoryChanges);
 | 
					        await addItems(inventory, questCompletionItems, inventoryChanges);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (inventory.ActiveQuest == questKey) inventory.ActiveQuest = "";
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const giveKeyChainItem = async (
 | 
					export const giveKeyChainItem = async (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
    keyChainInfo: IKeyChainRequest
 | 
					    keyChainInfo: IKeyChainRequest,
 | 
				
			||||||
 | 
					    isRerun: boolean = false
 | 
				
			||||||
): Promise<IInventoryChanges> => {
 | 
					): Promise<IInventoryChanges> => {
 | 
				
			||||||
    const inventoryChanges = await addKeyChainItems(inventory, keyChainInfo);
 | 
					    let inventoryChanges: IInventoryChanges = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!isRerun) {
 | 
				
			||||||
 | 
					        inventoryChanges = await addKeyChainItems(inventory, keyChainInfo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (isEmptyObject(inventoryChanges)) {
 | 
					        if (isEmptyObject(inventoryChanges)) {
 | 
				
			||||||
            logger.warn("inventory changes was empty after getting keychain items: should not happen");
 | 
					            logger.warn("inventory changes was empty after getting keychain items: should not happen");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // items were added: update quest stage's i (item was given)
 | 
					        // items were added: update quest stage's i (item was given)
 | 
				
			||||||
        updateQuestStage(inventory, keyChainInfo, { i: true });
 | 
					        updateQuestStage(inventory, keyChainInfo, { i: true });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -309,12 +326,17 @@ export const giveKeyChainItem = async (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export const giveKeyChainMessage = async (
 | 
					export const giveKeyChainMessage = async (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
    accountId: string | Types.ObjectId,
 | 
					    keyChainInfo: IKeyChainRequest,
 | 
				
			||||||
    keyChainInfo: IKeyChainRequest
 | 
					    isRerun: boolean = false
 | 
				
			||||||
): Promise<void> => {
 | 
					): Promise<void> => {
 | 
				
			||||||
    const keyChainMessage = getKeyChainMessage(keyChainInfo);
 | 
					    const keyChainMessage = getKeyChainMessage(keyChainInfo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await createMessage(accountId, [keyChainMessage]);
 | 
					    if (!isRerun) {
 | 
				
			||||||
 | 
					        keyChainMessage.att = [];
 | 
				
			||||||
 | 
					        keyChainMessage.countedAtt = [];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    await createMessage(inventory.accountOwnerId, [keyChainMessage]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    updateQuestStage(inventory, keyChainInfo, { m: true });
 | 
					    updateQuestStage(inventory, keyChainInfo, { m: true });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -328,8 +350,10 @@ export const giveKeyChainMissionReward = async (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (chainStages) {
 | 
					    if (chainStages) {
 | 
				
			||||||
        const missionName = chainStages[keyChainInfo.ChainStage].key;
 | 
					        const missionName = chainStages[keyChainInfo.ChainStage].key;
 | 
				
			||||||
        if (missionName) {
 | 
					        const questKey = inventory.QuestKeys.find(q => q.ItemType === keyChainInfo.KeyChain);
 | 
				
			||||||
 | 
					        if (missionName && questKey) {
 | 
				
			||||||
            const fixedLevelRewards = getLevelKeyRewards(missionName);
 | 
					            const fixedLevelRewards = getLevelKeyRewards(missionName);
 | 
				
			||||||
 | 
					            const run = questKey.Progress?.[0]?.c ?? 0;
 | 
				
			||||||
            if (fixedLevelRewards.levelKeyRewards) {
 | 
					            if (fixedLevelRewards.levelKeyRewards) {
 | 
				
			||||||
                const missionRewards: { StoreItem: string; ItemCount: number }[] = [];
 | 
					                const missionRewards: { StoreItem: string; ItemCount: number }[] = [];
 | 
				
			||||||
                inventory.RegularCredits += addFixedLevelRewards(fixedLevelRewards.levelKeyRewards, missionRewards);
 | 
					                inventory.RegularCredits += addFixedLevelRewards(fixedLevelRewards.levelKeyRewards, missionRewards);
 | 
				
			||||||
@ -338,7 +362,7 @@ export const giveKeyChainMissionReward = async (
 | 
				
			|||||||
                    await addItem(inventory, fromStoreItem(reward.StoreItem), reward.ItemCount);
 | 
					                    await addItem(inventory, fromStoreItem(reward.StoreItem), reward.ItemCount);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                updateQuestStage(inventory, keyChainInfo, { c: 0 });
 | 
					                updateQuestStage(inventory, keyChainInfo, { c: run });
 | 
				
			||||||
            } else if (fixedLevelRewards.levelKeyRewards2) {
 | 
					            } else if (fixedLevelRewards.levelKeyRewards2) {
 | 
				
			||||||
                for (const reward of fixedLevelRewards.levelKeyRewards2) {
 | 
					                for (const reward of fixedLevelRewards.levelKeyRewards2) {
 | 
				
			||||||
                    if (reward.rewardType == "RT_CREDITS") {
 | 
					                    if (reward.rewardType == "RT_CREDITS") {
 | 
				
			||||||
@ -352,7 +376,7 @@ export const giveKeyChainMissionReward = async (
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                updateQuestStage(inventory, keyChainInfo, { c: 0 });
 | 
					                updateQuestStage(inventory, keyChainInfo, { c: run });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -364,14 +388,17 @@ export const giveKeyChainStageTriggered = async (
 | 
				
			|||||||
): Promise<void> => {
 | 
					): Promise<void> => {
 | 
				
			||||||
    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
					    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
				
			||||||
    const chainStages = ExportKeys[keyChainInfo.KeyChain]?.chainStages;
 | 
					    const chainStages = ExportKeys[keyChainInfo.KeyChain]?.chainStages;
 | 
				
			||||||
 | 
					    const questKey = inventory.QuestKeys.find(qk => qk.ItemType === keyChainInfo.KeyChain);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (chainStages && questKey) {
 | 
				
			||||||
 | 
					        const run = questKey.Progress?.[0]?.c ?? 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (chainStages) {
 | 
					 | 
				
			||||||
        if (chainStages[keyChainInfo.ChainStage].itemsToGiveWhenTriggered.length > 0) {
 | 
					        if (chainStages[keyChainInfo.ChainStage].itemsToGiveWhenTriggered.length > 0) {
 | 
				
			||||||
            await giveKeyChainItem(inventory, keyChainInfo);
 | 
					            await giveKeyChainItem(inventory, keyChainInfo, run > 0);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (chainStages[keyChainInfo.ChainStage].messageToSendWhenTriggered) {
 | 
					        if (chainStages[keyChainInfo.ChainStage].messageToSendWhenTriggered) {
 | 
				
			||||||
            await giveKeyChainMessage(inventory, inventory.accountOwnerId, keyChainInfo);
 | 
					            await giveKeyChainMessage(inventory, keyChainInfo, run > 0);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -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) / 86400000;
 | 
					        const dayWithFraction = (timeMs - EPOCH) / unixTimesInMs.day;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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,22 +2814,14 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
 | 
				
			|||||||
                $date: {
 | 
					                $date: {
 | 
				
			||||||
                    $numberLong: config.worldState?.ghoulEmergenceOverride
 | 
					                    $numberLong: config.worldState?.ghoulEmergenceOverride
 | 
				
			||||||
                        ? "1753204900185"
 | 
					                        ? "1753204900185"
 | 
				
			||||||
                        : Date.UTC(
 | 
					                        : (EPOCH + activeStartDay * unixTimesInMs.day).toString()
 | 
				
			||||||
                              date.getUTCFullYear(),
 | 
					 | 
				
			||||||
                              date.getUTCMonth(),
 | 
					 | 
				
			||||||
                              date.getUTCDate() + activeStartDay
 | 
					 | 
				
			||||||
                          ).toString()
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            Expiry: {
 | 
					            Expiry: {
 | 
				
			||||||
                $date: {
 | 
					                $date: {
 | 
				
			||||||
                    $numberLong: config.worldState?.ghoulEmergenceOverride
 | 
					                    $numberLong: config.worldState?.ghoulEmergenceOverride
 | 
				
			||||||
                        ? "2000000000000"
 | 
					                        ? "2000000000000"
 | 
				
			||||||
                        : Date.UTC(
 | 
					                        : (EPOCH + activeEndDay * unixTimesInMs.day).toString()
 | 
				
			||||||
                              date.getUTCFullYear(),
 | 
					 | 
				
			||||||
                              date.getUTCMonth(),
 | 
					 | 
				
			||||||
                              date.getUTCDate() + activeEndDay
 | 
					 | 
				
			||||||
                          ).toString()
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            HealthPct: config.worldState?.ghoulEmergenceOverride ? 1 : healthPct,
 | 
					            HealthPct: config.worldState?.ghoulEmergenceOverride ? 1 : healthPct,
 | 
				
			||||||
 | 
				
			|||||||
@ -977,10 +977,10 @@ export interface IQuestKeyClient extends Omit<IQuestKeyDatabase, "CompletionDate
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IQuestStage {
 | 
					export interface IQuestStage {
 | 
				
			||||||
    c?: number;
 | 
					    c: number;
 | 
				
			||||||
    i?: boolean;
 | 
					    i: boolean;
 | 
				
			||||||
    m?: boolean;
 | 
					    m: boolean;
 | 
				
			||||||
    b?: any[];
 | 
					    b: any[];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IRawUpgrade {
 | 
					export interface IRawUpgrade {
 | 
				
			||||||
 | 
				
			|||||||
@ -45,6 +45,15 @@ 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 }[];
 | 
				
			||||||
@ -149,7 +158,6 @@ 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;
 | 
				
			||||||
 | 
				
			|||||||
@ -989,7 +989,8 @@ function updateInventory() {
 | 
				
			|||||||
            data.QuestKeys.forEach(item => {
 | 
					            data.QuestKeys.forEach(item => {
 | 
				
			||||||
                const tr = document.createElement("tr");
 | 
					                const tr = document.createElement("tr");
 | 
				
			||||||
                tr.setAttribute("data-item-type", item.ItemType);
 | 
					                tr.setAttribute("data-item-type", item.ItemType);
 | 
				
			||||||
                const stage = item.Progress?.length ?? 0;
 | 
					                const run = item.Progress[0]?.c ?? 0;
 | 
				
			||||||
 | 
					                const stage = run == 0 ? item.Progress.length : item.Progress.map(p => p.c ?? 0).lastIndexOf(run);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                const datalist = document.getElementById("datalist-QuestKeys");
 | 
					                const datalist = document.getElementById("datalist-QuestKeys");
 | 
				
			||||||
                const optionToRemove = datalist.querySelector(`option[data-key="${item.ItemType}"]`);
 | 
					                const optionToRemove = datalist.querySelector(`option[data-key="${item.ItemType}"]`);
 | 
				
			||||||
@ -1007,6 +1008,10 @@ function updateInventory() {
 | 
				
			|||||||
                        td.textContent += " | " + loc("code_completed");
 | 
					                        td.textContent += " | " + loc("code_completed");
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (run > 0) {
 | 
				
			||||||
 | 
					                        td.textContent += " | " + loc("code_replays") + ": " + (run + 1);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (data.ActiveQuest == item.ItemType) td.textContent += " | " + loc("code_active");
 | 
					                    if (data.ActiveQuest == item.ItemType) td.textContent += " | " + loc("code_active");
 | 
				
			||||||
                    tr.appendChild(td);
 | 
					                    tr.appendChild(td);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
				
			|||||||
@ -68,6 +68,7 @@ dict = {
 | 
				
			|||||||
    code_unmature: `Genetisches Altern zurücksetzen`,
 | 
					    code_unmature: `Genetisches Altern zurücksetzen`,
 | 
				
			||||||
    code_fund: `[UNTRANSLATED] Fund`,
 | 
					    code_fund: `[UNTRANSLATED] Fund`,
 | 
				
			||||||
    code_funded: `[UNTRANSLATED] Funded`,
 | 
					    code_funded: `[UNTRANSLATED] Funded`,
 | 
				
			||||||
 | 
					    code_replays: `[UNTRANSLATED] Replays`,
 | 
				
			||||||
    code_succChange: `Erfolgreich geändert.`,
 | 
					    code_succChange: `Erfolgreich geändert.`,
 | 
				
			||||||
    code_requiredInvigorationUpgrade: `Du musst sowohl ein offensives & defensives Upgrade auswählen.`,
 | 
					    code_requiredInvigorationUpgrade: `Du musst sowohl ein offensives & defensives Upgrade auswählen.`,
 | 
				
			||||||
    login_description: `Melde dich mit deinem OpenWF-Account an (denselben Angaben wie im Spiel, wenn du dich mit diesem Server verbindest).`,
 | 
					    login_description: `Melde dich mit deinem OpenWF-Account an (denselben Angaben wie im Spiel, wenn du dich mit diesem Server verbindest).`,
 | 
				
			||||||
 | 
				
			|||||||
@ -67,6 +67,7 @@ dict = {
 | 
				
			|||||||
    code_unmature: `Regress genetic aging`,
 | 
					    code_unmature: `Regress genetic aging`,
 | 
				
			||||||
    code_fund: `Fund`,
 | 
					    code_fund: `Fund`,
 | 
				
			||||||
    code_funded: `Funded`,
 | 
					    code_funded: `Funded`,
 | 
				
			||||||
 | 
					    code_replays: `Replays`,
 | 
				
			||||||
    code_succChange: `Successfully changed.`,
 | 
					    code_succChange: `Successfully changed.`,
 | 
				
			||||||
    code_requiredInvigorationUpgrade: `You must select both an offensive & defensive upgrade.`,
 | 
					    code_requiredInvigorationUpgrade: `You must select both an offensive & defensive upgrade.`,
 | 
				
			||||||
    login_description: `Login using your OpenWF account credentials (same as in-game when connecting to this server).`,
 | 
					    login_description: `Login using your OpenWF account credentials (same as in-game when connecting to this server).`,
 | 
				
			||||||
 | 
				
			|||||||
@ -68,6 +68,7 @@ dict = {
 | 
				
			|||||||
    code_unmature: `Regresar el envejecimiento genético`,
 | 
					    code_unmature: `Regresar el envejecimiento genético`,
 | 
				
			||||||
    code_fund: `[UNTRANSLATED] Fund`,
 | 
					    code_fund: `[UNTRANSLATED] Fund`,
 | 
				
			||||||
    code_funded: `[UNTRANSLATED] Funded`,
 | 
					    code_funded: `[UNTRANSLATED] Funded`,
 | 
				
			||||||
 | 
					    code_replays: `[UNTRANSLATED] Replays`,
 | 
				
			||||||
    code_succChange: `Cambiado correctamente`,
 | 
					    code_succChange: `Cambiado correctamente`,
 | 
				
			||||||
    code_requiredInvigorationUpgrade: `Debes seleccionar una mejora ofensiva y una defensiva.`,
 | 
					    code_requiredInvigorationUpgrade: `Debes seleccionar una mejora ofensiva y una defensiva.`,
 | 
				
			||||||
    login_description: `Inicia sesión con las credenciales de tu cuenta OpenWF (las mismas que usas en el juego al conectarte a este servidor).`,
 | 
					    login_description: `Inicia sesión con las credenciales de tu cuenta OpenWF (las mismas que usas en el juego al conectarte a este servidor).`,
 | 
				
			||||||
 | 
				
			|||||||
@ -68,6 +68,7 @@ dict = {
 | 
				
			|||||||
    code_unmature: `Régrésser l'âge génétique`,
 | 
					    code_unmature: `Régrésser l'âge génétique`,
 | 
				
			||||||
    code_fund: `Financer`,
 | 
					    code_fund: `Financer`,
 | 
				
			||||||
    code_funded: `Complété`,
 | 
					    code_funded: `Complété`,
 | 
				
			||||||
 | 
					    code_replays: `[UNTRANSLATED] Replays`,
 | 
				
			||||||
    code_succChange: `Changement effectué.`,
 | 
					    code_succChange: `Changement effectué.`,
 | 
				
			||||||
    code_requiredInvigorationUpgrade: `Augmentation offensive et défensive requises.`,
 | 
					    code_requiredInvigorationUpgrade: `Augmentation offensive et défensive requises.`,
 | 
				
			||||||
    login_description: `Connexion avec les informations de connexion OpenWF.`,
 | 
					    login_description: `Connexion avec les informations de connexion OpenWF.`,
 | 
				
			||||||
 | 
				
			|||||||
@ -68,6 +68,7 @@ dict = {
 | 
				
			|||||||
    code_unmature: `Регрессия генетического старения`,
 | 
					    code_unmature: `Регрессия генетического старения`,
 | 
				
			||||||
    code_fund: `Профинансировать`,
 | 
					    code_fund: `Профинансировать`,
 | 
				
			||||||
    code_funded: `Профинансировано`,
 | 
					    code_funded: `Профинансировано`,
 | 
				
			||||||
 | 
					    code_replays: `Повторов`,
 | 
				
			||||||
    code_succChange: `Успешно изменено.`,
 | 
					    code_succChange: `Успешно изменено.`,
 | 
				
			||||||
    code_requiredInvigorationUpgrade: `Вы должны выбрать как атакующее, так и вспомогательное улучшение.`,
 | 
					    code_requiredInvigorationUpgrade: `Вы должны выбрать как атакующее, так и вспомогательное улучшение.`,
 | 
				
			||||||
    login_description: `Войдите, используя учетные данные OpenWF (те же, что и в игре при подключении к этому серверу).`,
 | 
					    login_description: `Войдите, используя учетные данные OpenWF (те же, что и в игре при подключении к этому серверу).`,
 | 
				
			||||||
 | 
				
			|||||||
@ -68,6 +68,7 @@ dict = {
 | 
				
			|||||||
    code_unmature: `Обернути старіння`,
 | 
					    code_unmature: `Обернути старіння`,
 | 
				
			||||||
    code_fund: `[UNTRANSLATED] Fund`,
 | 
					    code_fund: `[UNTRANSLATED] Fund`,
 | 
				
			||||||
    code_funded: `[UNTRANSLATED] Funded`,
 | 
					    code_funded: `[UNTRANSLATED] Funded`,
 | 
				
			||||||
 | 
					    code_replays: `[UNTRANSLATED] Replays`,
 | 
				
			||||||
    code_succChange: `Успішно змінено.`,
 | 
					    code_succChange: `Успішно змінено.`,
 | 
				
			||||||
    code_requiredInvigorationUpgrade: `Ви повинні вибрати як атакуюче, так і допоміжне вдосконалення.`,
 | 
					    code_requiredInvigorationUpgrade: `Ви повинні вибрати як атакуюче, так і допоміжне вдосконалення.`,
 | 
				
			||||||
    login_description: `Увійдіть, використовуючи облікові дані OpenWF (ті ж, що й у грі при підключенні до цього серверу).`,
 | 
					    login_description: `Увійдіть, використовуючи облікові дані OpenWF (ті ж, що й у грі при підключенні до цього серверу).`,
 | 
				
			||||||
 | 
				
			|||||||
@ -68,6 +68,7 @@ dict = {
 | 
				
			|||||||
    code_unmature: `逆转衰老基因`,
 | 
					    code_unmature: `逆转衰老基因`,
 | 
				
			||||||
    code_fund: `[UNTRANSLATED] Fund`,
 | 
					    code_fund: `[UNTRANSLATED] Fund`,
 | 
				
			||||||
    code_funded: `[UNTRANSLATED] Funded`,
 | 
					    code_funded: `[UNTRANSLATED] Funded`,
 | 
				
			||||||
 | 
					    code_replays: `[UNTRANSLATED] Replays`,
 | 
				
			||||||
    code_succChange: `更改成功`,
 | 
					    code_succChange: `更改成功`,
 | 
				
			||||||
    code_requiredInvigorationUpgrade: `您必须同时选择一个进攻型和一个功能型活化属性.`,
 | 
					    code_requiredInvigorationUpgrade: `您必须同时选择一个进攻型和一个功能型活化属性.`,
 | 
				
			||||||
    login_description: `使用您的 OpenWF 账户凭证登录(与游戏内连接本服务器时使用的昵称相同)`,
 | 
					    login_description: `使用您的 OpenWF 账户凭证登录(与游戏内连接本服务器时使用的昵称相同)`,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user