use super::player::DWZPlayer;
pub struct Match<'a> {
player_one: &'a mut DWZPlayer,
player_two: &'a mut DWZPlayer,
pub result: f32
}
impl Match<'_> {
pub fn new<'a>(player_one: &'a mut DWZPlayer, player_two: &'a mut DWZPlayer, result: f32) -> Match<'a> {
Match { player_one, player_two, result }
}
pub fn update_ratings(&mut self, age_coefficients: &[f32; 3]) {
let p2_res = match self.result {
x if x == 1.0 => { 0.0 }
x if x == 0.5 => { 0.5 }
x if x == 0.0 => { 1.0 }
_ => { panic!("Unexpected value for game result: {}", self.result) }
};
let temp_dwz_1 = self.player_one.dwz.0;
let temp_dwz_2 = self.player_two.dwz.0;
self.player_one.update_rating(vec![temp_dwz_2], self.result, age_coefficients);
self.player_two.update_rating(vec![temp_dwz_1], p2_res, age_coefficients);
}
}