Skip to main content

rosu_pp/osu/
attributes.rs

1use crate::{model::beatmap::BeatmapAttributesExt, osu::performance::OsuPerformance};
2
3/// The result of a difficulty calculation on an osu!standard map.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct OsuDifficultyAttributes {
6    /// The difficulty of the aim skill.
7    pub aim: f64,
8    /// The number of sliders weighted by difficulty.
9    pub aim_difficult_slider_count: f64,
10    /// The difficulty of the speed skill.
11    pub speed: f64,
12    /// The difficulty of the flashlight skill.
13    pub flashlight: f64,
14    /// The ratio of the aim strain with and without considering sliders
15    pub slider_factor: f64,
16    /// Describes how much of aim's difficult strain count is contributed to by sliders
17    pub aim_top_weighted_slider_factor: f64,
18    /// Describes how much of speed's difficult strain count is contributed to by sliders
19    pub speed_top_weighted_slider_factor: f64,
20    /// The number of clickable objects weighted by difficulty.
21    pub speed_note_count: f64,
22    /// Weighted sum of aim strains.
23    pub aim_difficult_strain_count: f64,
24    /// Weighted sum of speed strains.
25    pub speed_difficult_strain_count: f64,
26    /// The amount of nested score per object.
27    pub nested_score_per_object: f64,
28    /// The legacy score base multiplier.
29    pub legacy_score_base_multiplier: f64,
30    /// The maximum legacy combo score.
31    pub maximum_legacy_combo_score: f64,
32    /// The approach rate.
33    pub ar: f64,
34    /// The great hit window.
35    pub great_hit_window: f64,
36    /// The ok hit window.
37    pub ok_hit_window: f64,
38    /// The meh hit window.
39    pub meh_hit_window: f64,
40    /// The health drain rate.
41    pub hp: f64,
42    /// The amount of circles.
43    pub n_circles: u32,
44    /// The amount of sliders.
45    pub n_sliders: u32,
46    /// The amount of "large ticks".
47    ///
48    /// The meaning depends on the kind of score:
49    /// - if set on osu!stable, this value is irrelevant
50    /// - if set on osu!lazer *with* slider accuracy, this value is the amount
51    ///   of hit slider ticks and repeats
52    /// - if set on osu!lazer *without* slider accuracy, this value is the
53    ///   amount of hit slider heads, ticks, and repeats
54    pub n_large_ticks: u32,
55    /// The amount of spinners.
56    pub n_spinners: u32,
57    /// The final star rating
58    pub stars: f64,
59    /// The maximum combo.
60    pub max_combo: u32,
61}
62
63impl OsuDifficultyAttributes {
64    /// Return the maximum combo.
65    pub const fn max_combo(&self) -> u32 {
66        self.max_combo
67    }
68
69    /// Return the amount of hitobjects.
70    pub const fn n_objects(&self) -> u32 {
71        self.n_circles + self.n_sliders + self.n_spinners
72    }
73
74    /// The overall difficulty
75    pub const fn od(&self) -> f64 {
76        BeatmapAttributesExt::osu_great_hit_window_to_od(self.great_hit_window)
77    }
78
79    /// Returns a builder for performance calculation.
80    pub fn performance<'a>(self) -> OsuPerformance<'a> {
81        self.into()
82    }
83}
84
85/// The result of a performance calculation on an osu!standard map.
86#[derive(Clone, Debug, Default, PartialEq)]
87pub struct OsuPerformanceAttributes {
88    /// The difficulty attributes that were used for the performance calculation
89    pub difficulty: OsuDifficultyAttributes,
90    /// The final performance points.
91    pub pp: f64,
92    /// The accuracy portion of the final pp.
93    pub pp_acc: f64,
94    /// The aim portion of the final pp.
95    pub pp_aim: f64,
96    /// The flashlight portion of the final pp.
97    pub pp_flashlight: f64,
98    /// The speed portion of the final pp.
99    pub pp_speed: f64,
100    /// Misses including an approximated amount of slider breaks
101    pub effective_miss_count: f64,
102    /// Approximated unstable-rate
103    pub speed_deviation: Option<f64>,
104    pub combo_based_estimated_miss_count: f64,
105    pub score_based_estimated_miss_count: Option<f64>,
106    pub aim_estimated_slider_breaks: f64,
107    pub speed_estimated_slider_breaks: f64,
108}
109
110impl OsuPerformanceAttributes {
111    /// Return the star value.
112    pub const fn stars(&self) -> f64 {
113        self.difficulty.stars
114    }
115
116    /// Return the performance point value.
117    pub const fn pp(&self) -> f64 {
118        self.pp
119    }
120
121    /// Return the maximum combo of the map.
122    pub const fn max_combo(&self) -> u32 {
123        self.difficulty.max_combo
124    }
125    /// Return the amount of hitobjects.
126    pub const fn n_objects(&self) -> u32 {
127        self.difficulty.n_objects()
128    }
129
130    /// Returns a builder for performance calculation.
131    pub fn performance<'a>(self) -> OsuPerformance<'a> {
132        self.difficulty.into()
133    }
134}
135
136impl From<OsuPerformanceAttributes> for OsuDifficultyAttributes {
137    fn from(attributes: OsuPerformanceAttributes) -> Self {
138        attributes.difficulty
139    }
140}