[−][src]Struct spacebattleship::game::simple::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]
&'a self,
player: Player
) -> impl 'a + Iterator<Item = (Ship, Option<&'a Placement>)>
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]
&'a self,
player: Player
) -> impl 'a + Iterator<Item = Ship>
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]
&self,
player: Player,
ship: Ship,
start: Coordinate,
dir: Orientation
) -> Result<(), CannotPlaceReason>
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]
&mut self,
player: Player,
ship: Ship,
start: Coordinate,
dir: Orientation
) -> Result<(), CannotPlaceReason>
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]
&'a self,
player: Player
) -> impl 'a + Iterator<Item = impl 'a + Iterator<Item = Option<Ship>>>
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
impl RefUnwindSafe for GameSetup
impl Send for GameSetup
impl Sync for GameSetup
impl Unpin for GameSetup
impl UnwindSafe for GameSetup
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,