refactor!: renamed gradual calc types

This commit is contained in:
MaxOhn
2023-11-08 21:47:54 +01:00
parent 06a76a834e
commit 1434e88cef
28 changed files with 168 additions and 167 deletions
+6 -6
View File
@@ -24,12 +24,12 @@ use super::{
/// Note that it does not return attributes after a tiny droplet. Only for fruits and droplets. /// Note that it does not return attributes after a tiny droplet. Only for fruits and droplets.
/// ///
/// If you want to calculate performance attributes, use /// If you want to calculate performance attributes, use
/// [`CatchGradualPerformanceAttributes`](crate::catch::CatchGradualPerformanceAttributes) instead. /// [`CatchGradualPerformanceAttributes`](crate::catch::CatchGradualPerformance) instead.
/// ///
/// # Example /// # Example
/// ///
/// ``` /// ```
/// use rosu_pp::{Beatmap, catch::CatchGradualDifficultyAttributes}; /// use rosu_pp::{Beatmap, catch::CatchGradualDifficulty};
/// ///
/// # /* /// # /*
/// let map: Beatmap = ... /// let map: Beatmap = ...
@@ -37,7 +37,7 @@ use super::{
/// # let map = Beatmap::default(); /// # let map = Beatmap::default();
/// ///
/// let mods = 64; // DT /// let mods = 64; // DT
/// let mut iter = CatchGradualDifficultyAttributes::new(&map, mods); /// let mut iter = CatchGradualDifficulty::new(&map, mods);
/// ///
/// let attrs1 = iter.next(); // the difficulty of the map after the first hit object /// let attrs1 = iter.next(); // the difficulty of the map after the first hit object
/// let attrs2 = iter.next(); // after the second hit object /// let attrs2 = iter.next(); // after the second hit object
@@ -48,7 +48,7 @@ use super::{
/// } /// }
/// ``` /// ```
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct CatchGradualDifficultyAttributes<'map> { pub struct CatchGradualDifficulty<'map> {
pub(crate) idx: usize, pub(crate) idx: usize,
clock_rate: f64, clock_rate: f64,
hit_objects: CatchObjectIter<'map>, hit_objects: CatchObjectIter<'map>,
@@ -61,7 +61,7 @@ pub struct CatchGradualDifficultyAttributes<'map> {
strain_peak_buf: Vec<f64>, strain_peak_buf: Vec<f64>,
} }
impl<'map> CatchGradualDifficultyAttributes<'map> { impl<'map> CatchGradualDifficulty<'map> {
/// Create a new difficulty attributes iterator for osu!catch maps. /// Create a new difficulty attributes iterator for osu!catch maps.
pub fn new(map: &'map Beatmap, mods: u32) -> Self { pub fn new(map: &'map Beatmap, mods: u32) -> Self {
let map_attributes = map.attributes().mods(mods).build(); let map_attributes = map.attributes().mods(mods).build();
@@ -105,7 +105,7 @@ impl<'map> CatchGradualDifficultyAttributes<'map> {
} }
} }
impl Iterator for CatchGradualDifficultyAttributes<'_> { impl Iterator for CatchGradualDifficulty<'_> {
type Item = CatchDifficultyAttributes; type Item = CatchDifficultyAttributes;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
+8 -8
View File
@@ -1,6 +1,6 @@
use crate::{Beatmap, CatchPP}; use crate::{Beatmap, CatchPP};
use super::{CatchGradualDifficultyAttributes, CatchPerformanceAttributes, CatchScoreState}; use super::{CatchGradualDifficulty, CatchPerformanceAttributes, CatchScoreState};
/// Gradually calculate the performance attributes of an osu!catch map. /// Gradually calculate the performance attributes of an osu!catch map.
/// ///
@@ -17,12 +17,12 @@ use super::{CatchGradualDifficultyAttributes, CatchPerformanceAttributes, CatchS
/// to be processed. Only fruits and droplets do. /// to be processed. Only fruits and droplets do.
/// ///
/// If you only want to calculate difficulty attributes use /// If you only want to calculate difficulty attributes use
/// [`CatchGradualDifficultyAttributes`](crate::catch::CatchGradualDifficultyAttributes) instead. /// [`CatchGradualDifficultyAttributes`](crate::catch::CatchGradualDifficulty) instead.
/// ///
/// # Example /// # Example
/// ///
/// ``` /// ```
/// use rosu_pp::{Beatmap, catch::{CatchGradualPerformanceAttributes, CatchScoreState}}; /// use rosu_pp::{Beatmap, catch::{CatchGradualPerformance, CatchScoreState}};
/// ///
/// # /* /// # /*
/// let map: Beatmap = ... /// let map: Beatmap = ...
@@ -30,7 +30,7 @@ use super::{CatchGradualDifficultyAttributes, CatchPerformanceAttributes, CatchS
/// # let map = Beatmap::default(); /// # let map = Beatmap::default();
/// ///
/// let mods = 64; // DT /// let mods = 64; // DT
/// let mut gradual_perf = CatchGradualPerformanceAttributes::new(&map, mods); /// let mut gradual_perf = CatchGradualPerformance::new(&map, mods);
/// let mut state = CatchScoreState::new(); // empty state, everything is on 0. /// let mut state = CatchScoreState::new(); // empty state, everything is on 0.
/// ///
/// // The first 10 hitresults are only fruits /// // The first 10 hitresults are only fruits
@@ -96,15 +96,15 @@ use super::{CatchGradualDifficultyAttributes, CatchPerformanceAttributes, CatchS
/// assert!(gradual_perf.next(state).is_none()); /// assert!(gradual_perf.next(state).is_none());
/// ``` /// ```
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct CatchGradualPerformanceAttributes<'map> { pub struct CatchGradualPerformance<'map> {
difficulty: CatchGradualDifficultyAttributes<'map>, difficulty: CatchGradualDifficulty<'map>,
performance: CatchPP<'map>, performance: CatchPP<'map>,
} }
impl<'map> CatchGradualPerformanceAttributes<'map> { impl<'map> CatchGradualPerformance<'map> {
/// Create a new gradual performance calculator for osu!standard maps. /// Create a new gradual performance calculator for osu!standard maps.
pub fn new(map: &'map Beatmap, mods: u32) -> Self { pub fn new(map: &'map Beatmap, mods: u32) -> Self {
let difficulty = CatchGradualDifficultyAttributes::new(map, mods); let difficulty = CatchGradualDifficulty::new(map, mods);
let performance = CatchPP::new(map).mods(mods).passed_objects(0); let performance = CatchPP::new(map).mods(mods).passed_objects(0);
Self { Self {
+2 -3
View File
@@ -17,8 +17,7 @@ pub use self::{catch_object::CatchObject, pp::*, score_state::CatchScoreState};
#[cfg(feature = "gradual")] #[cfg(feature = "gradual")]
pub use self::{ pub use self::{
gradual_difficulty::CatchGradualDifficultyAttributes, gradual_difficulty::CatchGradualDifficulty, gradual_performance::CatchGradualPerformance,
gradual_performance::CatchGradualPerformanceAttributes,
}; };
pub(crate) use self::fruit_or_juice::{FruitOrJuice, FruitParams}; pub(crate) use self::fruit_or_juice::{FruitOrJuice, FruitParams};
@@ -83,7 +82,7 @@ impl<'map> CatchStars<'map> {
/// ///
/// If you want to calculate the difficulty after every few objects, instead of /// If you want to calculate the difficulty after every few objects, instead of
/// using [`CatchStars`] multiple times with different `passed_objects`, you should use /// using [`CatchStars`] multiple times with different `passed_objects`, you should use
/// [`CatchGradualDifficultyAttributes`](crate::catch::CatchGradualDifficultyAttributes). /// [`CatchGradualDifficultyAttributes`](crate::catch::CatchGradualDifficulty).
#[inline] #[inline]
pub fn passed_objects(mut self, passed_objects: usize) -> Self { pub fn passed_objects(mut self, passed_objects: usize) -> Self {
self.passed_objects = Some(passed_objects); self.passed_objects = Some(passed_objects);
+1 -1
View File
@@ -141,7 +141,7 @@ impl<'map> CatchPP<'map> {
/// ///
/// If you want to calculate the performance after every few objects, instead of /// If you want to calculate the performance after every few objects, instead of
/// using [`CatchPP`] multiple times with different `passed_objects`, you should use /// using [`CatchPP`] multiple times with different `passed_objects`, you should use
/// [`CatchGradualPerformanceAttributes`](crate::catch::CatchGradualPerformanceAttributes). /// [`CatchGradualPerformanceAttributes`](crate::catch::CatchGradualPerformance).
#[inline] #[inline]
pub fn passed_objects(mut self, passed_objects: usize) -> Self { pub fn passed_objects(mut self, passed_objects: usize) -> Self {
self.passed_objects.replace(passed_objects); self.passed_objects.replace(passed_objects);
+45 -45
View File
@@ -1,10 +1,10 @@
#![cfg(feature = "gradual")] #![cfg(feature = "gradual")]
use crate::{ use crate::{
catch::{CatchGradualDifficultyAttributes, CatchGradualPerformanceAttributes}, catch::{CatchGradualDifficulty, CatchGradualPerformance},
mania::{ManiaGradualDifficultyAttributes, ManiaGradualPerformanceAttributes}, mania::{ManiaGradualDifficulty, ManiaGradualPerformance},
osu::{OsuGradualDifficultyAttributes, OsuGradualPerformanceAttributes}, osu::{OsuGradualDifficulty, OsuGradualPerformance},
taiko::{TaikoGradualDifficultyAttributes, TaikoGradualPerformanceAttributes}, taiko::{TaikoGradualDifficulty, TaikoGradualPerformance},
Beatmap, DifficultyAttributes, GameMode, PerformanceAttributes, ScoreState, Beatmap, DifficultyAttributes, GameMode, PerformanceAttributes, ScoreState,
}; };
@@ -14,12 +14,12 @@ use crate::{
/// On every call of [`Iterator::next`](Iterator::next), the map's next hit object will /// On every call of [`Iterator::next`](Iterator::next), the map's next hit object will
/// be processed and the [`DifficultyAttributes`] will be updated and returned. /// be processed and the [`DifficultyAttributes`] will be updated and returned.
/// ///
/// If you want to calculate performance attributes, use [`GradualPerformanceAttributes`] instead. /// If you want to calculate performance attributes, use [`GradualPerformance`] instead.
/// ///
/// # Example /// # Example
/// ///
/// ```no_run /// ```no_run
/// use rosu_pp::{Beatmap, GradualDifficultyAttributes}; /// use rosu_pp::{Beatmap, GradualDifficulty};
/// ///
/// # /* /// # /*
/// let map: Beatmap = ... /// let map: Beatmap = ...
@@ -27,7 +27,7 @@ use crate::{
/// # let map = Beatmap::default(); /// # let map = Beatmap::default();
/// ///
/// let mods = 64; // DT /// let mods = 64; // DT
/// let mut iter = GradualDifficultyAttributes::new(&map, mods); /// let mut iter = GradualDifficulty::new(&map, mods);
/// ///
/// let attrs1 = iter.next(); // the difficulty of the map after the first hit object /// let attrs1 = iter.next(); // the difficulty of the map after the first hit object
/// let attrs2 = iter.next(); // after the second hit object /// let attrs2 = iter.next(); // after the second hit object
@@ -38,51 +38,51 @@ use crate::{
/// } /// }
/// ``` /// ```
#[derive(Debug)] #[derive(Debug)]
pub enum GradualDifficultyAttributes<'map> { pub enum GradualDifficulty<'map> {
/// Gradual osu!standard difficulty attributes. /// Gradual osu!standard difficulty attributes.
Osu(OsuGradualDifficultyAttributes), Osu(OsuGradualDifficulty),
/// Gradual osu!taiko difficulty attributes. /// Gradual osu!taiko difficulty attributes.
Taiko(TaikoGradualDifficultyAttributes), Taiko(TaikoGradualDifficulty),
/// Gradual osu!catch difficulty attributes. /// Gradual osu!catch difficulty attributes.
Catch(CatchGradualDifficultyAttributes<'map>), Catch(CatchGradualDifficulty<'map>),
/// Gradual osu!mania difficulty attributes. /// Gradual osu!mania difficulty attributes.
Mania(ManiaGradualDifficultyAttributes<'map>), Mania(ManiaGradualDifficulty<'map>),
} }
impl<'map> GradualDifficultyAttributes<'map> { impl<'map> GradualDifficulty<'map> {
// FIXME: converted catch maps will always count as osu!std since their mode is not modified // FIXME: converted catch maps will always count as osu!std since their mode is not modified
/// Create a new gradual difficulty calculator for maps of any mode. /// Create a new gradual difficulty calculator for maps of any mode.
#[inline] #[inline]
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::Osu => Self::Osu(OsuGradualDifficultyAttributes::new(map, mods)), GameMode::Osu => Self::Osu(OsuGradualDifficulty::new(map, mods)),
GameMode::Taiko => Self::Taiko(TaikoGradualDifficultyAttributes::new(map, mods)), GameMode::Taiko => Self::Taiko(TaikoGradualDifficulty::new(map, mods)),
GameMode::Catch => Self::Catch(CatchGradualDifficultyAttributes::new(map, mods)), GameMode::Catch => Self::Catch(CatchGradualDifficulty::new(map, mods)),
GameMode::Mania => Self::Mania(ManiaGradualDifficultyAttributes::new(map, mods)), GameMode::Mania => Self::Mania(ManiaGradualDifficulty::new(map, mods)),
} }
} }
} }
impl Iterator for GradualDifficultyAttributes<'_> { impl Iterator for GradualDifficulty<'_> {
type Item = DifficultyAttributes; type Item = DifficultyAttributes;
#[inline] #[inline]
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
match self { match self {
GradualDifficultyAttributes::Osu(o) => o.next().map(DifficultyAttributes::Osu), GradualDifficulty::Osu(o) => o.next().map(DifficultyAttributes::Osu),
GradualDifficultyAttributes::Taiko(t) => t.next().map(DifficultyAttributes::Taiko), GradualDifficulty::Taiko(t) => t.next().map(DifficultyAttributes::Taiko),
GradualDifficultyAttributes::Catch(f) => f.next().map(DifficultyAttributes::Catch), GradualDifficulty::Catch(f) => f.next().map(DifficultyAttributes::Catch),
GradualDifficultyAttributes::Mania(m) => m.next().map(DifficultyAttributes::Mania), GradualDifficulty::Mania(m) => m.next().map(DifficultyAttributes::Mania),
} }
} }
#[inline] #[inline]
fn size_hint(&self) -> (usize, Option<usize>) { fn size_hint(&self) -> (usize, Option<usize>) {
match self { match self {
GradualDifficultyAttributes::Osu(o) => o.size_hint(), GradualDifficulty::Osu(o) => o.size_hint(),
GradualDifficultyAttributes::Taiko(t) => t.size_hint(), GradualDifficulty::Taiko(t) => t.size_hint(),
GradualDifficultyAttributes::Catch(f) => f.size_hint(), GradualDifficulty::Catch(f) => f.size_hint(),
GradualDifficultyAttributes::Mania(m) => m.size_hint(), GradualDifficulty::Mania(m) => m.size_hint(),
} }
} }
} }
@@ -101,15 +101,15 @@ impl Iterator for GradualDifficultyAttributes<'_> {
/// ///
/// Alternatively, you can match on the map's mode yourself and use the gradual /// Alternatively, you can match on the map's mode yourself and use the gradual
/// performance attribute struct for the corresponding mode, i.e. /// performance attribute struct for the corresponding mode, i.e.
/// [`OsuGradualPerformanceAttributes`], [`TaikoGradualPerformanceAttributes`], /// [`OsuGradualPerformance`], [`TaikoGradualPerformance`],
/// [`CatchGradualPerformanceAttributes`], or [`ManiaGradualPerformanceAttributes`]. /// [`CatchGradualPerformance`], or [`ManiaGradualPerformance`].
/// ///
/// If you only want to calculate difficulty attributes use [`GradualDifficultyAttributes`] instead. /// If you only want to calculate difficulty attributes use [`GradualDifficulty`] instead.
/// ///
/// # Example /// # Example
/// ///
/// ```no_run /// ```no_run
/// use rosu_pp::{Beatmap, GradualPerformanceAttributes, ScoreState}; /// use rosu_pp::{Beatmap, GradualPerformance, ScoreState};
/// ///
/// # /* /// # /*
/// let map: Beatmap = ... /// let map: Beatmap = ...
@@ -117,7 +117,7 @@ impl Iterator for GradualDifficultyAttributes<'_> {
/// # let map = Beatmap::default(); /// # let map = Beatmap::default();
/// ///
/// let mods = 64; // DT /// let mods = 64; // DT
/// let mut gradual_perf = GradualPerformanceAttributes::new(&map, mods); /// let mut gradual_perf = GradualPerformance::new(&map, mods);
/// let mut state = ScoreState::new(); // empty state, everything is on 0. /// let mut state = ScoreState::new(); // empty state, everything is on 0.
/// ///
/// // The first 10 hitresults are 300s /// // The first 10 hitresults are 300s
@@ -169,27 +169,27 @@ impl Iterator for GradualDifficultyAttributes<'_> {
/// ``` /// ```
#[derive(Debug)] #[derive(Debug)]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum GradualPerformanceAttributes<'map> { pub enum GradualPerformance<'map> {
/// Gradual osu!standard performance attributes. /// Gradual osu!standard performance attributes.
Osu(OsuGradualPerformanceAttributes<'map>), Osu(OsuGradualPerformance<'map>),
/// Gradual osu!taiko performance attributes. /// Gradual osu!taiko performance attributes.
Taiko(TaikoGradualPerformanceAttributes<'map>), Taiko(TaikoGradualPerformance<'map>),
/// Gradual osu!catch performance attributes. /// Gradual osu!catch performance attributes.
Catch(CatchGradualPerformanceAttributes<'map>), Catch(CatchGradualPerformance<'map>),
/// Gradual osu!mania performance attributes. /// Gradual osu!mania performance attributes.
Mania(ManiaGradualPerformanceAttributes<'map>), Mania(ManiaGradualPerformance<'map>),
} }
impl<'map> GradualPerformanceAttributes<'map> { impl<'map> GradualPerformance<'map> {
// FIXME: converted catch maps will always count as osu!std since their mode is not modified // FIXME: converted catch maps will always count as osu!std since their mode is not modified
/// Create a new gradual performance calculator for maps of any mode. /// Create a new gradual performance calculator for maps of any mode.
#[inline] #[inline]
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::Osu => Self::Osu(OsuGradualPerformanceAttributes::new(map, mods)), GameMode::Osu => Self::Osu(OsuGradualPerformance::new(map, mods)),
GameMode::Taiko => Self::Taiko(TaikoGradualPerformanceAttributes::new(map, mods)), GameMode::Taiko => Self::Taiko(TaikoGradualPerformance::new(map, mods)),
GameMode::Catch => Self::Catch(CatchGradualPerformanceAttributes::new(map, mods)), GameMode::Catch => Self::Catch(CatchGradualPerformance::new(map, mods)),
GameMode::Mania => Self::Mania(ManiaGradualPerformanceAttributes::new(map, mods)), GameMode::Mania => Self::Mania(ManiaGradualPerformance::new(map, mods)),
} }
} }
@@ -213,10 +213,10 @@ impl<'map> GradualPerformanceAttributes<'map> {
#[inline] #[inline]
pub fn nth(&mut self, state: ScoreState, n: usize) -> Option<PerformanceAttributes> { pub fn nth(&mut self, state: ScoreState, n: usize) -> Option<PerformanceAttributes> {
match self { match self {
GradualPerformanceAttributes::Osu(o) => o.nth(state.into(), n).map(From::from), GradualPerformance::Osu(o) => o.nth(state.into(), n).map(From::from),
GradualPerformanceAttributes::Taiko(t) => t.nth(state.into(), n).map(From::from), GradualPerformance::Taiko(t) => t.nth(state.into(), n).map(From::from),
GradualPerformanceAttributes::Catch(f) => f.nth(state.into(), n).map(From::from), GradualPerformance::Catch(f) => f.nth(state.into(), n).map(From::from),
GradualPerformanceAttributes::Mania(m) => m.nth(state.into(), n).map(From::from), GradualPerformance::Mania(m) => m.nth(state.into(), n).map(From::from),
} }
} }
} }
+4 -4
View File
@@ -79,11 +79,11 @@
//! 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 [`GradualDifficulty`] and [`GradualPerformance`]:
//! //!
//! ```no_run //! ```no_run
//! use rosu_pp::{ //! use rosu_pp::{
//! Beatmap, BeatmapExt, GradualPerformanceAttributes, ScoreState, //! Beatmap, BeatmapExt, GradualPerformance, ScoreState,
//! taiko::TaikoScoreState, //! taiko::TaikoScoreState,
//! }; //! };
//! //!
@@ -138,7 +138,7 @@
//! // Instead of starting off with `BeatmapExt::gradual_performance` one could have //! // Instead of starting off with `BeatmapExt::gradual_performance` one could have
//! // created the struct via `TaikoGradualPerformanceAttributes::new`. //! // created the struct via `TaikoGradualPerformanceAttributes::new`.
//! let mut gradual_performance = match gradual_performance { //! let mut gradual_performance = match gradual_performance {
//! GradualPerformanceAttributes::Taiko(gradual) => gradual, //! GradualPerformance::Taiko(gradual) => gradual,
//! _ => panic!("the map was not taiko but {:?}", map.mode), //! _ => panic!("the map was not taiko but {:?}", map.mode),
//! }; //! };
//! //!
@@ -201,7 +201,7 @@ pub use beatmap::{Beatmap, BeatmapExt, GameMode};
#[cfg(feature = "gradual")] #[cfg(feature = "gradual")]
mod gradual; mod gradual;
#[cfg(feature = "gradual")] #[cfg(feature = "gradual")]
pub use gradual::{GradualDifficultyAttributes, GradualPerformanceAttributes}; pub use gradual::{GradualDifficulty, GradualPerformance};
mod pp; mod pp;
pub use pp::{AnyPP, AttributeProvider, HitResultPriority}; pub use pp::{AnyPP, AttributeProvider, HitResultPriority};
+7 -7
View File
@@ -23,12 +23,12 @@ use super::{
/// be processed and the [`ManiaDifficultyAttributes`] will be updated and returned. /// be processed and the [`ManiaDifficultyAttributes`] will be updated and returned.
/// ///
/// If you want to calculate performance attributes, use /// If you want to calculate performance attributes, use
/// [`ManiaGradualPerformanceAttributes`](crate::mania::ManiaGradualPerformanceAttributes) instead. /// [`ManiaGradualPerformanceAttributes`](crate::mania::ManiaGradualPerformance) instead.
/// ///
/// # Example /// # Example
/// ///
/// ``` /// ```
/// use rosu_pp::{Beatmap, mania::ManiaGradualDifficultyAttributes}; /// use rosu_pp::{Beatmap, mania::ManiaGradualDifficulty};
/// ///
/// # /* /// # /*
/// let map: Beatmap = ... /// let map: Beatmap = ...
@@ -36,7 +36,7 @@ use super::{
/// # let map = Beatmap::default(); /// # let map = Beatmap::default();
/// ///
/// let mods = 64; // DT /// let mods = 64; // DT
/// let mut iter = ManiaGradualDifficultyAttributes::new(&map, mods); /// let mut iter = ManiaGradualDifficulty::new(&map, mods);
/// ///
/// let attrs1 = iter.next(); // the difficulty of the map after the first hit object /// let attrs1 = iter.next(); // the difficulty of the map after the first hit object
/// let attrs2 = iter.next(); // after the second hit object /// let attrs2 = iter.next(); // after the second hit object
@@ -47,7 +47,7 @@ use super::{
/// } /// }
/// ``` /// ```
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ManiaGradualDifficultyAttributes<'map> { pub struct ManiaGradualDifficulty<'map> {
pub(crate) idx: usize, pub(crate) idx: usize,
map: Cow<'map, Beatmap>, map: Cow<'map, Beatmap>,
hit_window: f64, hit_window: f64,
@@ -57,7 +57,7 @@ pub struct ManiaGradualDifficultyAttributes<'map> {
clock_rate: f64, clock_rate: f64,
} }
impl<'map> ManiaGradualDifficultyAttributes<'map> { impl<'map> ManiaGradualDifficulty<'map> {
/// Create a new difficulty attributes iterator for osu!mania maps. /// Create a new difficulty attributes iterator for osu!mania maps.
pub fn new(map: &'map Beatmap, mods: u32) -> Self { pub fn new(map: &'map Beatmap, mods: u32) -> Self {
let map = map.convert_mode(GameMode::Mania); let map = map.convert_mode(GameMode::Mania);
@@ -148,7 +148,7 @@ impl<'map> ManiaGradualDifficultyAttributes<'map> {
} }
} }
impl Iterator for ManiaGradualDifficultyAttributes<'_> { impl Iterator for ManiaGradualDifficulty<'_> {
type Item = ManiaDifficultyAttributes; type Item = ManiaDifficultyAttributes;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
@@ -206,7 +206,7 @@ impl Iterator for ManiaGradualDifficultyAttributes<'_> {
} }
} }
impl ExactSizeIterator for ManiaGradualDifficultyAttributes<'_> { impl ExactSizeIterator for ManiaGradualDifficulty<'_> {
#[inline] #[inline]
fn len(&self) -> usize { fn len(&self) -> usize {
self.diff_objects.len() + 1 - self.idx self.diff_objects.len() + 1 - self.idx
+8 -8
View File
@@ -2,7 +2,7 @@
use crate::{Beatmap, ManiaPP}; use crate::{Beatmap, ManiaPP};
use super::{ManiaGradualDifficultyAttributes, ManiaPerformanceAttributes, ManiaScoreState}; use super::{ManiaGradualDifficulty, ManiaPerformanceAttributes, ManiaScoreState};
/// Gradually calculate the performance attributes of an osu!mania map. /// Gradually calculate the performance attributes of an osu!mania map.
/// ///
@@ -15,12 +15,12 @@ use super::{ManiaGradualDifficultyAttributes, ManiaPerformanceAttributes, ManiaS
/// Be sure the given score is adjusted with respect to mods. /// Be sure the given score is adjusted with respect to mods.
/// ///
/// If you only want to calculate difficulty attributes use /// If you only want to calculate difficulty attributes use
/// [`ManiaGradualDifficultyAttributes`] instead. /// [`ManiaGradualDifficulty`] instead.
/// ///
/// # Example /// # Example
/// ///
/// ``` /// ```
/// use rosu_pp::{Beatmap, mania::{ManiaGradualPerformanceAttributes, ManiaScoreState}}; /// use rosu_pp::{Beatmap, mania::{ManiaGradualPerformance, ManiaScoreState}};
/// ///
/// # /* /// # /*
/// let map: Beatmap = ... /// let map: Beatmap = ...
@@ -28,7 +28,7 @@ use super::{ManiaGradualDifficultyAttributes, ManiaPerformanceAttributes, ManiaS
/// # let map = Beatmap::default(); /// # let map = Beatmap::default();
/// ///
/// let mods = 64; // DT /// let mods = 64; // DT
/// let mut gradual_perf = ManiaGradualPerformanceAttributes::new(&map, mods); /// let mut gradual_perf = ManiaGradualPerformance::new(&map, mods);
/// let mut state = ManiaScoreState::new(); // empty state, everything is on 0. /// let mut state = ManiaScoreState::new(); // empty state, everything is on 0.
/// ///
/// // The first 10 hitresults are 320s /// // The first 10 hitresults are 320s
@@ -77,15 +77,15 @@ use super::{ManiaGradualDifficultyAttributes, ManiaPerformanceAttributes, ManiaS
/// assert!(gradual_perf.next(state).is_none()); /// assert!(gradual_perf.next(state).is_none());
/// ``` /// ```
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ManiaGradualPerformanceAttributes<'map> { pub struct ManiaGradualPerformance<'map> {
difficulty: ManiaGradualDifficultyAttributes<'map>, difficulty: ManiaGradualDifficulty<'map>,
performance: ManiaPP<'map>, performance: ManiaPP<'map>,
} }
impl<'map> ManiaGradualPerformanceAttributes<'map> { impl<'map> ManiaGradualPerformance<'map> {
/// Create a new gradual performance calculator for osu!mania maps. /// Create a new gradual performance calculator for osu!mania maps.
pub fn new(map: &'map Beatmap, mods: u32) -> Self { pub fn new(map: &'map Beatmap, mods: u32) -> Self {
let difficulty = ManiaGradualDifficultyAttributes::new(map, mods); let difficulty = ManiaGradualDifficulty::new(map, mods);
let performance = ManiaPP::new(map).mods(mods).passed_objects(0); let performance = ManiaPP::new(map).mods(mods).passed_objects(0);
Self { Self {
+2 -3
View File
@@ -17,8 +17,7 @@ pub use self::{mania_object::ManiaObject, pp::*, score_state::ManiaScoreState};
#[cfg(feature = "gradual")] #[cfg(feature = "gradual")]
pub use self::{ pub use self::{
gradual_difficulty::ManiaGradualDifficultyAttributes, gradual_difficulty::ManiaGradualDifficulty, gradual_performance::ManiaGradualPerformance,
gradual_performance::ManiaGradualPerformanceAttributes,
}; };
pub(crate) use self::mania_object::ObjectParameters; pub(crate) use self::mania_object::ObjectParameters;
@@ -88,7 +87,7 @@ impl<'map> ManiaStars<'map> {
/// ///
/// If you want to calculate the difficulty after every few objects, instead of /// If you want to calculate the difficulty after every few objects, instead of
/// using [`ManiaStars`] multiple times with different `passed_objects`, you should use /// using [`ManiaStars`] multiple times with different `passed_objects`, you should use
/// [`ManiaGradualDifficultyAttributes`](crate::mania::ManiaGradualDifficultyAttributes). /// [`ManiaGradualDifficultyAttributes`](crate::mania::ManiaGradualDifficulty).
#[inline] #[inline]
pub fn passed_objects(mut self, passed_objects: usize) -> Self { pub fn passed_objects(mut self, passed_objects: usize) -> Self {
self.passed_objects = Some(passed_objects); self.passed_objects = Some(passed_objects);
+1 -1
View File
@@ -109,7 +109,7 @@ impl<'map> ManiaPP<'map> {
/// ///
/// If you want to calculate the performance after every few objects, instead of /// If you want to calculate the performance after every few objects, instead of
/// using [`ManiaPP`] multiple times with different `passed_objects`, you should use /// using [`ManiaPP`] multiple times with different `passed_objects`, you should use
/// [`ManiaGradualPerformanceAttributes`](crate::mania::ManiaGradualPerformanceAttributes). /// [`ManiaGradualPerformanceAttributes`](crate::mania::ManiaGradualPerformance).
#[inline] #[inline]
pub fn passed_objects(mut self, passed_objects: usize) -> Self { pub fn passed_objects(mut self, passed_objects: usize) -> Self {
self.passed_objects = Some(passed_objects); self.passed_objects = Some(passed_objects);
+1 -1
View File
@@ -1,6 +1,6 @@
/// Aggregation for a score's current state i.e. what are the current hitresults. /// Aggregation for a score's current state i.e. what are the current hitresults.
/// ///
/// This struct is used for [`ManiaGradualPerformanceAttributes`](crate::mania::ManiaGradualPerformanceAttributes). /// This struct is used for [`ManiaGradualPerformanceAttributes`](crate::mania::ManiaGradualPerformance).
#[derive(Clone, Debug, Default, Eq, PartialEq)] #[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct ManiaScoreState { pub struct ManiaScoreState {
/// Amount of current 320s. /// Amount of current 320s.
+8 -8
View File
@@ -26,12 +26,12 @@ use super::{
/// be processed and the [`OsuDifficultyAttributes`] will be updated and returned. /// be processed and the [`OsuDifficultyAttributes`] will be updated and returned.
/// ///
/// If you want to calculate performance attributes, use /// If you want to calculate performance attributes, use
/// [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualPerformanceAttributes) instead. /// [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualPerformance) instead.
/// ///
/// # Example /// # Example
/// ///
/// ``` /// ```
/// use rosu_pp::{Beatmap, osu::OsuGradualDifficultyAttributes}; /// use rosu_pp::{Beatmap, osu::OsuGradualDifficulty};
/// ///
/// # /* /// # /*
/// let map: Beatmap = ... /// let map: Beatmap = ...
@@ -39,7 +39,7 @@ use super::{
/// # let map = Beatmap::default(); /// # let map = Beatmap::default();
/// ///
/// let mods = 64; // DT /// let mods = 64; // DT
/// let mut iter = OsuGradualDifficultyAttributes::new(&map, mods); /// let mut iter = OsuGradualDifficulty::new(&map, mods);
/// ///
/// let attrs1 = iter.next(); // the difficulty of the map after the first hit object /// let attrs1 = iter.next(); // the difficulty of the map after the first hit object
/// let attrs2 = iter.next(); // after the second hit object /// let attrs2 = iter.next(); // after the second hit object
@@ -49,7 +49,7 @@ use super::{
/// // ... /// // ...
/// } /// }
/// ``` /// ```
pub struct OsuGradualDifficultyAttributes { pub struct OsuGradualDifficulty {
pub(crate) idx: usize, pub(crate) idx: usize,
mods: u32, mods: u32,
attrs: OsuDifficultyAttributes, attrs: OsuDifficultyAttributes,
@@ -61,7 +61,7 @@ pub struct OsuGradualDifficultyAttributes {
skills: Skills, skills: Skills,
} }
impl Debug for OsuGradualDifficultyAttributes { impl Debug for OsuGradualDifficulty {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
f.debug_struct("OsuGradualDifficultyAttributes") f.debug_struct("OsuGradualDifficultyAttributes")
.field("idx", &self.idx) .field("idx", &self.idx)
@@ -72,7 +72,7 @@ impl Debug for OsuGradualDifficultyAttributes {
} }
} }
impl OsuGradualDifficultyAttributes { impl OsuGradualDifficulty {
/// Create a new difficulty attributes iterator for osu!standard maps. /// Create a new difficulty attributes iterator for osu!standard maps.
pub fn new(map: &Beatmap, mods: u32) -> Self { pub fn new(map: &Beatmap, mods: u32) -> Self {
let clock_rate = mods.clock_rate(); let clock_rate = mods.clock_rate();
@@ -216,7 +216,7 @@ fn extend_lifetime(
unsafe { mem::transmute(diff_objects) } unsafe { mem::transmute(diff_objects) }
} }
impl Iterator for OsuGradualDifficultyAttributes { impl Iterator for OsuGradualDifficulty {
type Item = OsuDifficultyAttributes; type Item = OsuDifficultyAttributes;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
@@ -330,7 +330,7 @@ impl Iterator for OsuGradualDifficultyAttributes {
} }
} }
impl ExactSizeIterator for OsuGradualDifficultyAttributes { impl ExactSizeIterator for OsuGradualDifficulty {
#[inline] #[inline]
fn len(&self) -> usize { fn len(&self) -> usize {
self.diff_objects.len() + 1 - self.idx self.diff_objects.len() + 1 - self.idx
+8 -8
View File
@@ -2,7 +2,7 @@
use crate::{Beatmap, OsuPP}; use crate::{Beatmap, OsuPP};
use super::{OsuGradualDifficultyAttributes, OsuPerformanceAttributes, OsuScoreState}; use super::{OsuGradualDifficulty, OsuPerformanceAttributes, OsuScoreState};
/// Gradually calculate the performance attributes of an osu!standard map. /// Gradually calculate the performance attributes of an osu!standard map.
/// ///
@@ -15,12 +15,12 @@ use super::{OsuGradualDifficultyAttributes, OsuPerformanceAttributes, OsuScoreSt
/// hitresults as well as the maximum combo so far. /// hitresults as well as the maximum combo so far.
/// ///
/// If you only want to calculate difficulty attributes use /// If you only want to calculate difficulty attributes use
/// [`OsuGradualDifficultyAttributes`] instead. /// [`OsuGradualDifficulty`] instead.
/// ///
/// # Example /// # Example
/// ///
/// ``` /// ```
/// use rosu_pp::{Beatmap, osu::{OsuGradualPerformanceAttributes, OsuScoreState}}; /// use rosu_pp::{Beatmap, osu::{OsuGradualPerformance, OsuScoreState}};
/// ///
/// # /* /// # /*
/// let map: Beatmap = ... /// let map: Beatmap = ...
@@ -28,7 +28,7 @@ use super::{OsuGradualDifficultyAttributes, OsuPerformanceAttributes, OsuScoreSt
/// # let map = Beatmap::default(); /// # let map = Beatmap::default();
/// ///
/// let mods = 64; // DT /// let mods = 64; // DT
/// let mut gradual_perf = OsuGradualPerformanceAttributes::new(&map, mods); /// let mut gradual_perf = OsuGradualPerformance::new(&map, mods);
/// let mut state = OsuScoreState::new(); // empty state, everything is on 0. /// let mut state = OsuScoreState::new(); // empty state, everything is on 0.
/// ///
/// // The first 10 hitresults are 300s and there are no sliders for additional combo /// // The first 10 hitresults are 300s and there are no sliders for additional combo
@@ -91,15 +91,15 @@ use super::{OsuGradualDifficultyAttributes, OsuPerformanceAttributes, OsuScoreSt
/// assert!(gradual_perf.next(state).is_none()); /// assert!(gradual_perf.next(state).is_none());
/// ``` /// ```
#[derive(Debug)] #[derive(Debug)]
pub struct OsuGradualPerformanceAttributes<'map> { pub struct OsuGradualPerformance<'map> {
difficulty: OsuGradualDifficultyAttributes, difficulty: OsuGradualDifficulty,
performance: OsuPP<'map>, performance: OsuPP<'map>,
} }
impl<'map> OsuGradualPerformanceAttributes<'map> { impl<'map> OsuGradualPerformance<'map> {
/// Create a new gradual performance calculator for osu!standard maps. /// Create a new gradual performance calculator for osu!standard maps.
pub fn new(map: &'map Beatmap, mods: u32) -> Self { pub fn new(map: &'map Beatmap, mods: u32) -> Self {
let difficulty = OsuGradualDifficultyAttributes::new(map, mods); let difficulty = OsuGradualDifficulty::new(map, mods);
let performance = OsuPP::new(map).mods(mods).passed_objects(0); let performance = OsuPP::new(map).mods(mods).passed_objects(0);
Self { Self {
+3 -5
View File
@@ -22,8 +22,7 @@ pub use self::{osu_object::*, pp::*, score_state::OsuScoreState};
#[cfg(feature = "gradual")] #[cfg(feature = "gradual")]
pub use self::{ pub use self::{
gradual_difficulty::OsuGradualDifficultyAttributes, gradual_difficulty::OsuGradualDifficulty, gradual_performance::OsuGradualPerformance,
gradual_performance::OsuGradualPerformanceAttributes,
}; };
pub(crate) use self::scaling_factor::ScalingFactor; pub(crate) use self::scaling_factor::ScalingFactor;
@@ -102,7 +101,7 @@ impl<'map> OsuStars<'map> {
/// ///
/// If you want to calculate the difficulty after every few objects, instead of /// If you want to calculate the difficulty after every few objects, instead of
/// using [`OsuStars`] multiple times with different `passed_objects`, you should use /// using [`OsuStars`] multiple times with different `passed_objects`, you should use
/// [`OsuGradualDifficultyAttributes`]. /// [`OsuGradualDifficulty`].
#[inline] #[inline]
pub fn passed_objects(mut self, passed_objects: usize) -> Self { pub fn passed_objects(mut self, passed_objects: usize) -> Self {
self.passed_objects = Some(passed_objects); self.passed_objects = Some(passed_objects);
@@ -326,8 +325,7 @@ fn calculate_skills(params: OsuStars<'_>) -> (Skills, OsuDifficultyAttributes) {
let curr = curr.into_ref(); let curr = curr.into_ref();
let diff_obj = let diff_obj = OsuDifficultyObject::new(curr, last.get_ref(), clock_rate, i, dists);
OsuDifficultyObject::new(curr, last.get_ref(), clock_rate, i, dists);
diff_objects.push(diff_obj); diff_objects.push(diff_obj);
last_last = Some(last); last_last = Some(last);
+1 -1
View File
@@ -161,7 +161,7 @@ impl<'map> OsuPP<'map> {
/// ///
/// If you want to calculate the performance after every few objects, instead of /// If you want to calculate the performance after every few objects, instead of
/// using [`OsuPP`] multiple times with different `passed_objects`, you should use /// using [`OsuPP`] multiple times with different `passed_objects`, you should use
/// [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualPerformanceAttributes). /// [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualPerformance).
#[inline] #[inline]
pub fn passed_objects(mut self, passed_objects: usize) -> Self { pub fn passed_objects(mut self, passed_objects: usize) -> Self {
self.passed_objects = Some(passed_objects); self.passed_objects = Some(passed_objects);
+1 -1
View File
@@ -1,7 +1,7 @@
/// Aggregation for a score's current state i.e. what was the /// Aggregation for a score's current state i.e. what was the
/// maximum combo so far and what are the current hitresults. /// maximum combo so far and what are the current hitresults.
/// ///
/// This struct is used for [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualPerformanceAttributes). /// This struct is used for [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualPerformance).
#[derive(Clone, Debug, Default, Eq, PartialEq)] #[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct OsuScoreState { pub struct OsuScoreState {
/// Maximum combo that the score has had so far. /// Maximum combo that the score has had so far.
+1 -1
View File
@@ -116,7 +116,7 @@ impl<'map> AnyPP<'map> {
/// ///
/// If you want to calculate the performance after every few objects, instead of /// If you want to calculate the performance after every few objects, instead of
/// using [`AnyPP`] multiple times with different `passed_objects`, you should use /// using [`AnyPP`] multiple times with different `passed_objects`, you should use
/// [`GradualPerformanceAttributes`](crate::GradualPerformanceAttributes). /// [`GradualPerformanceAttributes`](crate::GradualPerformance).
#[inline] #[inline]
pub fn passed_objects(self, passed_objects: usize) -> Self { pub fn passed_objects(self, passed_objects: usize) -> Self {
match self { match self {
+1 -1
View File
@@ -75,7 +75,7 @@ impl<'map> AnyStars<'map> {
/// ///
/// If you want to calculate the performance after every few objects, instead of /// If you want to calculate the performance after every few objects, instead of
/// using [`AnyStars`] multiple times with different `passed_objects`, you should use /// using [`AnyStars`] multiple times with different `passed_objects`, you should use
/// [`GradualDifficultyAttributes`](crate::GradualDifficultyAttributes). /// [`GradualDifficultyAttributes`](crate::GradualDifficulty).
#[inline] #[inline]
pub fn passed_objects(self, passed_objects: usize) -> Self { pub fn passed_objects(self, passed_objects: usize) -> Self {
match self { match self {
+7 -7
View File
@@ -19,12 +19,12 @@ use super::{
/// be processed and the [`TaikoDifficultyAttributes`] will be updated and returned. /// be processed and the [`TaikoDifficultyAttributes`] will be updated and returned.
/// ///
/// If you want to calculate performance attributes, use /// If you want to calculate performance attributes, use
/// [`TaikoGradualPerformanceAttributes`](crate::taiko::TaikoGradualPerformanceAttributes) instead. /// [`TaikoGradualPerformanceAttributes`](crate::taiko::TaikoGradualPerformance) instead.
/// ///
/// # Example /// # Example
/// ///
/// ``` /// ```
/// use rosu_pp::{Beatmap, taiko::TaikoGradualDifficultyAttributes}; /// use rosu_pp::{Beatmap, taiko::TaikoGradualDifficulty};
/// ///
/// # /* /// # /*
/// let map: Beatmap = ... /// let map: Beatmap = ...
@@ -32,7 +32,7 @@ use super::{
/// # let map = Beatmap::default(); /// # let map = Beatmap::default();
/// ///
/// let mods = 64; // DT /// let mods = 64; // DT
/// let mut iter = TaikoGradualDifficultyAttributes::new(&map, mods); /// let mut iter = TaikoGradualDifficulty::new(&map, mods);
/// ///
/// let attrs1 = iter.next(); // the difficulty of the map after the first hit object /// let attrs1 = iter.next(); // the difficulty of the map after the first hit object
/// let attrs2 = iter.next(); // after the second hit object /// let attrs2 = iter.next(); // after the second hit object
@@ -43,7 +43,7 @@ use super::{
/// } /// }
/// ``` /// ```
#[derive(Debug)] #[derive(Debug)]
pub struct TaikoGradualDifficultyAttributes { pub struct TaikoGradualDifficulty {
pub(crate) idx: usize, pub(crate) idx: usize,
attrs: TaikoDifficultyAttributes, attrs: TaikoDifficultyAttributes,
diff_objects: IntoIter<Rc<RefCell<TaikoDifficultyObject>>>, diff_objects: IntoIter<Rc<RefCell<TaikoDifficultyObject>>>,
@@ -53,7 +53,7 @@ pub struct TaikoGradualDifficultyAttributes {
is_convert: bool, is_convert: bool,
} }
impl TaikoGradualDifficultyAttributes { impl TaikoGradualDifficulty {
/// Create a new difficulty attributes iterator for osu!taiko maps. /// Create a new difficulty attributes iterator for osu!taiko maps.
pub fn new(map: &Beatmap, mods: u32) -> Self { pub fn new(map: &Beatmap, mods: u32) -> Self {
let map = map.convert_mode(GameMode::Taiko); let map = map.convert_mode(GameMode::Taiko);
@@ -139,7 +139,7 @@ impl TaikoGradualDifficultyAttributes {
} }
} }
impl Iterator for TaikoGradualDifficultyAttributes { impl Iterator for TaikoGradualDifficulty {
type Item = TaikoDifficultyAttributes; type Item = TaikoDifficultyAttributes;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
@@ -236,7 +236,7 @@ impl Iterator for TaikoGradualDifficultyAttributes {
} }
} }
impl ExactSizeIterator for TaikoGradualDifficultyAttributes { impl ExactSizeIterator for TaikoGradualDifficulty {
#[inline] #[inline]
fn len(&self) -> usize { fn len(&self) -> usize {
self.total_hits - self.idx self.total_hits - self.idx
+8 -8
View File
@@ -2,7 +2,7 @@
use crate::{taiko::TaikoScoreState, Beatmap, TaikoPP}; use crate::{taiko::TaikoScoreState, Beatmap, TaikoPP};
use super::{TaikoGradualDifficultyAttributes, TaikoPerformanceAttributes}; use super::{TaikoGradualDifficulty, TaikoPerformanceAttributes};
/// Gradually calculate the performance attributes of an osu!taiko map. /// Gradually calculate the performance attributes of an osu!taiko map.
/// ///
@@ -15,12 +15,12 @@ use super::{TaikoGradualDifficultyAttributes, TaikoPerformanceAttributes};
/// hitresults as well as the maximum combo so far. /// hitresults as well as the maximum combo so far.
/// ///
/// If you only want to calculate difficulty attributes use /// If you only want to calculate difficulty attributes use
/// [`TaikoGradualDifficultyAttributes`] instead. /// [`TaikoGradualDifficulty`] instead.
/// ///
/// # Example /// # Example
/// ///
/// ``` /// ```
/// use rosu_pp::{Beatmap, taiko::{TaikoGradualPerformanceAttributes, TaikoScoreState}}; /// use rosu_pp::{Beatmap, taiko::{TaikoGradualPerformance, TaikoScoreState}};
/// ///
/// # /* /// # /*
/// let map: Beatmap = ... /// let map: Beatmap = ...
@@ -28,7 +28,7 @@ use super::{TaikoGradualDifficultyAttributes, TaikoPerformanceAttributes};
/// # let map = Beatmap::default(); /// # let map = Beatmap::default();
/// ///
/// let mods = 64; // DT /// let mods = 64; // DT
/// let mut gradual_perf = TaikoGradualPerformanceAttributes::new(&map, mods); /// let mut gradual_perf = TaikoGradualPerformance::new(&map, mods);
/// let mut state = TaikoScoreState::new(); // empty state, everything is on 0. /// let mut state = TaikoScoreState::new(); // empty state, everything is on 0.
/// ///
/// // The first 10 hitresults are 300s /// // The first 10 hitresults are 300s
@@ -89,15 +89,15 @@ use super::{TaikoGradualDifficultyAttributes, TaikoPerformanceAttributes};
/// assert!(gradual_perf.next(state).is_none()); /// assert!(gradual_perf.next(state).is_none());
/// ``` /// ```
#[derive(Debug)] #[derive(Debug)]
pub struct TaikoGradualPerformanceAttributes<'map> { pub struct TaikoGradualPerformance<'map> {
difficulty: TaikoGradualDifficultyAttributes, difficulty: TaikoGradualDifficulty,
performance: TaikoPP<'map>, performance: TaikoPP<'map>,
} }
impl<'map> TaikoGradualPerformanceAttributes<'map> { impl<'map> TaikoGradualPerformance<'map> {
/// Create a new gradual performance calculator for osu!taiko maps. /// Create a new gradual performance calculator for osu!taiko maps.
pub fn new(map: &'map Beatmap, mods: u32) -> Self { pub fn new(map: &'map Beatmap, mods: u32) -> Self {
let difficulty = TaikoGradualDifficultyAttributes::new(map, mods); let difficulty = TaikoGradualDifficulty::new(map, mods);
let performance = TaikoPP::new(map).mods(mods).passed_objects(0); let performance = TaikoPP::new(map).mods(mods).passed_objects(0);
Self { Self {
+2 -3
View File
@@ -17,8 +17,7 @@ pub use self::{pp::*, score_state::TaikoScoreState, taiko_object::TaikoObjectPub
#[cfg(feature = "gradual")] #[cfg(feature = "gradual")]
pub use self::{ pub use self::{
gradual_difficulty::TaikoGradualDifficultyAttributes, gradual_difficulty::TaikoGradualDifficulty, gradual_performance::TaikoGradualPerformance,
gradual_performance::TaikoGradualPerformanceAttributes,
}; };
pub(crate) use self::taiko_object::IntoTaikoObjectIter; pub(crate) use self::taiko_object::IntoTaikoObjectIter;
@@ -92,7 +91,7 @@ impl<'map> TaikoStars<'map> {
/// ///
/// If you want to calculate the difficulty after every few objects, instead of /// If you want to calculate the difficulty after every few objects, instead of
/// using [`TaikoStars`] multiple times with different `passed_objects`, you should use /// using [`TaikoStars`] multiple times with different `passed_objects`, you should use
/// [`TaikoGradualDifficultyAttributes`](crate::taiko::TaikoGradualDifficultyAttributes). /// [`TaikoGradualDifficultyAttributes`](crate::taiko::TaikoGradualDifficulty).
#[inline] #[inline]
pub fn passed_objects(mut self, passed_objects: usize) -> Self { pub fn passed_objects(mut self, passed_objects: usize) -> Self {
self.passed_objects = Some(passed_objects); self.passed_objects = Some(passed_objects);
+1 -1
View File
@@ -151,7 +151,7 @@ impl<'map> TaikoPP<'map> {
/// ///
/// If you want to calculate the performance after every few objects, instead of /// If you want to calculate the performance after every few objects, instead of
/// using [`TaikoPP`] multiple times with different `passed_objects`, you should use /// using [`TaikoPP`] multiple times with different `passed_objects`, you should use
/// [`TaikoGradualPerformanceAttributes`](crate::taiko::TaikoGradualPerformanceAttributes). /// [`TaikoGradualPerformanceAttributes`](crate::taiko::TaikoGradualPerformance).
#[inline] #[inline]
pub fn passed_objects(mut self, passed_objects: usize) -> Self { pub fn passed_objects(mut self, passed_objects: usize) -> Self {
self.passed_objects = Some(passed_objects); self.passed_objects = Some(passed_objects);
+1 -1
View File
@@ -1,7 +1,7 @@
/// Aggregation for a score's current state i.e. what was the /// Aggregation for a score's current state i.e. what was the
/// maximum combo so far and what are the current hitresults. /// maximum combo so far and what are the current hitresults.
/// ///
/// This struct is used for [`TaikoGradualPerformanceAttributes`](crate::taiko::TaikoGradualPerformanceAttributes). /// This struct is used for [`TaikoGradualPerformanceAttributes`](crate::taiko::TaikoGradualPerformance).
#[derive(Clone, Debug, Default, Eq, PartialEq)] #[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct TaikoScoreState { pub struct TaikoScoreState {
/// Maximum combo that the score has had so far. /// Maximum combo that the score has had so far.
+12 -9
View File
@@ -1,7 +1,10 @@
#![cfg(all(not(any(feature = "async_tokio", feature = "async_std")), feature = "gradual"))] #![cfg(all(
not(any(feature = "async_tokio", feature = "async_std")),
feature = "gradual"
))]
use rosu_pp::{ use rosu_pp::{
catch::{CatchGradualDifficultyAttributes, CatchGradualPerformanceAttributes, CatchScoreState}, catch::{CatchGradualDifficulty, CatchGradualPerformance, CatchScoreState},
Beatmap, CatchPP, CatchStars, Beatmap, CatchPP, CatchStars,
}; };
@@ -12,7 +15,7 @@ mod common;
#[test] #[test]
fn empty_map() { fn empty_map() {
let map = Beatmap::default(); let map = Beatmap::default();
let mut attributes = CatchGradualDifficultyAttributes::new(&map, 0); let mut attributes = CatchGradualDifficulty::new(&map, 0);
assert!(attributes.next().is_none()); assert!(attributes.next().is_none());
} }
@@ -22,7 +25,7 @@ fn iter_end_eq_regular() {
let map = test_map!(Catch); let map = test_map!(Catch);
let regular = CatchStars::new(&map).calculate(); let regular = CatchStars::new(&map).calculate();
let iter_end = CatchGradualDifficultyAttributes::new(&map, 0) let iter_end = CatchGradualDifficulty::new(&map, 0)
.last() .last()
.expect("empty iter"); .expect("empty iter");
@@ -32,7 +35,7 @@ fn iter_end_eq_regular() {
#[test] #[test]
fn correct_empty() { fn correct_empty() {
let map = test_map!(Catch); let map = test_map!(Catch);
let mut gradual = CatchGradualPerformanceAttributes::new(&map, 0); let mut gradual = CatchGradualPerformance::new(&map, 0);
let state = CatchScoreState::default(); let state = CatchScoreState::default();
let first_attrs = gradual.nth(state.clone(), usize::MAX); let first_attrs = gradual.nth(state.clone(), usize::MAX);
@@ -46,8 +49,8 @@ fn next_and_next_n() {
let map = test_map!(Catch); let map = test_map!(Catch);
let state = CatchScoreState::default(); let state = CatchScoreState::default();
let mut gradual1 = CatchGradualPerformanceAttributes::new(&map, 0); let mut gradual1 = CatchGradualPerformance::new(&map, 0);
let mut gradual2 = CatchGradualPerformanceAttributes::new(&map, 0); let mut gradual2 = CatchGradualPerformance::new(&map, 0);
for _ in 0..20 { for _ in 0..20 {
let _ = gradual1.next(state.clone()); let _ = gradual1.next(state.clone());
@@ -80,7 +83,7 @@ fn gradual_end_eq_regular() {
let map = test_map!(Catch); let map = test_map!(Catch);
let regular = CatchPP::new(&map).calculate(); let regular = CatchPP::new(&map).calculate();
let mut gradual = CatchGradualPerformanceAttributes::new(&map, 0); let mut gradual = CatchGradualPerformance::new(&map, 0);
let state = CatchScoreState { let state = CatchScoreState {
max_combo: 730, max_combo: 730,
@@ -102,7 +105,7 @@ fn gradual_eq_regular_passed() {
let n = 100; let n = 100;
let regular = CatchPP::new(&map).passed_objects(n).calculate(); let regular = CatchPP::new(&map).passed_objects(n).calculate();
let mut gradual = CatchGradualPerformanceAttributes::new(&map, 0); let mut gradual = CatchGradualPerformance::new(&map, 0);
let state = CatchScoreState { let state = CatchScoreState {
max_combo: 101, max_combo: 101,
+8 -8
View File
@@ -4,7 +4,7 @@
))] ))]
use rosu_pp::{ use rosu_pp::{
mania::{ManiaGradualDifficultyAttributes, ManiaGradualPerformanceAttributes, ManiaScoreState}, mania::{ManiaGradualDifficulty, ManiaGradualPerformance, ManiaScoreState},
Beatmap, ManiaPP, ManiaStars, Beatmap, ManiaPP, ManiaStars,
}; };
@@ -15,7 +15,7 @@ mod common;
#[test] #[test]
fn empty_map() { fn empty_map() {
let map = Beatmap::default(); let map = Beatmap::default();
let mut attributes = ManiaGradualDifficultyAttributes::new(&map, 0); let mut attributes = ManiaGradualDifficulty::new(&map, 0);
assert!(attributes.next().is_none()); assert!(attributes.next().is_none());
} }
@@ -25,7 +25,7 @@ fn iter_end_eq_regular() {
let map = test_map!(Mania); let map = test_map!(Mania);
let regular = ManiaStars::new(&map).calculate(); let regular = ManiaStars::new(&map).calculate();
let iter_end = ManiaGradualDifficultyAttributes::new(&map, 0) let iter_end = ManiaGradualDifficulty::new(&map, 0)
.last() .last()
.expect("empty iter"); .expect("empty iter");
@@ -35,7 +35,7 @@ fn iter_end_eq_regular() {
#[test] #[test]
fn correct_empty() { fn correct_empty() {
let map = test_map!(Mania); let map = test_map!(Mania);
let mut gradual = ManiaGradualPerformanceAttributes::new(&map, 0); let mut gradual = ManiaGradualPerformance::new(&map, 0);
let state = ManiaScoreState::default(); let state = ManiaScoreState::default();
@@ -51,8 +51,8 @@ fn next_and_next_n() {
let mut state = ManiaScoreState::default(); let mut state = ManiaScoreState::default();
let mut gradual1 = ManiaGradualPerformanceAttributes::new(&map, 0); let mut gradual1 = ManiaGradualPerformance::new(&map, 0);
let mut gradual2 = ManiaGradualPerformanceAttributes::new(&map, 0); let mut gradual2 = ManiaGradualPerformance::new(&map, 0);
for _ in 0..20 { for _ in 0..20 {
let _ = gradual1.next(state.clone()); let _ = gradual1.next(state.clone());
@@ -78,7 +78,7 @@ fn gradual_end_eq_regular() {
let map = test_map!(Mania); let map = test_map!(Mania);
let regular = ManiaPP::new(&map).calculate(); let regular = ManiaPP::new(&map).calculate();
let mut gradual = ManiaGradualPerformanceAttributes::new(&map, 0); let mut gradual = ManiaGradualPerformance::new(&map, 0);
let state = ManiaScoreState { let state = ManiaScoreState {
n320: map.hit_objects.len(), n320: map.hit_objects.len(),
@@ -105,7 +105,7 @@ fn gradual_eq_regular_passed() {
.state(state.clone()) .state(state.clone())
.calculate(); .calculate();
let gradual = ManiaGradualPerformanceAttributes::new(&map, 0) let gradual = ManiaGradualPerformance::new(&map, 0)
.nth(state, n - 1) .nth(state, n - 1)
.unwrap(); .unwrap();
+8 -8
View File
@@ -4,7 +4,7 @@
))] ))]
use rosu_pp::{ use rosu_pp::{
osu::{OsuGradualDifficultyAttributes, OsuGradualPerformanceAttributes, OsuScoreState}, osu::{OsuGradualDifficulty, OsuGradualPerformance, OsuScoreState},
Beatmap, OsuPP, OsuStars, Beatmap, OsuPP, OsuStars,
}; };
@@ -15,7 +15,7 @@ mod common;
#[test] #[test]
fn empty_map() { fn empty_map() {
let map = Beatmap::default(); let map = Beatmap::default();
let mut attributes = OsuGradualDifficultyAttributes::new(&map, 0); let mut attributes = OsuGradualDifficulty::new(&map, 0);
assert!(attributes.next().is_none()); assert!(attributes.next().is_none());
} }
@@ -25,7 +25,7 @@ fn iter_end_eq_regular() {
let map = test_map!(Osu); let map = test_map!(Osu);
let regular = OsuStars::new(&map).calculate(); let regular = OsuStars::new(&map).calculate();
let iter_end = OsuGradualDifficultyAttributes::new(&map, 0) let iter_end = OsuGradualDifficulty::new(&map, 0)
.last() .last()
.expect("empty iter"); .expect("empty iter");
@@ -35,7 +35,7 @@ fn iter_end_eq_regular() {
#[test] #[test]
fn correct_empty() { fn correct_empty() {
let map = test_map!(Osu); let map = test_map!(Osu);
let mut gradual = OsuGradualPerformanceAttributes::new(&map, 0); let mut gradual = OsuGradualPerformance::new(&map, 0);
let state = OsuScoreState::default(); let state = OsuScoreState::default();
let first_attrs = gradual.nth(state.clone(), usize::MAX); let first_attrs = gradual.nth(state.clone(), usize::MAX);
@@ -49,8 +49,8 @@ fn next_and_next_n() {
let map = test_map!(Osu); let map = test_map!(Osu);
let state = OsuScoreState::default(); let state = OsuScoreState::default();
let mut gradual1 = OsuGradualPerformanceAttributes::new(&map, 0); let mut gradual1 = OsuGradualPerformance::new(&map, 0);
let mut gradual2 = OsuGradualPerformanceAttributes::new(&map, 0); let mut gradual2 = OsuGradualPerformance::new(&map, 0);
for _ in 0..20 { for _ in 0..20 {
let _ = gradual1.next(state.clone()); let _ = gradual1.next(state.clone());
@@ -81,7 +81,7 @@ fn next_and_next_n() {
fn gradual_end_eq_regular() { fn gradual_end_eq_regular() {
let map = test_map!(Osu); let map = test_map!(Osu);
let regular = OsuPP::new(&map).calculate(); let regular = OsuPP::new(&map).calculate();
let mut gradual = OsuGradualPerformanceAttributes::new(&map, 0); let mut gradual = OsuGradualPerformance::new(&map, 0);
let state = OsuScoreState { let state = OsuScoreState {
max_combo: 909, max_combo: 909,
@@ -102,7 +102,7 @@ fn gradual_eq_regular_passed() {
let n = 100; let n = 100;
let regular = OsuPP::new(&map).passed_objects(n).calculate(); let regular = OsuPP::new(&map).passed_objects(n).calculate();
let mut gradual = OsuGradualPerformanceAttributes::new(&map, 0); let mut gradual = OsuGradualPerformance::new(&map, 0);
let state = OsuScoreState { let state = OsuScoreState {
max_combo: 122, max_combo: 122,
+12 -9
View File
@@ -1,7 +1,10 @@
#![cfg(all(not(any(feature = "async_tokio", feature = "async_std")), feature = "gradual"))] #![cfg(all(
not(any(feature = "async_tokio", feature = "async_std")),
feature = "gradual"
))]
use rosu_pp::{ use rosu_pp::{
taiko::{TaikoGradualDifficultyAttributes, TaikoGradualPerformanceAttributes, TaikoScoreState}, taiko::{TaikoGradualDifficulty, TaikoGradualPerformance, TaikoScoreState},
Beatmap, TaikoPP, TaikoStars, Beatmap, TaikoPP, TaikoStars,
}; };
@@ -12,7 +15,7 @@ mod common;
#[test] #[test]
fn empty_map() { fn empty_map() {
let map = Beatmap::default(); let map = Beatmap::default();
let mut attrs = TaikoGradualDifficultyAttributes::new(&map, 0); let mut attrs = TaikoGradualDifficulty::new(&map, 0);
assert!(attrs.next().is_none()); assert!(attrs.next().is_none());
} }
@@ -22,7 +25,7 @@ fn iter_end_eq_regular() {
let map = test_map!(Taiko); let map = test_map!(Taiko);
let regular = TaikoStars::new(&map).calculate(); let regular = TaikoStars::new(&map).calculate();
let iter_end = TaikoGradualDifficultyAttributes::new(&map, 0) let iter_end = TaikoGradualDifficulty::new(&map, 0)
.last() .last()
.expect("empty iter"); .expect("empty iter");
@@ -32,7 +35,7 @@ fn iter_end_eq_regular() {
#[test] #[test]
fn correct_empty() { fn correct_empty() {
let map = test_map!(Taiko); let map = test_map!(Taiko);
let mut gradual = TaikoGradualPerformanceAttributes::new(&map, 0); let mut gradual = TaikoGradualPerformance::new(&map, 0);
let state = TaikoScoreState::default(); let state = TaikoScoreState::default();
let first_attrs = gradual.nth(state.clone(), usize::MAX); let first_attrs = gradual.nth(state.clone(), usize::MAX);
@@ -46,8 +49,8 @@ fn next_and_next_n() {
let map = test_map!(Taiko); let map = test_map!(Taiko);
let state = TaikoScoreState::default(); let state = TaikoScoreState::default();
let mut gradual1 = TaikoGradualPerformanceAttributes::new(&map, 0); let mut gradual1 = TaikoGradualPerformance::new(&map, 0);
let mut gradual2 = TaikoGradualPerformanceAttributes::new(&map, 0); let mut gradual2 = TaikoGradualPerformance::new(&map, 0);
for _ in 0..50 { for _ in 0..50 {
let _ = gradual1.next(state.clone()); let _ = gradual1.next(state.clone());
@@ -77,7 +80,7 @@ fn next_and_next_n() {
fn gradual_end_eq_regular() { fn gradual_end_eq_regular() {
let map = test_map!(Taiko); let map = test_map!(Taiko);
let regular = TaikoPP::new(&map).calculate(); let regular = TaikoPP::new(&map).calculate();
let mut gradual = TaikoGradualPerformanceAttributes::new(&map, 0); let mut gradual = TaikoGradualPerformance::new(&map, 0);
let state = TaikoScoreState { let state = TaikoScoreState {
max_combo: 289, max_combo: 289,
@@ -97,7 +100,7 @@ fn gradual_eq_regular_passed() {
let n = 250; let n = 250;
let regular = TaikoPP::new(&map).passed_objects(n).calculate(); let regular = TaikoPP::new(&map).passed_objects(n).calculate();
let mut gradual = TaikoGradualPerformanceAttributes::new(&map, 0); let mut gradual = TaikoGradualPerformance::new(&map, 0);
let state = TaikoScoreState { let state = TaikoScoreState {
max_combo: 250, max_combo: 250,