diff --git a/Core/Controllers/ProfileController.cs b/Core/Controllers/ProfileController.cs index 4b3d31df..aa0926d1 100644 --- a/Core/Controllers/ProfileController.cs +++ b/Core/Controllers/ProfileController.cs @@ -2,7 +2,9 @@ using Core.Annotations; using Core.Generators; using Core.Helpers; using Core.Models.Eft.Common; +using Core.Models.Eft.Common.Tables; using Core.Models.Eft.Launcher; +using Core.Models.Eft.Player; using Core.Models.Eft.Profile; using Core.Models.Enums; using Core.Models.Utils; @@ -11,6 +13,7 @@ using Core.Servers; using Core.Services; using Core.Utils; using Core.Utils.Cloners; +using System.Collections.Generic; namespace Core.Controllers; @@ -269,61 +272,80 @@ public class ProfileController public GetOtherProfileResponse GetOtherProfile(string sessionId, GetOtherProfileRequest request) { // Find the profile by the account ID, fall back to the current player if we can't find the account - var profile = _profileHelper.GetFullProfileByAccountId(request.AccountId); - if (profile?.CharacterData?.PmcData == null || profile?.CharacterData?.ScavData == null) + var profileToView = _profileHelper.GetFullProfileByAccountId(request.AccountId); + if (profileToView?.CharacterData?.PmcData is null || profileToView.CharacterData.ScavData is null) { - profile = _profileHelper.GetFullProfile(sessionId); + _logger.Warning($"Unable to get profile: ${request.AccountId} to show, falling back to own profile"); + profileToView = _profileHelper.GetFullProfile(sessionId); } - var playerPmc = profile.CharacterData.PmcData; - var playerScav = profile.CharacterData.ScavData; + var profileToViewPmc = profileToView.CharacterData.PmcData; + var profileToViewScav = profileToView.CharacterData.ScavData; - return new GetOtherProfileResponse() + // Get the keys needed to find profiles hideout-related items + var hideoutKeys = new List(); + hideoutKeys.AddRange(profileToViewPmc.Inventory.HideoutAreaStashes.Keys); + hideoutKeys.Add(profileToViewPmc.Inventory.HideoutCustomizationStashId); + + // Find hideout items e.g. posters + var hideoutRootItems = profileToViewPmc.Inventory.Items.Where(x => hideoutKeys.Contains(x.Id)); + var itemsToReturn = new List(); + foreach (var rootItems in hideoutRootItems) { + // Check each root items for children and add + var itemWithChildren = _itemHelper.FindAndReturnChildrenAsItems(profileToViewPmc.Inventory.Items, rootItems.Id); + itemsToReturn.AddRange(itemWithChildren); + } + + return new GetOtherProfileResponse { - Id = playerPmc.Id, - Aid = playerPmc.Aid as int?, + Id = profileToViewPmc.Id, + Aid = profileToViewPmc.Aid, Info = { - Nickname = playerPmc.Info.Nickname, - Side = playerPmc.Info.Side, - Experience = playerPmc.Info.Experience as int?, - MemberCategory = playerPmc.Info.MemberCategory as int?, - BannedState = playerPmc.Info.BannedState, - BannedUntil = playerPmc.Info.BannedUntil, - RegistrationDate = playerPmc.Info.RegistrationDate, + Nickname = profileToViewPmc.Info.Nickname, + Side = profileToViewPmc.Info.Side, + Experience = profileToViewPmc.Info.Experience as int?, + MemberCategory = profileToViewPmc.Info.MemberCategory as int?, + BannedState = profileToViewPmc.Info.BannedState, + BannedUntil = profileToViewPmc.Info.BannedUntil, + RegistrationDate = profileToViewPmc.Info.RegistrationDate, }, Customization = { - Head = playerPmc.Customization.Head, - Body = playerPmc.Customization.Body, - Feet = playerPmc.Customization.Feet, - Hands = playerPmc.Customization.Hands, - Dogtag = playerPmc.Customization.DogTag, + Head = profileToViewPmc.Customization.Head, + Body = profileToViewPmc.Customization.Body, + Feet = profileToViewPmc.Customization.Feet, + Hands = profileToViewPmc.Customization.Hands, + Dogtag = profileToViewPmc.Customization.DogTag, }, - Skills = playerPmc.Skills, + Skills = profileToViewPmc.Skills, Equipment = { - Id = playerPmc.Inventory.Equipment, - Items = playerPmc.Inventory.Items, + Id = profileToViewPmc.Inventory.Equipment, + Items = profileToViewPmc.Inventory.Items, }, - Achievements = playerPmc.Achievements, - FavoriteItems = _profileHelper.GetOtherProfileFavorites(playerPmc), + Achievements = profileToViewPmc.Achievements, + FavoriteItems = _profileHelper.GetOtherProfileFavorites(profileToViewPmc), PmcStats = { Eft = { - TotalInGameTime = playerPmc.Stats.Eft.TotalInGameTime as int?, - OverAllCounters = playerPmc.Stats.Eft.OverallCounters, + TotalInGameTime = profileToViewPmc.Stats.Eft.TotalInGameTime, + OverAllCounters = profileToViewPmc.Stats.Eft.OverallCounters, }, }, ScavStats = { Eft = { - TotalInGameTime = playerScav.Stats.Eft.TotalInGameTime as int?, - OverAllCounters = playerScav.Stats.Eft.OverallCounters, + TotalInGameTime = profileToViewScav.Stats.Eft.TotalInGameTime, + OverAllCounters = profileToViewScav.Stats.Eft.OverallCounters, } - } + }, + Hideout = profileToViewPmc.Hideout, + CustomizationStash = profileToViewPmc.Inventory.HideoutCustomizationStashId, + HideoutAreaStashes = profileToViewPmc.Inventory.HideoutAreaStashes, + Items = itemsToReturn }; } diff --git a/Core/Models/Eft/Common/Tables/BotBase.cs b/Core/Models/Eft/Common/Tables/BotBase.cs index 99da7f4a..7d7fcafd 100644 --- a/Core/Models/Eft/Common/Tables/BotBase.cs +++ b/Core/Models/Eft/Common/Tables/BotBase.cs @@ -352,7 +352,7 @@ public class EftStats public DamageHistory? DamageHistory { get; set; } public DeathCause? DeathCause { get; set; } public LastPlayerState? LastPlayerState { get; set; } - public double? TotalInGameTime { get; set; } + public long? TotalInGameTime { get; set; } public string? SurvivorClass { get; set; } [JsonPropertyName("sptLastRaidFenceRepChange")] diff --git a/Core/Models/Eft/Profile/GetOtherProfileResponse.cs b/Core/Models/Eft/Profile/GetOtherProfileResponse.cs index e7f07c08..cac1cbd2 100644 --- a/Core/Models/Eft/Profile/GetOtherProfileResponse.cs +++ b/Core/Models/Eft/Profile/GetOtherProfileResponse.cs @@ -34,6 +34,18 @@ public class GetOtherProfileResponse [JsonPropertyName("scavStats")] public OtherProfileStats? ScavStats { get; set; } + + [JsonPropertyName("hideout")] + public Common.Tables.Hideout Hideout { get; set; } + + [JsonPropertyName("customizationStash")] + public string CustomizationStash { get; set; } + + [JsonPropertyName("hideoutAreaStashes")] + public Dictionary HideoutAreaStashes { get; set; } + + [JsonPropertyName("items")] + public List Items { get; set; } } public class OtherProfileInfo @@ -96,7 +108,7 @@ public class OtherProfileStats public class OtherProfileSubStats { [JsonPropertyName("totalInGameTime")] - public int? TotalInGameTime { get; set; } + public long? TotalInGameTime { get; set; } [JsonPropertyName("overAllCounters")] public OverallCounters? OverAllCounters { get; set; }