Difficulty

Struct Difficulty 

Source
pub struct Difficulty { /* private fields */ }
Expand description

Difficulty calculator on maps of any mode.

§Example

use rosu_pp::{Beatmap, Difficulty, any::DifficultyAttributes};

let map = Beatmap::from_path("./resources/2118524.osu").unwrap();

let attrs: DifficultyAttributes = Difficulty::new()
    .mods(8 + 1024) // HDFL
    .calculate(&map);

Implementations§

Source§

impl Difficulty

Source

pub const fn new() -> Self

Create a new difficulty calculator.

Source

pub fn inspect(self) -> InspectDifficulty

Turn this Difficulty into a InspectDifficulty to inspect its configured values.

Source

pub fn mods(self, mods: impl Into<GameMods>) -> Self

Source

pub const fn passed_objects(self, passed_objects: u32) -> Self

Amount of passed objects for partial plays, e.g. a fail.

Source

pub fn clock_rate(self, clock_rate: f64) -> 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.

MinimumMaximum
0.01100
Source

pub fn ar(self, ar: f32, with_mods: bool) -> Self

Override a beatmap’s set AR.

Only relevant for osu! and osu!catch.

with_mods determines if the given value should be used before or after accounting for mods, e.g. on true the value will be used as is and on false it will be modified based on the mods.

MinimumMaximum
-2020
Source

pub fn cs(self, cs: f32, with_mods: bool) -> Self

Override a beatmap’s set CS.

Only relevant for osu! and osu!catch.

with_mods determines if the given value should be used before or after accounting for mods, e.g. on true the value will be used as is and on false it will be modified based on the mods.

MinimumMaximum
-2020
Source

pub fn hp(self, hp: f32, with_mods: bool) -> Self

Override a beatmap’s set HP.

with_mods determines if the given value should be used before or after accounting for mods, e.g. on true the value will be used as is and on false it will be modified based on the mods.

MinimumMaximum
-2020
Source

pub fn od(self, od: f32, with_mods: bool) -> Self

Override a beatmap’s set OD.

with_mods determines if the given value should be used before or after accounting for mods, e.g. on true the value will be used as is and on false it will be modified based on the mods.

MinimumMaximum
-2020
Source

pub const fn hardrock_offsets(self, hardrock_offsets: bool) -> Self

Adjust patterns as if the HR mod is enabled.

Only relevant for osu!catch.

Source

pub const fn lazer(self, lazer: bool) -> Self

Whether the calculated attributes belong to an osu!lazer or osu!stable score.

Defaults to true.

Source

pub fn calculate(&self, map: &Beatmap) -> DifficultyAttributes

Perform the difficulty calculation.

Source

pub fn calculate_for_mode<M: IGameMode>( &self, map: &Beatmap, ) -> Result<M::DifficultyAttributes, ConvertError>

Perform the difficulty calculation for a specific IGameMode.

Source

pub fn strains(&self, map: &Beatmap) -> Strains

Perform the difficulty calculation but instead of evaluating the skill strains, return them as is.

Suitable to plot the difficulty of a map over time.

Source

pub fn strains_for_mode<M: IGameMode>( &self, map: &Beatmap, ) -> Result<M::Strains, ConvertError>

Perform the strain calculation for a specific IGameMode.

Source

pub fn gradual_difficulty(self, map: &Beatmap) -> GradualDifficulty

Create a gradual difficulty calculator for a Beatmap.

Source

pub fn gradual_difficulty_for_mode<M: IGameMode>( self, map: &Beatmap, ) -> Result<M::GradualDifficulty, ConvertError>

Create a gradual difficulty calculator for a Beatmap on a specific IGameMode.

Source

pub fn gradual_performance(self, map: &Beatmap) -> GradualPerformance

Create a gradual performance calculator for a Beatmap.

Source

pub fn gradual_performance_for_mode<M: IGameMode>( self, map: &Beatmap, ) -> Result<M::GradualPerformance, ConvertError>

Create a gradual performance calculator for a Beatmap on a specific IGameMode.

Trait Implementations§

Source§

impl Clone for Difficulty

Source§

fn clone(&self) -> Difficulty

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Difficulty

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl Default for Difficulty

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Difficulty> for InspectDifficulty

Source§

fn from(difficulty: Difficulty) -> Self

Converts to this type from the input type.
Source§

impl From<InspectDifficulty> for Difficulty

Source§

fn from(difficulty: InspectDifficulty) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Difficulty

Source§

fn eq(&self, other: &Difficulty) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Difficulty

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.