1pub mod ai;
11pub mod board;
12pub mod error;
13pub mod game;
14pub mod replay;
15pub mod rng;
16pub mod score;
17pub mod stats;
18
19pub use ai::{AIAlgorithm, AIGameController, AIPlayer};
20pub use board::Board;
21pub use error::{GameError, GameResult};
22pub use game::{Direction, Game, GameState};
23pub use replay::{
24 ReplayData, ReplayManager, ReplayMetadata, ReplayMove, ReplayPlayer, ReplayRecorder,
25};
26pub use rng::GameRng;
27pub use score::Score;
28pub use stats::{create_session_stats, GameSessionStats, StatisticsManager, StatisticsSummary};
29
30pub fn get_current_time() -> u64 {
32 #[cfg(target_arch = "wasm32")]
33 {
34 0
36 }
37 #[cfg(not(target_arch = "wasm32"))]
38 {
39 use std::time::{SystemTime, UNIX_EPOCH};
40 SystemTime::now()
41 .duration_since(UNIX_EPOCH)
42 .unwrap_or_default()
43 .as_secs()
44 }
45}
46
47#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
49pub struct GameConfig {
50 pub board_size: usize,
52 pub target_score: u32,
54 pub allow_undo: bool,
56 pub seed: Option<u64>,
58}
59
60impl Default for GameConfig {
61 fn default() -> Self {
62 Self {
63 board_size: 4,
64 target_score: 2048,
65 allow_undo: true,
66 seed: None,
67 }
68 }
69}
70
71#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Default)]
73pub struct GameStats {
74 pub score: u32,
76 pub best_score: u32,
78 pub moves: u32,
80 pub duration: u64,
82 pub won: bool,
84 pub game_over: bool,
86}