pub fn roll(&mut self, _ctx: &Context, p_name: String) -> Result<u32, &'static str> {
        if self.scores.len() >= (self.num_players as usize) {
            return Err("Maximum number of players rolled");
        }

        // each player is only allowed to roll once
        if self.scores.contains_key(&p_name) {
            return Err("Repeat rolls not allowed!");
        }

        let score = rand::thread_rng().gen_range(1, 7);
        if score > self.max_score {
            self.max_score = score;
        }

        self.scores.insert(p_name, score);
        Ok(score)
    }
/// Rolls a dice, resulting in a random number from 1-6.
Rolls a dice, resulting in a random number from 1-6.
Rolls a dice resulting in a random number from 1 - 6 .
pub fn roll(&mut self, _ctx: &Context, p_name: String) -> Result<u32, &'static str> {
        if self.scores.len() >= (self.num_players as usize) {
            return Err("Maximum number of players rolled");
        }
        // each player is only allowed to roll once
        if self.scores.contains_key(&p_name) {
            return Err("Repeat rolls not allowed!");
        }
        let score = rand::thread_rng().gen_range(1, 7);
        if score > self.max_score {
            self.max_score = score;
        }
        self.scores.insert(p_name, score);
        Ok(score)
    }
pub fn roll ( & mut self , _ctx : & Context , p_name : String ) -> Result < u32 , & ' static str > { if self . scores . len ( ) >= ( self . num_players as usize ) { return Err ( " " ) ; } // each player is only allowed to roll once if self . scores . contains_key ( & p_name ) { return Err ( " " ) ; } let score = rand :: thread_rng ( ) . gen_range ( 1 , 7 ) ; if score > self . max_score { self . max_score = score ; } self . scores . insert ( p_name , score ) ; Ok ( score ) }
Rolls a dice, resulting in a random number from 1-6.
Rolls a dice resulting in a random number from 1 - 6 .
&mut self
_ctx
&Context
p_name
String