Skip to content

Commit

Permalink
[#9]: update dice
Browse files Browse the repository at this point in the history
  • Loading branch information
3k-dome committed Apr 30, 2023
1 parent ea572e8 commit 86c1e70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion catan-lib/Interfaces/Components/IDice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public interface IDice
{
Random Random { get; }
Random Random { get; init; }
int Rolled { get; }
int Roll();
int RollTwice();
Expand Down
12 changes: 6 additions & 6 deletions catan-lib/Parts/Dice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ namespace CatanLib.Parts
{
public class Dice : IDice
{
public Random Random { get; init; }

public int Rolled { get; private set; }

public Dice(int seed)
private readonly Random? random;
public Random Random
{
Random = new(seed);
get => random ?? throw new NullReferenceException();
init => random = value;
}

public int Rolled { get; private set; }

public int Roll()
{
Rolled = Random.Next(1, 7);
Expand Down

0 comments on commit 86c1e70

Please sign in to comment.