fix: use 1-indexing for ChainStage
All checks were successful
Build / build (push) Successful in 46s
Build / build (pull_request) Successful in 1m25s

The railjack quest sends an inbox messages at stage 4, which means index 3 in the chainStages.
This commit is contained in:
Sainan 2025-04-13 02:18:11 +02:00
parent 2eb28c4e89
commit 184407d6f0
3 changed files with 7 additions and 7 deletions

View File

@ -107,7 +107,7 @@ export const manageQuestsController: RequestHandler = async (req, res) => {
questKey.CompletionDate = undefined; questKey.CompletionDate = undefined;
} }
questKey.Progress.pop(); questKey.Progress.pop();
const stage = questKey.Progress.length - 1; const stage = questKey.Progress.length;
if (stage > 0) { if (stage > 0) {
await giveKeyChainStageTriggered(inventory, { await giveKeyChainStageTriggered(inventory, {
KeyChain: questKey.ItemType, KeyChain: questKey.ItemType,

View File

@ -185,7 +185,7 @@ export const getKeyChainMessage = ({ KeyChain, ChainStage }: IKeyChainRequest):
throw new Error(`KeyChain ${KeyChain} does not contain chain stages`); throw new Error(`KeyChain ${KeyChain} does not contain chain stages`);
} }
const keyChainStage = chainStages[ChainStage]; const keyChainStage = chainStages[ChainStage - 1];
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!keyChainStage) { if (!keyChainStage) {
throw new Error(`KeyChainStage ${ChainStage} not found`); throw new Error(`KeyChainStage ${ChainStage} not found`);

View File

@ -63,13 +63,13 @@ export const updateQuestStage = (
throw new Error(`Progress should always exist when giving keychain triggered items or messages`); throw new Error(`Progress should always exist when giving keychain triggered items or messages`);
} }
const questStage = quest.Progress[ChainStage]; const questStage = quest.Progress[ChainStage - 1];
// 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(questStageUpdate) - 1;
if (questStageIndex !== ChainStage) { if (questStageIndex !== ChainStage - 1) {
throw new Error(`Quest stage index mismatch: ${questStageIndex} !== ${ChainStage}`); throw new Error(`Quest stage index mismatch: ${questStageIndex} !== ${ChainStage - 1}`);
} }
return; return;
} }
@ -308,11 +308,11 @@ export const giveKeyChainStageTriggered = async (
const chainStages = ExportKeys[keyChainInfo.KeyChain]?.chainStages; const chainStages = ExportKeys[keyChainInfo.KeyChain]?.chainStages;
if (chainStages) { if (chainStages) {
if (chainStages[keyChainInfo.ChainStage].itemsToGiveWhenTriggered.length > 0) { if (chainStages[keyChainInfo.ChainStage - 1].itemsToGiveWhenTriggered.length > 0) {
await giveKeyChainItem(inventory, keyChainInfo); await giveKeyChainItem(inventory, keyChainInfo);
} }
if (chainStages[keyChainInfo.ChainStage].messageToSendWhenTriggered) { if (chainStages[keyChainInfo.ChainStage - 1].messageToSendWhenTriggered) {
await giveKeyChainMessage(inventory, inventory.accountOwnerId, keyChainInfo); await giveKeyChainMessage(inventory, inventory.accountOwnerId, keyChainInfo);
} }
} }