genesys_dice_command_parser/dice_roll.rs
1use crate::dice::Dice;
2
3
4#[derive(Clone, Debug, PartialEq)]
5/// This struct represents the information required to calculate the result of a dice roll given the command string.
6/// Validating the sanity of each of the parameters is left to the user. e.g. The number of dice to roll could be 0.
7pub struct DiceRoll {
8 /// How many dice should be rolled.
9 pub number_of_dice_to_roll: u32,
10 /// Which type of dice it is.
11 pub die: Dice,
12}
13
14impl DiceRoll {
15 /// A convinience method for creating a `DiceRoll`.
16 ///
17 /// # Examples
18 ///
19 /// This represents rolling six Boost dice
20 /// ```
21 /// use dice_command_parser::dice_roll::{DiceRoll, Dice};
22 ///
23 /// let dice_roll = DiceRoll::new(Dice::Boost, 6);
24 /// ```
25 #[must_use]
26 pub fn new(
27 die: Dice,
28 number_of_dice_to_roll: u32,
29 ) -> Self {
30 DiceRoll {
31 die,
32 number_of_dice_to_roll,
33 }
34 }
35}