From 4e21239de310562fa92e2fb32cca5130c959d612 Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 6 Jan 2024 13:40:00 +0000 Subject: [PATCH] Improve accuracy of `view profile` --- project/src/controllers/DialogueController.ts | 4 +- project/src/controllers/ProfileController.ts | 38 ++++++++++++-- .../Dialogue/CommandoDialogueChatBot.ts | 2 +- .../helpers/Dialogue/SptDialogueChatBot.ts | 2 +- project/src/helpers/NotificationSendHelper.ts | 6 +-- project/src/models/eft/profile/IAkiProfile.ts | 2 +- .../eft/profile/IGetOtherProfileResponse.ts | 49 ++++++++++++++++--- project/src/services/GiftService.ts | 2 +- .../src/services/PmcChatResponseService.ts | 4 +- 9 files changed, 87 insertions(+), 22 deletions(-) diff --git a/project/src/controllers/DialogueController.ts b/project/src/controllers/DialogueController.ts index 51125bcb..17237ea6 100644 --- a/project/src/controllers/DialogueController.ts +++ b/project/src/controllers/DialogueController.ts @@ -141,7 +141,7 @@ export class DialogueController dialog.Users.push({ _id: profile.characters.pmc.sessionId, - info: { + Info: { Level: profile.characters.pmc.Info.Level, Nickname: profile.characters.pmc.Info.Nickname, Side: profile.characters.pmc.Info.Side, @@ -235,7 +235,7 @@ export class DialogueController const pmcProfile = fullProfile.characters.pmc; result.push({ _id: fullProfile.info.id, - info: { + Info: { Nickname: pmcProfile.Info.Nickname, Side: pmcProfile.Info.Side, Level: pmcProfile.Info.Level, diff --git a/project/src/controllers/ProfileController.ts b/project/src/controllers/ProfileController.ts index 0c16593c..6243c2c1 100644 --- a/project/src/controllers/ProfileController.ts +++ b/project/src/controllers/ProfileController.ts @@ -21,6 +21,7 @@ import { IProfileCreateRequestData } from "@spt-aki/models/eft/profile/IProfileC import { ISearchFriendRequestData } from "@spt-aki/models/eft/profile/ISearchFriendRequestData"; import { ISearchFriendResponse } from "@spt-aki/models/eft/profile/ISearchFriendResponse"; import { IValidateNicknameRequestData } from "@spt-aki/models/eft/profile/IValidateNicknameRequestData"; +import { MemberCategory } from "@spt-aki/models/enums/MemberCategory"; import { MessageType } from "@spt-aki/models/enums/MessageType"; import { QuestStatus } from "@spt-aki/models/enums/QuestStatus"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -399,14 +400,41 @@ export class ProfileController return { id: playerPmc._id, aid: playerPmc.aid, - info: playerPmc.Info, - customization: playerPmc.Customization, + info: { + nickname: playerPmc.Info.Nickname, + side: playerPmc.Info.Side, + experience: playerPmc.Info.Experience, + memberCategory: playerPmc.Info.MemberCategory, + bannedState: playerPmc.Info.BannedState, + bannedUntil: playerPmc.Info.BannedUntil, + registrationDate: playerPmc.Info.RegistrationDate + }, + customization: { + head: playerPmc.Customization.Head, + body: playerPmc.Customization.Body, + feet: playerPmc.Customization.Feet, + hands: playerPmc.Customization.Hands + }, skills: playerPmc.Skills, - equipment: playerPmc.Inventory, + equipment: { + // Default inventory tpl + Id: playerPmc.Inventory.items.find(x => x._tpl === "55d7217a4bdc2d86028b456d")._id, + Items: playerPmc.Inventory.items + }, achievements: playerPmc.Achievements, favoriteItems: playerPmc.Inventory.favoriteItems, - pmcStats: playerPmc.Stats, - scavStats: player.characters.scav.Stats + pmcStats: { + eft: { + totalInGameTime: playerPmc.Stats.Eft.TotalInGameTime, + overAllCounters: playerPmc.Stats.Eft.OverallCounters + } + }, + scavStats: { + eft: { + totalInGameTime: player.characters.scav.Stats.Eft.TotalInGameTime, + overAllCounters: player.characters.scav.Stats.Eft.OverallCounters + } + } }; } } diff --git a/project/src/helpers/Dialogue/CommandoDialogueChatBot.ts b/project/src/helpers/Dialogue/CommandoDialogueChatBot.ts index e73cda1c..32b383c4 100644 --- a/project/src/helpers/Dialogue/CommandoDialogueChatBot.ts +++ b/project/src/helpers/Dialogue/CommandoDialogueChatBot.ts @@ -34,7 +34,7 @@ export class CommandoDialogueChatBot implements IDialogueChatBot { return { _id: "sptCommando", - info: { Level: 1, MemberCategory: MemberCategory.DEVELOPER, Nickname: "Commando", Side: "Usec" }, + Info: { Level: 1, MemberCategory: MemberCategory.DEVELOPER, Nickname: "Commando", Side: "Usec" }, }; } diff --git a/project/src/helpers/Dialogue/SptDialogueChatBot.ts b/project/src/helpers/Dialogue/SptDialogueChatBot.ts index 2e56b338..119e9234 100644 --- a/project/src/helpers/Dialogue/SptDialogueChatBot.ts +++ b/project/src/helpers/Dialogue/SptDialogueChatBot.ts @@ -32,7 +32,7 @@ export class SptDialogueChatBot implements IDialogueChatBot { return { _id: "sptFriend", - info: { + Info: { Level: 1, MemberCategory: MemberCategory.DEVELOPER, Nickname: this.coreConfig.sptFriendNickname, diff --git a/project/src/helpers/NotificationSendHelper.ts b/project/src/helpers/NotificationSendHelper.ts index 788d0dbd..6fc23b2e 100644 --- a/project/src/helpers/NotificationSendHelper.ts +++ b/project/src/helpers/NotificationSendHelper.ts @@ -85,9 +85,9 @@ export class NotificationSendHelper protected getDialog(sessionId: string, messageType: MessageType, senderDetails: IUserDialogInfo): Dialogue { // Use trader id if sender is trader, otherwise use nickname - const key = (senderDetails.info.MemberCategory === MemberCategory.TRADER) + const key = (senderDetails.Info.MemberCategory === MemberCategory.TRADER) ? senderDetails._id - : senderDetails.info.Nickname; + : senderDetails.Info.Nickname; const dialogueData = this.saveServer.getProfile(sessionId).dialogues; const isNewDialogue = !(key in dialogueData); let dialogue: Dialogue = dialogueData[key]; @@ -102,7 +102,7 @@ export class NotificationSendHelper pinned: false, new: 0, attachmentsNew: 0, - Users: (senderDetails.info.MemberCategory === MemberCategory.TRADER) ? undefined : [senderDetails], + Users: (senderDetails.Info.MemberCategory === MemberCategory.TRADER) ? undefined : [senderDetails], }; dialogueData[key] = dialogue; diff --git a/project/src/models/eft/profile/IAkiProfile.ts b/project/src/models/eft/profile/IAkiProfile.ts index 0f8911f1..770ca2f5 100644 --- a/project/src/models/eft/profile/IAkiProfile.ts +++ b/project/src/models/eft/profile/IAkiProfile.ts @@ -113,7 +113,7 @@ export interface Dialogue export interface IUserDialogInfo { _id: string; - info: IUserDialogDetails; + Info: IUserDialogDetails; } export interface IUserDialogDetails diff --git a/project/src/models/eft/profile/IGetOtherProfileResponse.ts b/project/src/models/eft/profile/IGetOtherProfileResponse.ts index ba603b44..3a41f785 100644 --- a/project/src/models/eft/profile/IGetOtherProfileResponse.ts +++ b/project/src/models/eft/profile/IGetOtherProfileResponse.ts @@ -1,17 +1,54 @@ -import { Customization, Inventory, Skills, Stats } from "@spt-aki/models/eft/common/tables/IBotBase" +import { Customization, Inventory, OverallCounters, Skills, Stats } from "@spt-aki/models/eft/common/tables/IBotBase" import { Info } from "types/models/eft/common/tables/IBotBase" +import { Item } from "../common/tables/IItem" export interface IGetOtherProfileResponse { id: string aid: number - info: Info - customization: Customization + info: IOtherProfileInfo + customization: IOtherProfileCustomization skills: Skills - equipment: Inventory + equipment: IOtherProfileEquipment achievements: Record favoriteItems: string[] - pmcStats: Stats - scavStats: Stats + pmcStats: IOtherProfileStats + scavStats: IOtherProfileStats +} + +export interface IOtherProfileInfo +{ + nickname: string + side: string + experience: number + memberCategory: number + bannedState: boolean + bannedUntil: number + registrationDate: number +} + +export interface IOtherProfileCustomization +{ + head: string; + body: string; + feet: string; + hands: string; +} + +export interface IOtherProfileEquipment +{ + Id: string; + Items: Item[]; +} + +export interface IOtherProfileStats +{ + eft: IOtherProfileSubStats; +} + +export interface IOtherProfileSubStats +{ + totalInGameTime: number + overAllCounters: OverallCounters } \ No newline at end of file diff --git a/project/src/services/GiftService.ts b/project/src/services/GiftService.ts index 6a593fa5..92175368 100644 --- a/project/src/services/GiftService.ts +++ b/project/src/services/GiftService.ts @@ -134,7 +134,7 @@ export class GiftService const details: ISendMessageDetails = { recipientId: playerId, sender: this.getMessageType(giftData), - senderDetails: { _id: this.getSenderId(giftData), info: null }, + senderDetails: { _id: this.getSenderId(giftData), Info: null }, messageText: giftData.messageText, items: giftData.items, itemsMaxStorageLifetimeSeconds: this.timeUtil.getHoursAsSeconds(giftData.collectionTimeHours), diff --git a/project/src/services/PmcChatResponseService.ts b/project/src/services/PmcChatResponseService.ts index 597fc338..6cf68781 100644 --- a/project/src/services/PmcChatResponseService.ts +++ b/project/src/services/PmcChatResponseService.ts @@ -95,7 +95,7 @@ export class PmcChatResponseService const killerDetails: IUserDialogInfo = { _id: killerDetailsInCache._id, - info: { + Info: { Nickname: killerDetailsInCache.Info.Nickname, Side: killerDetailsInCache.Info.Side, Level: killerDetailsInCache.Info.Level, @@ -273,7 +273,7 @@ export class PmcChatResponseService ]; return { _id: pmcVictim.Name, - info: { + Info: { Nickname: pmcVictim.Name, Level: pmcVictim.Level, Side: pmcVictim.Side,