fix giveKeyChainTriggeredItems
This commit is contained in:
parent
7679ddec16
commit
3370dc10e1
@ -73,13 +73,31 @@ export const updateQuest = async (accountId: string, updateQuest: IUpdateQuestRe
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const giveKeyChainTriggeredItems = async (accountId: string, keyChain: string, chainStage: number) => {
|
export const giveKeyChainTriggeredItems = async (accountId: string, keyChain: string, chainStage: number) => {
|
||||||
logger.debug("keyChain: " + keyChain + " chainStage: " + chainStage);
|
const inventory = await getInventory(accountId);
|
||||||
|
|
||||||
// TODO:rewards
|
// TODO:rewards
|
||||||
const quest = ExportKeys[keyChain];
|
const quest = ExportKeys[keyChain];
|
||||||
|
|
||||||
if (quest.chainStages) {
|
if (quest.chainStages) {
|
||||||
const stage = quest.chainStages[chainStage];
|
const stage = quest.chainStages[chainStage];
|
||||||
|
|
||||||
|
if (stage.key && stage.key in ExportKeys) {
|
||||||
|
const stageQuest = ExportKeys[stage.key];
|
||||||
|
if (stageQuest.rewards) {
|
||||||
|
for (const item of stageQuest.rewards) {
|
||||||
|
switch (item.rewardType) {
|
||||||
|
case "RT_STORE_ITEM":
|
||||||
|
await addItem(accountId, item.itemType.replace("/Lotus/StoreItems/", "/Lotus/"), 1);
|
||||||
|
break;
|
||||||
|
case "RT_CREDITS":
|
||||||
|
inventory.RegularCredits += item.amount;
|
||||||
|
await inventory.save();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (stage.itemsToGiveWhenTriggered.length > 0) {
|
if (stage.itemsToGiveWhenTriggered.length > 0) {
|
||||||
const itemType = stage.itemsToGiveWhenTriggered[0];
|
const itemType = stage.itemsToGiveWhenTriggered[0];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user