added is_convert method to TaikoPP and ManiaPP
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
## Upcoming
|
||||
|
||||
- __Additions:__
|
||||
- Added the method `{TaikoPP/ManiaPP}::is_convert` which **needs** to be used if the map was manually converted beforehand
|
||||
|
||||
- __Fixes:__
|
||||
- The `Beatmap::bpm` method now works properly by considering the most common beat length instead of just the first one
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ impl<'map> ManiaStars<'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]
|
||||
pub fn is_convert(mut self, is_convert: bool) -> Self {
|
||||
self.is_convert = is_convert;
|
||||
|
||||
+19
-2
@@ -42,6 +42,7 @@ use crate::{
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct ManiaPP<'map> {
|
||||
map: Cow<'map, Beatmap>,
|
||||
is_convert: bool,
|
||||
attributes: Option<ManiaDifficultyAttributes>,
|
||||
mods: u32,
|
||||
passed_objects: Option<usize>,
|
||||
@@ -62,8 +63,11 @@ impl<'map> ManiaPP<'map> {
|
||||
/// Create a new performance calculator for osu!mania maps.
|
||||
#[inline]
|
||||
pub fn new(map: &'map Beatmap) -> Self {
|
||||
let map = map.convert_mode(GameMode::Mania);
|
||||
|
||||
Self {
|
||||
map: map.convert_mode(GameMode::Mania),
|
||||
is_convert: matches!(map, Cow::Owned(_)),
|
||||
map,
|
||||
attributes: None,
|
||||
mods: 0,
|
||||
passed_objects: None,
|
||||
@@ -190,6 +194,16 @@ impl<'map> ManiaPP<'map> {
|
||||
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`].
|
||||
#[inline]
|
||||
pub fn state(mut self, state: ManiaScoreState) -> Self {
|
||||
@@ -581,8 +595,11 @@ impl<'map> From<OsuPP<'map>> for ManiaPP<'map> {
|
||||
hitresult_priority,
|
||||
} = osu;
|
||||
|
||||
let map = map.convert_mode(GameMode::Mania);
|
||||
|
||||
Self {
|
||||
map: map.convert_mode(GameMode::Mania),
|
||||
is_convert: matches!(map, Cow::Owned(_)),
|
||||
map,
|
||||
attributes: None,
|
||||
mods,
|
||||
passed_objects,
|
||||
|
||||
@@ -104,6 +104,8 @@ impl<'map> TaikoStars<'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]
|
||||
pub fn is_convert(mut self, is_convert: bool) -> Self {
|
||||
self.is_convert = is_convert;
|
||||
|
||||
+20
-3
@@ -38,6 +38,7 @@ use crate::{
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct TaikoPP<'map> {
|
||||
pub(crate) map: Cow<'map, Beatmap>,
|
||||
is_convert: bool,
|
||||
attributes: Option<TaikoDifficultyAttributes>,
|
||||
mods: u32,
|
||||
combo: Option<usize>,
|
||||
@@ -55,8 +56,11 @@ impl<'map> TaikoPP<'map> {
|
||||
/// Create a new performance calculator for osu!taiko maps.
|
||||
#[inline]
|
||||
pub fn new(map: &'map Beatmap) -> Self {
|
||||
let map = map.convert_mode(GameMode::Taiko);
|
||||
|
||||
Self {
|
||||
map: map.convert_mode(GameMode::Taiko),
|
||||
is_convert: matches!(map, Cow::Owned(_)),
|
||||
map,
|
||||
attributes: None,
|
||||
mods: 0,
|
||||
combo: None,
|
||||
@@ -165,6 +169,16 @@ impl<'map> TaikoPP<'map> {
|
||||
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`].
|
||||
#[inline]
|
||||
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 mut calculator = TaikoStars::new(self.map.as_ref())
|
||||
.mods(self.mods)
|
||||
.is_convert(matches!(self.map, Cow::Owned(_)));
|
||||
.is_convert(self.is_convert);
|
||||
|
||||
if let Some(passed_objects) = self.passed_objects {
|
||||
calculator = calculator.passed_objects(passed_objects);
|
||||
@@ -404,8 +418,11 @@ impl<'map> From<OsuPP<'map>> for TaikoPP<'map> {
|
||||
hitresult_priority,
|
||||
} = osu;
|
||||
|
||||
let map = map.convert_mode(GameMode::Taiko);
|
||||
|
||||
Self {
|
||||
map: map.convert_mode(GameMode::Taiko),
|
||||
is_convert: matches!(map, Cow::Owned(_)),
|
||||
map,
|
||||
attributes: None,
|
||||
mods,
|
||||
combo,
|
||||
|
||||
Reference in New Issue
Block a user