added is_convert method to TaikoPP and ManiaPP

This commit is contained in:
MaxOhn
2023-02-02 08:54:47 +01:00
parent 741aa7a8e3
commit 1b5399070e
5 changed files with 46 additions and 5 deletions
+3
View File
@@ -1,5 +1,8 @@
## Upcoming ## Upcoming
- __Additions:__
- Added the method `{TaikoPP/ManiaPP}::is_convert` which **needs** to be used if the map was manually converted beforehand
- __Fixes:__ - __Fixes:__
- The `Beatmap::bpm` method now works properly by considering the most common beat length instead of just the first one - The `Beatmap::bpm` method now works properly by considering the most common beat length instead of just the first one
+2
View File
@@ -97,6 +97,8 @@ impl<'map> ManiaStars<'map> {
} }
/// Specify whether the map is a convert i.e. an osu!standard map. /// Specify whether the map is a convert i.e. an osu!standard map.
///
/// This only needs to be specified if the map was converted manually beforehand.
#[inline] #[inline]
pub fn is_convert(mut self, is_convert: bool) -> Self { pub fn is_convert(mut self, is_convert: bool) -> Self {
self.is_convert = is_convert; self.is_convert = is_convert;
+19 -2
View File
@@ -42,6 +42,7 @@ use crate::{
#[allow(clippy::upper_case_acronyms)] #[allow(clippy::upper_case_acronyms)]
pub struct ManiaPP<'map> { pub struct ManiaPP<'map> {
map: Cow<'map, Beatmap>, map: Cow<'map, Beatmap>,
is_convert: bool,
attributes: Option<ManiaDifficultyAttributes>, attributes: Option<ManiaDifficultyAttributes>,
mods: u32, mods: u32,
passed_objects: Option<usize>, passed_objects: Option<usize>,
@@ -62,8 +63,11 @@ impl<'map> ManiaPP<'map> {
/// Create a new performance calculator for osu!mania maps. /// Create a new performance calculator for osu!mania maps.
#[inline] #[inline]
pub fn new(map: &'map Beatmap) -> Self { pub fn new(map: &'map Beatmap) -> Self {
let map = map.convert_mode(GameMode::Mania);
Self { Self {
map: map.convert_mode(GameMode::Mania), is_convert: matches!(map, Cow::Owned(_)),
map,
attributes: None, attributes: None,
mods: 0, mods: 0,
passed_objects: None, passed_objects: None,
@@ -190,6 +194,16 @@ impl<'map> ManiaPP<'map> {
self self
} }
/// Specify whether the map is a convert i.e. an osu!standard map.
///
/// This only needs to be specified if the map was converted manually beforehand.
#[inline]
pub fn is_convert(mut self, is_convert: bool) -> Self {
self.is_convert = is_convert;
self
}
/// Provide parameters through an [`ManiaScoreState`]. /// Provide parameters through an [`ManiaScoreState`].
#[inline] #[inline]
pub fn state(mut self, state: ManiaScoreState) -> Self { pub fn state(mut self, state: ManiaScoreState) -> Self {
@@ -581,8 +595,11 @@ impl<'map> From<OsuPP<'map>> for ManiaPP<'map> {
hitresult_priority, hitresult_priority,
} = osu; } = osu;
let map = map.convert_mode(GameMode::Mania);
Self { Self {
map: map.convert_mode(GameMode::Mania), is_convert: matches!(map, Cow::Owned(_)),
map,
attributes: None, attributes: None,
mods, mods,
passed_objects, passed_objects,
+2
View File
@@ -104,6 +104,8 @@ impl<'map> TaikoStars<'map> {
} }
/// Specify whether the map is a convert i.e. an osu!standard map. /// Specify whether the map is a convert i.e. an osu!standard map.
///
/// This only needs to be specified if the map was converted manually beforehand.
#[inline] #[inline]
pub fn is_convert(mut self, is_convert: bool) -> Self { pub fn is_convert(mut self, is_convert: bool) -> Self {
self.is_convert = is_convert; self.is_convert = is_convert;
+20 -3
View File
@@ -38,6 +38,7 @@ use crate::{
#[allow(clippy::upper_case_acronyms)] #[allow(clippy::upper_case_acronyms)]
pub struct TaikoPP<'map> { pub struct TaikoPP<'map> {
pub(crate) map: Cow<'map, Beatmap>, pub(crate) map: Cow<'map, Beatmap>,
is_convert: bool,
attributes: Option<TaikoDifficultyAttributes>, attributes: Option<TaikoDifficultyAttributes>,
mods: u32, mods: u32,
combo: Option<usize>, combo: Option<usize>,
@@ -55,8 +56,11 @@ impl<'map> TaikoPP<'map> {
/// Create a new performance calculator for osu!taiko maps. /// Create a new performance calculator for osu!taiko maps.
#[inline] #[inline]
pub fn new(map: &'map Beatmap) -> Self { pub fn new(map: &'map Beatmap) -> Self {
let map = map.convert_mode(GameMode::Taiko);
Self { Self {
map: map.convert_mode(GameMode::Taiko), is_convert: matches!(map, Cow::Owned(_)),
map,
attributes: None, attributes: None,
mods: 0, mods: 0,
combo: None, combo: None,
@@ -165,6 +169,16 @@ impl<'map> TaikoPP<'map> {
self self
} }
/// Specify whether the map is a convert i.e. an osu!standard map.
///
/// This only needs to be specified if the map was converted manually beforehand.
#[inline]
pub fn is_convert(mut self, is_convert: bool) -> Self {
self.is_convert = is_convert;
self
}
/// Provide parameters through a [`TaikoScoreState`]. /// Provide parameters through a [`TaikoScoreState`].
#[inline] #[inline]
pub fn state(mut self, state: TaikoScoreState) -> Self { pub fn state(mut self, state: TaikoScoreState) -> Self {
@@ -188,7 +202,7 @@ impl<'map> TaikoPP<'map> {
let attrs = self.attributes.take().unwrap_or_else(|| { let attrs = self.attributes.take().unwrap_or_else(|| {
let mut calculator = TaikoStars::new(self.map.as_ref()) let mut calculator = TaikoStars::new(self.map.as_ref())
.mods(self.mods) .mods(self.mods)
.is_convert(matches!(self.map, Cow::Owned(_))); .is_convert(self.is_convert);
if let Some(passed_objects) = self.passed_objects { if let Some(passed_objects) = self.passed_objects {
calculator = calculator.passed_objects(passed_objects); calculator = calculator.passed_objects(passed_objects);
@@ -404,8 +418,11 @@ impl<'map> From<OsuPP<'map>> for TaikoPP<'map> {
hitresult_priority, hitresult_priority,
} = osu; } = osu;
let map = map.convert_mode(GameMode::Taiko);
Self { Self {
map: map.convert_mode(GameMode::Taiko), is_convert: matches!(map, Cow::Owned(_)),
map,
attributes: None, attributes: None,
mods, mods,
combo, combo,