Struct rosu_pp::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 const fn with_mode<M: IGameMode>(&self) -> ConvertedDifficulty<'_, M>

Use this Difficulty as a calculator for a specific IGameMode.

Note that ConvertedDifficulty won’t allow to further customize fields so be sure they’re all set before converting to it.

source

pub fn inspect(self) -> InspectDifficulty

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

source

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

Specify mods through their bit values.

See https://github.com/ppy/osu-api/wiki#mods

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 fn calculate(&self, map: &Beatmap) -> DifficultyAttributes

Perform the difficulty calculation.

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 gradual_difficulty(self, map: &Beatmap) -> GradualDifficulty

Create a gradual difficulty calculator for a Beatmap.

source

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

Create a gradual performance calculator for a Beatmap.

Trait Implementations§

source§

impl<M> AsRef<Difficulty> for ConvertedDifficulty<'_, M>

source§

fn as_ref(&self) -> &Difficulty

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Difficulty

source§

fn clone(&self) -> Difficulty

Returns a copy 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<'a, M: IGameMode> From<&'a Difficulty> for ConvertedDifficulty<'a, M>

source§

fn from(difficulty: &'a Difficulty) -> Self

Converts to this type from the input type.
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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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> 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,

§

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>,

§

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>,

§

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.