fn is_valid_sequence_same_suit(&mut self) -> bool {
        let mut jokers = self.take_jokers();
        let mut common_suit = Club;
        let mut current_value: u8 = 0;
        let mut di: usize = 0;
        for i in 0..self.0.len() {
            let card = &self.0[i+di];
            match card {
                RegularCard(suit, value) => {
                    if current_value == 0 {
                        common_suit = *suit;
                        current_value = *value;
                    } else {
                        if *suit != common_suit {
                            self.merge(jokers);
                            return false
                        }
                        if (*value != current_value + 1)
                              &&
                              ((current_value < MAX_VAL) || (*value != 1))
                        {
                            let next_val = match *value {
                                1 => MAX_VAL + 1,
                                n => n
                            };
                            if next_val < (current_value + 1) {
                                self.merge(jokers);
                                return false;
                            }
                            let diff = next_val - current_value - 1;
                            current_value += diff;
                            if (diff as usize) > jokers.number_cards() {
                                self.merge(jokers);
                                return false;
                            }
                            for _ in 0..diff {
                                di += 1;
                                self.0.insert(i+di-1, jokers.draw_card().unwrap());
                            }
                        }
                        current_value += 1;
                    }
                }
                Joker => ()
            }
        }
        self.merge(jokers);
        true
    }
/// check if the sequence is a valid one with a unique suit
check if the sequence is a valid one with a unique suit
check if the sequence is a valid one with a unique suit
fn is_valid_sequence_same_suit(&mut self) -> bool {
        let mut jokers = self.take_jokers();
        let mut common_suit = Club;
        let mut current_value: u8 = 0;
        let mut di: usize = 0;
        for i in 0..self.0.len() {
            let card = &self.0[i+di];
            match card {
                RegularCard(suit, value) => {
                    if current_value == 0 {
                        common_suit = *suit;
                        current_value = *value;
                    } else {
                        if *suit != common_suit {
                            self.merge(jokers);
                            return false
                        }
                        if (*value != current_value + 1)
                              &&
                              ((current_value < MAX_VAL) || (*value != 1))
                        {
                            let next_val = match *value {
                                1 => MAX_VAL + 1,
                                n => n
                            };
                            if next_val < (current_value + 1) {
                                self.merge(jokers);
                                return false;
                            }
                            let diff = next_val - current_value - 1;
                            current_value += diff;
                            if (diff as usize) > jokers.number_cards() {
                                self.merge(jokers);
                                return false;
                            }
                            for _ in 0..diff {
                                di += 1;
                                self.0.insert(i+di-1, jokers.draw_card().unwrap());
                            }
                        }
                        current_value += 1;
                    }
                }
                Joker => ()
            }
        }
        self.merge(jokers);
        true
    }
fn is_valid_sequence_same_suit ( & mut self ) -> bool { let mut jokers = self . take_jokers ( ) ; let mut common_suit = Club ; let mut current_value : u8 = 0 ; let mut di : usize = 0 ; for i in 0 .. self . 0 . len ( ) { let card = & self . 0 [ i + di ] ; match card { RegularCard ( suit , value ) => { if current_value == 0 { common_suit = * suit ; current_value = * value ; } else { if * suit != common_suit { self . merge ( jokers ) ; return false } if ( * value != current_value + 1 ) && ( ( current_value < MAX_VAL ) || ( * value != 1 ) ) { let next_val = match * value { 1 => MAX_VAL + 1 , n => n } ; if next_val < ( current_value + 1 ) { self . merge ( jokers ) ; return false ; } let diff = next_val - current_value - 1 ; current_value += diff ; if ( diff as usize ) > jokers . number_cards ( ) { self . merge ( jokers ) ; return false ; } for _ in 0 .. diff { di += 1 ; self . 0 . insert ( i + di - 1 , jokers . draw_card ( ) . unwrap ( ) ) ; } } current_value += 1 ; } } Joker => ( ) } } self . merge ( jokers ) ; true }
check if the sequence is a valid one with a unique suit
check if the sequence is a valid one with a unique suit
&mut self
&mut self