pub fn placement(
        board: &mut [[Option<Card>; 5]; 4],
        position: Position,
        bombs: &mut [[u8; 5]; 4],
        neighbours: &mut [Option<Position>; 4],
    ) {
        let y = position.0;
        let x = position.1;

        match board[y][x].as_ref().unwrap().name {
            // Saboteur places bombs on empty neighbours
            Unit::Saboteur => {
                // top neighbour
                if y > 0 && board[y - 1][x].is_none() {
                    bombs[y - 1][x] += 1;
                }
                // bottom neighbour
                if y < 3 && board[y + 1][x].is_none() {
                    bombs[y + 1][x] += 1;
                }
                // left neighbour
                if x > 0 && board[y][x - 1].is_none() {
                    bombs[y][x - 1] += 1;
                }
                // right neighbour
                if x < 4 && board[y][x + 1].is_none() {
                    bombs[y][x + 1] += 1;
                }
            }
            // Siren pulls cards
            Unit::Siren => {
                Card::pull(board, position, neighbours, bombs);
            }
            // Titan flips adjacent cards
            Unit::Titan => {
                Card::flip(board, *neighbours);
            }
            // Others do nothing at this stage
            _ => {}
        }

        // after card is placed, check for bombs
        Card::bomb_check(board, position, bombs);
    }
// placement event that needs to be run after card is placed on the board for the first time
placement event that needs to be run after card is placed on the board for the first time
placement event that needs to be run after card is placed on the board for the first time
pub fn placement(
        board: &mut [[Option<Card>; 5]; 4],
        position: Position,
        bombs: &mut [[u8; 5]; 4],
        neighbours: &mut [Option<Position>; 4],
    ) {
        let y = position.0;
        let x = position.1;
        match board[y][x].as_ref().unwrap().name {
            // Saboteur places bombs on empty neighbours
            Unit::Saboteur => {
                // top neighbour
                if y > 0 && board[y - 1][x].is_none() {
                    bombs[y - 1][x] += 1;
                }
                // bottom neighbour
                if y < 3 && board[y + 1][x].is_none() {
                    bombs[y + 1][x] += 1;
                }
                // left neighbour
                if x > 0 && board[y][x - 1].is_none() {
                    bombs[y][x - 1] += 1;
                }
                // right neighbour
                if x < 4 && board[y][x + 1].is_none() {
                    bombs[y][x + 1] += 1;
                }
            }
            // Siren pulls cards
            Unit::Siren => {
                Card::pull(board, position, neighbours, bombs);
            }
            // Titan flips adjacent cards
            Unit::Titan => {
                Card::flip(board, *neighbours);
            }
            // Others do nothing at this stage
            _ => {}
        }
        // after card is placed, check for bombs
        Card::bomb_check(board, position, bombs);
    }
pub fn placement ( board : & mut [ [ Option < Card > ; 5 ] ; 4 ] , position : Position , bombs : & mut [ [ u8 ; 5 ] ; 4 ] , neighbours : & mut [ Option < Position > ; 4 ] , ) { let y = position . 0 ; let x = position . 1 ; match board [ y ] [ x ] . as_ref ( ) . unwrap ( ) . name { // Saboteur places bombs on empty neighbours Unit :: Saboteur => { // top neighbour if y > 0 && board [ y - 1 ] [ x ] . is_none ( ) { bombs [ y - 1 ] [ x ] += 1 ; } // bottom neighbour if y < 3 && board [ y + 1 ] [ x ] . is_none ( ) { bombs [ y + 1 ] [ x ] += 1 ; } // left neighbour if x > 0 && board [ y ] [ x - 1 ] . is_none ( ) { bombs [ y ] [ x - 1 ] += 1 ; } // right neighbour if x < 4 && board [ y ] [ x + 1 ] . is_none ( ) { bombs [ y ] [ x + 1 ] += 1 ; } } // Siren pulls cards Unit :: Siren => { Card :: pull ( board , position , neighbours , bombs ) ; } // Titan flips adjacent cards Unit :: Titan => { Card :: flip ( board , * neighbours ) ; } // Others do nothing at this stage _ => { } } // after card is placed, check for bombs Card :: bomb_check ( board , position , bombs ) ; }
placement event that needs to be run after card is placed on the board for the first time
placement event that needs to be run after card is placed on the board for the first time
board
&mut [[Option<Card>; 5]; 4]
position
Position
bombs
&mut [[u8; 5]; 4]
neighbours
&mut [Option<Position>; 4]