rosu_pp/any/
attributes.rs1use crate::{
2 catch::{CatchDifficultyAttributes, CatchPerformanceAttributes},
3 mania::{ManiaDifficultyAttributes, ManiaPerformanceAttributes},
4 osu::{OsuDifficultyAttributes, OsuPerformanceAttributes},
5 taiko::{TaikoDifficultyAttributes, TaikoPerformanceAttributes},
6};
7
8use super::performance::{into::IntoPerformance, Performance};
9
10#[derive(Clone, Debug, PartialEq)]
12pub enum DifficultyAttributes {
13 Osu(OsuDifficultyAttributes),
15 Taiko(TaikoDifficultyAttributes),
17 Catch(CatchDifficultyAttributes),
19 Mania(ManiaDifficultyAttributes),
21}
22
23impl DifficultyAttributes {
24 pub const fn stars(&self) -> f64 {
26 match self {
27 Self::Osu(attrs) => attrs.stars,
28 Self::Taiko(attrs) => attrs.stars,
29 Self::Catch(attrs) => attrs.stars,
30 Self::Mania(attrs) => attrs.stars,
31 }
32 }
33
34 pub const fn max_combo(&self) -> u32 {
36 match self {
37 Self::Osu(attrs) => attrs.max_combo,
38 Self::Taiko(attrs) => attrs.max_combo,
39 Self::Catch(attrs) => attrs.max_combo(),
40 Self::Mania(attrs) => attrs.max_combo,
41 }
42 }
43
44 pub fn performance<'a>(self) -> Performance<'a> {
46 self.into_performance()
47 }
48}
49
50#[derive(Clone, Debug, PartialEq)]
52pub enum PerformanceAttributes {
53 Osu(OsuPerformanceAttributes),
55 Taiko(TaikoPerformanceAttributes),
57 Catch(CatchPerformanceAttributes),
59 Mania(ManiaPerformanceAttributes),
61}
62
63impl PerformanceAttributes {
64 pub const fn pp(&self) -> f64 {
66 match self {
67 Self::Osu(attrs) => attrs.pp,
68 Self::Taiko(attrs) => attrs.pp,
69 Self::Catch(attrs) => attrs.pp,
70 Self::Mania(attrs) => attrs.pp,
71 }
72 }
73
74 pub const fn stars(&self) -> f64 {
76 match self {
77 Self::Osu(attrs) => attrs.stars(),
78 Self::Taiko(attrs) => attrs.stars(),
79 Self::Catch(attrs) => attrs.stars(),
80 Self::Mania(attrs) => attrs.stars(),
81 }
82 }
83
84 pub fn difficulty_attributes(&self) -> DifficultyAttributes {
86 match self {
87 Self::Osu(attrs) => DifficultyAttributes::Osu(attrs.difficulty.clone()),
88 Self::Taiko(attrs) => DifficultyAttributes::Taiko(attrs.difficulty.clone()),
89 Self::Catch(attrs) => DifficultyAttributes::Catch(attrs.difficulty.clone()),
90 Self::Mania(attrs) => DifficultyAttributes::Mania(attrs.difficulty.clone()),
91 }
92 }
93
94 pub const fn max_combo(&self) -> u32 {
96 match self {
97 Self::Osu(attrs) => attrs.difficulty.max_combo,
98 Self::Taiko(attrs) => attrs.difficulty.max_combo,
99 Self::Catch(attrs) => attrs.difficulty.max_combo(),
100 Self::Mania(attrs) => attrs.difficulty.max_combo,
101 }
102 }
103
104 pub fn performance<'a>(self) -> Performance<'a> {
106 self.into_performance()
107 }
108}
109
110impl From<PerformanceAttributes> for DifficultyAttributes {
111 fn from(attrs: PerformanceAttributes) -> Self {
112 attrs.difficulty_attributes()
113 }
114}