< Summary

Information
Class: RaidLoop.Core.PlayerStatRules
Assembly: RaidLoop.Core
File(s): /home/runner/work/RaidLoop/RaidLoop/src/RaidLoop.Core/PlayerStats.cs
Line coverage
83%
Covered lines: 15
Uncovered lines: 3
Coverable lines: 18
Total lines: 63
Line coverage: 83.3%
Branch coverage
83%
Covered branches: 15
Total branches: 18
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetAbilityModifier(...)100%11100%
GetRaiseCost(...)80%111077.77%
GetLowerRefund(...)87.5%8887.5%

File(s)

/home/runner/work/RaidLoop/RaidLoop/src/RaidLoop.Core/PlayerStats.cs

#LineLine coverage
 1namespace RaidLoop.Core;
 2
 3public sealed record PlayerStats(
 4    int Strength,
 5    int Dexterity,
 6    int Constitution,
 7    int Intelligence,
 8    int Wisdom,
 9    int Charisma)
 10{
 11    public static PlayerStats Default => new(
 12        PlayerStatRules.MinimumScore,
 13        PlayerStatRules.MinimumScore,
 14        PlayerStatRules.MinimumScore,
 15        PlayerStatRules.MinimumScore,
 16        PlayerStatRules.MinimumScore,
 17        PlayerStatRules.MinimumScore);
 18}
 19
 20public sealed record PlayerStatAllocation(PlayerStats Stats, int AvailablePoints)
 21{
 22    public static PlayerStatAllocation CreateDefault()
 23    {
 24        return new PlayerStatAllocation(PlayerStats.Default, PlayerStatRules.StartingPool);
 25    }
 26}
 27
 28public static class PlayerStatRules
 29{
 30    public const int MinimumScore = 8;
 31    public const int MaximumScore = 18;
 32    public const int StartingPool = 27;
 33
 34    public static int GetAbilityModifier(int score)
 35    {
 3636        return (int)Math.Floor((score - 10) / 2.0);
 37    }
 38
 39    public static int GetRaiseCost(int currentScore)
 40    {
 841        return currentScore switch
 842        {
 043            < MinimumScore => throw new ArgumentOutOfRangeException(nameof(currentScore)),
 044            >= MaximumScore => 0,
 345            <= 12 => 1,
 246            <= 14 => 2,
 247            <= 16 => 3,
 148            _ => 4
 849        };
 50    }
 51
 52    public static int GetLowerRefund(int currentScore)
 53    {
 754        return currentScore switch
 755        {
 056            <= MinimumScore => 0,
 257            <= 13 => 1,
 258            <= 15 => 2,
 259            <= 17 => 3,
 160            _ => 4
 761        };
 62    }
 63}