rosu_mods/
mod_manual.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use super::GameMod;

impl GameMod {
    /// The clock rate of the [`GameMod`].
    ///
    /// Returns `None` if there is no single clock rate.
    pub const fn clock_rate(&self) -> Option<f64> {
        // TODO: replace with `Option::unwrap_or` when it's const stable
        const fn unwrap_or(opt: Option<f64>, default: f64) -> f64 {
            match opt {
                Some(n) => n,
                None => default,
            }
        }

        match self {
            Self::DoubleTimeOsu(m) => Some(unwrap_or(m.speed_change, 1.5)),
            Self::DoubleTimeTaiko(m) => Some(unwrap_or(m.speed_change, 1.5)),
            Self::DoubleTimeCatch(m) => Some(unwrap_or(m.speed_change, 1.5)),
            Self::DoubleTimeMania(m) => Some(unwrap_or(m.speed_change, 1.5)),
            Self::NightcoreOsu(m) => Some(unwrap_or(m.speed_change, 1.5)),
            Self::NightcoreTaiko(m) => Some(unwrap_or(m.speed_change, 1.5)),
            Self::NightcoreCatch(m) => Some(unwrap_or(m.speed_change, 1.5)),
            Self::NightcoreMania(m) => Some(unwrap_or(m.speed_change, 1.5)),
            Self::HalfTimeOsu(m) => Some(unwrap_or(m.speed_change, 0.75)),
            Self::HalfTimeTaiko(m) => Some(unwrap_or(m.speed_change, 0.75)),
            Self::HalfTimeCatch(m) => Some(unwrap_or(m.speed_change, 0.75)),
            Self::HalfTimeMania(m) => Some(unwrap_or(m.speed_change, 0.75)),
            Self::DaycoreOsu(m) => Some(unwrap_or(m.speed_change, 0.75)),
            Self::DaycoreTaiko(m) => Some(unwrap_or(m.speed_change, 0.75)),
            Self::DaycoreCatch(m) => Some(unwrap_or(m.speed_change, 0.75)),
            Self::DaycoreMania(m) => Some(unwrap_or(m.speed_change, 0.75)),
            Self::WindUpOsu(_) => None,
            Self::WindUpTaiko(_) => None,
            Self::WindUpCatch(_) => None,
            Self::WindUpMania(_) => None,
            Self::WindDownOsu(_) => None,
            Self::WindDownTaiko(_) => None,
            Self::WindDownCatch(_) => None,
            Self::WindDownMania(_) => None,
            Self::AdaptiveSpeedOsu(_) => None,
            Self::AdaptiveSpeedTaiko(_) => None,
            Self::AdaptiveSpeedMania(_) => None,
            _ => Some(1.0),
        }
    }
}