pub fn place_ship(&mut self) -> Result<(), &'static str> {
        if self.state != GameState::Placement {
            Err("tried to place ship outside of placement game state")
        } else {
            let ref mut player = self.players[self.turn as usize];
            let ship_count = player.ships().len();

            player.place_placement_ship()?;

            // If the player hasn't placed all their ships, add a new one.
            if ship_count < self.settings.ships.len() {
                player.add_ship(
                    [0, 0],
                    Direction::West,
                    self.settings.ships[ship_count],
                    true,
                )?;
            }

            Ok(())
        }
    }
/// Places the active player's placement ship.
///
/// # Errors
///
/// Returns an error if the game's state is not `GameState::Placement` or if the active
/// player's placement ship overlaps with another ship.
Places the active player's placement ship.
Places the active player ' s placement ship .
pub fn place_ship(&mut self) -> Result<(), &'static str> {
        if self.state != GameState::Placement {
            Err("tried to place ship outside of placement game state")
        } else {
            let ref mut player = self.players[self.turn as usize];
            let ship_count = player.ships().len();
            player.place_placement_ship()?;
            // If the player hasn't placed all their ships, add a new one.
            if ship_count < self.settings.ships.len() {
                player.add_ship(
                    [0, 0],
                    Direction::West,
                    self.settings.ships[ship_count],
                    true,
                )?;
            }
            Ok(())
        }
    }
pub fn place_ship ( & mut self ) -> Result < ( ) , & ' static str > { if self . state != GameState :: Placement { Err ( " " ) } else { let ref mut player = self . players [ self . turn as usize ] ; let ship_count = player . ships ( ) . len ( ) ; player . place_placement_ship ( ) ? ; // If the player hasn't placed all their ships, add a new one. if ship_count < self . settings . ships . len ( ) { player . add_ship ( [ 0 , 0 ] , Direction :: West , self . settings . ships [ ship_count ] , true , ) ? ; } Ok ( ( ) ) } }
Places the active player's placement ship.
Places the active player ' s placement ship .
&mut self
&mut self
errors
Returns an error if the game's state is not `GameState::Placement` or if the active
player's placement ship overlaps with another ship.
Returns an error if the game ' s state is not ` GameState :: Placement ` or if the active player ' s placement ship overlaps with another ship .