restructure Difficulty and ModeDifficulty
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::{
|
||||
CatchBeatmap, CatchDifficultyAttributes,
|
||||
},
|
||||
util::mods::Mods,
|
||||
ModeDifficulty,
|
||||
Difficulty,
|
||||
};
|
||||
|
||||
use super::{
|
||||
@@ -32,14 +32,14 @@ use super::{
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use rosu_pp::{Beatmap, ModeDifficulty};
|
||||
/// use rosu_pp::{Beatmap, Difficulty};
|
||||
/// use rosu_pp::catch::{Catch, CatchGradualDifficulty};
|
||||
///
|
||||
/// let converted = Beatmap::from_path("./resources/2118524.osu")
|
||||
/// .unwrap()
|
||||
/// .unchecked_into_converted::<Catch>();
|
||||
///
|
||||
/// let difficulty = ModeDifficulty::new().mods(64); // DT
|
||||
/// let difficulty = Difficulty::new().mods(64); // DT
|
||||
/// let mut iter = CatchGradualDifficulty::new(&difficulty, &converted);
|
||||
///
|
||||
/// // the difficulty of the map after the first hit object
|
||||
@@ -66,7 +66,7 @@ pub struct CatchGradualDifficulty {
|
||||
}
|
||||
|
||||
impl CatchGradualDifficulty {
|
||||
pub fn new(difficulty: &ModeDifficulty, converted: &CatchBeatmap<'_>) -> Self {
|
||||
pub fn new(difficulty: &Difficulty, converted: &CatchBeatmap<'_>) -> Self {
|
||||
let mods = difficulty.get_mods();
|
||||
let clock_rate = difficulty.get_clock_rate();
|
||||
|
||||
@@ -163,7 +163,7 @@ impl ExactSizeIterator for CatchGradualDifficulty {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::Beatmap;
|
||||
use crate::{any::difficulty::converted::ConvertedDifficulty, Beatmap};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -171,7 +171,7 @@ mod tests {
|
||||
fn empty() {
|
||||
let converted = Beatmap::from_bytes(&[]).unwrap().unchecked_into_converted();
|
||||
|
||||
let difficulty = ModeDifficulty::new();
|
||||
let difficulty = Difficulty::new();
|
||||
let mut gradual = CatchGradualDifficulty::new(&difficulty, &converted);
|
||||
|
||||
assert!(gradual.next().is_none());
|
||||
@@ -183,7 +183,7 @@ mod tests {
|
||||
.unwrap()
|
||||
.unchecked_into_converted();
|
||||
|
||||
let difficulty = ModeDifficulty::new();
|
||||
let difficulty = Difficulty::new();
|
||||
|
||||
let mut gradual = CatchGradualDifficulty::new(&difficulty, &converted);
|
||||
let mut gradual_2nd = CatchGradualDifficulty::new(&difficulty, &converted);
|
||||
@@ -207,7 +207,7 @@ mod tests {
|
||||
assert_eq!(next_gradual, next_gradual_3rd);
|
||||
}
|
||||
|
||||
let expected = ModeDifficulty::new()
|
||||
let expected = ConvertedDifficulty::new()
|
||||
.passed_objects(i as u32)
|
||||
.calculate(&converted);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
any::difficulty::{mode::ModeDifficulty, skills::Skill},
|
||||
any::difficulty::{skills::Skill, Difficulty},
|
||||
catch::{
|
||||
catcher::Catcher, convert::convert_objects, difficulty::object::CatchDifficultyObject,
|
||||
},
|
||||
@@ -22,7 +22,7 @@ mod skills;
|
||||
const STAR_SCALING_FACTOR: f64 = 0.153;
|
||||
|
||||
pub fn difficulty(
|
||||
difficulty: &ModeDifficulty,
|
||||
difficulty: &Difficulty,
|
||||
converted: &CatchBeatmap<'_>,
|
||||
) -> CatchDifficultyAttributes {
|
||||
let DifficultyValues {
|
||||
@@ -41,7 +41,7 @@ pub struct CatchDifficultySetup {
|
||||
}
|
||||
|
||||
impl CatchDifficultySetup {
|
||||
pub fn new(difficulty: &ModeDifficulty, converted: &CatchBeatmap<'_>) -> Self {
|
||||
pub fn new(difficulty: &Difficulty, converted: &CatchBeatmap<'_>) -> Self {
|
||||
let mods = difficulty.get_mods();
|
||||
let clock_rate = difficulty.get_clock_rate();
|
||||
|
||||
@@ -67,7 +67,7 @@ pub struct DifficultyValues {
|
||||
}
|
||||
|
||||
impl DifficultyValues {
|
||||
pub fn calculate(difficulty: &ModeDifficulty, converted: &CatchBeatmap<'_>) -> Self {
|
||||
pub fn calculate(difficulty: &Difficulty, converted: &CatchBeatmap<'_>) -> Self {
|
||||
let take = difficulty.get_passed_objects();
|
||||
let mods = difficulty.get_mods();
|
||||
let clock_rate = difficulty.get_clock_rate();
|
||||
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
use crate::{
|
||||
any::ModeDifficulty,
|
||||
model::{
|
||||
beatmap::Beatmap,
|
||||
mode::{ConvertStatus, IGameMode},
|
||||
},
|
||||
Difficulty,
|
||||
};
|
||||
|
||||
pub use self::{
|
||||
@@ -47,13 +47,13 @@ impl IGameMode for Catch {
|
||||
}
|
||||
|
||||
fn difficulty(
|
||||
difficulty: &ModeDifficulty,
|
||||
difficulty: &Difficulty,
|
||||
converted: &CatchBeatmap<'_>,
|
||||
) -> Self::DifficultyAttributes {
|
||||
difficulty::difficulty(difficulty, converted)
|
||||
}
|
||||
|
||||
fn strains(difficulty: &ModeDifficulty, converted: &CatchBeatmap<'_>) -> Self::Strains {
|
||||
fn strains(difficulty: &Difficulty, converted: &CatchBeatmap<'_>) -> Self::Strains {
|
||||
strains::strains(difficulty, converted)
|
||||
}
|
||||
|
||||
@@ -62,14 +62,14 @@ impl IGameMode for Catch {
|
||||
}
|
||||
|
||||
fn gradual_difficulty(
|
||||
difficulty: &ModeDifficulty,
|
||||
difficulty: &Difficulty,
|
||||
map: &CatchBeatmap<'_>,
|
||||
) -> Self::GradualDifficulty {
|
||||
CatchGradualDifficulty::new(difficulty, map)
|
||||
}
|
||||
|
||||
fn gradual_performance(
|
||||
difficulty: &ModeDifficulty,
|
||||
difficulty: &Difficulty,
|
||||
map: &CatchBeatmap<'_>,
|
||||
) -> Self::GradualPerformance {
|
||||
CatchGradualPerformance::new(difficulty, map)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
catch::{CatchBeatmap, CatchGradualDifficulty, CatchPerformanceAttributes, CatchScoreState},
|
||||
ModeDifficulty,
|
||||
Difficulty,
|
||||
};
|
||||
|
||||
/// Gradually calculate the performance attributes of an osu!catch map.
|
||||
@@ -21,14 +21,14 @@ use crate::{
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use rosu_pp::{Beatmap, ModeDifficulty};
|
||||
/// use rosu_pp::{Beatmap, Difficulty};
|
||||
/// use rosu_pp::catch::{Catch, CatchGradualPerformance, CatchScoreState};
|
||||
///
|
||||
/// let converted = Beatmap::from_path("./resources/2118524.osu")
|
||||
/// .unwrap()
|
||||
/// .unchecked_into_converted::<Catch>();
|
||||
///
|
||||
/// let difficulty = ModeDifficulty::new().mods(64); // DT
|
||||
/// let difficulty = Difficulty::new().mods(64); // DT
|
||||
/// let mut gradual = CatchGradualPerformance::new(&difficulty, &converted);
|
||||
/// let mut state = CatchScoreState::new(); // empty state, everything is on 0.
|
||||
///
|
||||
@@ -90,7 +90,7 @@ pub struct CatchGradualPerformance {
|
||||
|
||||
impl CatchGradualPerformance {
|
||||
/// Create a new gradual performance calculator for osu!catch maps.
|
||||
pub fn new(difficulty: &ModeDifficulty, converted: &CatchBeatmap<'_>) -> Self {
|
||||
pub fn new(difficulty: &Difficulty, converted: &CatchBeatmap<'_>) -> Self {
|
||||
let difficulty = CatchGradualDifficulty::new(difficulty, converted);
|
||||
|
||||
Self { difficulty }
|
||||
@@ -144,7 +144,7 @@ mod tests {
|
||||
.unchecked_into_converted();
|
||||
|
||||
let mods = 88; // HDHRDT
|
||||
let difficulty = ModeDifficulty::new().mods(88);
|
||||
let difficulty = Difficulty::new().mods(88);
|
||||
|
||||
let mut gradual = CatchGradualPerformance::new(&difficulty, &converted);
|
||||
let mut gradual_2nd = CatchGradualPerformance::new(&difficulty, &converted);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use std::cmp::{self, Ordering};
|
||||
|
||||
use crate::{
|
||||
any::ModeAttributeProvider,
|
||||
any::ModeDifficulty,
|
||||
any::{Difficulty, ModeAttributeProvider},
|
||||
osu::OsuPerformance,
|
||||
util::{map_or_attrs::MapOrAttrs, mods::Mods},
|
||||
};
|
||||
@@ -21,7 +20,7 @@ pub mod gradual;
|
||||
#[must_use]
|
||||
pub struct CatchPerformance<'map> {
|
||||
map_or_attrs: MapOrAttrs<'map, Catch>,
|
||||
difficulty: ModeDifficulty,
|
||||
difficulty: Difficulty,
|
||||
acc: Option<f64>,
|
||||
combo: Option<u32>,
|
||||
fruits: Option<u32>,
|
||||
@@ -36,7 +35,7 @@ impl<'map> CatchPerformance<'map> {
|
||||
pub const fn new(map: CatchBeatmap<'map>) -> Self {
|
||||
Self {
|
||||
map_or_attrs: MapOrAttrs::Map(map),
|
||||
difficulty: ModeDifficulty::new(),
|
||||
difficulty: Difficulty::new(),
|
||||
acc: None,
|
||||
combo: None,
|
||||
fruits: None,
|
||||
@@ -50,7 +49,7 @@ impl<'map> CatchPerformance<'map> {
|
||||
pub(crate) const fn from_catch_attributes(attrs: CatchDifficultyAttributes) -> Self {
|
||||
Self {
|
||||
map_or_attrs: MapOrAttrs::Attrs(attrs),
|
||||
difficulty: ModeDifficulty::new(),
|
||||
difficulty: Difficulty::new(),
|
||||
acc: None,
|
||||
combo: None,
|
||||
fruits: None,
|
||||
@@ -180,7 +179,7 @@ impl<'map> CatchPerformance<'map> {
|
||||
pub fn generate_state(&mut self) -> CatchScoreState {
|
||||
let attrs = match self.map_or_attrs {
|
||||
MapOrAttrs::Map(ref map) => {
|
||||
let attrs = self.generate_attributes(map);
|
||||
let attrs = self.difficulty.with_mode().calculate(map);
|
||||
|
||||
self.map_or_attrs.insert_attrs(attrs)
|
||||
}
|
||||
@@ -327,7 +326,7 @@ impl<'map> CatchPerformance<'map> {
|
||||
let state = self.generate_state();
|
||||
|
||||
let attrs = match self.map_or_attrs {
|
||||
MapOrAttrs::Map(ref map) => self.generate_attributes(map),
|
||||
MapOrAttrs::Map(ref map) => self.difficulty.with_mode().calculate(map),
|
||||
MapOrAttrs::Attrs(attrs) => attrs,
|
||||
};
|
||||
|
||||
@@ -340,10 +339,6 @@ impl<'map> CatchPerformance<'map> {
|
||||
inner.calculate()
|
||||
}
|
||||
|
||||
fn generate_attributes(&self, map: &CatchBeatmap<'_>) -> CatchDifficultyAttributes {
|
||||
self.difficulty.calculate(map)
|
||||
}
|
||||
|
||||
/// Try to create [`CatchPerformance`] through a [`ModeAttributeProvider`].
|
||||
///
|
||||
/// If you already calculated the attributes for the current map-mod
|
||||
@@ -547,7 +542,7 @@ mod test {
|
||||
|
||||
use proptest::prelude::*;
|
||||
|
||||
use crate::Beatmap;
|
||||
use crate::{any::difficulty::converted::ConvertedDifficulty, Beatmap};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -564,7 +559,7 @@ mod test {
|
||||
.unwrap()
|
||||
.unchecked_into_converted::<Catch>();
|
||||
|
||||
let attrs = ModeDifficulty::new().calculate(&converted);
|
||||
let attrs = ConvertedDifficulty::new().calculate(&converted);
|
||||
|
||||
assert_eq!(N_FRUITS, attrs.n_fruits);
|
||||
assert_eq!(N_DROPLETS, attrs.n_droplets);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{any::ModeDifficulty, catch::difficulty::DifficultyValues};
|
||||
use crate::{any::Difficulty, catch::difficulty::DifficultyValues};
|
||||
|
||||
use super::convert::CatchBeatmap;
|
||||
|
||||
@@ -16,7 +16,7 @@ impl CatchStrains {
|
||||
pub const SECTION_LEN: f64 = 750.0;
|
||||
}
|
||||
|
||||
pub fn strains(difficulty: &ModeDifficulty, converted: &CatchBeatmap<'_>) -> CatchStrains {
|
||||
pub fn strains(difficulty: &Difficulty, converted: &CatchBeatmap<'_>) -> CatchStrains {
|
||||
let DifficultyValues { movement, .. } = DifficultyValues::calculate(difficulty, converted);
|
||||
|
||||
CatchStrains {
|
||||
|
||||
Reference in New Issue
Block a user