Struct rosu_pp::osu::OsuPerformance

source ·
pub struct OsuPerformance<'map> { /* private fields */ }
Expand description

Performance calculator on osu!standard maps.

Implementations§

source§

impl<'map> OsuPerformance<'map>

source

pub fn new(map_or_attrs: impl IntoModePerformance<'map, Osu>) -> Self

Create a new performance calculator for osu! maps.

The argument map_or_attrs must be either

If a map is given, difficulty attributes will need to be calculated internally which is a costly operation. Hence, passing attributes should be prefered.

However, when passing previously calculated attributes, make sure they have been calculated for the same map and Difficulty settings. Otherwise, the final attributes will be incorrect.

source

pub fn try_new(map_or_attrs: impl IntoPerformance<'map>) -> Option<Self>

Try to create a new performance calculator for osu! maps.

Returns None if map_or_attrs does not belong to osu! e.g. a Converted, DifficultyAttributes, or PerformanceAttributes of a different mode.

See OsuPerformance::new for more information.

source

pub fn try_mode(self, mode: GameMode) -> Result<Performance<'map>, Self>

Attempt to convert the map to the specified mode.

Returns Err(self) if no beatmap is contained, i.e. if this OsuPerformance was created through attributes or OsuPerformance::generate_state was called.

If the given mode should be ignored in case of an error, use mode_or_ignore instead.

source

pub fn mode_or_ignore(self, mode: GameMode) -> Performance<'map>

Attempt to convert the map to the specified mode.

If the internal beatmap was already replaced with difficulty attributes, the map won’t be modified.

To see whether the internal beatmap was replaced, use try_mode instead.

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 combo(self, combo: u32) -> Self

Specify the max combo of the play.

source

pub const fn hitresult_priority(self, priority: HitResultPriority) -> Self

Specify how hitresults should be generated.

Defauls to HitResultPriority::BestCase.

source

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

Specify the amount of 300s of a play.

source

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

Specify the amount of 100s of a play.

source

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

Specify the amount of 50s of a play.

source

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

Specify the amount of misses of a play.

source

pub const fn difficulty(self, difficulty: Difficulty) -> Self

Use the specified settings of the given Difficulty.

source

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

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

If you want to calculate the performance after every few objects, instead of using OsuPerformance multiple times with different passed_objects, you should use OsuGradualPerformance.

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.

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.

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 state(self, state: OsuScoreState) -> Self

Provide parameters through an OsuScoreState.

source

pub fn accuracy(self, acc: f64) -> Self

Specify the accuracy of a play between 0.0 and 100.0. This will be used to generate matching hitresults.

source

pub fn generate_state(&mut self) -> OsuScoreState

Create the OsuScoreState that will be used for performance calculation.

source

pub fn calculate(self) -> OsuPerformanceAttributes

Calculate all performance related values, including pp and stars.

Trait Implementations§

source§

impl<'map> Clone for OsuPerformance<'map>

source§

fn clone(&self) -> OsuPerformance<'map>

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<'map> Debug for OsuPerformance<'map>

source§

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

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

impl<'map, T: IntoModePerformance<'map, Osu>> From<T> for OsuPerformance<'map>

source§

fn from(into: T) -> Self

Converts to this type from the input type.
source§

impl<'map> PartialEq for OsuPerformance<'map>

source§

fn eq(&self, other: &OsuPerformance<'map>) -> 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<'map> TryFrom<OsuPerformance<'map>> for CatchPerformance<'map>

source§

fn try_from(osu: OsuPerformance<'map>) -> Result<Self, Self::Error>

Try to create CatchPerformance through OsuPerformance.

Returns None if OsuPerformance does not contain a beatmap, i.e. if it was constructed through attributes or OsuPerformance::generate_state was called.

§

type Error = OsuPerformance<'map>

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

impl<'map> TryFrom<OsuPerformance<'map>> for ManiaPerformance<'map>

source§

fn try_from(osu: OsuPerformance<'map>) -> Result<Self, Self::Error>

Try to create ManiaPerformance through OsuPerformance.

Returns None if OsuPerformance does not contain a beatmap, i.e. if it was constructed through attributes or OsuPerformance::generate_state was called.

§

type Error = OsuPerformance<'map>

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

impl<'map> TryFrom<OsuPerformance<'map>> for TaikoPerformance<'map>

source§

fn try_from(osu: OsuPerformance<'map>) -> Result<Self, Self::Error>

Try to create TaikoPerformance through OsuPerformance.

Returns None if OsuPerformance does not contain a beatmap, i.e. if it was constructed through attributes or OsuPerformance::generate_state was called.

§

type Error = OsuPerformance<'map>

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

impl<'map> StructuralPartialEq for OsuPerformance<'map>

Auto Trait Implementations§

§

impl<'map> Freeze for OsuPerformance<'map>

§

impl<'map> RefUnwindSafe for OsuPerformance<'map>

§

impl<'map> Send for OsuPerformance<'map>

§

impl<'map> Sync for OsuPerformance<'map>

§

impl<'map> Unpin for OsuPerformance<'map>

§

impl<'map> UnwindSafe for OsuPerformance<'map>

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.