use crate::{
catch::{CatchDifficultyAttributes, CatchPerformanceAttributes},
mania::{ManiaDifficultyAttributes, ManiaPerformanceAttributes},
osu::{OsuDifficultyAttributes, OsuPerformanceAttributes},
taiko::{TaikoDifficultyAttributes, TaikoPerformanceAttributes},
};
use super::performance::{into::IntoPerformance, Performance};
#[derive(Clone, Debug, PartialEq)]
pub enum DifficultyAttributes {
Osu(OsuDifficultyAttributes),
Taiko(TaikoDifficultyAttributes),
Catch(CatchDifficultyAttributes),
Mania(ManiaDifficultyAttributes),
}
impl DifficultyAttributes {
pub const fn stars(&self) -> f64 {
match self {
Self::Osu(attrs) => attrs.stars,
Self::Taiko(attrs) => attrs.stars,
Self::Catch(attrs) => attrs.stars,
Self::Mania(attrs) => attrs.stars,
}
}
pub const fn max_combo(&self) -> u32 {
match self {
Self::Osu(attrs) => attrs.max_combo,
Self::Taiko(attrs) => attrs.max_combo,
Self::Catch(attrs) => attrs.max_combo(),
Self::Mania(attrs) => attrs.max_combo,
}
}
pub fn performance<'a>(self) -> Performance<'a> {
self.into_performance()
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum PerformanceAttributes {
Osu(OsuPerformanceAttributes),
Taiko(TaikoPerformanceAttributes),
Catch(CatchPerformanceAttributes),
Mania(ManiaPerformanceAttributes),
}
impl PerformanceAttributes {
pub const fn pp(&self) -> f64 {
match self {
Self::Osu(attrs) => attrs.pp,
Self::Taiko(attrs) => attrs.pp,
Self::Catch(attrs) => attrs.pp,
Self::Mania(attrs) => attrs.pp,
}
}
pub const fn stars(&self) -> f64 {
match self {
Self::Osu(attrs) => attrs.stars(),
Self::Taiko(attrs) => attrs.stars(),
Self::Catch(attrs) => attrs.stars(),
Self::Mania(attrs) => attrs.stars(),
}
}
pub fn difficulty_attributes(&self) -> DifficultyAttributes {
match self {
Self::Osu(attrs) => DifficultyAttributes::Osu(attrs.difficulty.clone()),
Self::Taiko(attrs) => DifficultyAttributes::Taiko(attrs.difficulty.clone()),
Self::Catch(attrs) => DifficultyAttributes::Catch(attrs.difficulty.clone()),
Self::Mania(attrs) => DifficultyAttributes::Mania(attrs.difficulty.clone()),
}
}
pub const fn max_combo(&self) -> u32 {
match self {
Self::Osu(attrs) => attrs.difficulty.max_combo,
Self::Taiko(attrs) => attrs.difficulty.max_combo,
Self::Catch(attrs) => attrs.difficulty.max_combo(),
Self::Mania(attrs) => attrs.difficulty.max_combo,
}
}
pub fn performance<'a>(self) -> Performance<'a> {
self.into_performance()
}
}
impl From<PerformanceAttributes> for DifficultyAttributes {
fn from(attrs: PerformanceAttributes) -> Self {
attrs.difficulty_attributes()
}
}