pub fn place_card(
        board: &mut [[Option<Card>; 5]; 4],
        deck1: &mut Vec<Card>,
        deck2: &mut Vec<Card>,
        card: usize,
        mov: Position,
        player: u8,
        bombs: &mut [[u8; 5]; 4],
        neighbours: &mut [Option<Position>; 4],
    ) -> bool {
        // determine the cell on the board
        let cell = &mut board[mov.0][mov.1];

        // replace cell placeholder card if move is legal
        match cell {
            // there is already a card in that cell
            Some(c) => {
                println!(
                    "{}-{} is already occupied with a {:?} !",
                    mov.0, mov.1, c.name
                );
                return false;
            }
            // cell is free to place a card
            None => {
                // player 1 plays
                if player == 1 {
                    *cell = Some(deck1.remove(card));
                }
                // player 2 plays
                else {
                    *cell = Some(deck2.remove(card));
                }

                Card::placement(board, mov, bombs, neighbours);

                Card::play(board, mov.0, mov.1, false, Some(*neighbours));

                return true;
            }
        }
    }
// places a card out of the player's deck on to the board. returns success
places a card out of the player's deck on to the board. returns success
places a card out of the player ' s deck on to the board . returns success
pub fn place_card(
        board: &mut [[Option<Card>; 5]; 4],
        deck1: &mut Vec<Card>,
        deck2: &mut Vec<Card>,
        card: usize,
        mov: Position,
        player: u8,
        bombs: &mut [[u8; 5]; 4],
        neighbours: &mut [Option<Position>; 4],
    ) -> bool {
        // determine the cell on the board
        let cell = &mut board[mov.0][mov.1];
        // replace cell placeholder card if move is legal
        match cell {
            // there is already a card in that cell
            Some(c) => {
                println!(
                    "{}-{} is already occupied with a {:?} !",
                    mov.0, mov.1, c.name
                );
                return false;
            }
            // cell is free to place a card
            None => {
                // player 1 plays
                if player == 1 {
                    *cell = Some(deck1.remove(card));
                }
                // player 2 plays
                else {
                    *cell = Some(deck2.remove(card));
                }
                Card::placement(board, mov, bombs, neighbours);
                Card::play(board, mov.0, mov.1, false, Some(*neighbours));
                return true;
            }
        }
    }
pub fn place_card ( board : & mut [ [ Option < Card > ; 5 ] ; 4 ] , deck1 : & mut Vec < Card > , deck2 : & mut Vec < Card > , card : usize , mov : Position , player : u8 , bombs : & mut [ [ u8 ; 5 ] ; 4 ] , neighbours : & mut [ Option < Position > ; 4 ] , ) -> bool { // determine the cell on the board let cell = & mut board [ mov . 0 ] [ mov . 1 ] ; // replace cell placeholder card if move is legal match cell { // there is already a card in that cell Some ( c ) => { println ! ( " " mov 0 mov 1 c name ) ; return false ; } // cell is free to place a card None => { // player 1 plays if player == 1 { * cell = Some ( deck1 . remove ( card ) ) ; } // player 2 plays else { * cell = Some ( deck2 . remove ( card ) ) ; } Card :: placement ( board , mov , bombs , neighbours ) ; Card :: play ( board , mov . 0 , mov . 1 , false , Some ( * neighbours ) ) ; return true ; } } }
places a card out of the player's deck on to the board.
places a card out of the player ' s deck on to the board .
board
&mut [[Option<Card>; 5]; 4]
deck1
&mut Vec<Card>
deck2
&mut Vec<Card>
card
usize
mov
Position
player
u8
bombs
&mut [[u8; 5]; 4]
neighbours
&mut [Option<Position>; 4]