dont store map in gradual mania calc
This commit is contained in:
@@ -1,10 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
any::difficulty::skills::Skill,
|
any::difficulty::skills::Skill,
|
||||||
mania::{object::ObjectParams, ManiaBeatmap},
|
mania::{object::ObjectParams, ManiaBeatmap},
|
||||||
model::{
|
model::{beatmap::HitWindows, hit_object::HitObject},
|
||||||
beatmap::HitWindows,
|
|
||||||
hit_object::{HitObject, HitObjectKind},
|
|
||||||
},
|
|
||||||
util::float_ext::FloatExt,
|
util::float_ext::FloatExt,
|
||||||
ModeDifficulty,
|
ModeDifficulty,
|
||||||
};
|
};
|
||||||
@@ -48,20 +45,21 @@ use super::{
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`ManiaGradualPerformance`]: crate::mania::ManiaGradualPerformance
|
/// [`ManiaGradualPerformance`]: crate::mania::ManiaGradualPerformance
|
||||||
pub struct ManiaGradualDifficulty<'map> {
|
pub struct ManiaGradualDifficulty {
|
||||||
pub(crate) idx: usize,
|
pub(crate) idx: usize,
|
||||||
pub(crate) mods: u32,
|
pub(crate) mods: u32,
|
||||||
pub(crate) clock_rate: f64,
|
pub(crate) clock_rate: f64,
|
||||||
converted: ManiaBeatmap<'map>,
|
objects_is_circle: Box<[bool]>,
|
||||||
|
is_convert: bool,
|
||||||
strain: Strain,
|
strain: Strain,
|
||||||
diff_objects: Box<[ManiaDifficultyObject]>,
|
diff_objects: Box<[ManiaDifficultyObject]>,
|
||||||
hit_window: f64,
|
hit_window: f64,
|
||||||
curr_combo: u32,
|
curr_combo: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'map> ManiaGradualDifficulty<'map> {
|
impl ManiaGradualDifficulty {
|
||||||
/// Create a new difficulty attributes iterator for osu!mania maps.
|
/// Create a new difficulty attributes iterator for osu!mania maps.
|
||||||
pub fn new(difficulty: &ModeDifficulty, converted: ManiaBeatmap<'map>) -> Self {
|
pub fn new(difficulty: &ModeDifficulty, converted: &ManiaBeatmap<'_>) -> Self {
|
||||||
let take = difficulty.get_passed_objects();
|
let take = difficulty.get_passed_objects();
|
||||||
let mods = difficulty.get_mods();
|
let mods = difficulty.get_mods();
|
||||||
let total_columns = converted.map.cs.round_even().max(1.0);
|
let total_columns = converted.map.cs.round_even().max(1.0);
|
||||||
@@ -87,11 +85,18 @@ impl<'map> ManiaGradualDifficulty<'map> {
|
|||||||
|
|
||||||
let mut curr_combo = 0;
|
let mut curr_combo = 0;
|
||||||
|
|
||||||
|
let objects_is_circle: Box<[_]> = converted
|
||||||
|
.map
|
||||||
|
.hit_objects
|
||||||
|
.iter()
|
||||||
|
.map(HitObject::is_circle)
|
||||||
|
.collect();
|
||||||
|
|
||||||
if let Some(h) = converted.map.hit_objects.first() {
|
if let Some(h) = converted.map.hit_objects.first() {
|
||||||
let hit_object = ManiaObject::new(h, total_columns, &mut params);
|
let hit_object = ManiaObject::new(h, total_columns, &mut params);
|
||||||
|
|
||||||
increment_combo_raw(
|
increment_combo_raw(
|
||||||
h,
|
objects_is_circle[0],
|
||||||
hit_object.start_time,
|
hit_object.start_time,
|
||||||
hit_object.end_time,
|
hit_object.end_time,
|
||||||
&mut curr_combo,
|
&mut curr_combo,
|
||||||
@@ -102,7 +107,8 @@ impl<'map> ManiaGradualDifficulty<'map> {
|
|||||||
idx: 0,
|
idx: 0,
|
||||||
mods,
|
mods,
|
||||||
clock_rate,
|
clock_rate,
|
||||||
converted,
|
objects_is_circle,
|
||||||
|
is_convert: converted.is_convert,
|
||||||
strain,
|
strain,
|
||||||
diff_objects,
|
diff_objects,
|
||||||
hit_window,
|
hit_window,
|
||||||
@@ -111,7 +117,7 @@ impl<'map> ManiaGradualDifficulty<'map> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for ManiaGradualDifficulty<'_> {
|
impl Iterator for ManiaGradualDifficulty {
|
||||||
type Item = ManiaDifficultyAttributes;
|
type Item = ManiaDifficultyAttributes;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
@@ -123,9 +129,9 @@ impl Iterator for ManiaGradualDifficulty<'_> {
|
|||||||
let curr = self.diff_objects.get(self.idx - 1)?;
|
let curr = self.diff_objects.get(self.idx - 1)?;
|
||||||
Skill::new(&mut self.strain, &self.diff_objects).process(curr);
|
Skill::new(&mut self.strain, &self.diff_objects).process(curr);
|
||||||
|
|
||||||
let h = &self.converted.map.hit_objects[self.idx];
|
let is_circle = self.objects_is_circle[self.idx];
|
||||||
increment_combo(h, curr, &mut self.curr_combo, self.clock_rate);
|
increment_combo(is_circle, curr, &mut self.curr_combo, self.clock_rate);
|
||||||
} else if self.converted.map.hit_objects.is_empty() {
|
} else if self.objects_is_circle.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +142,7 @@ impl Iterator for ManiaGradualDifficulty<'_> {
|
|||||||
hit_window: self.hit_window,
|
hit_window: self.hit_window,
|
||||||
max_combo: self.curr_combo,
|
max_combo: self.curr_combo,
|
||||||
n_objects: self.idx as u32,
|
n_objects: self.idx as u32,
|
||||||
is_convert: self.converted.is_convert,
|
is_convert: self.is_convert,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +156,7 @@ impl Iterator for ManiaGradualDifficulty<'_> {
|
|||||||
let skip_iter = self
|
let skip_iter = self
|
||||||
.diff_objects
|
.diff_objects
|
||||||
.iter()
|
.iter()
|
||||||
.zip(self.converted.map.hit_objects.iter().skip(1))
|
.zip(self.objects_is_circle.iter().skip(1))
|
||||||
.skip(self.idx.saturating_sub(1));
|
.skip(self.idx.saturating_sub(1));
|
||||||
|
|
||||||
let mut take = n.min(self.len().saturating_sub(1));
|
let mut take = n.min(self.len().saturating_sub(1));
|
||||||
@@ -163,8 +169,8 @@ impl Iterator for ManiaGradualDifficulty<'_> {
|
|||||||
|
|
||||||
let mut strain = Skill::new(&mut self.strain, &self.diff_objects);
|
let mut strain = Skill::new(&mut self.strain, &self.diff_objects);
|
||||||
|
|
||||||
for (curr, h) in skip_iter.take(take) {
|
for (curr, is_circle) in skip_iter.take(take) {
|
||||||
increment_combo(h, curr, &mut self.curr_combo, self.clock_rate);
|
increment_combo(*is_circle, curr, &mut self.curr_combo, self.clock_rate);
|
||||||
strain.process(curr);
|
strain.process(curr);
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
}
|
}
|
||||||
@@ -173,30 +179,31 @@ impl Iterator for ManiaGradualDifficulty<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExactSizeIterator for ManiaGradualDifficulty<'_> {
|
impl ExactSizeIterator for ManiaGradualDifficulty {
|
||||||
fn len(&self) -> usize {
|
fn len(&self) -> usize {
|
||||||
self.diff_objects.len() + 1 - self.idx
|
self.diff_objects.len() + 1 - self.idx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn increment_combo(
|
fn increment_combo(
|
||||||
h: &HitObject,
|
is_circle: bool,
|
||||||
diff_obj: &ManiaDifficultyObject,
|
diff_obj: &ManiaDifficultyObject,
|
||||||
curr_combo: &mut u32,
|
curr_combo: &mut u32,
|
||||||
clock_rate: f64,
|
clock_rate: f64,
|
||||||
) {
|
) {
|
||||||
increment_combo_raw(
|
increment_combo_raw(
|
||||||
h,
|
is_circle,
|
||||||
diff_obj.start_time * clock_rate,
|
diff_obj.start_time * clock_rate,
|
||||||
diff_obj.end_time * clock_rate,
|
diff_obj.end_time * clock_rate,
|
||||||
curr_combo,
|
curr_combo,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn increment_combo_raw(h: &HitObject, start_time: f64, end_time: f64, curr_combo: &mut u32) {
|
fn increment_combo_raw(is_circle: bool, start_time: f64, end_time: f64, curr_combo: &mut u32) {
|
||||||
match h.kind {
|
if is_circle {
|
||||||
HitObjectKind::Circle => *curr_combo += 1,
|
*curr_combo += 1;
|
||||||
_ => *curr_combo += 1 + ((end_time - start_time) / 100.0) as u32,
|
} else {
|
||||||
|
*curr_combo += 1 + ((end_time - start_time) / 100.0) as u32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +220,7 @@ mod tests {
|
|||||||
.unchecked_into_converted::<Mania>();
|
.unchecked_into_converted::<Mania>();
|
||||||
|
|
||||||
let difficulty = ModeDifficulty::new();
|
let difficulty = ModeDifficulty::new();
|
||||||
let mut gradual = ManiaGradualDifficulty::new(&difficulty, converted);
|
let mut gradual = ManiaGradualDifficulty::new(&difficulty, &converted);
|
||||||
|
|
||||||
assert!(gradual.next().is_none());
|
assert!(gradual.next().is_none());
|
||||||
}
|
}
|
||||||
@@ -226,9 +233,9 @@ mod tests {
|
|||||||
|
|
||||||
let difficulty = ModeDifficulty::new();
|
let difficulty = ModeDifficulty::new();
|
||||||
|
|
||||||
let mut gradual = ManiaGradualDifficulty::new(&difficulty, converted.as_owned());
|
let mut gradual = ManiaGradualDifficulty::new(&difficulty, &converted);
|
||||||
let mut gradual_2nd = ManiaGradualDifficulty::new(&difficulty, converted.as_owned());
|
let mut gradual_2nd = ManiaGradualDifficulty::new(&difficulty, &converted);
|
||||||
let mut gradual_3rd = ManiaGradualDifficulty::new(&difficulty, converted.as_owned());
|
let mut gradual_3rd = ManiaGradualDifficulty::new(&difficulty, &converted);
|
||||||
|
|
||||||
let hit_objects_len = converted.map.hit_objects.len();
|
let hit_objects_len = converted.map.hit_objects.len();
|
||||||
|
|
||||||
|
|||||||
@@ -69,13 +69,13 @@ use super::{ManiaPerformanceAttributes, ManiaScoreState};
|
|||||||
///
|
///
|
||||||
/// [`next`]: ManiaGradualPerformance::next
|
/// [`next`]: ManiaGradualPerformance::next
|
||||||
/// [`nth`]: ManiaGradualPerformance::nth
|
/// [`nth`]: ManiaGradualPerformance::nth
|
||||||
pub struct ManiaGradualPerformance<'map> {
|
pub struct ManiaGradualPerformance {
|
||||||
difficulty: ManiaGradualDifficulty<'map>,
|
difficulty: ManiaGradualDifficulty,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'map> ManiaGradualPerformance<'map> {
|
impl ManiaGradualPerformance {
|
||||||
/// Create a new gradual performance calculator for osu!mania maps.
|
/// Create a new gradual performance calculator for osu!mania maps.
|
||||||
pub fn new(difficulty: &ModeDifficulty, converted: ManiaBeatmap<'map>) -> Self {
|
pub fn new(difficulty: &ModeDifficulty, converted: &ManiaBeatmap<'_>) -> Self {
|
||||||
let difficulty = ManiaGradualDifficulty::new(difficulty, converted);
|
let difficulty = ManiaGradualDifficulty::new(difficulty, converted);
|
||||||
|
|
||||||
Self { difficulty }
|
Self { difficulty }
|
||||||
@@ -131,9 +131,9 @@ mod tests {
|
|||||||
let mods = 88; // HDHRDT
|
let mods = 88; // HDHRDT
|
||||||
let difficulty = ModeDifficulty::new().mods(88);
|
let difficulty = ModeDifficulty::new().mods(88);
|
||||||
|
|
||||||
let mut gradual = ManiaGradualPerformance::new(&difficulty, converted.as_owned());
|
let mut gradual = ManiaGradualPerformance::new(&difficulty, &converted);
|
||||||
let mut gradual_2nd = ManiaGradualPerformance::new(&difficulty, converted.as_owned());
|
let mut gradual_2nd = ManiaGradualPerformance::new(&difficulty, &converted);
|
||||||
let mut gradual_3rd = ManiaGradualPerformance::new(&difficulty, converted.as_owned());
|
let mut gradual_3rd = ManiaGradualPerformance::new(&difficulty, &converted);
|
||||||
|
|
||||||
let mut state = ManiaScoreState::default();
|
let mut state = ManiaScoreState::default();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user