spru 0.1.0

Reusable components for the spru strategy and digital board game framework.
Documentation
//! Events generated by [Client](crate::Client) operations

use std::marker::PhantomData;

use derive_where::derive_where;

use crate::interaction;

/// An event which occurred on the [Server](crate::Server).
#[derive_where(Debug; GameComplete<Client>)]
#[derive(derive_more::From)]
#[non_exhaustive]
pub enum Event<Client: super::Client> {
    /// The [Server](crate::Server) has responded with the fate of a pending [Interaction](trait@crate::Interaction)
    InteractionResult(InteractionResult<Client>),
    /// The game has completed
    GameComplete(GameComplete<Client>),
}

/// The game has completed
#[derive_where(Debug; Client::GameOutcome)]
#[non_exhaustive]
pub struct GameComplete<Client: super::Client> {
    /// The outcome of the game, as defined by the [Reaction](trait@crate::Reaction).  
    /// Usually contains the winner of the game and any other notable stats.
    pub game_outcome: Client::GameOutcome,
}

/// The [Server](crate::Server) has responded with the fate of a pending [Interaction](trait@crate::Interaction)
#[derive_where(Debug; )]
#[non_exhaustive]
pub struct InteractionResult<Client: super::Client> {
    /// The pending interaction
    pub pending_interaction_id: interaction::Pending,
    /// True if the interaction was confirmed, false if the interaction
    /// was rejected and rolled back.
    pub confirmed: bool,
    pub(crate) _client: PhantomData<fn() -> Client>,
}