Added code to insert SellitemToTrader
condition counter to profile on quest start
This commit is contained in:
parent
98d4bcc8ae
commit
060b0bb2de
@ -248,6 +248,8 @@ export class QuestController {
|
|||||||
// Note that for starting quests, the correct locale field is "description", not "startedMessageText".
|
// Note that for starting quests, the correct locale field is "description", not "startedMessageText".
|
||||||
const questFromDb = this.questHelper.getQuestFromDb(acceptedQuest.qid, pmcData);
|
const questFromDb = this.questHelper.getQuestFromDb(acceptedQuest.qid, pmcData);
|
||||||
|
|
||||||
|
this.addTaskConditionCountersToProfile(questFromDb.conditions.AvailableForFinish, pmcData, acceptedQuest.qid);
|
||||||
|
|
||||||
// Get messageId of text to send to player as text message in game
|
// Get messageId of text to send to player as text message in game
|
||||||
const messageId = this.questHelper.getMessageIdForQuestStart(
|
const messageId = this.questHelper.getMessageIdForQuestStart(
|
||||||
questFromDb.startedMessageText,
|
questFromDb.startedMessageText,
|
||||||
@ -281,6 +283,37 @@ export class QuestController {
|
|||||||
return acceptQuestResponse;
|
return acceptQuestResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param questConditions Conditions to iterate over and possibly add to profile
|
||||||
|
* @param pmcData Profile to add to
|
||||||
|
* @param questId Quest conditions came from
|
||||||
|
*/
|
||||||
|
protected addTaskConditionCountersToProfile(
|
||||||
|
questConditions: IQuestCondition[],
|
||||||
|
pmcData: IPmcData,
|
||||||
|
questId: string,
|
||||||
|
) {
|
||||||
|
for (const condition of questConditions) {
|
||||||
|
if (pmcData.TaskConditionCounters[condition.id]) {
|
||||||
|
this.logger.error(
|
||||||
|
`Unable to add new task condition counter: ${condition.conditionType} for qeust: ${questId} to profile: ${pmcData.sessionId} as it already exists:`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (condition.conditionType) {
|
||||||
|
case "SellItemToTrader":
|
||||||
|
pmcData.TaskConditionCounters[condition.id] = {
|
||||||
|
id: condition.id,
|
||||||
|
sourceId: questId,
|
||||||
|
type: condition.conditionType,
|
||||||
|
value: 0,
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the client accepting a repeatable quest and starting it
|
* Handle the client accepting a repeatable quest and starting it
|
||||||
* Send starting rewards if any to player and
|
* Send starting rewards if any to player and
|
||||||
|
Loading…
Reference in New Issue
Block a user