| | | 1 | | namespace RaidLoop.Core; |
| | | 2 | | |
| | | 3 | | public 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 | | |
| | 8 | 20 | | public sealed record PlayerStatAllocation(PlayerStats Stats, int AvailablePoints) |
| | | 21 | | { |
| | | 22 | | public static PlayerStatAllocation CreateDefault() |
| | | 23 | | { |
| | 1 | 24 | | return new PlayerStatAllocation(PlayerStats.Default, PlayerStatRules.StartingPool); |
| | | 25 | | } |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | public 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 | | } |