From 473156fadd1e07c1986233db040511174e8eff41 Mon Sep 17 00:00:00 2001 From: smallbenji Date: Wed, 25 Mar 2026 12:36:36 +0100 Subject: [PATCH] adding RNG --- PeopleVille/RNG.cs | 41 +++++++++++++++++++++++++++++++++++++++++ README.md | 10 ++++++++++ 2 files changed, 51 insertions(+) create mode 100644 PeopleVille/RNG.cs diff --git a/PeopleVille/RNG.cs b/PeopleVille/RNG.cs new file mode 100644 index 0000000..b044458 --- /dev/null +++ b/PeopleVille/RNG.cs @@ -0,0 +1,41 @@ +namespace PeopleVille +{ + public class RNG + { + static readonly Random random = new(); + + public static int Range(int minVal, int maxVal) + { + return random.Next(minVal, maxVal); + } + + public static int ThrowDice(Die die, int throws = 1) + { + var res = 0; + + for (var i = 0; i < throws; i++) + { + res += Range(1, die.Sides + 1); + } + + return res; + } + } + + public static class Dices + { + public static Die D2 = new(2); + public static Die D4 = new(4); + public static Die D6 = new(6); + } + + public class Die + { + public Die(int sides) + { + Sides = sides; + } + + public int Sides { get; set; } + } +} \ No newline at end of file diff --git a/README.md b/README.md index b60f0e2..0cabd47 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,16 @@ classDiagram +Task StartClock() } + class RNG { + +int ThrowDice() + +int Range() + } + + class Die { + +int Sides + } + RNG --|> Die + Gun ..|> IEquipment Food ..|> IEquipment