rosu_pp/catch/
strains.rs

1use rosu_map::section::general::GameMode;
2
3use crate::{
4    any::{difficulty::skills::StrainSkill, Difficulty},
5    catch::difficulty::DifficultyValues,
6    model::mode::ConvertError,
7    Beatmap,
8};
9
10/// The result of calculating the strains on a osu!catch map.
11///
12/// Suitable to plot the difficulty of a map over time.
13#[derive(Clone, Debug, PartialEq)]
14pub struct CatchStrains {
15    /// Strain peaks of the movement skill.
16    pub movement: Vec<f64>,
17}
18
19impl CatchStrains {
20    /// Time between two strains in ms.
21    pub const SECTION_LEN: f64 = 750.0;
22}
23
24pub fn strains(difficulty: &Difficulty, map: &Beatmap) -> Result<CatchStrains, ConvertError> {
25    let map = map.convert_ref(GameMode::Catch, difficulty.get_mods())?;
26    let DifficultyValues { movement, .. } = DifficultyValues::calculate(difficulty, &map);
27
28    Ok(CatchStrains {
29        movement: movement.into_current_strain_peaks().into_vec(),
30    })
31}