apply new settings of Difficulty
This commit is contained in:
@@ -49,8 +49,7 @@ use super::{
|
||||
/// [`ManiaGradualPerformance`]: crate::mania::ManiaGradualPerformance
|
||||
pub struct ManiaGradualDifficulty {
|
||||
pub(crate) idx: usize,
|
||||
pub(crate) mods: u32,
|
||||
pub(crate) clock_rate: f64,
|
||||
pub(crate) difficulty: Difficulty,
|
||||
objects_is_circle: Box<[bool]>,
|
||||
is_convert: bool,
|
||||
strain: Strain,
|
||||
@@ -61,18 +60,14 @@ pub struct ManiaGradualDifficulty {
|
||||
|
||||
impl ManiaGradualDifficulty {
|
||||
/// Create a new difficulty attributes iterator for osu!mania maps.
|
||||
pub fn new(difficulty: &Difficulty, converted: &ManiaBeatmap<'_>) -> Self {
|
||||
pub fn new(difficulty: Difficulty, converted: &ManiaBeatmap<'_>) -> Self {
|
||||
let take = difficulty.get_passed_objects();
|
||||
let mods = difficulty.get_mods();
|
||||
let total_columns = converted.cs.round_even().max(1.0);
|
||||
let clock_rate = difficulty.get_clock_rate();
|
||||
let mut params = ObjectParams::new(converted);
|
||||
|
||||
let HitWindows { od: hit_window, .. } = converted
|
||||
.attributes()
|
||||
.mods(mods)
|
||||
.clock_rate(clock_rate)
|
||||
.hit_windows();
|
||||
let HitWindows { od: hit_window, .. } =
|
||||
converted.attributes().difficulty(&difficulty).hit_windows();
|
||||
|
||||
let mania_objects = converted
|
||||
.hit_objects
|
||||
@@ -105,8 +100,7 @@ impl ManiaGradualDifficulty {
|
||||
|
||||
Self {
|
||||
idx: 0,
|
||||
mods,
|
||||
clock_rate,
|
||||
difficulty,
|
||||
objects_is_circle,
|
||||
is_convert: converted.is_convert,
|
||||
strain,
|
||||
@@ -130,7 +124,12 @@ impl Iterator for ManiaGradualDifficulty {
|
||||
Skill::new(&mut self.strain, &self.diff_objects).process(curr);
|
||||
|
||||
let is_circle = self.objects_is_circle[self.idx];
|
||||
increment_combo(is_circle, curr, &mut self.curr_combo, self.clock_rate);
|
||||
increment_combo(
|
||||
is_circle,
|
||||
curr,
|
||||
&mut self.curr_combo,
|
||||
self.difficulty.get_clock_rate(),
|
||||
);
|
||||
} else if self.objects_is_circle.is_empty() {
|
||||
return None;
|
||||
}
|
||||
@@ -168,9 +167,10 @@ impl Iterator for ManiaGradualDifficulty {
|
||||
}
|
||||
|
||||
let mut strain = Skill::new(&mut self.strain, &self.diff_objects);
|
||||
let clock_rate = self.difficulty.get_clock_rate();
|
||||
|
||||
for (curr, is_circle) in skip_iter.take(take) {
|
||||
increment_combo(*is_circle, curr, &mut self.curr_combo, self.clock_rate);
|
||||
increment_combo(*is_circle, curr, &mut self.curr_combo, clock_rate);
|
||||
strain.process(curr);
|
||||
self.idx += 1;
|
||||
}
|
||||
@@ -219,8 +219,7 @@ mod tests {
|
||||
.unwrap()
|
||||
.unchecked_into_converted::<Mania>();
|
||||
|
||||
let difficulty = Difficulty::new();
|
||||
let mut gradual = ManiaGradualDifficulty::new(&difficulty, &converted);
|
||||
let mut gradual = ManiaGradualDifficulty::new(Difficulty::new(), &converted);
|
||||
|
||||
assert!(gradual.next().is_none());
|
||||
}
|
||||
@@ -233,9 +232,9 @@ mod tests {
|
||||
|
||||
let difficulty = Difficulty::new();
|
||||
|
||||
let mut gradual = ManiaGradualDifficulty::new(&difficulty, &converted);
|
||||
let mut gradual_2nd = ManiaGradualDifficulty::new(&difficulty, &converted);
|
||||
let mut gradual_3rd = ManiaGradualDifficulty::new(&difficulty, &converted);
|
||||
let mut gradual = ManiaGradualDifficulty::new(difficulty.clone(), &converted);
|
||||
let mut gradual_2nd = ManiaGradualDifficulty::new(difficulty.clone(), &converted);
|
||||
let mut gradual_3rd = ManiaGradualDifficulty::new(difficulty.clone(), &converted);
|
||||
|
||||
let hit_objects_len = converted.hit_objects.len();
|
||||
|
||||
@@ -257,7 +256,8 @@ mod tests {
|
||||
assert_eq!(next_gradual, next_gradual_3rd);
|
||||
}
|
||||
|
||||
let expected = Difficulty::new()
|
||||
let expected = difficulty
|
||||
.clone()
|
||||
.passed_objects(i as u32)
|
||||
.with_mode()
|
||||
.calculate(&converted);
|
||||
|
||||
@@ -27,8 +27,7 @@ pub fn difficulty(
|
||||
|
||||
let hit_window = converted
|
||||
.attributes()
|
||||
.mods(difficulty.get_mods())
|
||||
.clock_rate(difficulty.get_clock_rate())
|
||||
.difficulty(difficulty)
|
||||
.hit_windows()
|
||||
.od;
|
||||
|
||||
|
||||
+2
-2
@@ -59,14 +59,14 @@ impl IGameMode for Mania {
|
||||
}
|
||||
|
||||
fn gradual_difficulty(
|
||||
difficulty: &Difficulty,
|
||||
difficulty: Difficulty,
|
||||
map: &ManiaBeatmap<'_>,
|
||||
) -> Self::GradualDifficulty {
|
||||
ManiaGradualDifficulty::new(difficulty, map)
|
||||
}
|
||||
|
||||
fn gradual_performance(
|
||||
difficulty: &Difficulty,
|
||||
difficulty: Difficulty,
|
||||
map: &ManiaBeatmap<'_>,
|
||||
) -> Self::GradualPerformance {
|
||||
ManiaGradualPerformance::new(difficulty, map)
|
||||
|
||||
@@ -75,7 +75,7 @@ pub struct ManiaGradualPerformance {
|
||||
|
||||
impl ManiaGradualPerformance {
|
||||
/// Create a new gradual performance calculator for osu!mania maps.
|
||||
pub fn new(difficulty: &Difficulty, converted: &ManiaBeatmap<'_>) -> Self {
|
||||
pub fn new(difficulty: Difficulty, converted: &ManiaBeatmap<'_>) -> Self {
|
||||
let difficulty = ManiaGradualDifficulty::new(difficulty, converted);
|
||||
|
||||
Self { difficulty }
|
||||
@@ -104,8 +104,7 @@ impl ManiaGradualPerformance {
|
||||
.nth(n)?
|
||||
.performance()
|
||||
.state(state)
|
||||
.mods(self.difficulty.mods)
|
||||
.clock_rate(self.difficulty.clock_rate)
|
||||
.difficulty(self.difficulty.difficulty.clone())
|
||||
.passed_objects(self.difficulty.idx as u32)
|
||||
.calculate();
|
||||
|
||||
@@ -128,12 +127,11 @@ mod tests {
|
||||
.unwrap()
|
||||
.unchecked_into_converted::<Mania>();
|
||||
|
||||
let mods = 88; // HDHRDT
|
||||
let difficulty = Difficulty::new().mods(88);
|
||||
let difficulty = Difficulty::new().mods(88); // HDHRDT
|
||||
|
||||
let mut gradual = ManiaGradualPerformance::new(&difficulty, &converted);
|
||||
let mut gradual_2nd = ManiaGradualPerformance::new(&difficulty, &converted);
|
||||
let mut gradual_3rd = ManiaGradualPerformance::new(&difficulty, &converted);
|
||||
let mut gradual = ManiaGradualPerformance::new(difficulty.clone(), &converted);
|
||||
let mut gradual_2nd = ManiaGradualPerformance::new(difficulty.clone(), &converted);
|
||||
let mut gradual_3rd = ManiaGradualPerformance::new(difficulty.clone(), &converted);
|
||||
|
||||
let mut state = ManiaScoreState::default();
|
||||
|
||||
@@ -160,7 +158,7 @@ mod tests {
|
||||
}
|
||||
|
||||
let mut regular_calc = ManiaPerformance::new(converted.as_owned())
|
||||
.mods(mods)
|
||||
.difficulty(difficulty.clone())
|
||||
.passed_objects(i as u32)
|
||||
.state(state.clone());
|
||||
|
||||
|
||||
@@ -64,8 +64,10 @@ impl<'map> ManiaPerformance<'map> {
|
||||
}
|
||||
|
||||
/// Provide the result of a previous difficulty or performance calculation.
|
||||
/// If you already calculated the attributes for the current map-mod combination,
|
||||
/// be sure to put them in here so that they don't have to be recalculated.
|
||||
///
|
||||
/// If you already calculated the attributes for the current
|
||||
/// [`ManiaBeatmap`] and [`Difficulty`], be sure to put them in here so
|
||||
/// that they don't have to be recalculated.
|
||||
pub fn attributes(mut self, attrs: impl ModeAttributeProvider<Mania>) -> Self {
|
||||
if let Some(attrs) = attrs.attributes() {
|
||||
self.map_or_attrs = MapOrAttrs::Attrs(attrs);
|
||||
@@ -83,6 +85,13 @@ impl<'map> ManiaPerformance<'map> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Use the specified settings of the given [`Difficulty`].
|
||||
pub const fn difficulty(mut self, difficulty: Difficulty) -> Self {
|
||||
self.difficulty = difficulty;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Amount of passed objects for partial plays, e.g. a fail.
|
||||
///
|
||||
/// If you want to calculate the performance after every few objects,
|
||||
@@ -97,14 +106,49 @@ impl<'map> ManiaPerformance<'map> {
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
/// | Minimum | Maximum |
|
||||
/// | :-----: | :-----: |
|
||||
/// | 0.01 | 100 |
|
||||
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
|
||||
self.difficulty = self.difficulty.clock_rate(clock_rate);
|
||||
|
||||
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.
|
||||
///
|
||||
/// | Minimum | Maximum |
|
||||
/// | :-----: | :-----: |
|
||||
/// | -20 | 20 |
|
||||
pub fn hp(mut self, hp: f32, with_mods: bool) -> Self {
|
||||
self.difficulty = self.difficulty.hp(hp, with_mods);
|
||||
|
||||
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.
|
||||
///
|
||||
/// | Minimum | Maximum |
|
||||
/// | :-----: | :-----: |
|
||||
/// | -20 | 20 |
|
||||
pub fn od(mut self, od: f32, with_mods: bool) -> Self {
|
||||
self.difficulty = self.difficulty.od(od, with_mods);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Specify the accuracy of a play between `0.0` and `100.0`.
|
||||
/// This will be used to generate matching hitresults.
|
||||
pub fn accuracy(mut self, acc: f64) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user