Skip to main content

Game

Struct Game 

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

Primary game state. Internally manages player rotation, scoring, and cards.

Implementations§

Source§

impl Game

Source

pub fn new( id: Uuid, player_ids: [Uuid; 4], max_points: i32, timer_config: Option<TimerConfig>, ) -> Game

Source

pub fn get_id(&self) -> &Uuid

Source

pub fn get_state(&self) -> &State

See State

Source

pub fn get_team_a_score(&self) -> Result<&i32, GetError>

Source

pub fn get_team_b_score(&self) -> Result<&i32, GetError>

Source

pub fn get_team_a_bags(&self) -> Result<&i32, GetError>

Source

pub fn get_team_b_bags(&self) -> Result<&i32, GetError>

Source

pub fn get_current_player_id(&self) -> Result<&Uuid, GetError>

Returns GetError when the current game is not in the Betting or Trick stages.

Source

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.

Source

pub fn get_current_hand(&self) -> Result<&Vec<Card>, GetError>

Source

pub fn get_leading_suit(&self) -> Result<&Suit, GetError>

Source

pub fn get_current_trick_cards(&self) -> Result<&[Card; 4], GetError>

Returns an array with (only if in the trick stage).

Source

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_id
Source

pub fn get_winner_ids(&self) -> Result<(&Uuid, &Uuid), GetError>

Source

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 -> …

Source

pub fn set_player_name( &mut self, player_id: Uuid, name: Option<String>, ) -> Result<(), GetError>

Source

pub fn get_player_names(&self) -> [(Uuid, Option<&str>); 4]

Source

pub fn get_timer_config(&self) -> Option<&TimerConfig>

Source

pub fn get_player_clocks(&self) -> Option<&PlayerClocks>

Source

pub fn get_player_clocks_mut(&mut self) -> Option<&mut PlayerClocks>

Source

pub fn get_current_player_index_num(&self) -> usize

Source

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).

Source

pub fn get_turn_started_at_epoch_ms(&self) -> Option<u64>

Source

pub fn set_turn_started_at_epoch_ms(&mut self, epoch_ms: Option<u64>)

Source

pub fn get_player_bets(&self) -> Option<[i32; 4]>

Source

pub fn get_player_tricks_won(&self) -> Option<[i32; 4]>

Source

pub fn get_last_trick_winner_id(&self) -> Option<Uuid>

Source

pub fn get_last_completed_trick(&self) -> Option<&[Card; 4]>

Source

pub fn set_state(&mut self, state: State)

Set the game state directly (used by GameManager for abort).

Returns the list of legal cards the current player can play. Only valid in the Trick state.

Trait Implementations§

Source§

impl Debug for Game

Source§

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

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

impl<'de> Deserialize<'de> for Game

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 Serialize for Game

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

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> 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> 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, 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

Source§

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