rosu_mods/
mod_manual.rs

1use super::GameMod;
2
3impl GameMod {
4    /// The clock rate of the [`GameMod`].
5    ///
6    /// Returns `None` if there is no single clock rate.
7    pub const fn clock_rate(&self) -> Option<f64> {
8        // TODO: replace with `Option::unwrap_or` when it's const stable
9        const fn unwrap_or(opt: Option<f64>, default: f64) -> f64 {
10            match opt {
11                Some(n) => n,
12                None => default,
13            }
14        }
15
16        match self {
17            Self::DoubleTimeOsu(m) => Some(unwrap_or(m.speed_change, 1.5)),
18            Self::DoubleTimeTaiko(m) => Some(unwrap_or(m.speed_change, 1.5)),
19            Self::DoubleTimeCatch(m) => Some(unwrap_or(m.speed_change, 1.5)),
20            Self::DoubleTimeMania(m) => Some(unwrap_or(m.speed_change, 1.5)),
21            Self::NightcoreOsu(m) => Some(unwrap_or(m.speed_change, 1.5)),
22            Self::NightcoreTaiko(m) => Some(unwrap_or(m.speed_change, 1.5)),
23            Self::NightcoreCatch(m) => Some(unwrap_or(m.speed_change, 1.5)),
24            Self::NightcoreMania(m) => Some(unwrap_or(m.speed_change, 1.5)),
25            Self::HalfTimeOsu(m) => Some(unwrap_or(m.speed_change, 0.75)),
26            Self::HalfTimeTaiko(m) => Some(unwrap_or(m.speed_change, 0.75)),
27            Self::HalfTimeCatch(m) => Some(unwrap_or(m.speed_change, 0.75)),
28            Self::HalfTimeMania(m) => Some(unwrap_or(m.speed_change, 0.75)),
29            Self::DaycoreOsu(m) => Some(unwrap_or(m.speed_change, 0.75)),
30            Self::DaycoreTaiko(m) => Some(unwrap_or(m.speed_change, 0.75)),
31            Self::DaycoreCatch(m) => Some(unwrap_or(m.speed_change, 0.75)),
32            Self::DaycoreMania(m) => Some(unwrap_or(m.speed_change, 0.75)),
33            Self::WindUpOsu(_) => None,
34            Self::WindUpTaiko(_) => None,
35            Self::WindUpCatch(_) => None,
36            Self::WindUpMania(_) => None,
37            Self::WindDownOsu(_) => None,
38            Self::WindDownTaiko(_) => None,
39            Self::WindDownCatch(_) => None,
40            Self::WindDownMania(_) => None,
41            Self::AdaptiveSpeedOsu(_) => None,
42            Self::AdaptiveSpeedTaiko(_) => None,
43            Self::AdaptiveSpeedMania(_) => None,
44            _ => Some(1.0),
45        }
46    }
47}