renamed GameMode variants

This commit is contained in:
MaxOhn
2022-07-06 15:56:07 +02:00
parent a732d28b34
commit 970f9ff69f
17 changed files with 286 additions and 286 deletions
+1
View File
@@ -4,6 +4,7 @@
- Slider velocity is now adjusted properly for taiko converts - Slider velocity is now adjusted properly for taiko converts
- __Breaking changes:__ - __Breaking changes:__
- Replaced the simple `Strains` struct with a new struct `{Mode}Strains` that contains more detail w.r.t. the mode. - Replaced the simple `Strains` struct with a new struct `{Mode}Strains` that contains more detail w.r.t. the mode.
- Renamed all `GameMode` variants to more idiomatic names
# v0.6.0 (2022-07-05) # v0.6.0 (2022-07-05)
+1 -1
View File
@@ -195,7 +195,7 @@ impl Beatmap {
legacy_sort(&mut map.hit_objects); legacy_sort(&mut map.hit_objects);
map.mode = GameMode::MNA; map.mode = GameMode::Mania;
map map
} }
+1 -1
View File
@@ -87,7 +87,7 @@ impl Beatmap {
map.hit_objects map.hit_objects
.sort_by(|p1, p2| p1.partial_cmp(p2).unwrap_or(Ordering::Equal)); .sort_by(|p1, p2| p1.partial_cmp(p2).unwrap_or(Ordering::Equal));
map.mode = GameMode::TKO; map.mode = GameMode::Taiko;
map map
} }
+3 -3
View File
@@ -132,9 +132,9 @@ impl Beatmap {
} }
match mode { match mode {
GameMode::STD | GameMode::CTB => Cow::Borrowed(self), GameMode::Osu | GameMode::Catch => Cow::Borrowed(self),
GameMode::TKO => Cow::Owned(self.convert_to_taiko()), GameMode::Taiko => Cow::Owned(self.convert_to_taiko()),
GameMode::MNA => Cow::Owned(self.convert_to_mania()), GameMode::Mania => Cow::Owned(self.convert_to_mania()),
} }
} }
+5 -6
View File
@@ -1,20 +1,19 @@
/// The mode of a beatmap. /// The mode of a beatmap.
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
#[allow(clippy::upper_case_acronyms)]
pub enum GameMode { pub enum GameMode {
/// osu!standard /// osu!standard
STD = 0, Osu = 0,
/// osu!taiko /// osu!taiko
TKO = 1, Taiko = 1,
/// osu!catch /// osu!catch
CTB = 2, Catch = 2,
/// osu!mania /// osu!mania
MNA = 3, Mania = 3,
} }
impl Default for GameMode { impl Default for GameMode {
#[inline] #[inline]
fn default() -> Self { fn default() -> Self {
Self::STD Self::Osu
} }
} }
+8 -8
View File
@@ -53,10 +53,10 @@ impl<'map> GradualDifficultyAttributes<'map> {
/// Create a new gradual difficulty calculator for maps of any mode. /// Create a new gradual difficulty calculator for maps of any mode.
pub fn new(map: &'map Beatmap, mods: impl Mods) -> Self { pub fn new(map: &'map Beatmap, mods: impl Mods) -> Self {
match map.mode { match map.mode {
GameMode::STD => Self::Osu(OsuGradualDifficultyAttributes::new(map, mods)), GameMode::Osu => Self::Osu(OsuGradualDifficultyAttributes::new(map, mods)),
GameMode::TKO => Self::Taiko(TaikoGradualDifficultyAttributes::new(map, mods)), GameMode::Taiko => Self::Taiko(TaikoGradualDifficultyAttributes::new(map, mods)),
GameMode::CTB => Self::Catch(CatchGradualDifficultyAttributes::new(map, mods)), GameMode::Catch => Self::Catch(CatchGradualDifficultyAttributes::new(map, mods)),
GameMode::MNA => Self::Mania(ManiaGradualDifficultyAttributes::new(map, mods)), GameMode::Mania => Self::Mania(ManiaGradualDifficultyAttributes::new(map, mods)),
} }
} }
} }
@@ -285,10 +285,10 @@ impl<'map> GradualPerformanceAttributes<'map> {
/// Create a new gradual performance calculator for maps of any mode. /// Create a new gradual performance calculator for maps of any mode.
pub fn new(map: &'map Beatmap, mods: u32) -> Self { pub fn new(map: &'map Beatmap, mods: u32) -> Self {
match map.mode { match map.mode {
GameMode::STD => Self::Osu(OsuGradualPerformanceAttributes::new(map, mods)), GameMode::Osu => Self::Osu(OsuGradualPerformanceAttributes::new(map, mods)),
GameMode::TKO => Self::Taiko(TaikoGradualPerformanceAttributes::new(map, mods)), GameMode::Taiko => Self::Taiko(TaikoGradualPerformanceAttributes::new(map, mods)),
GameMode::CTB => Self::Catch(CatchGradualPerformanceAttributes::new(map, mods)), GameMode::Catch => Self::Catch(CatchGradualPerformanceAttributes::new(map, mods)),
GameMode::MNA => Self::Mania(ManiaGradualPerformanceAttributes::new(map, mods)), GameMode::Mania => Self::Mania(ManiaGradualPerformanceAttributes::new(map, mods)),
} }
} }
+13 -13
View File
@@ -80,7 +80,7 @@
//! This could be done by using `passed_objects` as the amount of objects that were passed so far. //! This could be done by using `passed_objects` as the amount of objects that were passed so far.
//! However, this requires to recalculate the beginning again and again, we can be more efficient than that. //! However, this requires to recalculate the beginning again and again, we can be more efficient than that.
//! //!
//! Instead, you should use `GradualDifficultyAttributes` and `GradualPerformanceAttributes`: //! Instead, you should use [`GradualDifficultyAttributes`] and [`GradualPerformanceAttributes`]:
//! //!
//! ```no_run //! ```no_run
//! use rosu_pp::{ //! use rosu_pp::{
@@ -255,24 +255,24 @@ impl BeatmapExt for Beatmap {
#[inline] #[inline]
fn stars(&self) -> AnyStars<'_> { fn stars(&self) -> AnyStars<'_> {
match self.mode { match self.mode {
GameMode::STD => AnyStars::Osu(OsuStars::new(self)), GameMode::Osu => AnyStars::Osu(OsuStars::new(self)),
GameMode::MNA => AnyStars::Mania(ManiaStars::new(self)), GameMode::Mania => AnyStars::Mania(ManiaStars::new(self)),
GameMode::TKO => AnyStars::Taiko(TaikoStars::new(self)), GameMode::Taiko => AnyStars::Taiko(TaikoStars::new(self)),
GameMode::CTB => AnyStars::Catch(CatchStars::new(self)), GameMode::Catch => AnyStars::Catch(CatchStars::new(self)),
} }
} }
#[inline] #[inline]
fn max_pp(&self, mods: u32) -> PerformanceAttributes { fn max_pp(&self, mods: u32) -> PerformanceAttributes {
match self.mode { match self.mode {
GameMode::STD => PerformanceAttributes::Osu(OsuPP::new(self).mods(mods).calculate()), GameMode::Osu => PerformanceAttributes::Osu(OsuPP::new(self).mods(mods).calculate()),
GameMode::MNA => { GameMode::Mania => {
PerformanceAttributes::Mania(ManiaPP::new(self).mods(mods).calculate()) PerformanceAttributes::Mania(ManiaPP::new(self).mods(mods).calculate())
} }
GameMode::TKO => { GameMode::Taiko => {
PerformanceAttributes::Taiko(TaikoPP::new(self).mods(mods).calculate()) PerformanceAttributes::Taiko(TaikoPP::new(self).mods(mods).calculate())
} }
GameMode::CTB => { GameMode::Catch => {
PerformanceAttributes::Catch(CatchPP::new(self).mods(mods).calculate()) PerformanceAttributes::Catch(CatchPP::new(self).mods(mods).calculate())
} }
} }
@@ -286,10 +286,10 @@ impl BeatmapExt for Beatmap {
#[inline] #[inline]
fn strains(&self, mods: u32) -> Strains { fn strains(&self, mods: u32) -> Strains {
match self.mode { match self.mode {
GameMode::STD => Strains::Osu(OsuStars::new(self).mods(mods).strains()), GameMode::Osu => Strains::Osu(OsuStars::new(self).mods(mods).strains()),
GameMode::MNA => Strains::Mania(ManiaStars::new(self).mods(mods).strains()), GameMode::Mania => Strains::Mania(ManiaStars::new(self).mods(mods).strains()),
GameMode::TKO => Strains::Taiko(TaikoStars::new(self).mods(mods).strains()), GameMode::Taiko => Strains::Taiko(TaikoStars::new(self).mods(mods).strains()),
GameMode::CTB => Strains::Catch(CatchStars::new(self).mods(mods).strains()), GameMode::Catch => Strains::Catch(CatchStars::new(self).mods(mods).strains()),
} }
} }
+2 -2
View File
@@ -56,8 +56,8 @@ impl<'map> ManiaGradualDifficultyAttributes<'map> {
let rounded_cs = map.cs.round(); let rounded_cs = map.cs.round();
let columns = match map.mode { let columns = match map.mode {
GameMode::MNA => rounded_cs.max(1.0) as u8, GameMode::Mania => rounded_cs.max(1.0) as u8,
GameMode::STD => { GameMode::Osu => {
let rounded_od = map.od.round(); let rounded_od = map.od.round();
let n_objects = map.n_circles + map.n_sliders + map.n_spinners; let n_objects = map.n_circles + map.n_sliders + map.n_spinners;
+3 -3
View File
@@ -140,8 +140,8 @@ fn calculate_strain(params: ManiaStars<'_>) -> Strain {
let rounded_cs = map.cs.round(); let rounded_cs = map.cs.round();
let columns = match map.mode { let columns = match map.mode {
GameMode::MNA => rounded_cs.max(1.0) as u8, GameMode::Mania => rounded_cs.max(1.0) as u8,
GameMode::STD => { GameMode::Osu => {
let rounded_od = map.od.round(); let rounded_od = map.od.round();
let n_objects = map.n_circles + map.n_sliders + map.n_spinners; let n_objects = map.n_circles + map.n_sliders + map.n_spinners;
@@ -270,7 +270,7 @@ impl<'map> From<OsuStars<'map>> for ManiaStars<'map> {
} = osu; } = osu;
Self { Self {
map: map.convert_mode(GameMode::MNA), map: map.convert_mode(GameMode::Mania),
mods, mods,
passed_objects, passed_objects,
clock_rate, clock_rate,
+1 -1
View File
@@ -225,7 +225,7 @@ impl<'map> From<OsuPP<'map>> for ManiaPP<'map> {
} = osu; } = osu;
Self { Self {
map: map.convert_mode(GameMode::MNA), map: map.convert_mode(GameMode::Mania),
stars: None, stars: None,
mods, mods,
score: None, score: None,
+4 -4
View File
@@ -71,10 +71,10 @@ impl<'map> OsuStars<'map> {
#[inline] #[inline]
pub fn mode(self, mode: GameMode) -> AnyStars<'map> { pub fn mode(self, mode: GameMode) -> AnyStars<'map> {
match mode { match mode {
GameMode::STD => AnyStars::Osu(self), GameMode::Osu => AnyStars::Osu(self),
GameMode::TKO => AnyStars::Taiko(self.into()), GameMode::Taiko => AnyStars::Taiko(self.into()),
GameMode::CTB => AnyStars::Catch(self.into()), GameMode::Catch => AnyStars::Catch(self.into()),
GameMode::MNA => AnyStars::Mania(self.into()), GameMode::Mania => AnyStars::Mania(self.into()),
} }
} }
+4 -4
View File
@@ -73,10 +73,10 @@ impl<'map> OsuPP<'map> {
#[inline] #[inline]
pub fn mode(self, mode: GameMode) -> AnyPP<'map> { pub fn mode(self, mode: GameMode) -> AnyPP<'map> {
match mode { match mode {
GameMode::STD => AnyPP::Osu(self), GameMode::Osu => AnyPP::Osu(self),
GameMode::TKO => AnyPP::Taiko(self.into()), GameMode::Taiko => AnyPP::Taiko(self.into()),
GameMode::CTB => AnyPP::Catch(self.into()), GameMode::Catch => AnyPP::Catch(self.into()),
GameMode::MNA => AnyPP::Mania(self.into()), GameMode::Mania => AnyPP::Mania(self.into()),
} }
} }
+6 -6
View File
@@ -101,10 +101,10 @@ macro_rules! parse_general_body {
if key == b"Mode" { if key == b"Mode" {
mode = match value { mode = match value {
"0" => Some(GameMode::STD), "0" => Some(GameMode::Osu),
"1" => Some(GameMode::TKO), "1" => Some(GameMode::Taiko),
"2" => Some(GameMode::CTB), "2" => Some(GameMode::Catch),
"3" => Some(GameMode::MNA), "3" => Some(GameMode::Mania),
_ => return Err(ParseError::InvalidMode), _ => return Err(ParseError::InvalidMode),
}; };
} }
@@ -114,7 +114,7 @@ macro_rules! parse_general_body {
} }
} }
$self.mode = mode.unwrap_or(GameMode::STD); $self.mode = mode.unwrap_or(GameMode::Osu);
$self.stack_leniency = stack_leniency.unwrap_or(0.7); $self.stack_leniency = stack_leniency.unwrap_or(0.7);
Ok(empty) Ok(empty)
@@ -456,7 +456,7 @@ macro_rules! parse_hitobjects_body {
// BUG: If [General] section comes after [HitObjects] then the mode // BUG: If [General] section comes after [HitObjects] then the mode
// won't be set yet so mania objects won't be sorted properly // won't be set yet so mania objects won't be sorted properly
if $self.mode == GameMode::MNA { if $self.mode == GameMode::Mania {
// First a _stable_ sort by time // First a _stable_ sort by time
$self $self
.hit_objects .hit_objects
+8 -8
View File
@@ -53,10 +53,10 @@ impl<'map> AnyPP<'map> {
#[inline] #[inline]
pub fn new(map: &'map Beatmap) -> Self { pub fn new(map: &'map Beatmap) -> Self {
match map.mode { match map.mode {
GameMode::CTB => Self::Catch(CatchPP::new(map)), GameMode::Catch => Self::Catch(CatchPP::new(map)),
GameMode::MNA => Self::Mania(ManiaPP::new(map)), GameMode::Mania => Self::Mania(ManiaPP::new(map)),
GameMode::STD => Self::Osu(OsuPP::new(map)), GameMode::Osu => Self::Osu(OsuPP::new(map)),
GameMode::TKO => Self::Taiko(TaikoPP::new(map)), GameMode::Taiko => Self::Taiko(TaikoPP::new(map)),
} }
} }
@@ -90,10 +90,10 @@ impl<'map> AnyPP<'map> {
pub fn mode(self, mode: GameMode) -> Self { pub fn mode(self, mode: GameMode) -> Self {
match self { match self {
AnyPP::Osu(o) => match mode { AnyPP::Osu(o) => match mode {
GameMode::STD => AnyPP::Osu(o), GameMode::Osu => AnyPP::Osu(o),
GameMode::TKO => AnyPP::Taiko(o.into()), GameMode::Taiko => AnyPP::Taiko(o.into()),
GameMode::CTB => AnyPP::Catch(o.into()), GameMode::Catch => AnyPP::Catch(o.into()),
GameMode::MNA => AnyPP::Mania(o.into()), GameMode::Mania => AnyPP::Mania(o.into()),
}, },
other => other, other => other,
} }
+8 -8
View File
@@ -37,10 +37,10 @@ impl<'map> AnyStars<'map> {
#[inline] #[inline]
pub fn new(map: &'map Beatmap) -> Self { pub fn new(map: &'map Beatmap) -> Self {
match map.mode { match map.mode {
GameMode::CTB => Self::Catch(CatchStars::new(map)), GameMode::Catch => Self::Catch(CatchStars::new(map)),
GameMode::MNA => Self::Mania(ManiaStars::new(map)), GameMode::Mania => Self::Mania(ManiaStars::new(map)),
GameMode::STD => Self::Osu(OsuStars::new(map)), GameMode::Osu => Self::Osu(OsuStars::new(map)),
GameMode::TKO => Self::Taiko(TaikoStars::new(map)), GameMode::Taiko => Self::Taiko(TaikoStars::new(map)),
} }
} }
@@ -49,10 +49,10 @@ impl<'map> AnyStars<'map> {
pub fn mode(self, mode: GameMode) -> Self { pub fn mode(self, mode: GameMode) -> Self {
match self { match self {
AnyStars::Osu(o) => match mode { AnyStars::Osu(o) => match mode {
GameMode::STD => AnyStars::Osu(o), GameMode::Osu => AnyStars::Osu(o),
GameMode::TKO => AnyStars::Taiko(o.into()), GameMode::Taiko => AnyStars::Taiko(o.into()),
GameMode::CTB => AnyStars::Catch(o.into()), GameMode::Catch => AnyStars::Catch(o.into()),
GameMode::MNA => AnyStars::Mania(o.into()), GameMode::Mania => AnyStars::Mania(o.into()),
}, },
other => other, other => other,
} }
+1 -1
View File
@@ -362,7 +362,7 @@ impl<'map> From<OsuStars<'map>> for TaikoStars<'map> {
} = osu; } = osu;
Self { Self {
map: map.convert_mode(GameMode::TKO), map: map.convert_mode(GameMode::Taiko),
mods, mods,
passed_objects, passed_objects,
clock_rate, clock_rate,
+1 -1
View File
@@ -321,7 +321,7 @@ impl<'map> From<OsuPP<'map>> for TaikoPP<'map> {
} = osu; } = osu;
Self { Self {
map: map.convert_mode(GameMode::TKO), map: map.convert_mode(GameMode::Taiko),
attributes: None, attributes: None,
mods, mods,
combo, combo,