fix: use 1-indexing for ChainStage
The railjack quest sends an inbox messages at stage 4, which means index 3 in the chainStages.
This commit is contained in:
parent
2eb28c4e89
commit
184407d6f0
@ -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,
|
||||||
|
@ -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`);
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user