namespace Deathwatch.Pages { public partial class DiceThrowing { private Random? _random; public int NbOfDice { get; set; } = 1; public int DiceValue { get; set; } = 1; public int NbOfCritics { get; set; } public List? Rolls { get; set; } public int Total { get; set; } //protected override async Task OnInitializedAsync() //{ // _random = new Random(); // Rolls = new List(); // var Task = new Task(() => { Thread.Sleep(1000); }); // await Task; //} protected override void OnInitialized() { base.OnInitialized(); _random = new Random(); Rolls = new List(); } public void ThrowDice() { var nbOfRolls = NbOfDice; Total = 0; Rolls = new List(); for (int i = 0; i <= nbOfRolls; i++) { var roll = _random.Next(1, DiceValue); Total += roll; Rolls?.Add(roll); if (roll == DiceValue && roll > 0) nbOfRolls++; } } } }