allow custom clock rates
This commit is contained in:
+16
-3
@@ -56,6 +56,7 @@ pub struct TaikoStars<'map> {
|
||||
map: &'map Beatmap,
|
||||
mods: u32,
|
||||
passed_objects: Option<usize>,
|
||||
clock_rate: Option<f64>,
|
||||
}
|
||||
|
||||
impl<'map> TaikoStars<'map> {
|
||||
@@ -66,6 +67,7 @@ impl<'map> TaikoStars<'map> {
|
||||
map,
|
||||
mods: 0,
|
||||
passed_objects: None,
|
||||
clock_rate: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +93,16 @@ impl<'map> TaikoStars<'map> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Adjust the clock rate used in the calculation.
|
||||
/// If none is specified, it will take the clock rate based on the mods
|
||||
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
||||
#[inline]
|
||||
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
||||
self.clock_rate = Some(clock_rate);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Calculate all difficulty related values, including stars.
|
||||
#[inline]
|
||||
pub fn calculate(self) -> TaikoDifficultyAttributes {
|
||||
@@ -127,7 +139,7 @@ impl<'map> TaikoStars<'map> {
|
||||
/// Suitable to plot the difficulty of a map over time.
|
||||
#[inline]
|
||||
pub fn strains(self) -> Strains {
|
||||
let mods = self.mods;
|
||||
let clock_rate = self.clock_rate.unwrap_or_else(|| self.mods.speed());
|
||||
let (skills, _) = calculate_skills(self);
|
||||
|
||||
let strains = skills
|
||||
@@ -143,7 +155,7 @@ impl<'map> TaikoStars<'map> {
|
||||
.collect();
|
||||
|
||||
Strains {
|
||||
section_length: SECTION_LEN * mods.speed(),
|
||||
section_length: SECTION_LEN * clock_rate,
|
||||
strains,
|
||||
}
|
||||
}
|
||||
@@ -154,14 +166,15 @@ fn calculate_skills(params: TaikoStars<'_>) -> (Skills, usize) {
|
||||
map,
|
||||
mods,
|
||||
passed_objects,
|
||||
clock_rate,
|
||||
} = params;
|
||||
|
||||
let take = passed_objects.unwrap_or_else(|| map.hit_objects.len());
|
||||
let clock_rate = clock_rate.unwrap_or_else(|| mods.speed());
|
||||
|
||||
// True if the object at that index is stamina cheese
|
||||
let cheese = map.find_cheese();
|
||||
let mut skills = Skills::new();
|
||||
let clock_rate = mods.speed();
|
||||
let mut max_combo = 0;
|
||||
|
||||
match map.hit_objects.get(0) {
|
||||
|
||||
+23
-4
@@ -39,6 +39,7 @@ pub struct TaikoPP<'map> {
|
||||
combo: Option<usize>,
|
||||
acc: f64,
|
||||
passed_objects: Option<usize>,
|
||||
clock_rate: Option<f64>,
|
||||
|
||||
pub(crate) n300: Option<usize>,
|
||||
pub(crate) n100: Option<usize>,
|
||||
@@ -57,6 +58,7 @@ impl<'map> TaikoPP<'map> {
|
||||
acc: 1.0,
|
||||
n_misses: 0,
|
||||
passed_objects: None,
|
||||
clock_rate: None,
|
||||
n300: None,
|
||||
n100: None,
|
||||
}
|
||||
@@ -138,6 +140,16 @@ impl<'map> TaikoPP<'map> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Adjust the clock rate used in the calculation.
|
||||
/// If none is specified, it will take the clock rate based on the mods
|
||||
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
|
||||
#[inline]
|
||||
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
||||
self.clock_rate = Some(clock_rate);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Provide parameters through a [`TaikoScoreState`].
|
||||
#[inline]
|
||||
pub fn state(mut self, state: TaikoScoreState) -> Self {
|
||||
@@ -159,10 +171,17 @@ impl<'map> TaikoPP<'map> {
|
||||
/// Calculate all performance related values, including pp and stars.
|
||||
pub fn calculate(mut self) -> TaikoPerformanceAttributes {
|
||||
let attributes = self.attributes.take().unwrap_or_else(|| {
|
||||
TaikoStars::new(self.map)
|
||||
.mods(self.mods)
|
||||
.passed_objects(self.passed_objects.unwrap_or(usize::MAX))
|
||||
.calculate()
|
||||
let mut calculator = TaikoStars::new(self.map).mods(self.mods);
|
||||
|
||||
if let Some(passed_objects) = self.passed_objects {
|
||||
calculator = calculator.passed_objects(passed_objects);
|
||||
}
|
||||
|
||||
if let Some(clock_rate) = self.clock_rate {
|
||||
calculator = calculator.clock_rate(clock_rate);
|
||||
}
|
||||
|
||||
calculator.calculate()
|
||||
});
|
||||
|
||||
if self.n300.or(self.n100).is_some() {
|
||||
|
||||
Reference in New Issue
Block a user