implemented skill system according to designdocuments
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NightclubArcadia.Skills
|
||||
{
|
||||
/// <summary>
|
||||
/// Pure rank state. No rolling, DC comparison, modifier math, UI, or Yarn.
|
||||
/// </summary>
|
||||
public sealed class PlayerSkills
|
||||
{
|
||||
readonly Dictionary<string, int> _ranks =
|
||||
new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public PlayerSkills(SkillDatabase db)
|
||||
{
|
||||
if (db == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(db));
|
||||
}
|
||||
|
||||
foreach (var skill in db.All)
|
||||
{
|
||||
if (skill == null || string.IsNullOrEmpty(skill.Id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_ranks[skill.Id] = skill.StartingRank;
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<string, int> AllRanks => _ranks;
|
||||
|
||||
public int GetRank(string skillId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(skillId))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _ranks.TryGetValue(skillId, out var rank) ? rank : 0;
|
||||
}
|
||||
|
||||
public void SetRank(string skillId, int rank)
|
||||
{
|
||||
if (string.IsNullOrEmpty(skillId))
|
||||
{
|
||||
throw new ArgumentException("Skill id is required.", nameof(skillId));
|
||||
}
|
||||
|
||||
_ranks[skillId] = rank;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user