use crate::Difficulty;
use super::ModsDependent;
#[derive(Clone, Debug, Default, PartialEq)]
pub struct InspectDifficulty {
pub mods: u32,
pub passed_objects: Option<u32>,
pub clock_rate: Option<f64>,
pub ar: Option<ModsDependent>,
pub cs: Option<ModsDependent>,
pub hp: Option<ModsDependent>,
pub od: Option<ModsDependent>,
pub hardrock_offsets: Option<bool>,
}
impl InspectDifficulty {
pub fn into_difficulty(self) -> Difficulty {
let Self {
mods,
passed_objects,
clock_rate,
ar,
cs,
hp,
od,
hardrock_offsets,
} = self;
let mut difficulty = Difficulty::new().mods(mods);
if let Some(passed_objects) = passed_objects {
difficulty = difficulty.passed_objects(passed_objects);
}
if let Some(clock_rate) = clock_rate {
difficulty = difficulty.clock_rate(clock_rate);
}
if let Some(ar) = ar {
difficulty = difficulty.ar(ar.value, ar.with_mods);
}
if let Some(cs) = cs {
difficulty = difficulty.cs(cs.value, cs.with_mods);
}
if let Some(hp) = hp {
difficulty = difficulty.hp(hp.value, hp.with_mods);
}
if let Some(od) = od {
difficulty = difficulty.od(od.value, od.with_mods);
}
if let Some(hardrock_offsets) = hardrock_offsets {
difficulty = difficulty.hardrock_offsets(hardrock_offsets);
}
difficulty
}
}
impl From<InspectDifficulty> for Difficulty {
fn from(difficulty: InspectDifficulty) -> Self {
difficulty.into_difficulty()
}
}
impl From<Difficulty> for InspectDifficulty {
fn from(difficulty: Difficulty) -> Self {
difficulty.inspect()
}
}