Skip to main content

rosu_pp/catch/
strains.rs

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