diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs index 132a64fe..7fc5b5ab 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs @@ -628,8 +628,8 @@ public class BotGenerator( { var skillsToReturn = new Skills { - Common = GetSkillsWithRandomisedProgressValue(botSkills.Common, true), - Mastering = GetSkillsWithRandomisedProgressValue(botSkills.Mastering, false), + Common = GetCommonSkillsWithRandomisedProgressValue(botSkills.Common), + Mastering = GetMasteringSkillsWithRandomisedProgressValue(botSkills.Mastering), Points = 0 }; @@ -640,9 +640,43 @@ public class BotGenerator( /// Randomise the progress value of passed in skills based on the min/max value /// /// Skills to randomise - /// Are the skills 'common' skills - /// Skills with randomised progress values as an array - public List GetSkillsWithRandomisedProgressValue(Dictionary>? skills, bool isCommonSkills) + /// Skills with randomised progress values as a collection + public List GetCommonSkillsWithRandomisedProgressValue(Dictionary>? skills) + { + if (skills is null) + { + return []; + } + + return skills + .Select(kvp => + { + // Get skill from dict, skip if not found + var skill = kvp.Value; + if (skill == null) + { + return null; + } + + return new CommonSkill + { + Id = Enum.Parse(kvp.Key), + Progress = _randomUtil.GetDouble(skill.Min, skill.Max), + PointsEarnedDuringSession = 0, + LastAccess = 0 + }; + } + ) + .Where(baseSkill => baseSkill != null) + .ToList(); + } + + /// + /// Randomise the progress value of passed in skills based on the min/max value + /// + /// Skills to randomise + /// Skills with randomised progress values as a collection + public List GetMasteringSkillsWithRandomisedProgressValue(Dictionary>? skills) { if (skills is null) { @@ -660,20 +694,11 @@ public class BotGenerator( } // All skills have id and progress props - var skillToAdd = new BaseSkill + return new MasterySkill { - Id = Enum.Parse(kvp.Key), + Id = kvp.Key, Progress = _randomUtil.GetDouble(skill.Min, skill.Max) }; - - // Common skills have additional props - if (isCommonSkills) - { - skillToAdd.PointsEarnedDuringSession = 0; - skillToAdd.LastAccess = 0; - } - - return skillToAdd; } ) .Where(baseSkill => baseSkill != null) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/PrestigeHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/PrestigeHelper.cs index 020f12ba..1424a20b 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/PrestigeHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/PrestigeHelper.cs @@ -1,6 +1,4 @@ -using System.Text.Json; -using SPTarkov.Common.Extensions; -using SPTarkov.DI.Annotations; +using SPTarkov.DI.Annotations; using SPTarkov.Server.Core.Models.Eft.Common.Tables; using SPTarkov.Server.Core.Models.Eft.Profile; using SPTarkov.Server.Core.Models.Enums; diff --git a/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs index c0efd552..391b6565 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs @@ -537,7 +537,7 @@ public class ProfileHelper( /// Player profile /// Skill to look up and return value from /// Common skill object from desired profile - public BaseSkill? GetSkillFromProfile(PmcData pmcData, SkillTypes skill) + public CommonSkill? GetSkillFromProfile(PmcData pmcData, SkillTypes skill) { var skillToReturn = pmcData?.Skills?.Common.FirstOrDefault(s => s.Id == skill); if (skillToReturn == null) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/QuestHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/QuestHelper.cs index 5889b013..b0758ab8 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/QuestHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/QuestHelper.cs @@ -123,7 +123,7 @@ public class QuestHelper( /// the skill experience is being added to /// the amount of experience being added to the skill /// the adjusted skill progress gain - public int AdjustSkillExpForLowLevels(Models.Eft.Common.Tables.Common profileSkill, int progressAmount) + public int AdjustSkillExpForLowLevels(CommonSkill profileSkill, int progressAmount) { var currentLevel = Math.Floor((double) (profileSkill.Progress / 100)); diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotBase.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotBase.cs index 0961f76a..3548f501 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotBase.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotBase.cs @@ -931,43 +931,18 @@ public record BotBaseInventory } } -public record BaseJsonSkills -{ - [JsonExtensionData] - public Dictionary ExtensionData { get; set; } - - public List? Common - { - get; - set; - } - - - public List? Mastering - { - get; - set; - } - - public double? Points - { - get; - set; - } -} - public record Skills { [JsonExtensionData] public Dictionary ExtensionData { get; set; } - public List? Common + public List? Common { get; set; } - public List? Mastering + public List? Mastering { get; set; @@ -980,7 +955,22 @@ public record Skills } } -public record BaseSkill +public record MasterySkill +{ + public string? Id + { + get; + set; + } + + public double? Progress + { + get; + set; + } +} + +public record CommonSkill { [JsonExtensionData] public Dictionary ExtensionData { get; set; } @@ -1024,14 +1014,6 @@ public record BaseSkill } } -public record Common : BaseSkill -{ -} - -public record Mastering : BaseSkill -{ -} - public record Stats { [JsonExtensionData] diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Health/WorkoutData.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Health/WorkoutData.cs index 9b9c9a7f..384ad26a 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Health/WorkoutData.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Health/WorkoutData.cs @@ -24,7 +24,7 @@ public record WorkoutSkills public Dictionary ExtensionData { get; set; } [JsonPropertyName("Common")] - public List Common + public List Common { get; set; diff --git a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs index e9fc034d..f2cdd727 100644 --- a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs @@ -1144,7 +1144,7 @@ public class LocationLifecycleService /// Reset the skill points earned in a raid to 0, ready for next raid /// /// Profile common skills to update - protected void ResetSkillPointsEarnedDuringRaid(List commonSkills) + protected void ResetSkillPointsEarnedDuringRaid(List commonSkills) { foreach (var skill in commonSkills) {