restructured StarResult to unify modes

This commit is contained in:
MaxOhn
2021-01-19 20:59:44 +01:00
parent bd6130d79c
commit f12a190d4f
11 changed files with 98 additions and 80 deletions
+2 -4
View File
@@ -13,7 +13,7 @@ impl OsuAttributeProvider for DifficultyAttributes {
impl OsuAttributeProvider for StarResult {
fn attributes(self) -> Option<DifficultyAttributes> {
if let Self::Osu { attributes } = self {
if let Self::Osu(attributes) = self {
Some(attributes)
} else {
None
@@ -235,9 +235,7 @@ impl<'m> OsuPP<'m> {
.powf(1.0 / 1.1)
* multiplier;
let attributes = StarResult::Osu {
attributes: self.attributes.unwrap(),
};
let attributes = StarResult::Osu(self.attributes.unwrap());
PpResult { pp, attributes }
}
+6 -8
View File
@@ -27,13 +27,11 @@ pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> S
let od = (80.0 - hitwindow) / 6.0;
if take < 2 {
return StarResult::Osu {
attributes: DifficultyAttributes {
ar: attributes.ar,
od,
..Default::default()
},
};
return StarResult::Osu(DifficultyAttributes {
ar: attributes.ar,
od,
..Default::default()
});
}
let section_len = SECTION_LEN * attributes.clock_rate;
@@ -127,7 +125,7 @@ pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> S
n_spinners: 0, // TODO
};
StarResult::Osu { attributes }
StarResult::Osu(attributes)
}
// TODO: strains function
+2 -6
View File
@@ -47,9 +47,7 @@ pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> S
};
if take < 2 {
return StarResult::Osu {
attributes: diff_attributes,
};
return StarResult::Osu(diff_attributes);
}
let section_len = SECTION_LEN * map_attributes.clock_rate;
@@ -148,9 +146,7 @@ pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> S
diff_attributes.speed_strain = speed_strain;
diff_attributes.aim_strain = aim_strain;
StarResult::Osu {
attributes: diff_attributes,
}
StarResult::Osu(diff_attributes)
}
/// Essentially the same as the `stars` function but instead of
+15 -19
View File
@@ -39,13 +39,11 @@ pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> S
let od = (80.0 - hitwindow) / 6.0;
if take < 2 {
return StarResult::Osu {
attributes: DifficultyAttributes {
ar: attributes.ar,
od,
..Default::default()
},
};
return StarResult::Osu(DifficultyAttributes {
ar: attributes.ar,
od,
..Default::default()
});
}
let section_len = SECTION_LEN * attributes.clock_rate;
@@ -163,18 +161,16 @@ pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> S
let stars = aim_strain + speed_strain + (aim_strain - speed_strain).abs() / 2.0;
StarResult::Osu {
attributes: DifficultyAttributes {
stars,
ar: attributes.ar,
od,
speed_strain,
aim_strain,
max_combo,
n_circles,
n_spinners,
},
}
StarResult::Osu(DifficultyAttributes {
stars,
ar: attributes.ar,
od,
speed_strain,
aim_strain,
max_combo,
n_circles,
n_spinners,
})
}
/// Essentially the same as the `stars` function but instead of