feature-gated modes and osu!standard versions
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#![cfg(feature = "osu")]
|
||||
|
||||
mod pp;
|
||||
mod versions;
|
||||
|
||||
|
||||
+25
-4
@@ -13,6 +13,7 @@ impl OsuAttributeProvider for DifficultyAttributes {
|
||||
|
||||
impl OsuAttributeProvider for StarResult {
|
||||
fn attributes(self) -> Option<DifficultyAttributes> {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
if let Self::Osu(attributes) = self {
|
||||
Some(attributes)
|
||||
} else {
|
||||
@@ -144,6 +145,7 @@ impl<'m> OsuPP<'m> {
|
||||
let acc = acc / 100.0;
|
||||
|
||||
if self.n100.or(self.n50).is_some() {
|
||||
// TODO: Improve this branch
|
||||
self.n300.replace(
|
||||
n_objects - self.n100.unwrap_or(0) - self.n50.unwrap_or(0) - self.n_misses,
|
||||
);
|
||||
@@ -168,13 +170,32 @@ impl<'m> OsuPP<'m> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Returns an object which contains the pp and [`DifficultyAttributes`](crate::osu::DifficultyAttributes)
|
||||
/// containing stars and other attributes.
|
||||
#[cfg(feature = "no_leniency")]
|
||||
pub fn calculate(self) -> PpResult {
|
||||
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) -> PpResult {
|
||||
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) -> PpResult {
|
||||
self.calculate_with_func(super::all_included::stars)
|
||||
}
|
||||
|
||||
/// Returns an object which contains the pp and [`DifficultyAttributes`](crate::osu::DifficultyAttributes)
|
||||
/// containing stars and other attributes.
|
||||
///
|
||||
/// `stars_func` will be used to calculate the difficulty attributes if not already given.
|
||||
/// Only called if `attributes` was not set.
|
||||
/// The default is suggested to be [`no_leniency::stars`](crate::osu::no_leniency::stars).
|
||||
pub fn calculate(
|
||||
/// `stars_func` will be used to calculate the difficulty attributes if they are not yet given.
|
||||
fn calculate_with_func(
|
||||
mut self,
|
||||
stars_func: impl FnOnce(&Beatmap, u32, Option<usize>) -> StarResult,
|
||||
) -> PpResult {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![cfg(feature = "all_included")]
|
||||
#![allow(unused)]
|
||||
|
||||
mod difficulty_object;
|
||||
@@ -11,7 +12,7 @@ use skill::Skill;
|
||||
use skill_kind::SkillKind;
|
||||
|
||||
use super::super::DifficultyAttributes;
|
||||
use crate::{Beatmap, Mods, StarResult};
|
||||
use crate::{Beatmap, Mods, StarResult, Strains};
|
||||
|
||||
const SECTION_LEN: f32 = 400.0;
|
||||
const DIFFICULTY_MULTIPLIER: f32 = 0.0675;
|
||||
@@ -128,7 +129,13 @@ pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> S
|
||||
StarResult::Osu(attributes)
|
||||
}
|
||||
|
||||
// TODO: strains function
|
||||
/// Essentially the same as the `stars` function but instead of
|
||||
/// evaluating the final strains, it just returns them as is.
|
||||
///
|
||||
/// Suitable to plot the difficulty of a map over time.
|
||||
pub fn strains(_map: &Beatmap, _mods: impl Mods) -> Strains {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
@@ -150,7 +157,7 @@ mod tests {
|
||||
Err(why) => panic!("Error while parsing map: {}", why),
|
||||
};
|
||||
|
||||
let result = OsuPP::new(&map).mods(64).calculate(stars);
|
||||
let result = OsuPP::new(&map).mods(64).calculate();
|
||||
|
||||
println!("Stars: {}", result.stars());
|
||||
println!("PP: {}", result.pp());
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
mod all_included;
|
||||
#[cfg(feature = "all_included")]
|
||||
pub mod all_included;
|
||||
|
||||
#[cfg(feature = "no_leniency")]
|
||||
pub mod no_leniency;
|
||||
|
||||
#[cfg(feature = "no_sliders_no_leniency")]
|
||||
pub mod no_sliders_no_leniency;
|
||||
|
||||
const OSU_OD_MAX: f32 = 20.0;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
//! This means the jump distance inbetween notes might be slightly off, resulting in small inaccuracies.
|
||||
//! Since calculating these offsets is relatively expensive though, this version is considerably faster than `all_included`.
|
||||
|
||||
#![cfg(feature = "no_leniency")]
|
||||
|
||||
use super::super::DifficultyAttributes;
|
||||
|
||||
mod control_point_iter;
|
||||
@@ -271,7 +273,6 @@ pub fn strains(map: &Beatmap, mods: impl Mods) -> Strains {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::super::super::OsuPP;
|
||||
use super::stars;
|
||||
use crate::Beatmap;
|
||||
use std::fs::File;
|
||||
|
||||
@@ -288,7 +289,7 @@ mod tests {
|
||||
Err(why) => panic!("Error while parsing map: {}", why),
|
||||
};
|
||||
|
||||
let result = OsuPP::new(&map).mods(0).calculate(stars);
|
||||
let result = OsuPP::new(&map).mods(0).calculate();
|
||||
|
||||
println!("Stars: {}", result.stars());
|
||||
println!("PP: {}", result.pp());
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
//! This means the travel distance of notes is completely omitted which may cause further inaccuracies.
|
||||
//! Since the slider paths don't have to be computed though, it should generally be faster than `no_leniency`.
|
||||
|
||||
#![cfg(feature = "no_sliders_no_leniency")]
|
||||
|
||||
use super::super::DifficultyAttributes;
|
||||
|
||||
mod control_point_iter;
|
||||
@@ -285,7 +287,6 @@ pub fn strains(map: &Beatmap, mods: impl Mods) -> Strains {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::super::super::OsuPP;
|
||||
use super::stars;
|
||||
use crate::Beatmap;
|
||||
use std::fs::File;
|
||||
|
||||
@@ -302,7 +303,7 @@ mod tests {
|
||||
Err(why) => panic!("Error while parsing map: {}", why),
|
||||
};
|
||||
|
||||
let result = OsuPP::new(&map).mods(2).calculate(stars);
|
||||
let result = OsuPP::new(&map).mods(2).calculate();
|
||||
|
||||
println!("Stars: {}", result.stars());
|
||||
println!("PP: {}", result.pp());
|
||||
|
||||
Reference in New Issue
Block a user