pub enum GameEvent {
Asked {
asker: usize,
target: usize,
rank: String,
},
Gave {
from: usize,
to: usize,
rank: String,
count: usize,
},
GoFish {
player: usize,
},
Drew {
player: usize,
matched: bool,
},
Book {
player: usize,
rank: String,
},
GameOver {
winner: Option<usize>,
},
}Expand description
An event emitted by the game engine as a result of a player action.
Game::act returns the most recently emitted event for that action.
Observers can use a sequence of events to reconstruct the full game
history; the history feature enables structured turn-by-turn recording.
§Examples
use gfcore::prelude::{Game, GameEvent, GameVariant, Player, PlayerAction};
use cardpack::prelude::{DeckedBase, Standard52};
// Build a minimal game; the exact events depend on the shuffled deck.
let players = vec![Player::new("Alice"), Player::new("Bob")];
let mut game = Game::new(GameVariant::Standard, players).unwrap();
// The game starts in WaitingForAsk — we can inspect state safely.
let state = game.state().unwrap();
assert!(state.last_event.is_none());Variants§
Asked
The current player asked another player for cards of a rank.
Note: Game::act returns the final event for each action (either
GameEvent::GoFish or GameEvent::Gave), so this variant does not
appear in the return value of act(). It is present for constructing
crate::history::TurnRecords manually or via future event-log APIs.
Fields
Gave
The target player gave cards to the asker.
Fields
GoFish
The current player was told to “Go Fish” (target had no matching cards).
Drew
The current player drew a card from the draw pile.
Fields
Book
A player completed a book.
Fields
GameOver
The game has ended.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for GameEvent
impl<'de> Deserialize<'de> for GameEvent
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 StructuralPartialEq for GameEvent
Auto Trait Implementations§
impl Freeze for GameEvent
impl RefUnwindSafe for GameEvent
impl Send for GameEvent
impl Sync for GameEvent
impl Unpin for GameEvent
impl UnsafeUnpin for GameEvent
impl UnwindSafe for GameEvent
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,
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