Trait Game

Source
pub trait Game: Diff {
    type Options: Serialize + for<'de> Deserialize<'de> + Sync + Send + Clone + 'static;
    type OptionsPreset: Debug + Serialize + for<'de> Deserialize<'de> + Sync + Send + Clone + 'static + Into<Self::Options>;
    type PlayerOptions: PlayerOptions<Self> + Serialize + for<'de> Deserialize<'de> + Sync + Send + Clone + 'static;
    type Action: Serialize + for<'de> Deserialize<'de> + Trans + Sync + Send + Clone + 'static;
    type Event: Serialize + for<'de> Deserialize<'de> + Trans + Sync + Send + Clone + 'static;
    type PlayerView: Serialize + for<'de> Deserialize<'de> + Trans + Sync + Send + Clone + 'static;
    type Results: Serialize + for<'de> Deserialize<'de> + Sync + Send + Clone + 'static;
    type DebugData: Serialize + for<'de> Deserialize<'de> + Trans + Sync + Send + Clone + 'static;
    type DebugState: Serialize + for<'de> Deserialize<'de> + Trans + Sync + Send + Clone + 'static;

    // Required methods
    fn init(
        rng: &mut dyn RngCore,
        player_count: usize,
        options: Self::Options,
    ) -> Self;
    fn player_view(&self, player_index: usize) -> Self::PlayerView;
    fn process_turn(
        &mut self,
        rng: &mut dyn RngCore,
        actions: HashMap<usize, Self::Action>,
    ) -> Vec<Self::Event>;
    fn finished(&self) -> bool;
    fn results(&self) -> Self::Results;
}

Required Associated Types§

Source

type Options: Serialize + for<'de> Deserialize<'de> + Sync + Send + Clone + 'static

Source

type OptionsPreset: Debug + Serialize + for<'de> Deserialize<'de> + Sync + Send + Clone + 'static + Into<Self::Options>

Source

type PlayerOptions: PlayerOptions<Self> + Serialize + for<'de> Deserialize<'de> + Sync + Send + Clone + 'static

Source

type Action: Serialize + for<'de> Deserialize<'de> + Trans + Sync + Send + Clone + 'static

Source

type Event: Serialize + for<'de> Deserialize<'de> + Trans + Sync + Send + Clone + 'static

Source

type PlayerView: Serialize + for<'de> Deserialize<'de> + Trans + Sync + Send + Clone + 'static

Source

type Results: Serialize + for<'de> Deserialize<'de> + Sync + Send + Clone + 'static

Source

type DebugData: Serialize + for<'de> Deserialize<'de> + Trans + Sync + Send + Clone + 'static

Source

type DebugState: Serialize + for<'de> Deserialize<'de> + Trans + Sync + Send + Clone + 'static

Required Methods§

Source

fn init( rng: &mut dyn RngCore, player_count: usize, options: Self::Options, ) -> Self

Source

fn player_view(&self, player_index: usize) -> Self::PlayerView

Source

fn process_turn( &mut self, rng: &mut dyn RngCore, actions: HashMap<usize, Self::Action>, ) -> Vec<Self::Event>

Source

fn finished(&self) -> bool

Source

fn results(&self) -> Self::Results

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§