refactor mania hitwindows
This commit is contained in:
@@ -4,7 +4,7 @@ use crate::{
|
||||
difficulty::{object::ManiaDifficultyObject, skills::strain::Strain},
|
||||
object::{ManiaObject, ObjectParams},
|
||||
},
|
||||
util::{float_ext::FloatExt, mods::Mods},
|
||||
util::float_ext::FloatExt,
|
||||
};
|
||||
|
||||
use super::{attributes::ManiaDifficultyAttributes, convert::ManiaBeatmap};
|
||||
@@ -21,10 +21,12 @@ pub fn difficulty(
|
||||
let n_objects = converted.map.hit_objects.len() as u32;
|
||||
let values = DifficultyValues::calculate(difficulty, converted);
|
||||
|
||||
let mods = difficulty.get_mods();
|
||||
let clock_rate = difficulty.get_clock_rate();
|
||||
let hit_window =
|
||||
(f64::from((get_hit_window(converted, mods) * clock_rate) as i32) / clock_rate).ceil();
|
||||
let hit_window = converted
|
||||
.attributes()
|
||||
.mods(difficulty.get_mods())
|
||||
.clock_rate(difficulty.get_clock_rate())
|
||||
.hit_windows()
|
||||
.od;
|
||||
|
||||
ManiaDifficultyAttributes {
|
||||
stars: values.strain.difficulty_value() * STAR_SCALING_FACTOR,
|
||||
@@ -35,32 +37,6 @@ pub fn difficulty(
|
||||
}
|
||||
}
|
||||
|
||||
fn get_hit_window(converted: &ManiaBeatmap<'_>, mods: u32) -> f64 {
|
||||
fn apply_mod_adjustments(mut value: f64, mods: u32) -> f64 {
|
||||
if mods.hr() {
|
||||
value /= 1.4;
|
||||
} else if mods.ez() {
|
||||
value *= 1.4;
|
||||
}
|
||||
|
||||
value
|
||||
}
|
||||
|
||||
let od = f64::from(converted.map.od);
|
||||
|
||||
if !converted.is_convert {
|
||||
let od = ((10.0 - od).max(0.0)).min(10.0);
|
||||
|
||||
return apply_mod_adjustments(34.0 + 3.0 * od, mods);
|
||||
}
|
||||
|
||||
if od.round_even() > 4.0 {
|
||||
return apply_mod_adjustments(34.0, mods);
|
||||
}
|
||||
|
||||
apply_mod_adjustments(47.0, mods)
|
||||
}
|
||||
|
||||
pub struct DifficultyValues {
|
||||
pub strain: Strain,
|
||||
pub max_combo: u32,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use rosu_map::section::general::GameMode;
|
||||
|
||||
use crate::util::mods::Mods;
|
||||
use crate::util::{float_ext::FloatExt, mods::Mods};
|
||||
|
||||
use super::{converted::Converted, Beatmap};
|
||||
|
||||
@@ -157,7 +157,7 @@ impl BeatmapAttributesBuilder {
|
||||
GameMode::Mania => {
|
||||
let mut value = if !self.is_convert {
|
||||
34.0 + 3.0 * (10.0 - self.od).clamp(0.0, 10.0)
|
||||
} else if self.od > 4.0 {
|
||||
} else if self.od.round_even() > 4.0 {
|
||||
34.0
|
||||
} else {
|
||||
47.0
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
pub trait FloatExt: Sized {
|
||||
// Workaround since rust rounds ties away from 0.0
|
||||
// while C# rounds them to the nearest even integer.
|
||||
// See github
|
||||
// - https://github.com/rust-lang/rust/issues/96710
|
||||
// - https://github.com/rust-lang/rust/pull/82273
|
||||
/// Workaround since rust rounds ties away from 0.0
|
||||
/// while C# rounds them to the nearest even integer.
|
||||
/// See github
|
||||
/// - https://github.com/rust-lang/rust/issues/96710
|
||||
/// - https://github.com/rust-lang/rust/pull/82273
|
||||
fn round_even(self) -> Self;
|
||||
|
||||
/// `self == other`
|
||||
|
||||
Reference in New Issue
Block a user