From c3a4caa38a4716c462610d8714a904d037fa0051 Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 22 Jul 2023 14:02:13 +0100 Subject: [PATCH] Convert sptDev profiles quest starter email function to use mail send service --- project/src/controllers/ProfileController.ts | 12 ++++++++++-- project/src/controllers/QuestController.ts | 6 ------ project/src/helpers/QuestHelper.ts | 3 --- project/src/helpers/RagfairServerHelper.ts | 6 ------ 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/project/src/controllers/ProfileController.ts b/project/src/controllers/ProfileController.ts index 2d9e7a52..e5f95a6d 100644 --- a/project/src/controllers/ProfileController.ts +++ b/project/src/controllers/ProfileController.ts @@ -28,6 +28,7 @@ import { EventOutputHolder } from "../routers/EventOutputHolder"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { LocalisationService } from "../services/LocalisationService"; +import { MailSendService } from "../services/MailSendService"; import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; @@ -44,6 +45,7 @@ export class ProfileController @inject("ItemHelper") protected itemHelper: ItemHelper, @inject("ProfileFixerService") protected profileFixerService: ProfileFixerService, @inject("LocalisationService") protected localisationService: LocalisationService, + @inject("MailSendService") protected mailSendService: MailSendService, @inject("PlayerScavGenerator") protected playerScavGenerator: PlayerScavGenerator, @inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder, @inject("TraderHelper") protected traderHelper: TraderHelper, @@ -232,9 +234,15 @@ export class ProfileController // Get messageId of text to send to player as text message in game // Copy of code from QuestController.acceptQuest() const messageId = this.questHelper.getMessageIdForQuestStart(questFromDb.startedMessageText, questFromDb.description); - const messageContent = this.dialogueHelper.createMessageContext(messageId, MessageType.QUEST_START, 99999); const itemRewards = this.questHelper.applyQuestReward(profileDetails.characters.pmc, quest.qid, QuestStatus.Started, sessionID, response); - this.dialogueHelper.addDialogueMessage(questFromDb.traderId, messageContent, sessionID, itemRewards); + + this.mailSendService.sendLocalisedNpcMessageToPlayer( + sessionID, + this.traderHelper.getTraderById(questFromDb.traderId), + MessageType.QUEST_START, + messageId, + itemRewards, + this.timeUtil.getHoursAsSeconds(100)); } } diff --git a/project/src/controllers/QuestController.ts b/project/src/controllers/QuestController.ts index 783a13de..6c62c70e 100644 --- a/project/src/controllers/QuestController.ts +++ b/project/src/controllers/QuestController.ts @@ -275,10 +275,7 @@ export class QuestController const questFromDb = this.questHelper.getQuestFromDb(acceptedQuest.qid, pmcData); // Get messageId of text to send to player as text message in game const messageId = this.questHelper.getMessageIdForQuestStart(questFromDb.startedMessageText, questFromDb.description); - //const messageContent = this.dialogueHelper.createMessageContext(messageId, MessageType.QUEST_START, this.questConfig.redeemTime); - const startedQuestRewards = this.questHelper.applyQuestReward(pmcData, acceptedQuest.qid, QuestStatus.Started, sessionID, acceptQuestResponse); - //this.dialogueHelper.addDialogueMessage(questFromDb.traderId, messageContent, sessionID, startedQuestRewards); this.mailSendService.sendLocalisedNpcMessageToPlayer( sessionID, @@ -342,9 +339,6 @@ export class QuestController } const questRewards = this.questHelper.getQuestRewardItems(repeatableQuestProfile, state); - //const messageContent = this.dialogueHelper.createMessageContext(questStartedMessageKey, MessageType.QUEST_START, this.questConfig.redeemTime); - - //this.dialogueHelper.addDialogueMessage(repeatableQuestProfile.traderId, messageContent, sessionID, questRewards); this.mailSendService.sendLocalisedNpcMessageToPlayer( sessionID, diff --git a/project/src/helpers/QuestHelper.ts b/project/src/helpers/QuestHelper.ts index 766e362c..26391c17 100644 --- a/project/src/helpers/QuestHelper.ts +++ b/project/src/helpers/QuestHelper.ts @@ -519,9 +519,6 @@ export class QuestHelper // Create a dialog message for completing the quest. const quest = this.getQuestFromDb(failRequest.qid, pmcData); - //const messageContent = this.dialogueHelper.createMessageContext(quest.failMessageText, MessageType.QUEST_FAIL, this.questConfig.redeemTime); - //this.dialogueHelper.addDialogueMessage(quest.traderId, messageContent, sessionID, questRewards); - this.mailSendService.sendLocalisedNpcMessageToPlayer( sessionID, this.traderHelper.getTraderById(quest.traderId), diff --git a/project/src/helpers/RagfairServerHelper.ts b/project/src/helpers/RagfairServerHelper.ts index feb1eaaf..b84d4ce0 100644 --- a/project/src/helpers/RagfairServerHelper.ts +++ b/project/src/helpers/RagfairServerHelper.ts @@ -147,12 +147,6 @@ export class RagfairServerHelper */ public returnItems(sessionID: string, returnedItems: Item[]): void { - //const messageContent = this.dialogueHelper.createMessageContext(undefined, MessageType.MESSAGE_WITH_ITEMS, this.questConfig.redeemTime); - //const locale = this.localeService.getLocaleDb(); - //messageContent.text = locale[RagfairServerHelper.goodsReturnedTemplate]; - - //this.dialogueHelper.addDialogueMessage(Traders.RAGMAN, messageContent, sessionID, returnedItems); - this.mailSendService.sendLocalisedNpcMessageToPlayer( sessionID, Traders.RAGMAN,