Refactored how skills are parsed, fixes issues with bot generation and end of raid profile parsing
This commit is contained in:
@@ -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
|
||||
/// </summary>
|
||||
/// <param name="skills">Skills to randomise</param>
|
||||
/// <param name="isCommonSkills">Are the skills 'common' skills</param>
|
||||
/// <returns>Skills with randomised progress values as an array</returns>
|
||||
public List<BaseSkill> GetSkillsWithRandomisedProgressValue(Dictionary<string, MinMax<double>>? skills, bool isCommonSkills)
|
||||
/// <returns>Skills with randomised progress values as a collection</returns>
|
||||
public List<CommonSkill> GetCommonSkillsWithRandomisedProgressValue(Dictionary<string, MinMax<double>>? 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<SkillTypes>(kvp.Key),
|
||||
Progress = _randomUtil.GetDouble(skill.Min, skill.Max),
|
||||
PointsEarnedDuringSession = 0,
|
||||
LastAccess = 0
|
||||
};
|
||||
}
|
||||
)
|
||||
.Where(baseSkill => baseSkill != null)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Randomise the progress value of passed in skills based on the min/max value
|
||||
/// </summary>
|
||||
/// <param name="skills">Skills to randomise</param>
|
||||
/// <returns>Skills with randomised progress values as a collection</returns>
|
||||
public List<MasterySkill> GetMasteringSkillsWithRandomisedProgressValue(Dictionary<string, MinMax<double>>? 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<SkillTypes>(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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -537,7 +537,7 @@ public class ProfileHelper(
|
||||
/// <param name="pmcData">Player profile</param>
|
||||
/// <param name="skill">Skill to look up and return value from</param>
|
||||
/// <returns>Common skill object from desired profile</returns>
|
||||
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)
|
||||
|
||||
@@ -123,7 +123,7 @@ public class QuestHelper(
|
||||
/// <param name="profileSkill">the skill experience is being added to</param>
|
||||
/// <param name="progressAmount">the amount of experience being added to the skill</param>
|
||||
/// <returns>the adjusted skill progress gain</returns>
|
||||
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));
|
||||
|
||||
|
||||
@@ -931,43 +931,18 @@ public record BotBaseInventory
|
||||
}
|
||||
}
|
||||
|
||||
public record BaseJsonSkills
|
||||
{
|
||||
[JsonExtensionData]
|
||||
public Dictionary<string, object> ExtensionData { get; set; }
|
||||
|
||||
public List<Common>? Common
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
public List<Mastering>? Mastering
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public double? Points
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
public record Skills
|
||||
{
|
||||
[JsonExtensionData]
|
||||
public Dictionary<string, object> ExtensionData { get; set; }
|
||||
|
||||
public List<BaseSkill>? Common
|
||||
public List<CommonSkill>? Common
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public List<BaseSkill>? Mastering
|
||||
public List<MasterySkill>? 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<string, object> ExtensionData { get; set; }
|
||||
@@ -1024,14 +1014,6 @@ public record BaseSkill
|
||||
}
|
||||
}
|
||||
|
||||
public record Common : BaseSkill
|
||||
{
|
||||
}
|
||||
|
||||
public record Mastering : BaseSkill
|
||||
{
|
||||
}
|
||||
|
||||
public record Stats
|
||||
{
|
||||
[JsonExtensionData]
|
||||
|
||||
@@ -24,7 +24,7 @@ public record WorkoutSkills
|
||||
public Dictionary<string, object> ExtensionData { get; set; }
|
||||
|
||||
[JsonPropertyName("Common")]
|
||||
public List<BaseSkill> Common
|
||||
public List<CommonSkill> Common
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
||||
@@ -1144,7 +1144,7 @@ public class LocationLifecycleService
|
||||
/// Reset the skill points earned in a raid to 0, ready for next raid
|
||||
/// </summary>
|
||||
/// <param name="commonSkills"> Profile common skills to update </param>
|
||||
protected void ResetSkillPointsEarnedDuringRaid(List<BaseSkill> commonSkills)
|
||||
protected void ResetSkillPointsEarnedDuringRaid(List<CommonSkill> commonSkills)
|
||||
{
|
||||
foreach (var skill in commonSkills)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user