1#![cfg_attr(not(feature = "std"), no_std)]
7
8extern crate alloc;
9
10use parity_scale_codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
11use scale_info::TypeInfo;
12
13#[cfg(feature = "std")]
14use serde::{Deserialize, Serialize};
15
16pub mod constructed;
17pub mod sealed;
18pub mod state;
19pub mod view;
20
21pub use state::{
23 derive_hand_indices_logic, GamePhase, GameSession, GameState, LocalGameState,
24};
25pub use view::*;
26
27#[derive(Debug, Clone, PartialEq, Encode, Decode, DecodeWithMemTracking, TypeInfo, MaxEncodedLen)]
33#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
34pub struct GameConfig {
35 pub starting_lives: i32,
37 pub wins_to_victory: i32,
39 pub starting_mana_limit: i32,
41 pub max_mana_limit: i32,
43 pub full_mana_each_round: bool,
46 pub board_size: u32,
48 pub hand_size: u32,
50 pub bag_size: u32,
52}
53
54impl GameConfig {
55 pub fn mana_limit_for_round(&self, round: i32) -> i32 {
57 (self.starting_mana_limit + round - 1).min(self.max_mana_limit)
58 }
59}
60
61#[cfg(feature = "bounded")]
62pub mod bounded;
63
64#[cfg(test)]
65mod tests;