private void RollWithModifier(object sender, RoutedEventArgs e) { var button = sender as Button; try { int modifier = Convert.ToInt32(button.Content); DRollResult roll = diceRoller.OnDiceRolled(sender, new DiceEventArgs() { Dice = new Dice(1, 20, modifier) }); rollResultBox.Text = roll.RollResult.ToString(); rollResultStringBox.Text = roll.RollString; rollResultList.Add(roll.RollString); } catch (Exception) { MessageBox.Show("No active monster selected"); } }
protected virtual void OnDiceRolled(object sender, RoutedEventArgs e) { try { int numberOfDice = Convert.ToInt32(diceNumber.Text); int typeOfDice = Convert.ToInt32(diceType.Text); int modifier = Convert.ToInt32(diceModifier.Text); DRollResult roll = diceRoller.OnDiceRolled(sender, new DiceEventArgs() { Dice = new Dice(numberOfDice, typeOfDice, modifier) }); rollResultBox.Text = roll.RollResult.ToString(); rollResultStringBox.Text = roll.RollString; rollResultList.Add(roll.RollString); } catch (Exception) { MessageBox.Show("Dice parameters must be integers"); } }
public RollResult() { Rolls = new List <int>(); DRoll = new DRollResult(); }