fn find_unchecked_space(
        &self,
        pos: &[u8; 2],
        direction: Direction,
        check_for_line: bool,
    ) -> Option<[u8; 2]> {
        let mut check_pos = self.movement(pos, direction);

        while let Some(next_pos) = check_pos {
            let next_space = self.space(&next_pos);

            match next_space.is_hit() {
                true => check_pos = self.movement(&next_pos, direction),
                false => {
                    if !next_space.is_unchecked() {
                        check_pos = None;
                    }
                    break;
                }
            };
        }

        if check_for_line && check_pos.is_some() {
            let unchecked = check_pos.unwrap();
            let opposite_dir = direction.opposite();
            let prev_pos = self.movement(&unchecked, opposite_dir).unwrap();

            if &prev_pos == pos {
                check_pos = None;
            }
        }

        check_pos
    }
/// Finds the first non-hit, unchecked space in a `direction` from `pos`.
/// Can also make sure the space is at the end of a `line` of hit spaces.
/// Returns `None` if the first non-hit space has been checked or if a grid
/// boundary is reached.
Finds the first non-hit, unchecked space in a `direction` from `pos`.
Can also make sure the space is at the end of a `line` of hit spaces.
Returns `None` if the first non-hit space has been checked or if a grid
boundary is reached.
Finds the first non - hit unchecked space in a ` direction ` from ` pos ` . Can also make sure the space is at the end of a ` line ` of hit spaces . Returns ` None ` if the first non - hit space has been checked or if a grid boundary is reached .
fn find_unchecked_space(
        &self,
        pos: &[u8; 2],
        direction: Direction,
        check_for_line: bool,
    ) -> Option<[u8; 2]> {
        let mut check_pos = self.movement(pos, direction);
        while let Some(next_pos) = check_pos {
            let next_space = self.space(&next_pos);
            match next_space.is_hit() {
                true => check_pos = self.movement(&next_pos, direction),
                false => {
                    if !next_space.is_unchecked() {
                        check_pos = None;
                    }
                    break;
                }
            };
        }
        if check_for_line && check_pos.is_some() {
            let unchecked = check_pos.unwrap();
            let opposite_dir = direction.opposite();
            let prev_pos = self.movement(&unchecked, opposite_dir).unwrap();
            if &prev_pos == pos {
                check_pos = None;
            }
        }
        check_pos
    }
fn find_unchecked_space ( & self , pos : & [ u8 ; 2 ] , direction : Direction , check_for_line : bool , ) -> Option < [ u8 ; 2 ] > { let mut check_pos = self . movement ( pos , direction ) ; while let Some ( next_pos ) = check_pos { let next_space = self . space ( & next_pos ) ; match next_space . is_hit ( ) { true => check_pos = self . movement ( & next_pos , direction ) , false => { if ! next_space . is_unchecked ( ) { check_pos = None ; } break ; } } ; } if check_for_line && check_pos . is_some ( ) { let unchecked = check_pos . unwrap ( ) ; let opposite_dir = direction . opposite ( ) ; let prev_pos = self . movement ( & unchecked , opposite_dir ) . unwrap ( ) ; if & prev_pos == pos { check_pos = None ; } } check_pos }
Finds the first non-hit, unchecked space in a `direction` from `pos`.
Finds the first non - hit unchecked space in a ` direction ` from ` pos ` .
&self
pos
&[u8; 2]
direction
Direction
check_for_line
bool
&self
pos
&[u8; 2]
direction
Direction
check_for_line
bool