added a bunch of documentation

This commit is contained in:
MaxOhn
2021-11-17 18:59:52 +01:00
parent 82b124fa75
commit 58bf4bd6e0
18 changed files with 238 additions and 44 deletions
+22 -4
View File
@@ -548,29 +548,47 @@ fn lerp(start: f64, end: f64, percent: f64) -> f64 {
/// The result of a difficulty calculation on an osu!standard map.
#[derive(Clone, Debug, Default)]
pub struct OsuDifficultyAttributes {
/// The aim portion of the total strain.
pub aim_strain: f64,
/// The speed portion of the total strain.
pub speed_strain: f64,
/// The flashlight portion of the total strain.
pub flashlight_rating: f64,
/// The ratio of the aim strain with and without considering sliders
pub slider_factor: f64,
/// The approach rate.
pub ar: f64,
/// The overall difficulty
pub od: f64,
/// The health drain rate.
pub hp: f64,
/// The amount of circles.
pub n_circles: usize,
/// The amount of sliders.
pub n_sliders: usize,
/// The amount of spinners.
pub n_spinners: usize,
/// The final star rating
pub stars: f64,
/// The maximum combo.
pub max_combo: usize,
}
/// The result of a performance calculation on an osu!standard map.
#[derive(Clone, Debug, Default)]
pub struct OsuPerformanceAttributes {
/// The difficulty attributes that were used for the performance calculation
pub attributes: OsuDifficultyAttributes,
pub pp_acc: f64,
pub pp_aim: f64,
pub pp_flashlight: f64,
pub pp_speed: f64,
/// The final performance points.
pub pp: f64,
/// The accuracy portion of the final pp.
pub pp_acc: f64,
/// The aim portion of the final pp.
pub pp_aim: f64,
/// The flashlight portion of the final pp.
pub pp_flashlight: f64,
/// The speed portion of the final pp.
pub pp_speed: f64,
}
impl OsuPerformanceAttributes {
+10 -6
View File
@@ -6,11 +6,13 @@ use crate::{Beatmap, DifficultyAttributes, Mods, PerformanceAttributes};
/// # Example
///
/// ```
/// # use rosu_pp::{OsuPP, PpResult, Beatmap};
/// use rosu_pp::{OsuPP, Beatmap};
///
/// # /*
/// let map: Beatmap = ...
/// # */
/// # let map = Beatmap::default();
///
/// let pp_result = OsuPP::new(&map)
/// .mods(8 + 64) // HDDT
/// .combo(1234)
@@ -30,8 +32,8 @@ use crate::{Beatmap, DifficultyAttributes, Mods, PerformanceAttributes};
/// ```
#[derive(Clone, Debug)]
#[allow(clippy::upper_case_acronyms)]
pub struct OsuPP<'m> {
map: &'m Beatmap,
pub struct OsuPP<'map> {
map: &'map Beatmap,
attributes: Option<OsuDifficultyAttributes>,
mods: u32,
combo: Option<usize>,
@@ -44,9 +46,10 @@ pub struct OsuPP<'m> {
passed_objects: Option<usize>,
}
impl<'m> OsuPP<'m> {
impl<'map> OsuPP<'map> {
/// Create a new performance calculator for osu!standard maps.
#[inline]
pub fn new(map: &'m Beatmap) -> Self {
pub fn new(map: &'map Beatmap) -> Self {
Self {
map,
attributes: None,
@@ -62,7 +65,7 @@ impl<'m> OsuPP<'m> {
}
}
/// Provide the result of previous a difficulty or performance calculation.
/// Provide the result of previous difficulty or performance calculation.
/// If you already calculated the attributes for the current map-mod combination,
/// be sure to put them in here so that they don't have to be recalculated.
#[inline]
@@ -590,6 +593,7 @@ fn calculate_effective_misses(
/// Abstract type to provide flexibility when passing difficulty attributes to a performance calculation.
pub trait OsuAttributeProvider {
/// Provide the actual difficulty attributes.
fn attributes(self) -> Option<OsuDifficultyAttributes>;
}