rosu_pp/mania/
attributes.rs

1use crate::mania::performance::ManiaPerformance;
2
3/// The result of a difficulty calculation on an osu!mania map.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ManiaDifficultyAttributes {
6    /// The final star rating.
7    pub stars: f64,
8    /// The amount of hitobjects in the map.
9    pub n_objects: u32,
10    /// The amount of hold notes in the map.
11    pub n_hold_notes: u32,
12    /// The maximum achievable combo.
13    pub max_combo: u32,
14    /// Whether the [`Beatmap`] was a convert i.e. an osu!standard map.
15    ///
16    /// [`Beatmap`]: crate::model::beatmap::Beatmap
17    pub is_convert: bool,
18}
19
20impl ManiaDifficultyAttributes {
21    /// Return the maximum combo.
22    pub const fn max_combo(&self) -> u32 {
23        self.max_combo
24    }
25
26    /// Return the amount of hitobjects.
27    pub const fn n_objects(&self) -> u32 {
28        self.n_objects
29    }
30
31    /// Whether the [`Beatmap`] was a convert i.e. an osu!standard map.
32    ///
33    /// [`Beatmap`]: crate::model::beatmap::Beatmap
34    pub const fn is_convert(&self) -> bool {
35        self.is_convert
36    }
37
38    /// Returns a builder for performance calculation.
39    pub fn performance<'a>(self) -> ManiaPerformance<'a> {
40        self.into()
41    }
42}
43
44/// The result of a performance calculation on an osu!mania map.
45#[derive(Clone, Debug, Default, PartialEq)]
46pub struct ManiaPerformanceAttributes {
47    /// The difficulty attributes that were used for the performance calculation.
48    pub difficulty: ManiaDifficultyAttributes,
49    /// The final performance points.
50    pub pp: f64,
51    /// The difficulty portion of the final pp.
52    pub pp_difficulty: f64,
53}
54
55impl ManiaPerformanceAttributes {
56    /// Return the star value.
57    pub const fn stars(&self) -> f64 {
58        self.difficulty.stars
59    }
60
61    /// Return the performance point value.
62    pub const fn pp(&self) -> f64 {
63        self.pp
64    }
65
66    /// Return the maximum combo of the map.
67    pub const fn max_combo(&self) -> u32 {
68        self.difficulty.max_combo
69    }
70
71    /// Return the amount of hitobjects.
72    pub const fn n_objects(&self) -> u32 {
73        self.difficulty.n_objects
74    }
75
76    /// Whether the [`Beatmap`] was a convert i.e. an osu!standard map.
77    ///
78    /// [`Beatmap`]: crate::model::beatmap::Beatmap
79    pub const fn is_convert(&self) -> bool {
80        self.difficulty.is_convert
81    }
82
83    /// Returns a builder for performance calculation.
84    pub fn performance<'a>(self) -> ManiaPerformance<'a> {
85        self.difficulty.into()
86    }
87}
88
89impl From<ManiaPerformanceAttributes> for ManiaDifficultyAttributes {
90    fn from(attributes: ManiaPerformanceAttributes) -> Self {
91        attributes.difficulty
92    }
93}