34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
namespace NeonSprawl.Server.Game.Mastery;
|
|
|
|
/// <summary>Read model for one player's perk state (NEO-47).</summary>
|
|
public sealed class PerkStateSnapshot
|
|
{
|
|
public static PerkStateSnapshot Empty { get; } = new(
|
|
new Dictionary<string, IReadOnlyDictionary<int, string>>(StringComparer.Ordinal),
|
|
new HashSet<string>(StringComparer.Ordinal));
|
|
|
|
public PerkStateSnapshot(
|
|
IReadOnlyDictionary<string, IReadOnlyDictionary<int, string>> branchPicksBySkillId,
|
|
IReadOnlySet<string> unlockedPerkIds)
|
|
{
|
|
BranchPicksBySkillId = branchPicksBySkillId;
|
|
UnlockedPerkIds = unlockedPerkIds;
|
|
}
|
|
|
|
/// <summary><c>skillId</c> → <c>tierIndex</c> → <c>branchId</c>.</summary>
|
|
public IReadOnlyDictionary<string, IReadOnlyDictionary<int, string>> BranchPicksBySkillId { get; }
|
|
|
|
public IReadOnlySet<string> UnlockedPerkIds { get; }
|
|
|
|
public bool TryGetBranchPick(string skillId, int tierIndex, out string branchId)
|
|
{
|
|
branchId = string.Empty;
|
|
if (!BranchPicksBySkillId.TryGetValue(skillId, out var tiers))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return tiers.TryGetValue(tierIndex, out branchId!);
|
|
}
|
|
}
|