pub struct Match { /* private fields */ }Expand description
Represents a Backgammon match.
A match is a series of games played until a player reaches the predefined number of points.
Implementations§
Source§impl Match
Implements methods for the Match struct
impl Match
Implements methods for the Match struct
Sourcepub fn offer_double(&mut self, player: Player) -> Result<(), Error>
pub fn offer_double(&mut self, player: Player) -> Result<(), Error>
Offer the cube to the other player.
Sourcepub fn accept_double(&mut self, player: Player) -> Result<(), Error>
pub fn accept_double(&mut self, player: Player) -> Result<(), Error>
After a double has been offered, the other player can accept it.
Sourcepub fn beaver(&mut self, player: Player) -> Result<(), Error>
pub fn beaver(&mut self, player: Player) -> Result<(), Error>
When offered the cube, a player can beaver it.
Sourcepub fn raccoon(&mut self, player: Player) -> Result<(), Error>
pub fn raccoon(&mut self, player: Player) -> Result<(), Error>
When a player beavers, the other player may raccoon it.
Sourcepub fn reject_double(&mut self, player: Player) -> Result<(), Error>
pub fn reject_double(&mut self, player: Player) -> Result<(), Error>
After a double has been offered, the other player can reject it.
Sourcepub fn get_state(&self) -> Result<&MatchState, Error>
pub fn get_state(&self) -> Result<&MatchState, Error>
Return the current state of the match.
Sourcepub fn get_player(&self) -> Result<Player, Error>
pub fn get_player(&self) -> Result<Player, Error>
Return the current player, i.e. the player who needs to perform an action.
Trait Implementations§
Source§impl MatchRules for Match
impl MatchRules for Match
Source§fn set_points(&mut self, points: u64) -> Result<(), Error>
fn set_points(&mut self, points: u64) -> Result<(), Error>
Set the number of points required to win the match.
Source§fn get_points(&self) -> Result<u64, Error>
fn get_points(&self) -> Result<u64, Error>
Get the number of points required to win the match.
Source§fn set_crawford(&mut self, state: bool) -> Result<(), Error>
fn set_crawford(&mut self, state: bool) -> Result<(), Error>
Apply the Crawford rule: if the first player reaches a score of points - 1, no doubling is
allowed for the following game.
Source§fn set_beaver(&mut self, state: bool) -> Result<(), Error>
fn set_beaver(&mut self, state: bool) -> Result<(), Error>
Apply the Beaver rule: if offered the cube, allow to re-double but keep it.
Source§fn set_raccoon(&mut self, state: bool) -> Result<(), Error>
fn set_raccoon(&mut self, state: bool) -> Result<(), Error>
Apply the Raccoon rule: if a player beavered the offered cube, the other may double again,
letting the player keep the cube. This requires the Crawford rule to be enabled.
Source§fn set_murphy(&mut self, state: bool, limit: u8) -> Result<(), Error>
fn set_murphy(&mut self, state: bool, limit: u8) -> Result<(), Error>
Apply the Murphy rule: if both players roll the same opening number, the cube is doubled,
remaining in the middle of the board. The limit parameter defines how often to apply the
automatic doubling rule in a Murphy game. 0 means always on.
Source§fn get_murphy(&self) -> Result<(bool, u8), Error>
fn get_murphy(&self) -> Result<(bool, u8), Error>
Get the Murphy rule status and the limit setting. A limit of 0 means that the Murphy rule is
always on, given the rule is enabled.
Source§fn set_jacobi(&mut self, state: bool) -> Result<(), Error>
fn set_jacobi(&mut self, state: bool) -> Result<(), Error>
Apply the Jacobi rule: Gammon and Backgammon only count for double or triple values if the
cube has already been offered.
Source§impl Move for Match
impl Move for Match
Source§fn get_board(&self) -> BoardDisplay
fn get_board(&self) -> BoardDisplay
Get the current board in a human-readable format.
Source§fn move_checkers(
&mut self,
player: Player,
moves: Vec<(Position, Position)>,
) -> Result<(), Error>
fn move_checkers( &mut self, player: Player, moves: Vec<(Position, Position)>, ) -> Result<(), Error>
Move a sequence of checkers from a given position to another position. Read more
Source§impl Roll for Match
impl Roll for Match
Source§fn set_dice(&mut self, player: Player, v: (u8, u8)) -> Result<(), Error>
fn set_dice(&mut self, player: Player, v: (u8, u8)) -> Result<(), Error>
Set the values of the dice.
Source§fn dice_available(&self) -> &Vec<u8> ⓘ
fn dice_available(&self) -> &Vec<u8> ⓘ
Returns the available dice values. These are the dice not yet consumed by a move.
Source§fn dice_consumed(&self) -> bool
fn dice_consumed(&self) -> bool
Return true if all dice have been consumed and no die is available for playing.
Auto Trait Implementations§
impl Freeze for Match
impl RefUnwindSafe for Match
impl Send for Match
impl Sync for Match
impl Unpin for Match
impl UnsafeUnpin for Match
impl UnwindSafe for Match
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more