added 'state' methods to PP calculator structs
This commit is contained in:
@@ -156,16 +156,11 @@ impl<'map> OsuGradualPerformanceAttributes<'map> {
|
||||
let n = n.min(self.difficulty.len()).saturating_sub(1);
|
||||
let difficulty = self.difficulty.nth(n)?;
|
||||
|
||||
let _ = self.performance.n300.insert(state.n300);
|
||||
let _ = self.performance.n100.insert(state.n100);
|
||||
let _ = self.performance.n50.insert(state.n50);
|
||||
self.performance.n_misses = state.misses;
|
||||
|
||||
let performance = self
|
||||
.performance
|
||||
.clone()
|
||||
.attributes(difficulty)
|
||||
.combo(state.max_combo)
|
||||
.state(state)
|
||||
.passed_objects(self.difficulty.idx)
|
||||
.calculate();
|
||||
|
||||
|
||||
+22
-2
@@ -1,4 +1,4 @@
|
||||
use super::{OsuDifficultyAttributes, OsuPerformanceAttributes};
|
||||
use super::{OsuDifficultyAttributes, OsuPerformanceAttributes, OsuScoreState};
|
||||
use crate::{Beatmap, DifficultyAttributes, Mods, PerformanceAttributes};
|
||||
|
||||
/// Performance calculator on osu!standard maps.
|
||||
@@ -131,7 +131,7 @@ impl<'map> OsuPP<'map> {
|
||||
///
|
||||
/// If you want to calculate the performance after every few objects, instead of
|
||||
/// using [`OsuPP`] multiple times with different `passed_objects`, you should use
|
||||
/// [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualDifficultyAttributes).
|
||||
/// [`OsuGradualPerformanceAttributes`](crate::osu::OsuGradualPerformanceAttributes).
|
||||
#[inline]
|
||||
pub fn passed_objects(mut self, passed_objects: usize) -> Self {
|
||||
self.passed_objects.replace(passed_objects);
|
||||
@@ -139,6 +139,26 @@ impl<'map> OsuPP<'map> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Provide parameters through an [`OsuScoreState`].
|
||||
#[inline]
|
||||
pub fn state(mut self, state: OsuScoreState) -> Self {
|
||||
let OsuScoreState {
|
||||
max_combo,
|
||||
n300,
|
||||
n100,
|
||||
n50,
|
||||
misses,
|
||||
} = state;
|
||||
|
||||
self.combo = Some(max_combo);
|
||||
self.n300 = Some(n300);
|
||||
self.n100 = Some(n100);
|
||||
self.n50 = Some(n50);
|
||||
self.n_misses = misses;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Generate the hit results with respect to the given accuracy between `0` and `100`.
|
||||
///
|
||||
/// Be sure to set `misses` beforehand!
|
||||
|
||||
Reference in New Issue
Block a user