use serde::{Deserialize, Serialize}; /// Simple ELO rating without deviation or volatility #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub struct EloRating { pub rating: f64, // Display scale (e.g., 1500) } impl EloRating { pub fn new_player() -> Self { Self { rating: 1500.0, } } pub fn new_with_rating(rating: f64) -> Self { Self { rating } } } #[cfg(test)] mod tests { use super::*; #[test] fn test_new_player() { let rating = EloRating::new_player(); assert_eq!(rating.rating, 1500.0); } #[test] fn test_new_with_rating() { let rating = EloRating::new_with_rating(1600.0); assert_eq!(rating.rating, 1600.0); } }