[][src]Struct hex_game::board::Board

pub struct Board {
    pub size: u16,
    // some fields omitted
}

A Hex board of a given size, with pieces placed. The maximum size is 26, due to the limitations of the standard Hex coordinate system.

Fields

size: u16

The size of the board: both width and length. The size should be no larger than 26 due to the limitations of the Hex coordinate system. It's a u16 because, when mapping coordinates to numbers, it will be converted to a u16 enough to just make that the case here.

Methods

impl Board
[src]

pub fn new(size: u16) -> Board
[src]

Initializes a blank board with given size less than or equal to 26.

pub fn place_piece(&mut self, coord: Coord, color: Color) -> bool
[src]

Places the piece at the given spot if the placement is valid (there are no other pieces and the coordinate is within range), modifying the board's state and returning true. Otherwise, does not modify the board state and returns false.

pub fn piece(&self, coord: Coord) -> HexCell
[src]

Returns a HexCell value describing the piece at the given location: Empty if no piece is there, Black if Black has a piece, or White if White has a piece. If the coordinate is out of bounds, returns Empty.

pub fn status(&self) -> GameStatus
[src]

Returns the current game status. This is updated automatically as the game progresses, so this function has basically no runtime cost.

Trait Implementations

impl Default for Board
[src]

impl Clone for Board
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Board
[src]

impl Display for Board
[src]

Auto Trait Implementations

impl Send for Board

impl Sync for Board

Blanket Implementations

impl<T> From for T
[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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