pub struct Thud { /* private fields */ }Expand description
Stores the current state of a game of Thud
Implementations§
Source§impl Thud
impl Thud
Sourcepub fn turn(&self) -> Option<Player>
pub fn turn(&self) -> Option<Player>
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.
Sourcepub fn winner(&mut self) -> Option<EndState>
pub fn winner(&mut self) -> Option<EndState>
Wrapper for Board::winner()
Sourcepub fn score(&self) -> (usize, usize)
pub fn score(&self) -> (usize, usize)
Wrapper for Board::score()
Sourcepub fn move_piece(&mut self, src: Coord, target: Coord) -> Result<(), ThudError>
pub fn move_piece(&mut self, src: Coord, target: Coord) -> Result<(), ThudError>
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().
Sourcepub fn attack(&mut self, src: Coord, target: Coord) -> Result<(), ThudError>
pub fn attack(&mut self, src: Coord, target: Coord) -> Result<(), ThudError>
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().
Sourcepub fn troll_cap(
&mut self,
troll: Coord,
targets: Vec<Direction>,
) -> Result<(), ThudError>
pub fn troll_cap( &mut self, troll: Coord, targets: Vec<Direction>, ) -> Result<(), ThudError>
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.