pub fn is_valid(&mut self) -> bool {
        
        if self.0.len() == 0 {
            return false;
        }
        
        if self.has_only_jokers() {
            return true;
        }

        if self.0.len() < 3 {
            return false;
        }

        // sort the equence
        self.sort_by_rank();
     
        if self.is_valid_sequence_same_val() {
            return true;
        }
        
        if self.is_valid_sequence_same_suit() {
            return true;
        }
        
        // if the first card is an ace, also try with the ace at the end
        match self.0[0] {
            RegularCard(_, 1) => {
                let ace = self.0[0].clone();
                self.0 = self.0[1..].to_vec();
                self.0.push(ace);
            },
            _ => ()
        };
        
        if self.is_valid_sequence_same_suit() {
            return true;
        }
 
        false
    }
/// Check if a sequence if valid for the Machiavelli game
///
/// # Example
///
/// ```
/// use machiavelli::sequence_cards::{ Sequence, Card::* , Suit::*};
///
/// let cards = [
///     RegularCard(Heart, 1),
///     Joker, 
///     RegularCard(Heart, 3),
/// ];
/// let mut sequence = Sequence::from_cards(&cards);
///
/// assert_eq!(sequence.is_valid(), true);
/// ```
Check if a sequence if valid for the Machiavelli game
Check if a sequence if valid for the Machiavelli game
pub fn is_valid(&mut self) -> bool {
        if self.0.len() == 0 {
            return false;
        }
        if self.has_only_jokers() {
            return true;
        }
        if self.0.len() < 3 {
            return false;
        }
        // sort the equence
        self.sort_by_rank();
        if self.is_valid_sequence_same_val() {
            return true;
        }
        if self.is_valid_sequence_same_suit() {
            return true;
        }
        // if the first card is an ace, also try with the ace at the end
        match self.0[0] {
            RegularCard(_, 1) => {
                let ace = self.0[0].clone();
                self.0 = self.0[1..].to_vec();
                self.0.push(ace);
            },
            _ => ()
        };
        if self.is_valid_sequence_same_suit() {
            return true;
        }
        false
    }
pub fn is_valid ( & mut self ) -> bool { if self . 0 . len ( ) == 0 { return false ; } if self . has_only_jokers ( ) { return true ; } if self . 0 . len ( ) < 3 { return false ; } // sort the equence self . sort_by_rank ( ) ; if self . is_valid_sequence_same_val ( ) { return true ; } if self . is_valid_sequence_same_suit ( ) { return true ; } // if the first card is an ace, also try with the ace at the end match self . 0 [ 0 ] { RegularCard ( _ , 1 ) => { let ace = self . 0 [ 0 ] . clone ( ) ; self . 0 = self . 0 [ 1 .. ] . to_vec ( ) ; self . 0 . push ( ace ) ; } , _ => ( ) } ; if self . is_valid_sequence_same_suit ( ) { return true ; } false }
Check if a sequence if valid for the Machiavelli game
Check if a sequence if valid for the Machiavelli game
&mut self
&mut self
example
```
use machiavelli::sequence_cards::{ Sequence, Card::* , Suit::*}.

let cards = [
RegularCard(Heart, 1),
Joker,
RegularCard(Heart, 3),
];
let mut sequence = Sequence::from_cards(&cards).

assert_eq!(sequence.is_valid(), true);
```
` ` ` use machiavelli :: sequence_cards :: { Sequence Card :: * Suit :: * } . let cards = [ RegularCard ( Heart 1 ) Joker RegularCard ( Heart 3 ) ] ; let mut sequence = Sequence :: from_cards ( &cards ) . assert_eq! ( sequence . is_valid () true ) ; ` ` `