Struct rosu_pp::mania::ManiaGradualPerformance
source · pub struct ManiaGradualPerformance { /* private fields */ }
Expand description
Gradually calculate the performance attributes of an osu!mania map.
After each hit object you can call next
and it will return the
resulting current ManiaPerformanceAttributes
. To process multiple
objects at once, use nth
instead.
Both methods require a play’s current score so far. Be sure the given score is adjusted with respect to mods.
If you only want to calculate difficulty attributes use
ManiaGradualDifficulty
instead.
§Example
use rosu_pp::{Beatmap, Difficulty};
use rosu_pp::mania::{Mania, ManiaGradualPerformance, ManiaScoreState};
let converted = Beatmap::from_path("./resources/1638954.osu")
.unwrap()
.unchecked_into_converted::<Mania>();
let difficulty = Difficulty::new().mods(64); // DT
let mut gradual = ManiaGradualPerformance::new(difficulty, &converted);
let mut state = ManiaScoreState::new(); // empty state, everything is on 0.
// The first 10 hitresults are 320s
for _ in 0..10 {
state.n320 += 1;
let attrs = gradual.next(state.clone()).unwrap();
println!("PP: {}", attrs.pp);
}
// Then comes a miss.
state.misses += 1;
let attrs = gradual.next(state.clone()).unwrap();
println!("PP: {}", attrs.pp);
// The next 10 objects will be a mixture of 320s and 100s.
// Notice how all 10 objects will be processed in one go.
state.n320 += 3;
state.n100 += 7;
// The `nth` method takes a zero-based value.
let attrs = gradual.nth(state.clone(), 9).unwrap();
println!("PP: {}", attrs.pp);
// Skip to the end
state.max_combo = ...
state.n300 = ...
state.n100 = ...
state.misses = ...
let attrs = gradual.last(state.clone()).unwrap();
println!("PP: {}", attrs.pp);
// Once the final performance was calculated,
// attempting to process further objects will return `None`.
assert!(gradual.next(state).is_none());
Implementations§
source§impl ManiaGradualPerformance
impl ManiaGradualPerformance
sourcepub fn new(difficulty: Difficulty, converted: &ManiaBeatmap<'_>) -> Self
pub fn new(difficulty: Difficulty, converted: &ManiaBeatmap<'_>) -> Self
Create a new gradual performance calculator for osu!mania maps.
sourcepub fn next(
&mut self,
state: ManiaScoreState
) -> Option<ManiaPerformanceAttributes>
pub fn next( &mut self, state: ManiaScoreState ) -> Option<ManiaPerformanceAttributes>
Process the next hit object and calculate the performance attributes for the resulting score.
sourcepub fn last(
&mut self,
state: ManiaScoreState
) -> Option<ManiaPerformanceAttributes>
pub fn last( &mut self, state: ManiaScoreState ) -> Option<ManiaPerformanceAttributes>
Process all remaining hit objects and calculate the final performance attributes.
sourcepub fn nth(
&mut self,
state: ManiaScoreState,
n: usize
) -> Option<ManiaPerformanceAttributes>
pub fn nth( &mut self, state: ManiaScoreState, n: usize ) -> Option<ManiaPerformanceAttributes>
Process everything up the the next n
th hit object 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.