[−][src]Struct spacebattleship::board::setup::BoardSetup
Setup phase for a Board
. Allows placing ships and does not allow shooting.
Implementations
impl<I: ShipId, D: Dimensions, S: ShipShape<D>> BoardSetup<I, D, S>
[src]
pub fn new(dim: D) -> Self
[src]
Begin game setup by constructing a new board with the given Dimensions
.
pub fn dimensions(&self) -> &D
[src]
Get the [Dimesnsions
] of this Board
.
pub fn start(self) -> Result<Board<I, D>, Self>
[src]
Tries to start the game. If all ships are placed, returns a Board
with the
current placements. If no ships have been added or any ship has not been placed,
returns self.
pub fn ready(&self) -> bool
[src]
Checks if this board is ready to start. Returns true
if at least one ship has
been added and all ships are placed.
pub fn iter_ships(&self) -> impl Iterator<Item = ShipEntry<I, D, S>>
[src]
Get an iterator over the ships configured on this board.
pub fn add_ship(
&mut self,
id: I,
shape: S
) -> Result<ShipEntryMut<I, D, S>, AddShipError<I, S>>
[src]
&mut self,
id: I,
shape: S
) -> Result<ShipEntryMut<I, D, S>, AddShipError<I, S>>
Attempts to add a ship with the given ID. If the given ShipID is already used, returns the shape passed to this function. Otherwise adds the shape and returns the ShipEntryMut for it to allow placement.
pub fn get_ship(&self, id: I) -> Option<ShipEntry<I, D, S>>
[src]
Get the ShipEntry
for the ship with the specified ID if such a ship exists.
pub fn get_ship_mut(&mut self, id: I) -> Option<ShipEntryMut<I, D, S>>
[src]
Get the ShipEntryMut
for the ship with the specified ID if such a ship exists.
pub fn get_coord(&self, coord: &D::Coordinate) -> Option<&I>
[src]
Get the ID of the ship placed at the specified coordinate if any. Returns None if the coordinate is out of bounds or no ship was placed on the specified point.
Auto Trait Implementations
impl<I, D, S> RefUnwindSafe for BoardSetup<I, D, S> where
D: RefUnwindSafe,
I: RefUnwindSafe,
S: RefUnwindSafe,
<D as Dimensions>::Coordinate: RefUnwindSafe,
D: RefUnwindSafe,
I: RefUnwindSafe,
S: RefUnwindSafe,
<D as Dimensions>::Coordinate: RefUnwindSafe,
impl<I, D, S> Send for BoardSetup<I, D, S> where
D: Send,
I: Send,
S: Send,
<D as Dimensions>::Coordinate: Send,
D: Send,
I: Send,
S: Send,
<D as Dimensions>::Coordinate: Send,
impl<I, D, S> Sync for BoardSetup<I, D, S> where
D: Sync,
I: Sync,
S: Sync,
<D as Dimensions>::Coordinate: Sync,
D: Sync,
I: Sync,
S: Sync,
<D as Dimensions>::Coordinate: Sync,
impl<I, D, S> Unpin for BoardSetup<I, D, S> where
D: Unpin,
I: Unpin,
S: Unpin,
<D as Dimensions>::Coordinate: Unpin,
D: Unpin,
I: Unpin,
S: Unpin,
<D as Dimensions>::Coordinate: Unpin,
impl<I, D, S> UnwindSafe for BoardSetup<I, D, S> where
D: UnwindSafe,
I: UnwindSafe,
S: UnwindSafe,
<D as Dimensions>::Coordinate: UnwindSafe,
D: UnwindSafe,
I: UnwindSafe,
S: UnwindSafe,
<D as Dimensions>::Coordinate: UnwindSafe,
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>,