[][src]Struct spacebattleship::game::simple::GameSetup

pub struct GameSetup(_);

Struct used to setup the simple game.

Implementations

impl GameSetup[src]

pub fn new() -> Self[src]

Create a GameSetup for the game, including two players with one of each ship.

pub fn start(self) -> Result<Game, Self>[src]

Tries to start the game. If all players are ready, returns a Game, otherwise returns self.

pub fn ready(&self) -> bool[src]

Return true if both players are ready to start the game.

pub fn is_player_ready(&self, player: Player) -> bool[src]

Check if the specified player is ready.

pub fn get_ships<'a>(
    &'a self,
    player: Player
) -> impl 'a + Iterator<Item = (Ship, Option<&'a Placement>)>
[src]

Get an iterator over all the ship IDs for the given player and the coordinates where that ship is placed, if any.

pub fn get_pending_ships<'a>(
    &'a self,
    player: Player
) -> impl 'a + Iterator<Item = Ship>
[src]

Get the ships for the specified player which still need to be placed.

pub fn get_placement(&self, player: Player, ship: Ship) -> Option<&Placement>[src]

Get the the coordinates where the given ship is placed, if any.

pub fn check_placement(
    &self,
    player: Player,
    ship: Ship,
    start: Coordinate,
    dir: Orientation
) -> Result<(), CannotPlaceReason>
[src]

Check if the given placement would be valid, without attempting to actually place the ship.

pub fn place_ship(
    &mut self,
    player: Player,
    ship: Ship,
    start: Coordinate,
    dir: Orientation
) -> Result<(), CannotPlaceReason>
[src]

Try to place the specified ship at the specified position, returning an error if placement is not possible.

pub fn unplace_ship(&mut self, player: Player, ship: Ship) -> bool[src]

Clear the placement of the specified ship. Return true if the ship was previously placed.

pub fn iter_board<'a>(
    &'a self,
    player: Player
) -> impl 'a + Iterator<Item = impl 'a + Iterator<Item = Option<Ship>>>
[src]

Get an iterator over the specified player's board. The iterator's item is another iterator that iterates over a single row.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.