using SPTarkov.Server.Core.Models.Eft.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
using SPTarkov.Server.Core.Models.Enums;
namespace SPTarkov.Server.Core.Extensions
{
public static class ProfileExtensions
{
///
/// Return all quest items current in the supplied profile
///
/// Profile to get quest items from
/// List of item objects
public static List- GetQuestItemsInProfile(this PmcData profile)
{
return profile
?.Inventory?.Items.Where(i => i.ParentId == profile.Inventory.QuestRaidItems)
.ToList();
}
///
/// Upgrade hideout wall from starting level to interactable level if necessary stations have been upgraded
///
/// Profile to upgrade wall in
public static void UnlockHideoutWallInProfile(this PmcData profile)
{
var profileHideoutAreas = profile.Hideout.Areas;
var waterCollector = profileHideoutAreas.FirstOrDefault(x =>
x.Type == HideoutAreas.WaterCollector
);
var medStation = profileHideoutAreas.FirstOrDefault(x =>
x.Type == HideoutAreas.MedStation
);
var wall = profileHideoutAreas.FirstOrDefault(x =>
x.Type == HideoutAreas.EmergencyWall
);
// No collector or med station, skip
if (waterCollector is null && medStation is null)
{
return;
}
// If med-station > level 1 AND water collector > level 1 AND wall is level 0
if (waterCollector?.Level >= 1 && medStation?.Level >= 1 && wall?.Level <= 0)
{
wall.Level = 3;
}
}
///
/// Does the provided profile contain any condition counters
///
/// Profile to check for condition counters
/// Profile has condition counters
public static bool ProfileHasConditionCounters(this PmcData profile)
{
if (profile.TaskConditionCounters is null)
{
return false;
}
return profile.TaskConditionCounters.Count > 0;
}
///
/// Get a specific common skill from supplied profile
///
/// Player profile
/// Skill to look up and return value from
/// Common skill object from desired profile
public static CommonSkill? GetSkillFromProfile(this PmcData profile, SkillTypes skill)
{
return profile?.Skills?.Common?.FirstOrDefault(s => s.Id == skill);
}
///
/// Get the scav karma level for a profile
/// Is also the fence trader rep level
///
/// pmc profile
/// karma level
public static double GetScavKarmaLevel(this PmcData pmcData)
{
// can be empty during profile creation
if (!pmcData.TradersInfo.TryGetValue(Traders.FENCE, out var fenceInfo))
{
return 0;
}
if (fenceInfo.Standing > 6)
{
return 6;
}
return Math.Floor(fenceInfo.Standing ?? 0);
}
}
}