Fix issue with completing Sadist not failing Colleagues Part 3

Added fail state to colleagues p3
Reworked loop inside `getQuestsFailedByCompletingQuest()`  to use .some() instead
Reworked `failQuests()` to check all fail conditions instead of just the first one
This commit is contained in:
Dev 2023-07-25 19:20:17 +01:00
parent 903dbdf432
commit 0a1913ab49
3 changed files with 25 additions and 13 deletions

View File

@ -52036,6 +52036,23 @@
"visibilityConditions": []
},
"dynamicLocale": false
},
{
"_parent": "Quest",
"_props": {
"availableAfter": 0,
"dispersion": 0,
"dynamicLocale": false,
"id": "5edac4fb16d984318871ba2e",
"index": 1,
"parentId": "",
"status": [
4
],
"target": "5edab4b1218d181e29451435",
"visibilityConditions": []
},
"dynamicLocale": false
}
]
},

View File

@ -397,7 +397,7 @@ export class QuestController
// Check if any of linked quest is failed, and that is unrestartable.
const questsToFail = this.getQuestsFailedByCompletingQuest(completedQuestId);
if (questsToFail && questsToFail.length > 0)
if (questsToFail?.length > 0)
{
this.failQuests(sessionID, pmcData, questsToFail);
}
@ -498,7 +498,8 @@ export class QuestController
*/
protected getQuestsFailedByCompletingQuest(completedQuestId: string): IQuest[]
{
return this.questHelper.getQuestsFromDb().filter((x) =>
const questsInDb = this.questHelper.getQuestsFromDb();
return questsInDb.filter((x) =>
{
// No fail conditions, exit early
if (!x.conditions.Fail || x.conditions.Fail.length === 0)
@ -506,20 +507,12 @@ export class QuestController
return false;
}
for (const failCondition of x.conditions.Fail)
{
if (failCondition._props.target === completedQuestId)
{
return true;
}
}
return false;
return x.conditions.Fail.some(y => y._props.target === completedQuestId);
});
}
/**
* Fail the quests provided
* Fail the provided quests
* Update quest in profile, otherwise add fresh quest object with failed status
* @param sessionID session id
* @param pmcData player profile
@ -529,7 +522,8 @@ export class QuestController
{
for (const questToFail of questsToFail)
{
if (questToFail.conditions.Fail[0]._props.status[0] !== QuestStatus.Success)
// Skip failing a quest that has a fail status of something other than success
if (questToFail.conditions.Fail?.some(x => x._props.status?.some(y => y !== QuestStatus.Success)))
{
continue;
}

View File

@ -77,6 +77,7 @@ export interface AvailableForProps
zoneId?: string
type?: boolean
countInRaid?: boolean
globalQuestCounterId?: any
}
export interface AvailableForCounter