pub struct PlayState { /* private fields */ }Expand description
Represents the current state of play during the pegging phase.
Tracks which player’s turn it is, pending cards, the go status, current and previous plays.
Implementations§
Source§impl PlayState
impl PlayState
Sourcepub fn new(next_to_play: Player) -> Self
pub fn new(next_to_play: Player) -> Self
Creates a new PlayState with the specified next player to play.
Sourcepub const fn next_to_play(&self) -> Player
pub const fn next_to_play(&self) -> Player
Returns the player whose turn is next.
Sourcepub fn with_pending_plays(self, player: Player, cards: &[Card]) -> Self
pub fn with_pending_plays(self, player: Player, cards: &[Card]) -> Self
Sets pending plays for a player and returns the updated state.
(Note: This is really part of the constructor information)
Sourcepub fn running_total(&self) -> Value
pub fn running_total(&self) -> Value
Returns the current running total of points in the play sequence.
Sourcepub fn has_cards(&self, player: Player) -> bool
pub fn has_cards(&self, player: Player) -> bool
Returns true if the specified player has any cards left to play regardless
whether they are currently legal plays or not.
Sourcepub fn legal_plays(&self, player: Player) -> Vec<Card>
pub fn legal_plays(&self, player: Player) -> Vec<Card>
Returns the legal cards the specified player may play without exceeding the play limit.
Sourcepub fn current_plays(&self) -> &Vec<Play>
pub fn current_plays(&self) -> &Vec<Play>
Returns an immutable reference to the current plays.
Sourcepub fn previous_plays(&self) -> &Vec<Play>
pub fn previous_plays(&self) -> &Vec<Play>
Returns an immutable reference to the previous plays.
Sourcepub fn play(&mut self, card: Card) -> ScoreSheet
pub fn play(&mut self, card: Card) -> ScoreSheet
Plays a card for the current player, updating the state and returning the resulting score sheet for the played card.
Sourcepub fn go(&mut self) -> ScoreSheet
pub fn go(&mut self) -> ScoreSheet
Calls “go” for the current player, updating the state and returning the resulting score sheet.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns true if all players have no cards left.
Sourcepub fn finish_plays(&mut self) -> Hands
pub fn finish_plays(&mut self) -> Hands
Finishes the current plays and returns the regathered hands.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PlayState
impl<'de> Deserialize<'de> for PlayState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for PlayState
impl StructuralPartialEq for PlayState
Auto Trait Implementations§
impl Freeze for PlayState
impl RefUnwindSafe for PlayState
impl Send for PlayState
impl Sync for PlayState
impl Unpin for PlayState
impl UnwindSafe for PlayState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more