Files
TheriapolisV3/Theriapolis.Core/Rules/Stats/SaveId.cs
T

33 lines
846 B
C#
Raw Normal View History

namespace Theriapolis.Core.Rules.Stats;
/// <summary>
/// Saving-throw categories. There's exactly one per ability; this enum is
/// a thin alias of <see cref="AbilityId"/> kept distinct so callsites read
/// clearly ("MakeSave(SaveId.DEX, dc)" vs "Mod(AbilityId.DEX)").
/// </summary>
public enum SaveId : byte
{
STR = 0,
DEX = 1,
CON = 2,
INT = 3,
WIS = 4,
CHA = 5,
}
public static class SaveIdExtensions
{
public static AbilityId Ability(this SaveId s) => (AbilityId)(byte)s;
public static SaveId FromJson(string raw) => raw.ToUpperInvariant() switch
{
"STR" => SaveId.STR,
"DEX" => SaveId.DEX,
"CON" => SaveId.CON,
"INT" => SaveId.INT,
"WIS" => SaveId.WIS,
"CHA" => SaveId.CHA,
_ => throw new ArgumentException($"Unknown save: '{raw}'"),
};
}