pub struct Game { /* private fields */ }Expand description
Primary game state. Internally manages player rotation, scoring, and cards.
Implementations§
Source§impl Game
impl Game
pub fn new( id: Uuid, player_ids: [Uuid; 4], max_points: i32, timer_config: Option<TimerConfig>, ) -> Game
pub fn get_id(&self) -> &Uuid
pub fn get_team_a_score(&self) -> Result<&i32, GetError>
pub fn get_team_b_score(&self) -> Result<&i32, GetError>
pub fn get_team_a_bags(&self) -> Result<&i32, GetError>
pub fn get_team_b_bags(&self) -> Result<&i32, GetError>
Sourcepub fn get_current_player_id(&self) -> Result<&Uuid, GetError>
pub fn get_current_player_id(&self) -> Result<&Uuid, GetError>
Returns GetError when the current game is not in the Betting or Trick stages.
Sourcepub fn get_hand_by_player_id(
&self,
player_id: Uuid,
) -> Result<&Vec<Card>, GetError>
pub fn get_hand_by_player_id( &self, player_id: Uuid, ) -> Result<&Vec<Card>, GetError>
Returns a GetError::InvalidUuid if the game does not contain a player with the given Uuid.
pub fn get_current_hand(&self) -> Result<&Vec<Card>, GetError>
pub fn get_leading_suit(&self) -> Result<&Suit, GetError>
Sourcepub fn get_current_trick_cards(&self) -> Result<&[Card; 4], GetError>
pub fn get_current_trick_cards(&self) -> Result<&[Card; 4], GetError>
Returns an array with (only if in the trick stage).
pub fn get_hand(&self, player: usize) -> Result<&Vec<Card>, GetError>
👎Deprecated since 1.0.0: Please use
get_current_hand or get_hand_by_player_idpub fn get_winner_ids(&self) -> Result<(&Uuid, &Uuid), GetError>
Sourcepub fn play(
&mut self,
entry: GameTransition,
) -> Result<TransitionSuccess, TransitionError>
pub fn play( &mut self, entry: GameTransition, ) -> Result<TransitionSuccess, TransitionError>
The primary function used to progress the game state. The first GameTransition argument must always be
GameTransition::Start. The stages and player rotations are managed
internally. The order of GameTransition arguments should be:
Start -> Bet * 4 -> Card * 13 -> Bet * 4 -> Card * 13 -> Bet * 4 -> …
pub fn set_player_name( &mut self, player_id: Uuid, name: Option<String>, ) -> Result<(), GetError>
pub fn get_player_names(&self) -> [(Uuid, Option<&str>); 4]
pub fn get_timer_config(&self) -> Option<&TimerConfig>
pub fn get_player_clocks(&self) -> Option<&PlayerClocks>
pub fn get_player_clocks_mut(&mut self) -> Option<&mut PlayerClocks>
pub fn get_current_player_index_num(&self) -> usize
Sourcepub fn is_first_round_betting(&self) -> bool
pub fn is_first_round_betting(&self) -> bool
Returns true if the game is in the first round’s betting phase (round 0, Betting state).
pub fn get_turn_started_at_epoch_ms(&self) -> Option<u64>
pub fn set_turn_started_at_epoch_ms(&mut self, epoch_ms: Option<u64>)
pub fn get_player_bets(&self) -> Option<[i32; 4]>
pub fn get_player_tricks_won(&self) -> Option<[i32; 4]>
pub fn get_last_trick_winner_id(&self) -> Option<Uuid>
pub fn get_last_completed_trick(&self) -> Option<&[Card; 4]>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Game
impl<'de> Deserialize<'de> for Game
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Game
impl RefUnwindSafe for Game
impl Send for Game
impl Sync for Game
impl Unpin for Game
impl UnsafeUnpin for Game
impl UnwindSafe for Game
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