pub mod rating;
pub mod calculator;
pub mod score_weight;
pub mod doubles;

pub use rating::GlickoRating;
pub use calculator::Glicko2Calculator;
pub use score_weight::calculate_weighted_score;
pub use doubles::{calculate_team_rating, distribute_rating_change};

/// Convenience function to calculate new ratings for a single match
/// Returns (winner_new_rating, loser_new_rating)
pub fn calculate_new_ratings(
    player1: &GlickoRating,
    player2: &GlickoRating,
    player1_score: f64,  // 1.0 = win, 0.0 = loss, 0.5 = draw
    margin_multiplier: f64,  // From calculate_weighted_score
) -> (GlickoRating, GlickoRating) {
    let calc = Glicko2Calculator::new();
    
    let player2_score = 1.0 - player1_score;
    
    let new_p1 = calc.update_rating(player1, &[(*player2, player1_score * margin_multiplier.min(1.2))]);
    let new_p2 = calc.update_rating(player2, &[(*player1, player2_score * margin_multiplier.min(1.2))]);
    
    (new_p1, new_p2)
}
