osu: clean up of feature based functions
This commit is contained in:
+1
-2
@@ -256,8 +256,7 @@ impl<'m> FruitsPP<'m> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an object which contains the pp and [`DifficultyAttributes`](crate::fruits::DifficultyAttributes)
|
/// Calculate all performance related values, including pp and stars.
|
||||||
/// containing stars and other attributes.
|
|
||||||
pub fn calculate(mut self) -> PerformanceAttributes {
|
pub fn calculate(mut self) -> PerformanceAttributes {
|
||||||
let attributes = self
|
let attributes = self
|
||||||
.attributes
|
.attributes
|
||||||
|
|||||||
+1
-1
@@ -89,7 +89,7 @@ impl<'m> ManiaPP<'m> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an object which contains the pp and stars.
|
/// Calculate all performance related values, including pp and stars.
|
||||||
pub fn calculate(self) -> PerformanceAttributes {
|
pub fn calculate(self) -> PerformanceAttributes {
|
||||||
let stars = self
|
let stars = self
|
||||||
.stars
|
.stars
|
||||||
|
|||||||
+12
-38
@@ -1,6 +1,15 @@
|
|||||||
use super::{DifficultyAttributes, PerformanceAttributes};
|
use super::{DifficultyAttributes, PerformanceAttributes};
|
||||||
use crate::{Beatmap, Mods, PpResult, StarResult};
|
use crate::{Beatmap, Mods, PpResult, StarResult};
|
||||||
|
|
||||||
|
#[cfg(feature = "no_sliders_no_leniency")]
|
||||||
|
use super::no_sliders_no_leniency::stars;
|
||||||
|
|
||||||
|
#[cfg(feature = "no_leniency")]
|
||||||
|
use super::no_leniency::stars;
|
||||||
|
|
||||||
|
#[cfg(feature = "all_included")]
|
||||||
|
use super::all_included::stars;
|
||||||
|
|
||||||
/// Calculator for pp on osu!standard maps.
|
/// Calculator for pp on osu!standard maps.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
@@ -277,47 +286,12 @@ impl<'m> OsuPP<'m> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an object which contains the pp and [`DifficultyAttributes`](crate::osu::DifficultyAttributes)
|
/// Calculate all performance related values, including pp and stars.
|
||||||
/// containing stars and other attributes.
|
pub fn calculate(mut self) -> PerformanceAttributes {
|
||||||
#[cfg(feature = "no_leniency")]
|
|
||||||
pub fn calculate(self) -> PerformanceAttributes {
|
|
||||||
self.calculate_with_func(super::no_leniency::stars)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns an object which contains the pp and [`DifficultyAttributes`](crate::osu::DifficultyAttributes)
|
|
||||||
/// containing stars and other attributes.
|
|
||||||
#[cfg(feature = "no_sliders_no_leniency")]
|
|
||||||
pub fn calculate(self) -> PerformanceAttributes {
|
|
||||||
self.calculate_with_func(super::no_sliders_no_leniency::stars)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns an object which contains the pp and [`DifficultyAttributes`](crate::osu::DifficultyAttributes)
|
|
||||||
/// containing stars and other attributes.
|
|
||||||
#[cfg(feature = "all_included")]
|
|
||||||
pub fn calculate(self) -> PerformanceAttributes {
|
|
||||||
self.calculate_with_func(super::all_included::stars)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: import `stars` function based on features
|
|
||||||
|
|
||||||
// Omits an unnecessary error when enabled features are invalid
|
|
||||||
#[cfg(not(any(
|
|
||||||
feature = "no_leniency",
|
|
||||||
feature = "no_sliders_no_leniency",
|
|
||||||
feature = "all_included"
|
|
||||||
)))]
|
|
||||||
pub(crate) fn calculate(self) -> PerformanceAttributes {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn calculate_with_func(
|
|
||||||
mut self,
|
|
||||||
stars_func: impl FnOnce(&Beatmap, u32, Option<usize>) -> DifficultyAttributes,
|
|
||||||
) -> PerformanceAttributes {
|
|
||||||
let attributes = self
|
let attributes = self
|
||||||
.attributes
|
.attributes
|
||||||
.take()
|
.take()
|
||||||
.unwrap_or_else(|| stars_func(self.map, self.mods, self.passed_objects));
|
.unwrap_or_else(|| stars(self.map, self.mods, self.passed_objects));
|
||||||
|
|
||||||
self.assert_hitresults(attributes).calculate()
|
self.assert_hitresults(attributes).calculate()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -135,7 +135,7 @@ impl<'m> TaikoPP<'m> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an object which contains the pp and stars.
|
/// Calculate all performance related values, including pp and stars.
|
||||||
pub fn calculate(mut self) -> PerformanceAttributes {
|
pub fn calculate(mut self) -> PerformanceAttributes {
|
||||||
let stars = self
|
let stars = self
|
||||||
.stars
|
.stars
|
||||||
|
|||||||
Reference in New Issue
Block a user