[][src]Struct thud::Thud

pub struct Thud { /* fields omitted */ }

Stores the current state of a game of Thud

Methods

impl Thud[src]

pub fn new() -> Self[src]

Get a Thud ready to be played!

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

Find which player's turn it is.

Will return Some(Player) if the game is still in progress, or if the game is ended None will be returned.

pub fn board(&self) -> Board[src]

Get a copy of the current Board

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

Wrapper for Board::winner()

pub fn score(&self) -> (usize, usize)[src]

Wrapper for Board::score()

pub fn move_piece(&mut self, src: Coord, target: Coord) -> Result<(), ThudError>[src]

Move a piece of the player whose turn it is

On a Dwarf turn, the turn will automatically tick over, on a Troll turn, the player may make a capture afterward with .troll_cap(). Should the troll player not wish to make a capture, they may call .troll_cap() with an empty Vec.

Will pass errors from Board.dwarf_move() and Board.troll_move().

pub fn attack(&mut self, src: Coord, target: Coord) -> Result<(), ThudError>[src]

Attack with a piece of the player whose turn it is

This can only be taken as the first action of the player's turn, otherwise Err(ThudError::BadAction) will be returned.

On a Dwarf turn, it will automatically tick over to the next turn, on a Troll turn, at least one capture must be made afterward with .troll_cap().

Will pass errors from Board.dwarf_hurl() and Board.troll_shove().

pub fn troll_cap(
    &mut self,
    troll: Coord,
    targets: Vec<Direction>
) -> Result<(), ThudError>
[src]

Capture a number of dwarves with a troll

This may only be called after a move or a shove/attack on a troll player's turn.

If the previous action was a shove/attack then targets must contain at least 1 valid dwarf to take, otherwise Err(ThudError::IllegalMove) will be returned and the method must be called again before play can continue.

Otherwise, the turn will be ticked over automatically.

Auto Trait Implementations

impl RefUnwindSafe for Thud

impl Send for Thud

impl Sync for Thud

impl Unpin for Thud

impl UnwindSafe for Thud

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.