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