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
+7 -2
View File
@@ -172,16 +172,21 @@ impl<'o> DifficultyHitObject<'o> {
/// The result of a difficulty calculation on an osu!mania map.
#[derive(Copy, Clone, Debug, Default)]
pub struct ManiaDifficultyAttributes {
/// The final star rating.
pub stars: f64,
}
/// The result of a performance calculation on an osu!mania map.
#[derive(Copy, Clone, Debug, Default)]
pub struct ManiaPerformanceAttributes {
/// The difficulty attributes that were used for the performance calculation
pub attributes: ManiaDifficultyAttributes,
pub pp_acc: f64,
pub pp_strain: f64,
/// The final performance points.
pub pp: f64,
/// The accuracy portion of the final pp.
pub pp_acc: f64,
/// The strain portion of the final pp.
pub pp_strain: f64,
}
impl ManiaPerformanceAttributes {
+10 -6
View File
@@ -6,11 +6,13 @@ use crate::{Beatmap, DifficultyAttributes, Mods, PerformanceAttributes};
/// # Example
///
/// ```
/// # use rosu_pp::{ManiaPP, PpResult, Beatmap};
/// use rosu_pp::{ManiaPP, Beatmap};
///
/// # /*
/// let map: Beatmap = ...
/// # */
/// # let map = Beatmap::default();
///
/// let pp_result = ManiaPP::new(&map)
/// .mods(64) // DT
/// .score(765_432)
@@ -28,17 +30,18 @@ use crate::{Beatmap, DifficultyAttributes, Mods, PerformanceAttributes};
/// ```
#[derive(Clone, Debug)]
#[allow(clippy::upper_case_acronyms)]
pub struct ManiaPP<'m> {
map: &'m Beatmap,
pub struct ManiaPP<'map> {
map: &'map Beatmap,
stars: Option<f64>,
mods: u32,
score: Option<f64>,
passed_objects: Option<usize>,
}
impl<'m> ManiaPP<'m> {
impl<'map> ManiaPP<'map> {
/// Create a new performance calculator for osu!mania maps.
#[inline]
pub fn new(map: &'m Beatmap) -> Self {
pub fn new(map: &'map Beatmap) -> Self {
Self {
map,
stars: None,
@@ -48,7 +51,7 @@ impl<'m> ManiaPP<'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]
@@ -169,6 +172,7 @@ impl<'m> ManiaPP<'m> {
/// Abstract type to provide flexibility when passing difficulty attributes to a performance calculation.
pub trait ManiaAttributeProvider {
/// Provide the star rating (only difficulty attribute for osu!mania).
fn attributes(self) -> Option<f64>;
}