-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace CatanLib.Interfaces | ||
{ | ||
public interface IDice | ||
{ | ||
Random Random { get; } | ||
int Rolled { get; } | ||
int Roll(); | ||
int RollTwice(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using CatanLib.Interfaces; | ||
|
||
namespace CatanLib.Parts | ||
{ | ||
public class Dice : IDice | ||
{ | ||
public Random Random { get; init; } | ||
|
||
public int Rolled { get; private set; } | ||
|
||
public Dice(int seed) | ||
{ | ||
Random = new(seed); | ||
} | ||
|
||
public int Roll() | ||
{ | ||
Rolled = Random.Next(1, 7); | ||
return Rolled; | ||
} | ||
|
||
public int RollTwice() | ||
{ | ||
Rolled = Random.Next(1, 7) + Random.Next(1, 7); | ||
return Rolled; | ||
} | ||
} | ||
} |