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

pub struct Game(_);

Simplified game that uses a fixed set of ships and players.

Implementations

impl Game[src]

pub fn current(&self) -> Player[src]

Get the player whose turn it currently is.

pub fn winner(&self) -> Option<Player>[src]

Get the status of the game. Returns None if the game is in progress, otherwise returns the winner.

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

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

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

Get an iterator over the specified player's ships.

pub fn get_coord(&self, player: Player, coord: Coordinate) -> Option<CellRef>[src]

Get a reference to the cell with the specified coordinate in the specified player's board. Return None if the coord is out of bounds.

pub fn get_ship(&self, player: Player, ship: Ship) -> ShipRef[src]

Get a reference to the specified ship from the specified player's board.

pub fn shoot(
    &mut self,
    target: Player,
    coord: Coordinate
) -> Result<ShotOutcome, CannotShootReason>
[src]

Fire at the specified player on the specified coordinate.

Auto Trait Implementations

impl RefUnwindSafe for Game

impl Send for Game

impl Sync for Game

impl Unpin for Game

impl UnwindSafe for Game

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.