Fix issue with insurance message being incorrect
Moved `sendLostInsuranceMessage()` to `insuranceService` + make it read correct id from locale file
This commit is contained in:
parent
9bf533a1b1
commit
cfbe2739f9
@ -6,7 +6,6 @@ import { PlayerScavGenerator } from "../generators/PlayerScavGenerator";
|
||||
import { HealthHelper } from "../helpers/HealthHelper";
|
||||
import { InRaidHelper } from "../helpers/InRaidHelper";
|
||||
import { ItemHelper } from "../helpers/ItemHelper";
|
||||
import { NotificationSendHelper } from "../helpers/NotificationSendHelper";
|
||||
import { ProfileHelper } from "../helpers/ProfileHelper";
|
||||
import { QuestHelper } from "../helpers/QuestHelper";
|
||||
import { TraderHelper } from "../helpers/TraderHelper";
|
||||
@ -16,10 +15,7 @@ import { BodyPartHealth } from "../models/eft/common/tables/IBotBase";
|
||||
import { Item } from "../models/eft/common/tables/IItem";
|
||||
import { IRegisterPlayerRequestData } from "../models/eft/inRaid/IRegisterPlayerRequestData";
|
||||
import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData";
|
||||
import { IUserDialogInfo } from "../models/eft/profile/IAkiProfile";
|
||||
import { ConfigTypes } from "../models/enums/ConfigTypes";
|
||||
import { MemberCategory } from "../models/enums/MemberCategory";
|
||||
import { MessageType } from "../models/enums/MessageType";
|
||||
import { Traders } from "../models/enums/Traders";
|
||||
import { IAirdropConfig } from "../models/spt/config/IAirdropConfig";
|
||||
import { IInRaidConfig } from "../models/spt/config/IInRaidConfig";
|
||||
@ -28,7 +24,6 @@ import { ConfigServer } from "../servers/ConfigServer";
|
||||
import { DatabaseServer } from "../servers/DatabaseServer";
|
||||
import { SaveServer } from "../servers/SaveServer";
|
||||
import { InsuranceService } from "../services/InsuranceService";
|
||||
import { LocaleService } from "../services/LocaleService";
|
||||
import { MatchBotDetailsCacheService } from "../services/MatchBotDetailsCacheService";
|
||||
import { PmcChatResponseService } from "../services/PmcChatResponseService";
|
||||
import { JsonUtil } from "../utils/JsonUtil";
|
||||
@ -49,14 +44,12 @@ export class InraidController
|
||||
@inject("JsonUtil") protected jsonUtil: JsonUtil,
|
||||
@inject("TimeUtil") protected timeUtil: TimeUtil,
|
||||
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
|
||||
@inject("LocaleService") protected localeService: LocaleService,
|
||||
@inject("PmcChatResponseService") protected pmcChatResponseService: PmcChatResponseService,
|
||||
@inject("MatchBotDetailsCacheService") protected matchBotDetailsCacheService: MatchBotDetailsCacheService,
|
||||
@inject("QuestHelper") protected questHelper: QuestHelper,
|
||||
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
||||
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
|
||||
@inject("PlayerScavGenerator") protected playerScavGenerator: PlayerScavGenerator,
|
||||
@inject("NotificationSendHelper") protected notificationSendHelper: NotificationSendHelper,
|
||||
@inject("HealthHelper") protected healthHelper: HealthHelper,
|
||||
@inject("TraderHelper") protected traderHelper: TraderHelper,
|
||||
@inject("InsuranceService") protected insuranceService: InsuranceService,
|
||||
@ -141,7 +134,7 @@ export class InraidController
|
||||
{
|
||||
if (locationName.toLowerCase() === "laboratory")
|
||||
{
|
||||
this.sendLostInsuranceMessage(sessionID);
|
||||
this.insuranceService.sendLostInsuranceMessage(sessionID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,24 +248,6 @@ export class InraidController
|
||||
this.handlePostRaidPlayerScavProcess(scavData, sessionID, offraidData, pmcData, isDead);
|
||||
}
|
||||
|
||||
protected sendLostInsuranceMessage(sessionID: string): void
|
||||
{
|
||||
const localeDb = this.localeService.getLocaleDb();
|
||||
|
||||
const failedText = localeDb["5a8fd75188a45036844e0b0c"];
|
||||
const senderDetails: IUserDialogInfo = {
|
||||
_id: Traders.PRAPOR,
|
||||
info: {
|
||||
Nickname: "Prapor",
|
||||
Level: 1,
|
||||
Side: "Bear",
|
||||
MemberCategory: MemberCategory.TRADER
|
||||
}
|
||||
};
|
||||
|
||||
this.notificationSendHelper.sendMessageToPlayer(sessionID, senderDetails, failedText, MessageType.NPC_TRADER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the player dead after a raid - dead is anything other than "survived" / "runner"
|
||||
* @param statusOnExit exit value from offraidData object
|
||||
|
@ -28,6 +28,13 @@ export class DialogueHelper
|
||||
)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Create basic message context template
|
||||
* @param templateId
|
||||
* @param messageType
|
||||
* @param maxStoreTime
|
||||
* @returns
|
||||
*/
|
||||
public createMessageContext(templateId: string, messageType: MessageType, maxStoreTime: number): MessageContent
|
||||
{
|
||||
return {
|
||||
|
@ -3,14 +3,18 @@ import { ITraderBase } from "../models/eft/common/tables/ITrader";
|
||||
|
||||
import { DialogueHelper } from "../helpers/DialogueHelper";
|
||||
import { HandbookHelper } from "../helpers/HandbookHelper";
|
||||
import { NotificationSendHelper } from "../helpers/NotificationSendHelper";
|
||||
import { SecureContainerHelper } from "../helpers/SecureContainerHelper";
|
||||
import { TraderHelper } from "../helpers/TraderHelper";
|
||||
import { IPmcData } from "../models/eft/common/IPmcData";
|
||||
import { InsuredItem } from "../models/eft/common/tables/IBotBase";
|
||||
import { Item } from "../models/eft/common/tables/IItem";
|
||||
import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData";
|
||||
import { IUserDialogInfo } from "../models/eft/profile/IAkiProfile";
|
||||
import { ConfigTypes } from "../models/enums/ConfigTypes";
|
||||
import { MemberCategory } from "../models/enums/MemberCategory";
|
||||
import { MessageType } from "../models/enums/MessageType";
|
||||
import { Traders } from "../models/enums/Traders";
|
||||
import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig";
|
||||
import { ILogger } from "../models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "../servers/ConfigServer";
|
||||
@ -18,6 +22,7 @@ import { DatabaseServer } from "../servers/DatabaseServer";
|
||||
import { SaveServer } from "../servers/SaveServer";
|
||||
import { RandomUtil } from "../utils/RandomUtil";
|
||||
import { TimeUtil } from "../utils/TimeUtil";
|
||||
import { LocaleService } from "./LocaleService";
|
||||
import { LocalisationService } from "./LocalisationService";
|
||||
|
||||
@injectable()
|
||||
@ -37,6 +42,8 @@ export class InsuranceService
|
||||
@inject("DialogueHelper") protected dialogueHelper: DialogueHelper,
|
||||
@inject("HandbookHelper") protected handbookHelper: HandbookHelper,
|
||||
@inject("LocalisationService") protected localisationService: LocalisationService,
|
||||
@inject("LocaleService") protected localeService: LocaleService,
|
||||
@inject("NotificationSendHelper") protected notificationSendHelper: NotificationSendHelper,
|
||||
@inject("ConfigServer") protected configServer: ConfigServer
|
||||
)
|
||||
{
|
||||
@ -108,18 +115,14 @@ export class InsuranceService
|
||||
const insuranceReturnTimestamp = this.getInsuranceReturnTimestamp(pmcData, trader);
|
||||
const dialogueTemplates = this.databaseServer.getTables().traders[traderId].dialogue;
|
||||
|
||||
let messageContent = this.dialogueHelper.createMessageContext(this.randomUtil.getArrayValue(dialogueTemplates.insuranceStart), MessageType.NPC_TRADER, trader.insurance.max_storage_time);
|
||||
messageContent = {
|
||||
templateId: this.randomUtil.getArrayValue(dialogueTemplates.insuranceFound),
|
||||
type: MessageType.INSURANCE_RETURN,
|
||||
text: "", // live insurance returns have an empty string for the text property
|
||||
maxStorageTime: trader.insurance.max_storage_time * TimeUtil.oneHourAsSeconds,
|
||||
profileChangeEvents: [],
|
||||
systemData: {
|
||||
date: this.timeUtil.getDateMailFormat(),
|
||||
time: this.timeUtil.getTimeMailFormat(),
|
||||
location: mapId
|
||||
}
|
||||
// Send "i will go look for your stuff" message
|
||||
const messageContent = this.dialogueHelper.createMessageContext(this.randomUtil.getArrayValue(dialogueTemplates.insuranceStart), MessageType.NPC_TRADER, trader.insurance.max_storage_time);
|
||||
messageContent.text = ""; // live insurance returns have an empty string for the text property
|
||||
messageContent.profileChangeEvents = [];
|
||||
messageContent.systemData = {
|
||||
date: this.timeUtil.getDateMailFormat(),
|
||||
time: this.timeUtil.getTimeMailFormat(),
|
||||
location: mapId
|
||||
};
|
||||
|
||||
// Must occur after systemData is hydrated
|
||||
@ -128,6 +131,11 @@ export class InsuranceService
|
||||
// Remove 'hideout' slotid property on all insurance items
|
||||
this.removeLocationProperty(sessionID, traderId);
|
||||
|
||||
// Reuse existing context for message sent to player with insurance return
|
||||
messageContent.templateId = this.randomUtil.getArrayValue(dialogueTemplates.insuranceFound);
|
||||
messageContent.type = MessageType.INSURANCE_RETURN;
|
||||
|
||||
// Store insurance return details in profile + "hey i found your stuff, here you go!" message details to send player at a later date
|
||||
this.saveServer.getProfile(sessionID).insurance.push({
|
||||
scheduledTime: insuranceReturnTimestamp,
|
||||
traderId: traderId,
|
||||
@ -139,6 +147,28 @@ export class InsuranceService
|
||||
this.resetInsurance(sessionID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to player informing them gear was lost
|
||||
* @param sessionID Session id
|
||||
*/
|
||||
public sendLostInsuranceMessage(sessionID: string): void
|
||||
{
|
||||
const localeDb = this.localeService.getLocaleDb();
|
||||
const dialogueTemplates = this.databaseServer.getTables().traders[Traders.PRAPOR].dialogue; // todo: get trader id instead of hard coded prapor
|
||||
const failedText = localeDb[this.randomUtil.getArrayValue(dialogueTemplates.insuranceFailed)];
|
||||
const senderDetails: IUserDialogInfo = {
|
||||
_id: Traders.PRAPOR,
|
||||
info: {
|
||||
Nickname: "Prapor",
|
||||
Level: 1,
|
||||
Side: "Bear",
|
||||
MemberCategory: MemberCategory.TRADER
|
||||
}
|
||||
};
|
||||
|
||||
this.notificationSendHelper.sendMessageToPlayer(sessionID, senderDetails, failedText, MessageType.NPC_TRADER);
|
||||
}
|
||||
|
||||
protected removeLocationProperty(sessionId: string, traderId: string): void
|
||||
{
|
||||
const insuredItems = this.getInsurance(sessionId)[traderId];
|
||||
|
Loading…
Reference in New Issue
Block a user