< Summary

Information
Class: RaidLoop.Core.PlayerStatAllocation
Assembly: RaidLoop.Core
File(s): /home/runner/work/RaidLoop/RaidLoop/src/RaidLoop.Core/PlayerStats.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 63
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Stats()100%11100%
CreateDefault()100%11100%

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
 820public sealed record PlayerStatAllocation(PlayerStats Stats, int AvailablePoints)
 21{
 22    public static PlayerStatAllocation CreateDefault()
 23    {
 124        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    {
 36        return (int)Math.Floor((score - 10) / 2.0);
 37    }
 38
 39    public static int GetRaiseCost(int currentScore)
 40    {
 41        return currentScore switch
 42        {
 43            < MinimumScore => throw new ArgumentOutOfRangeException(nameof(currentScore)),
 44            >= MaximumScore => 0,
 45            <= 12 => 1,
 46            <= 14 => 2,
 47            <= 16 => 3,
 48            _ => 4
 49        };
 50    }
 51
 52    public static int GetLowerRefund(int currentScore)
 53    {
 54        return currentScore switch
 55        {
 56            <= MinimumScore => 0,
 57            <= 13 => 1,
 58            <= 15 => 2,
 59            <= 17 => 3,
 60            _ => 4
 61        };
 62    }
 63}

Methods/Properties

get_Stats()
CreateDefault()