private void _rollWorker_DoWork(object sender, DoWorkEventArgs e) { int rolls = 0; while (++rolls < 10) { foreach (RandomTableRowViewModel rowView in _rows) { if (rowView.Selected == true) { rowView.Selected = false; break; } } string dieString = !String.IsNullOrWhiteSpace(_randomTableModel.Die) ? _randomTableModel.Die.Replace("d", String.Empty) : "2"; if (Int32.TryParse(dieString, out int die)) { _rolledValue = null; _rolledNumber = _diceService.RandomNumber(1, die); foreach (RandomTableRowViewModel rowView in _rows) { if (_rolledNumber >= rowView.Min && _rolledNumber <= rowView.Max) { _rolledValue = rowView.Value; rowView.Selected = true; break; } } } Thread.Sleep(100); } }
private void RollHitDie(LevelViewModel levelView) { if (Int32.TryParse(levelView.HitDie.Replace("d", ""), out int hitDie)) { levelView.HitDieRestRoll = _diceService.RandomNumber(1, hitDie); UpdateTotal(); } }