Struct backgammon::rules::Rules

source ·
pub struct Rules {
    pub points: u32,
    pub beaver: bool,
    pub raccoon: bool,
    pub murphy: bool,
    pub murphy_limit: u8,
    pub jacoby: bool,
    pub crawford: bool,
    pub holland: bool,
}
Expand description

Holds all the rule settings

Fields§

§points: u32

The amount of points to reach for declaring a winner of the match, default is 7.

§beaver: bool

When offered the cube, allow to re-double but keep it, default is false.

§raccoon: bool

If a player plays “beaver”, the other may double again, letting the opponent keep the cube. Default is false

§murphy: bool

If both players roll the same opening number, the dice is doubled, remaining in the middle of the board. Default is false.

§murphy_limit: u8

How often to apply automatic doubling rule. 0 means always on. Default is 0.

§jacoby: bool

Gammon and Backgammon only count for double or triple values if the cube has already been offered. Default is false.

§crawford: bool

When a player first reaches a score of points - 1, no doubling is allowed for the following game. Default is true.

§holland: bool

Permits to double after Crawford game only if both players have rolled at least twice. Default is false.

Trait Implementations§

source§

impl Clone for Rules

source§

fn clone(&self) -> Rules

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Rules

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Rules

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Rules

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Rules

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl GameRules for Rules

Implements SetRules for Rules

source§

fn with_beaver(self) -> Self

When offered the cube, allow to re-double but keep it
source§

fn with_raccoon(self) -> Self

If a player plays “beaver”, the other may double again, letting the opponent keep the cube
source§

fn with_murphy(self, limit: u8) -> Self

If both players roll the same opening number, the dice is doubled, remaining in the middle of the board
source§

fn with_jacoby(self) -> Self

Gammon and Backgammon only count for double or triple values if the cube has already been offered
source§

fn with_holland(self) -> Self

Permits to double after Crawford game only if both players have rolled at least twice
source§

impl Hash for Rules

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl MatchRules for Rules

Implements SetRules for Rules

source§

fn with_points(self, points: u32) -> Self

Set the amount of points to reach for declaring a winner
source§

fn with_crawford(self) -> Self

When a player first reaches a score of points - 1, no doubling is allowed for the following game
source§

impl Ord for Rules

source§

fn cmp(&self, other: &Rules) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Rules> for Rules

source§

fn eq(&self, other: &Rules) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Rules> for Rules

source§

fn partial_cmp(&self, other: &Rules) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Rules

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for Rules

source§

impl Eq for Rules

source§

impl StructuralEq for Rules

source§

impl StructuralPartialEq for Rules

Auto Trait Implementations§

§

impl RefUnwindSafe for Rules

§

impl Send for Rules

§

impl Sync for Rules

§

impl Unpin for Rules

§

impl UnwindSafe for Rules

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,