BasicRules

Struct BasicRules 

Source
pub struct BasicRules { /* private fields */ }
Expand description

The rules for basic Rummy.

Implementations§

Source§

impl BasicRules

Source

pub fn new(config: BasicConfig) -> Self

Initialize the rules.

Trait Implementations§

Source§

impl Clone for BasicRules

Source§

fn clone(&self) -> BasicRules

Returns a duplicate 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 BasicRules

Source§

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

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

impl GameRules for BasicRules

Source§

type VariantState = BasicState

The state that this variant requires.
Source§

type VariantScore = BasicScore

The score type of this variant (for each player).
Source§

fn handle_draw_deck( &self, state: &mut GameState<BasicScore, BasicRules>, action: DrawDeckAction, ) -> Result<(), ActionError>

Handle drawing from the deck.
Source§

fn handle_draw_discard_pile( &self, state: &mut GameState<BasicScore, BasicRules>, action: DrawDiscardPileAction, ) -> Result<(), ActionError>

Handle drawing from the discard pile.
Source§

fn handle_lay_off( &self, state: &mut GameState<BasicScore, BasicRules>, action: LayOffAction, ) -> Result<(), ActionError>

Handle laying off a card from the player’s hand.
Source§

fn handle_form_meld( &self, state: &mut GameState<BasicScore, BasicRules>, action: FormMeldAction, ) -> Result<(), ActionError>

Handle forming a single meld.
Source§

fn handle_form_melds( &self, state: &mut GameState<BasicScore, BasicRules>, action: FormMeldsAction, ) -> Result<(), ActionError>

Handle forming multiple melds at one time. Either all melds successfully form, or none do.
Source§

fn handle_discard( &self, state: &mut GameState<BasicScore, BasicRules>, action: DiscardAction, ) -> Result<(), ActionError>

Handle discarding a card.
Source§

fn calculate_round_score( &self, state: &GameState<BasicScore, BasicRules>, ) -> Result<RoundScore<Self::VariantScore>, GameError>

Calculate the score for a round. Returns an Err if the round hasn’t ended.
Source§

fn execute_action( &self, state: &mut GameState<Self::VariantScore, Self>, action: GameAction, ) -> Result<(), ActionError>

Executes an action, returning an () or ActionError.
Source§

impl PartialEq for BasicRules

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl VariantState<BasicScore, BasicRules> for BasicState

Source§

fn validate_action( state: &GameState<P, R>, action: &GameAction, ) -> Result<(), ActionError>

Validate if an action is generally valid in the current gamestate, for the variant. Read more
Source§

impl Eq for BasicRules

Source§

impl StructuralPartialEq for BasicRules

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V