added distinct strains struct for each mode

This commit is contained in:
MaxOhn
2022-07-06 12:54:00 +02:00
parent af2530e836
commit 8ec61f96d0
7 changed files with 168 additions and 72 deletions
+22 -4
View File
@@ -10,7 +10,7 @@ pub use gradual_performance::*;
pub use pp::*;
use strain::Strain;
use crate::{parse::HitObject, Beatmap, GameMode, Mods, OsuStars, Strains};
use crate::{parse::HitObject, Beatmap, GameMode, Mods, OsuStars};
const SECTION_LEN: f64 = 400.0;
const STAR_SCALING_FACTOR: f64 = 0.018;
@@ -99,17 +99,35 @@ impl<'map> ManiaStars<'map> {
///
/// Suitable to plot the difficulty of a map over time.
#[inline]
pub fn strains(self) -> Strains {
pub fn strains(self) -> ManiaStrains {
let clock_rate = self.clock_rate.unwrap_or_else(|| self.mods.clock_rate());
let strain = calculate_strain(self);
Strains {
section_length: SECTION_LEN * clock_rate,
ManiaStrains {
section_len: SECTION_LEN * clock_rate,
strains: strain.strain_peaks,
}
}
}
/// The result of calculating the strains on a osu!taiko map.
/// Suitable to plot the difficulty of a map over time.
#[derive(Clone, Debug)]
pub struct ManiaStrains {
/// Time in ms inbetween two strains.
pub section_len: f64,
/// Strain peaks of the strain skill.
pub strains: Vec<f64>,
}
impl ManiaStrains {
/// Returns the number of strain peaks per skill.
#[inline]
pub fn len(&self) -> usize {
self.strains.len()
}
}
fn calculate_strain(params: ManiaStars<'_>) -> Strain {
let ManiaStars {
map,