Compare commits
5 Commits
quest-refa
...
main
Author | SHA1 | Date | |
---|---|---|---|
2c552f7b8a | |||
e903dce307 | |||
5aedb579aa | |||
7a2c187d54 | |||
76e40685ab |
@ -1,5 +1,7 @@
|
|||||||
import { IKeyChainRequest } from "@/src/types/requestTypes";
|
import { IKeyChainRequest } from "@/src/types/requestTypes";
|
||||||
import { getIndexAfter } from "@/src/helpers/stringHelpers";
|
import { getIndexAfter } from "@/src/helpers/stringHelpers";
|
||||||
|
import { ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
|
import { logger } from "@/src/utils/logger";
|
||||||
import {
|
import {
|
||||||
dict_de,
|
dict_de,
|
||||||
dict_en,
|
dict_en,
|
||||||
@ -32,6 +34,7 @@ import {
|
|||||||
IRecipe,
|
IRecipe,
|
||||||
TReward
|
TReward
|
||||||
} from "warframe-public-export-plus";
|
} from "warframe-public-export-plus";
|
||||||
|
import questCompletionItems from "@/static/fixed_responses/questCompletionRewards.json";
|
||||||
import { IMessage } from "../models/inboxModel";
|
import { IMessage } from "../models/inboxModel";
|
||||||
|
|
||||||
export type WeaponTypeInternal =
|
export type WeaponTypeInternal =
|
||||||
@ -178,6 +181,32 @@ export const getLevelKeyRewards = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getQuestCompletionItems = (questKey: string): ITypeCount[] | undefined => {
|
||||||
|
if (questKey in questCompletionItems) {
|
||||||
|
return questCompletionItems[questKey as keyof typeof questCompletionItems];
|
||||||
|
}
|
||||||
|
logger.warn(`Quest ${questKey} not found in questCompletionItems`);
|
||||||
|
|
||||||
|
const items: ITypeCount[] = [];
|
||||||
|
const meta = ExportKeys[questKey];
|
||||||
|
if (meta.rewards) {
|
||||||
|
for (const reward of meta.rewards) {
|
||||||
|
if (reward.rewardType == "RT_STORE_ITEM") {
|
||||||
|
items.push({
|
||||||
|
ItemType: fromStoreItem(reward.itemType),
|
||||||
|
ItemCount: 1
|
||||||
|
});
|
||||||
|
} else if (reward.rewardType == "RT_RESOURCE" || reward.rewardType == "RT_RECIPE") {
|
||||||
|
items.push({
|
||||||
|
ItemType: reward.itemType,
|
||||||
|
ItemCount: reward.amount
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
};
|
||||||
|
|
||||||
export const getKeyChainMessage = ({ KeyChain, ChainStage }: IKeyChainRequest): IMessage => {
|
export const getKeyChainMessage = ({ KeyChain, ChainStage }: IKeyChainRequest): IMessage => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
const chainStages = ExportKeys[KeyChain]?.chainStages;
|
const chainStages = ExportKeys[KeyChain]?.chainStages;
|
||||||
|
@ -3,14 +3,18 @@ import { isEmptyObject } from "@/src/helpers/general";
|
|||||||
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
|
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
|
||||||
import { createMessage } from "@/src/services/inboxService";
|
import { createMessage } from "@/src/services/inboxService";
|
||||||
import { addItem, addItems, addKeyChainItems, setupKahlSyndicate } from "@/src/services/inventoryService";
|
import { addItem, addItems, addKeyChainItems, setupKahlSyndicate } from "@/src/services/inventoryService";
|
||||||
import { fromStoreItem, getKeyChainMessage, getLevelKeyRewards } from "@/src/services/itemDataService";
|
import {
|
||||||
import { IQuestKeyClient, IQuestKeyDatabase, IQuestStage, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
|
fromStoreItem,
|
||||||
|
getKeyChainMessage,
|
||||||
|
getLevelKeyRewards,
|
||||||
|
getQuestCompletionItems
|
||||||
|
} from "@/src/services/itemDataService";
|
||||||
|
import { IQuestKeyClient, IQuestKeyDatabase, IQuestStage } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import { ExportKeys } from "warframe-public-export-plus";
|
import { ExportKeys } from "warframe-public-export-plus";
|
||||||
import { addFixedLevelRewards } from "./missionInventoryUpdateService";
|
import { addFixedLevelRewards } from "./missionInventoryUpdateService";
|
||||||
import { IInventoryChanges } from "../types/purchaseTypes";
|
import { IInventoryChanges } from "../types/purchaseTypes";
|
||||||
import questCompletionItems from "@/static/fixed_responses/questCompletionRewards.json";
|
|
||||||
|
|
||||||
export interface IUpdateQuestRequest {
|
export interface IUpdateQuestRequest {
|
||||||
QuestKeys: Omit<IQuestKeyDatabase, "CompletionDate">[];
|
QuestKeys: Omit<IQuestKeyDatabase, "CompletionDate">[];
|
||||||
@ -38,12 +42,23 @@ export const updateQuestKey = async (
|
|||||||
|
|
||||||
inventory.QuestKeys[questKeyIndex].overwrite(questKeyUpdate[0]);
|
inventory.QuestKeys[questKeyIndex].overwrite(questKeyUpdate[0]);
|
||||||
|
|
||||||
const inventoryChanges: IInventoryChanges = {};
|
let inventoryChanges: IInventoryChanges = {};
|
||||||
if (questKeyUpdate[0].Completed) {
|
if (questKeyUpdate[0].Completed) {
|
||||||
inventory.QuestKeys[questKeyIndex].CompletionDate = new Date();
|
inventory.QuestKeys[questKeyIndex].CompletionDate = new Date();
|
||||||
|
|
||||||
const questKey = questKeyUpdate[0].ItemType;
|
logger.debug(`completed quest ${questKeyUpdate[0].ItemType} `);
|
||||||
await handleQuestCompletion(inventory, questKey, inventoryChanges);
|
const questKeyName = questKeyUpdate[0].ItemType;
|
||||||
|
const questCompletionItems = getQuestCompletionItems(questKeyName);
|
||||||
|
logger.debug(`quest completion items`, questCompletionItems);
|
||||||
|
|
||||||
|
if (questCompletionItems) {
|
||||||
|
inventoryChanges = await addItems(inventory, questCompletionItems);
|
||||||
|
}
|
||||||
|
inventory.ActiveQuest = "";
|
||||||
|
|
||||||
|
if (questKeyUpdate[0].ItemType == "/Lotus/Types/Keys/NewWarQuest/NewWarQuestKeyChain") {
|
||||||
|
setupKahlSyndicate(inventory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return inventoryChanges;
|
return inventoryChanges;
|
||||||
};
|
};
|
||||||
@ -162,46 +177,26 @@ export const completeQuest = async (inventory: TInventoryDatabaseDocument, quest
|
|||||||
await giveKeyChainMissionReward(inventory, { KeyChain: questKey, ChainStage: i });
|
await giveKeyChainMissionReward(inventory, { KeyChain: questKey, ChainStage: i });
|
||||||
}
|
}
|
||||||
|
|
||||||
await handleQuestCompletion(inventory, questKey);
|
if (questKey == "/Lotus/Types/Keys/OrokinMoonQuest/OrokinMoonQuestKeyChain") {
|
||||||
};
|
void createMessage(inventory.accountOwnerId, [
|
||||||
|
{
|
||||||
const getQuestCompletionItems = (questKey: string): ITypeCount[] | undefined => {
|
sndr: "/Lotus/Language/Bosses/Ordis",
|
||||||
if (questKey in questCompletionItems) {
|
msg: "/Lotus/Language/G1Quests/SecondDreamFinishInboxMessage",
|
||||||
return questCompletionItems[questKey as keyof typeof questCompletionItems];
|
att: [
|
||||||
}
|
"/Lotus/Weapons/Tenno/Melee/Swords/StalkerTwo/StalkerTwoSmallSword",
|
||||||
logger.warn(`Quest ${questKey} not found in questCompletionItems`);
|
"/Lotus/Upgrades/Skins/Sigils/ScarSigil"
|
||||||
|
],
|
||||||
const items: ITypeCount[] = [];
|
sub: "/Lotus/Language/G1Quests/SecondDreamFinishInboxTitle",
|
||||||
const meta = ExportKeys[questKey];
|
icon: "/Lotus/Interface/Icons/Npcs/Ordis.png",
|
||||||
if (meta.rewards) {
|
highPriority: true
|
||||||
for (const reward of meta.rewards) {
|
|
||||||
if (reward.rewardType == "RT_STORE_ITEM") {
|
|
||||||
items.push({
|
|
||||||
ItemType: fromStoreItem(reward.itemType),
|
|
||||||
ItemCount: 1
|
|
||||||
});
|
|
||||||
} else if (reward.rewardType == "RT_RESOURCE" || reward.rewardType == "RT_RECIPE") {
|
|
||||||
items.push({
|
|
||||||
ItemType: reward.itemType,
|
|
||||||
ItemCount: reward.amount
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
]);
|
||||||
}
|
}
|
||||||
return items;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleQuestCompletion = async (
|
|
||||||
inventory: TInventoryDatabaseDocument,
|
|
||||||
questKey: string,
|
|
||||||
inventoryChanges: IInventoryChanges = {}
|
|
||||||
): Promise<void> => {
|
|
||||||
logger.debug(`completed quest ${questKey}`);
|
|
||||||
|
|
||||||
const questCompletionItems = getQuestCompletionItems(questKey);
|
const questCompletionItems = getQuestCompletionItems(questKey);
|
||||||
logger.debug(`quest completion items`, questCompletionItems);
|
logger.debug(`quest completion items`, questCompletionItems);
|
||||||
if (questCompletionItems) {
|
if (questCompletionItems) {
|
||||||
await addItems(inventory, questCompletionItems, inventoryChanges);
|
await addItems(inventory, questCompletionItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inventory.ActiveQuest == questKey) inventory.ActiveQuest = "";
|
if (inventory.ActiveQuest == questKey) inventory.ActiveQuest = "";
|
||||||
|
@ -5,5 +5,11 @@
|
|||||||
"ItemCount": 1
|
"ItemCount": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"/Lotus/Types/Keys/InfestedMicroplanetQuest/InfestedMicroplanetQuestKeyChain": [{ "ItemType": "/Lotus/Types/Recipes/WarframeRecipes/BrokenFrameBlueprint", "ItemCount": 1 }]
|
"/Lotus/Types/Keys/InfestedMicroplanetQuest/InfestedMicroplanetQuestKeyChain": [{ "ItemType": "/Lotus/Types/Recipes/WarframeRecipes/BrokenFrameBlueprint", "ItemCount": 1 }],
|
||||||
|
"/Lotus/Types/Keys/OrokinMoonQuest/OrokinMoonQuestKeyChain": [
|
||||||
|
{
|
||||||
|
"ItemType": "/Lotus/Types/Keys/RailJackBuildQuest/RailjackBuildQuestEmailItem",
|
||||||
|
"ItemCount": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user