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
+8 -8
View File
@@ -26,12 +26,12 @@ use super::{
/// be processed and the [`OsuDifficultyAttributes`] will be updated and returned.
///
/// If you want to calculate performance attributes, use
/// [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualPerformanceAttributes) instead.
/// [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualPerformance) instead.
///
/// # Example
///
/// ```
/// use rosu_pp::{Beatmap, osu::OsuGradualDifficultyAttributes};
/// use rosu_pp::{Beatmap, osu::OsuGradualDifficulty};
///
/// # /*
/// let map: Beatmap = ...
@@ -39,7 +39,7 @@ use super::{
/// # let map = Beatmap::default();
///
/// 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 attrs2 = iter.next(); // after the second hit object
@@ -49,7 +49,7 @@ use super::{
/// // ...
/// }
/// ```
pub struct OsuGradualDifficultyAttributes {
pub struct OsuGradualDifficulty {
pub(crate) idx: usize,
mods: u32,
attrs: OsuDifficultyAttributes,
@@ -61,7 +61,7 @@ pub struct OsuGradualDifficultyAttributes {
skills: Skills,
}
impl Debug for OsuGradualDifficultyAttributes {
impl Debug for OsuGradualDifficulty {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
f.debug_struct("OsuGradualDifficultyAttributes")
.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.
pub fn new(map: &Beatmap, mods: u32) -> Self {
let clock_rate = mods.clock_rate();
@@ -216,7 +216,7 @@ fn extend_lifetime(
unsafe { mem::transmute(diff_objects) }
}
impl Iterator for OsuGradualDifficultyAttributes {
impl Iterator for OsuGradualDifficulty {
type Item = OsuDifficultyAttributes;
fn next(&mut self) -> Option<Self::Item> {
@@ -330,7 +330,7 @@ impl Iterator for OsuGradualDifficultyAttributes {
}
}
impl ExactSizeIterator for OsuGradualDifficultyAttributes {
impl ExactSizeIterator for OsuGradualDifficulty {
#[inline]
fn len(&self) -> usize {
self.diff_objects.len() + 1 - self.idx
+8 -8
View File
@@ -2,7 +2,7 @@
use crate::{Beatmap, OsuPP};
use super::{OsuGradualDifficultyAttributes, OsuPerformanceAttributes, OsuScoreState};
use super::{OsuGradualDifficulty, OsuPerformanceAttributes, OsuScoreState};
/// 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.
///
/// If you only want to calculate difficulty attributes use
/// [`OsuGradualDifficultyAttributes`] instead.
/// [`OsuGradualDifficulty`] instead.
///
/// # Example
///
/// ```
/// use rosu_pp::{Beatmap, osu::{OsuGradualPerformanceAttributes, OsuScoreState}};
/// use rosu_pp::{Beatmap, osu::{OsuGradualPerformance, OsuScoreState}};
///
/// # /*
/// let map: Beatmap = ...
@@ -28,7 +28,7 @@ use super::{OsuGradualDifficultyAttributes, OsuPerformanceAttributes, OsuScoreSt
/// # let map = Beatmap::default();
///
/// 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.
///
/// // 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());
/// ```
#[derive(Debug)]
pub struct OsuGradualPerformanceAttributes<'map> {
difficulty: OsuGradualDifficultyAttributes,
pub struct OsuGradualPerformance<'map> {
difficulty: OsuGradualDifficulty,
performance: OsuPP<'map>,
}
impl<'map> OsuGradualPerformanceAttributes<'map> {
impl<'map> OsuGradualPerformance<'map> {
/// Create a new gradual performance calculator for osu!standard maps.
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);
Self {
+3 -5
View File
@@ -22,8 +22,7 @@ pub use self::{osu_object::*, pp::*, score_state::OsuScoreState};
#[cfg(feature = "gradual")]
pub use self::{
gradual_difficulty::OsuGradualDifficultyAttributes,
gradual_performance::OsuGradualPerformanceAttributes,
gradual_difficulty::OsuGradualDifficulty, gradual_performance::OsuGradualPerformance,
};
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
/// using [`OsuStars`] multiple times with different `passed_objects`, you should use
/// [`OsuGradualDifficultyAttributes`].
/// [`OsuGradualDifficulty`].
#[inline]
pub fn passed_objects(mut self, passed_objects: usize) -> Self {
self.passed_objects = Some(passed_objects);
@@ -326,8 +325,7 @@ fn calculate_skills(params: OsuStars<'_>) -> (Skills, OsuDifficultyAttributes) {
let curr = curr.into_ref();
let diff_obj =
OsuDifficultyObject::new(curr, last.get_ref(), clock_rate, i, dists);
let diff_obj = OsuDifficultyObject::new(curr, last.get_ref(), clock_rate, i, dists);
diff_objects.push(diff_obj);
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
/// using [`OsuPP`] multiple times with different `passed_objects`, you should use
/// [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualPerformanceAttributes).
/// [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualPerformance).
#[inline]
pub fn passed_objects(mut self, passed_objects: usize) -> Self {
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
/// 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)]
pub struct OsuScoreState {
/// Maximum combo that the score has had so far.