pub enum GradualPerformance {
    Osu(OsuGradualPerformance),
    Taiko(TaikoGradualPerformance),
    Catch(CatchGradualPerformance),
    Mania(ManiaGradualPerformance),
}
Expand description

Gradually calculate the performance attributes on maps of any mode.

After each hit object you can call next and it will return the resulting current PerformanceAttributes. To process multiple objects at the once, use nth instead.

Both methods require a ScoreState that contains the current hitresults as well as the maximum combo so far. Since the map could have any mode, all fields of ScoreState could be of use and should be updated properly.

Alternatively, you can match on the map’s mode yourself and use the gradual performance attribute struct for the corresponding mode, i.e. OsuGradualPerformance, TaikoGradualPerformance, CatchGradualPerformance, or ManiaGradualPerformance.

If you only want to calculate difficulty attributes use GradualDifficulty instead.

§Example

use rosu_pp::{Beatmap, GradualPerformance, Difficulty, any::ScoreState};

let map = Beatmap::from_path("./resources/2785319.osu").unwrap();
let difficulty = Difficulty::new().mods(64); // DT
let mut gradual = GradualPerformance::new(difficulty, &map);
let mut state = ScoreState::new(); // empty state, everything is on 0.

// The first 10 hitresults are 300s
for _ in 0..10 {
    state.n300 += 1;
    state.max_combo += 1;

    let attrs = gradual.next(state.clone()).unwrap();
    println!("PP: {}", attrs.pp());
}

// Then comes a miss.
// Note that state's max combo won't be incremented for
// the next few objects because the combo is reset.
state.misses += 1;

let attrs = gradual.next(state.clone()).unwrap();
println!("PP: {}", attrs.pp());

// The next 10 objects will be a mixture of 300s, 100s, and 50s.
// Notice how all 10 objects will be processed in one go.
state.n300 += 2;
state.n100 += 7;
state.n50 += 1;

// The `nth` method takes a zero-based value.
let attrs = gradual.nth(state.clone(), 9).unwrap();
println!("PP: {}", attrs.pp());

// Now comes another 300. Note that the max combo gets incremented again.
state.n300 += 1;
state.max_combo += 1;

let attrs = gradual.next(state.clone()).unwrap();
println!("PP: {}", attrs.pp());

// Skip to the end
state.max_combo = ...
state.n300 = ...
...
let attrs = gradual.last(state.clone()).unwrap();
println!("PP: {}", attrs.pp());

// Once the final performance has been calculated, attempting to process
// further objects will return `None`.
assert!(gradual.next(state).is_none());

Variants§

Implementations§

source§

impl GradualPerformance

source

pub fn new(difficulty: Difficulty, map: &Beatmap) -> Self

Create a GradualPerformance for a map of any mode.

source

pub fn from_osu_map(difficulty: Difficulty, converted: &OsuBeatmap<'_>) -> Self

source

pub fn from_taiko_map( difficulty: Difficulty, converted: &TaikoBeatmap<'_> ) -> Self

source

pub fn from_catch_map( difficulty: Difficulty, converted: &CatchBeatmap<'_> ) -> Self

source

pub fn from_mania_map( difficulty: Difficulty, converted: &ManiaBeatmap<'_> ) -> Self

source

pub fn next(&mut self, state: ScoreState) -> Option<PerformanceAttributes>

Process the next hit object and calculate the performance attributes for the resulting score state.

source

pub fn last(&mut self, state: ScoreState) -> Option<PerformanceAttributes>

Process all remaining hit objects and calculate the final performance attributes.

source

pub fn nth( &mut self, state: ScoreState, n: usize ) -> Option<PerformanceAttributes>

Process everything up to the next nth hitobject and calculate the performance attributes for the resulting score state.

Note that the count is zero-indexed, so n=0 will process 1 object, n=1 will process 2, and so on.

source

pub fn len(&self) -> usize

Returns the amount of remaining objects.

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