Improved Quest crafting unlock reward matching with Draks new gen:productionquests command output

This commit is contained in:
Dev 2024-11-02 16:47:49 +00:00
parent 05faafb9b3
commit 7ab3935b4b

View File

@ -1034,17 +1034,33 @@ export class QuestHelper {
response: IItemEventRouterResponse, response: IItemEventRouterResponse,
): void { ): void {
// Get hideout crafts and find those that match by areatype/required level/end product tpl - hope for just one match // Get hideout crafts and find those that match by areatype/required level/end product tpl - hope for just one match
const hideoutProductions = this.databaseService.getHideout().production; const craftingRecipes = this.databaseService.getHideout().production.recipes;
const matchingProductions = hideoutProductions.recipes.filter(
// Area that will be used to craft unlocked item
const desiredHideoutAreaType = Number.parseInt(craftUnlockReward.traderId);
let matchingProductions = craftingRecipes.filter(
(prod) => (prod) =>
prod.areaType === Number.parseInt(craftUnlockReward.traderId) && prod.areaType === desiredHideoutAreaType &&
//prod.requirements.some((requirement) => requirement.questId === questDetails._id) && // BSG dont store the quest id in requirement any more! //prod.requirements.some((requirement) => requirement.questId === questDetails._id) && // BSG dont store the quest id in requirement any more!
prod.requirements.some((requirement) => requirement.type === "QuestComplete") && prod.requirements.some((requirement) => requirement.type === "QuestComplete") &&
prod.requirements.some((x) => x.requiredLevel === craftUnlockReward.loyaltyLevel) && prod.requirements.some((requirement) => requirement.requiredLevel === craftUnlockReward.loyaltyLevel) &&
prod.endProduct === craftUnlockReward.items[0]._tpl,
);
// More/less than single match, above filtering wasn't strict enough
if (matchingProductions.length !== 1) {
// Multiple match were found, last ditch attempt to match by questid (value we add manually to production.json via `gen:productionquests` command)
matchingProductions = craftingRecipes.filter(
(prod) =>
prod.areaType === desiredHideoutAreaType &&
prod.requirements.some((requirement) => requirement.questId === questDetails._id) &&
prod.requirements.some(
(requirement) => requirement.requiredLevel === craftUnlockReward.loyaltyLevel,
) &&
prod.endProduct === craftUnlockReward.items[0]._tpl, prod.endProduct === craftUnlockReward.items[0]._tpl,
); );
// More/less than 1 match, above filtering wasn't strict enough
if (matchingProductions.length !== 1) { if (matchingProductions.length !== 1) {
this.logger.error( this.logger.error(
this.localisationService.getText("quest-unable_to_find_matching_hideout_production", { this.localisationService.getText("quest-unable_to_find_matching_hideout_production", {
@ -1055,6 +1071,7 @@ export class QuestHelper {
return; return;
} }
}
// Add above match to pmc profile + client response // Add above match to pmc profile + client response
const matchingCraftId = matchingProductions[0]._id; const matchingCraftId = matchingProductions[0]._id;