Skip to main content

GameEvent

Enum GameEvent 

Source
pub enum GameEvent {
Show 16 variants LobbyGameCreated { game_id: GameId, host: UserId, name: String, }, LobbyGameJoined { guest: UserId, }, ComputerGameCreated { game_id: GameId, host: UserId, guest: UserId, name: String, }, CutForDealMade { player: Player, cut: Card, }, GameStarted { player: Player, }, CutForDealTied, CutForDealDecided { dealer: Dealer, }, HandDealt { player: Player, hand: Hand, }, CardsDiscarded { player: Player, cards: Vec<Card>, }, StarterSelected { cut: StarterCut, pegging: Pegging, }, CardPlayed { player: Player, card: Card, pegging: Pegging, }, GoCalled { player: Player, pegging: Pegging, }, PoneScored { player: Player, pegging: Pegging, }, DealerScored { player: Player, pegging: Pegging, }, CribScored { player: Player, pegging: Pegging, }, NextRoundStarted { player: Player, },
}
Expand description

Domain events which represent the single source of truth for game history and are persisted in the event store. The current game state is derived by folding them in order.

Variants§

§

LobbyGameCreated

A user created a lobby game and is waiting for another user to join

Fields

§game_id: GameId

The identity of the game that was created.

§host: UserId

The user that created the game.

§name: String

The name assigned to the game. It’s possible this may be the same as another game; the game_id provides the unique id.

§

LobbyGameJoined

A user joined a game that was previously a lobby game.

Fields

§guest: UserId

The user that joined the game.

§

ComputerGameCreated

A user a computer game.

Fields

§game_id: GameId

The identity of the game that was created.

§host: UserId

The user that created the game.

§guest: UserId

The computer “user” that will play against the host.

§name: String

The name assigned to the game. It’s possible this may be the same as another game; the game_id provides the unique id.

§

CutForDealMade

A player cut a card for the choice of initial dealer.

Fields

§player: Player

The player identity (essentially host or guest)

§cut: Card

The card that was cut.

§

GameStarted

A player has acknowledged the cut for deal. When both players have acknowledge the cards will be dealt and discarding begin.

Fields

§player: Player

The player identity (essentially host or guest)

§

CutForDealTied

Both plays have cut for deal (and acknowledged the cut); the cuts were the same rank, so the cut needs to be redrawn.

§

CutForDealDecided

Both plays have cut for deal (and acknowledged the cut); the cuts were different, so the dealer is selected and the deal can progress.

Fields

§dealer: Dealer

The selected dealer.

§

HandDealt

A hand has been dealt to the player, following CutForDealDecided or NextRoundStarted.

Fields

§player: Player

The player identity (essentially host or guest)

§hand: Hand

The hand that has been dealt.

§

CardsDiscarded

A player has discarded cards to the crib.

Fields

§player: Player

The player identity (essentially host or guest)

§cards: Vec<Card>

The cards that were discarded.

§

StarterSelected

Both players have discarded cards to the crib and the “Starter” card selected.

Fields

§cut: StarterCut

The starter card.

§pegging: Pegging

Record HisHeels.

§

CardPlayed

A player has played a card during the Playing (or Pegging) phase.

Fields

§player: Player

The player identity (essentially host or guest)

§card: Card

The card that was played.

§pegging: Pegging

Points awarded during pegging (may include 31 for 2).

§

GoCalled

A player has called Go during the Playing (or Pegging) phase.

Fields

§player: Player

The player identity (essentially host or guest)

§pegging: Pegging

Points awarded for the Go.

§

PoneScored

A player has acknowledged End of Plays; when both players have acknowledged then the Pone’s hand will be scored.

Fields

§player: Player

The player identity (essentially host or guest)

§pegging: Pegging

The pone’s hand scores.

§

DealerScored

A player has acknowledged the Pone Score; when both players have acknowledged then the Dealer’s hand will be scored.

Fields

§player: Player

The player identity (essentially host or guest)

§pegging: Pegging

The dealer’s hand scores.

§

CribScored

A player has acknowledged the Dealer Score; when both players have acknowledged then the Dealer’s crib will be scored.

Fields

§player: Player

The player identity (essentially host or guest)

§pegging: Pegging

The dealer’s crib scores.

§

NextRoundStarted

A player has acknowledged the Crib Score; when both players have acknowledged then the next round will start, swapping dealers.

Fields

§player: Player

The player identity (essentially host or guest)

Trait Implementations§

Source§

impl AsRef<str> for GameEvent

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for GameEvent

Source§

fn clone(&self) -> GameEvent

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 GameEvent

Source§

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

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

impl<'de> Deserialize<'de> for GameEvent

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 DomainEvent for GameEvent

Source§

fn event_type(&self) -> String

A name specifying the event, used for event upcasting.
Source§

fn event_version(&self) -> String

A version of the event_type, used for event upcasting.
Source§

impl PartialEq for GameEvent

Source§

fn eq(&self, other: &GameEvent) -> 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 Serialize for GameEvent

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 Eq for GameEvent

Source§

impl StructuralPartialEq for GameEvent

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

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