renamed GameMode variants

This commit is contained in:
MaxOhn
2022-07-06 15:56:07 +02:00
parent a732d28b34
commit 970f9ff69f
17 changed files with 286 additions and 286 deletions
+1
View File
@@ -4,6 +4,7 @@
- Slider velocity is now adjusted properly for taiko converts
- __Breaking changes:__
- Replaced the simple `Strains` struct with a new struct `{Mode}Strains` that contains more detail w.r.t. the mode.
- Renamed all `GameMode` variants to more idiomatic names
# v0.6.0 (2022-07-05)
+1 -1
View File
@@ -195,7 +195,7 @@ impl Beatmap {
legacy_sort(&mut map.hit_objects);
map.mode = GameMode::MNA;
map.mode = GameMode::Mania;
map
}
+1 -1
View File
@@ -87,7 +87,7 @@ impl Beatmap {
map.hit_objects
.sort_by(|p1, p2| p1.partial_cmp(p2).unwrap_or(Ordering::Equal));
map.mode = GameMode::TKO;
map.mode = GameMode::Taiko;
map
}
+3 -3
View File
@@ -132,9 +132,9 @@ impl Beatmap {
}
match mode {
GameMode::STD | GameMode::CTB => Cow::Borrowed(self),
GameMode::TKO => Cow::Owned(self.convert_to_taiko()),
GameMode::MNA => Cow::Owned(self.convert_to_mania()),
GameMode::Osu | GameMode::Catch => Cow::Borrowed(self),
GameMode::Taiko => Cow::Owned(self.convert_to_taiko()),
GameMode::Mania => Cow::Owned(self.convert_to_mania()),
}
}
+5 -6
View File
@@ -1,20 +1,19 @@
/// The mode of a beatmap.
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
#[allow(clippy::upper_case_acronyms)]
pub enum GameMode {
/// osu!standard
STD = 0,
Osu = 0,
/// osu!taiko
TKO = 1,
Taiko = 1,
/// osu!catch
CTB = 2,
Catch = 2,
/// osu!mania
MNA = 3,
Mania = 3,
}
impl Default for GameMode {
#[inline]
fn default() -> Self {
Self::STD
Self::Osu
}
}
+8 -8
View File
@@ -53,10 +53,10 @@ impl<'map> GradualDifficultyAttributes<'map> {
/// Create a new gradual difficulty calculator for maps of any mode.
pub fn new(map: &'map Beatmap, mods: impl Mods) -> Self {
match map.mode {
GameMode::STD => Self::Osu(OsuGradualDifficultyAttributes::new(map, mods)),
GameMode::TKO => Self::Taiko(TaikoGradualDifficultyAttributes::new(map, mods)),
GameMode::CTB => Self::Catch(CatchGradualDifficultyAttributes::new(map, mods)),
GameMode::MNA => Self::Mania(ManiaGradualDifficultyAttributes::new(map, mods)),
GameMode::Osu => Self::Osu(OsuGradualDifficultyAttributes::new(map, mods)),
GameMode::Taiko => Self::Taiko(TaikoGradualDifficultyAttributes::new(map, mods)),
GameMode::Catch => Self::Catch(CatchGradualDifficultyAttributes::new(map, mods)),
GameMode::Mania => Self::Mania(ManiaGradualDifficultyAttributes::new(map, mods)),
}
}
}
@@ -285,10 +285,10 @@ impl<'map> GradualPerformanceAttributes<'map> {
/// Create a new gradual performance calculator for maps of any mode.
pub fn new(map: &'map Beatmap, mods: u32) -> Self {
match map.mode {
GameMode::STD => Self::Osu(OsuGradualPerformanceAttributes::new(map, mods)),
GameMode::TKO => Self::Taiko(TaikoGradualPerformanceAttributes::new(map, mods)),
GameMode::CTB => Self::Catch(CatchGradualPerformanceAttributes::new(map, mods)),
GameMode::MNA => Self::Mania(ManiaGradualPerformanceAttributes::new(map, mods)),
GameMode::Osu => Self::Osu(OsuGradualPerformanceAttributes::new(map, mods)),
GameMode::Taiko => Self::Taiko(TaikoGradualPerformanceAttributes::new(map, mods)),
GameMode::Catch => Self::Catch(CatchGradualPerformanceAttributes::new(map, mods)),
GameMode::Mania => Self::Mania(ManiaGradualPerformanceAttributes::new(map, mods)),
}
}
+13 -13
View File
@@ -80,7 +80,7 @@
//! This could be done by using `passed_objects` as the amount of objects that were passed so far.
//! However, this requires to recalculate the beginning again and again, we can be more efficient than that.
//!
//! Instead, you should use `GradualDifficultyAttributes` and `GradualPerformanceAttributes`:
//! Instead, you should use [`GradualDifficultyAttributes`] and [`GradualPerformanceAttributes`]:
//!
//! ```no_run
//! use rosu_pp::{
@@ -255,24 +255,24 @@ impl BeatmapExt for Beatmap {
#[inline]
fn stars(&self) -> AnyStars<'_> {
match self.mode {
GameMode::STD => AnyStars::Osu(OsuStars::new(self)),
GameMode::MNA => AnyStars::Mania(ManiaStars::new(self)),
GameMode::TKO => AnyStars::Taiko(TaikoStars::new(self)),
GameMode::CTB => AnyStars::Catch(CatchStars::new(self)),
GameMode::Osu => AnyStars::Osu(OsuStars::new(self)),
GameMode::Mania => AnyStars::Mania(ManiaStars::new(self)),
GameMode::Taiko => AnyStars::Taiko(TaikoStars::new(self)),
GameMode::Catch => AnyStars::Catch(CatchStars::new(self)),
}
}
#[inline]
fn max_pp(&self, mods: u32) -> PerformanceAttributes {
match self.mode {
GameMode::STD => PerformanceAttributes::Osu(OsuPP::new(self).mods(mods).calculate()),
GameMode::MNA => {
GameMode::Osu => PerformanceAttributes::Osu(OsuPP::new(self).mods(mods).calculate()),
GameMode::Mania => {
PerformanceAttributes::Mania(ManiaPP::new(self).mods(mods).calculate())
}
GameMode::TKO => {
GameMode::Taiko => {
PerformanceAttributes::Taiko(TaikoPP::new(self).mods(mods).calculate())
}
GameMode::CTB => {
GameMode::Catch => {
PerformanceAttributes::Catch(CatchPP::new(self).mods(mods).calculate())
}
}
@@ -286,10 +286,10 @@ impl BeatmapExt for Beatmap {
#[inline]
fn strains(&self, mods: u32) -> Strains {
match self.mode {
GameMode::STD => Strains::Osu(OsuStars::new(self).mods(mods).strains()),
GameMode::MNA => Strains::Mania(ManiaStars::new(self).mods(mods).strains()),
GameMode::TKO => Strains::Taiko(TaikoStars::new(self).mods(mods).strains()),
GameMode::CTB => Strains::Catch(CatchStars::new(self).mods(mods).strains()),
GameMode::Osu => Strains::Osu(OsuStars::new(self).mods(mods).strains()),
GameMode::Mania => Strains::Mania(ManiaStars::new(self).mods(mods).strains()),
GameMode::Taiko => Strains::Taiko(TaikoStars::new(self).mods(mods).strains()),
GameMode::Catch => Strains::Catch(CatchStars::new(self).mods(mods).strains()),
}
}
+218 -218
View File
@@ -1,218 +1,218 @@
use std::{
iter::{self, Skip, Zip},
slice::Iter,
};
use crate::{
mania::{strain::Strain, SECTION_LEN},
parse::HitObject,
Beatmap, GameMode, Mods,
};
use super::{DifficultyHitObject, ManiaDifficultyAttributes, STAR_SCALING_FACTOR};
/// Gradually calculate the difficulty attributes of an osu!mania map.
///
/// Note that this struct implements [`Iterator`](std::iter::Iterator).
/// On every call of [`Iterator::next`](std::iter::Iterator::next), the map's next hit object will
/// be processed and the [`ManiaDifficultyAttributes`] will be updated and returned.
///
/// If you want to calculate performance attributes, use
/// [`ManiaGradualPerformanceAttributes`](crate::mania::ManiaGradualPerformanceAttributes) instead.
///
/// # Example
///
/// ```
/// use rosu_pp::{Beatmap, mania::ManiaGradualDifficultyAttributes};
///
/// # /*
/// let map: Beatmap = ...
/// # */
/// # let map = Beatmap::default();
///
/// let mods = 64; // DT
/// let mut iter = ManiaGradualDifficultyAttributes::new(&map, mods);
///
/// let attrs1 = iter.next(); // the difficulty of the map after the first hit object
/// let attrs2 = iter.next(); // after the second hit object
///
/// // Remaining hit objects
/// for difficulty in iter {
/// // ...
/// }
/// ```
#[derive(Clone, Debug)]
pub struct ManiaGradualDifficultyAttributes<'map> {
pub(crate) idx: usize,
difficulty_objects: ManiaObjectIter<'map>,
strain: Strain,
curr_section_end: f64,
strain_peak_buf: Vec<f64>,
}
impl<'map> ManiaGradualDifficultyAttributes<'map> {
/// Create a new difficulty attributes iterator for osu!mania maps.
pub fn new(map: &'map Beatmap, mods: impl Mods) -> Self {
let rounded_cs = map.cs.round();
let columns = match map.mode {
GameMode::MNA => rounded_cs.max(1.0) as u8,
GameMode::STD => {
let rounded_od = map.od.round();
let n_objects = map.n_circles + map.n_sliders + map.n_spinners;
let slider_or_spinner_ratio = (n_objects - map.n_circles) as f32 / n_objects as f32;
if slider_or_spinner_ratio < 0.2 {
7
} else if slider_or_spinner_ratio < 0.3 || rounded_cs >= 5.0 {
6 + (rounded_od > 5.0) as u8
} else if slider_or_spinner_ratio > 0.6 {
4 + (rounded_od > 4.0) as u8
} else {
(rounded_od as u8 + 1).max(4).min(7)
}
}
other => panic!("can not calculate mania difficulty on a {:?} map", other),
};
let clock_rate = mods.clock_rate();
let strain = Strain::new(columns);
let columns = columns as f32;
let difficulty_objects = ManiaObjectIter::new(&map.hit_objects, columns, clock_rate);
Self {
idx: 0,
difficulty_objects,
strain,
curr_section_end: 0.0,
strain_peak_buf: Vec::new(),
}
}
}
impl Iterator for ManiaGradualDifficultyAttributes<'_> {
type Item = ManiaDifficultyAttributes;
fn next(&mut self) -> Option<Self::Item> {
self.idx = self.idx.saturating_add(1);
if self.idx == 1 {
return (!self.difficulty_objects.is_empty).then(ManiaDifficultyAttributes::default);
}
let h = self.difficulty_objects.next()?;
if self.idx == 2 {
self.curr_section_end = (h.start_time / SECTION_LEN).ceil() * SECTION_LEN;
} else {
while h.start_time > self.curr_section_end {
self.strain.save_current_peak();
self.strain.start_new_section_from(self.curr_section_end);
self.curr_section_end += SECTION_LEN;
}
}
self.strain.process(&h);
let missing = self.strain.strain_peaks.len() + 1 - self.strain_peak_buf.len();
self.strain_peak_buf.extend(iter::repeat(0.0).take(missing));
self.strain_peak_buf[..self.strain.strain_peaks.len()]
.copy_from_slice(&self.strain.strain_peaks);
if let Some(last) = self.strain_peak_buf.last_mut() {
*last = self.strain.curr_section_peak;
}
let stars = Strain::difficulty_value(&mut self.strain_peak_buf) * STAR_SCALING_FACTOR;
Some(ManiaDifficultyAttributes { stars })
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
let len = self.len();
(len, Some(len))
}
}
impl ExactSizeIterator for ManiaGradualDifficultyAttributes<'_> {
#[inline]
fn len(&self) -> usize {
self.difficulty_objects.len() + (self.idx == 0) as usize
}
}
#[derive(Clone, Debug)]
struct ManiaObjectIter<'map> {
hit_objects: Zip<Skip<Iter<'map, HitObject>>, Iter<'map, HitObject>>,
columns: f32,
clock_rate: f64,
is_empty: bool,
}
impl<'map> ManiaObjectIter<'map> {
fn new(hit_objects: &'map [HitObject], columns: f32, clock_rate: f64) -> Self {
let is_empty = hit_objects.is_empty();
let hit_objects = hit_objects.iter().skip(1).zip(hit_objects);
Self {
hit_objects,
columns,
clock_rate,
is_empty,
}
}
}
impl<'map> Iterator for ManiaObjectIter<'map> {
type Item = DifficultyHitObject<'map>;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
let (base, prev) = self.hit_objects.next()?;
let obj = DifficultyHitObject::new(base, prev, self.columns, self.clock_rate);
Some(obj)
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.hit_objects.size_hint()
}
}
impl ExactSizeIterator for ManiaObjectIter<'_> {
#[inline]
fn len(&self) -> usize {
self.hit_objects.len()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn empty_map() {
let map = Beatmap::default();
let mut attributes = ManiaGradualDifficultyAttributes::new(&map, 0);
assert!(attributes.next().is_none());
}
#[cfg(not(any(feature = "async_tokio", feature = "async_std")))]
#[test]
fn iter_end_eq_regular() {
let map = Beatmap::from_path("./maps/1974394.osu").expect("failed to parse map");
let mods = 64;
let regular = crate::ManiaStars::new(&map).mods(mods).calculate();
let iter_end = ManiaGradualDifficultyAttributes::new(&map, mods)
.last()
.expect("empty iter");
assert_eq!(regular, iter_end);
}
}
use std::{
iter::{self, Skip, Zip},
slice::Iter,
};
use crate::{
mania::{strain::Strain, SECTION_LEN},
parse::HitObject,
Beatmap, GameMode, Mods,
};
use super::{DifficultyHitObject, ManiaDifficultyAttributes, STAR_SCALING_FACTOR};
/// Gradually calculate the difficulty attributes of an osu!mania map.
///
/// Note that this struct implements [`Iterator`](std::iter::Iterator).
/// On every call of [`Iterator::next`](std::iter::Iterator::next), the map's next hit object will
/// be processed and the [`ManiaDifficultyAttributes`] will be updated and returned.
///
/// If you want to calculate performance attributes, use
/// [`ManiaGradualPerformanceAttributes`](crate::mania::ManiaGradualPerformanceAttributes) instead.
///
/// # Example
///
/// ```
/// use rosu_pp::{Beatmap, mania::ManiaGradualDifficultyAttributes};
///
/// # /*
/// let map: Beatmap = ...
/// # */
/// # let map = Beatmap::default();
///
/// let mods = 64; // DT
/// let mut iter = ManiaGradualDifficultyAttributes::new(&map, mods);
///
/// let attrs1 = iter.next(); // the difficulty of the map after the first hit object
/// let attrs2 = iter.next(); // after the second hit object
///
/// // Remaining hit objects
/// for difficulty in iter {
/// // ...
/// }
/// ```
#[derive(Clone, Debug)]
pub struct ManiaGradualDifficultyAttributes<'map> {
pub(crate) idx: usize,
difficulty_objects: ManiaObjectIter<'map>,
strain: Strain,
curr_section_end: f64,
strain_peak_buf: Vec<f64>,
}
impl<'map> ManiaGradualDifficultyAttributes<'map> {
/// Create a new difficulty attributes iterator for osu!mania maps.
pub fn new(map: &'map Beatmap, mods: impl Mods) -> Self {
let rounded_cs = map.cs.round();
let columns = match map.mode {
GameMode::Mania => rounded_cs.max(1.0) as u8,
GameMode::Osu => {
let rounded_od = map.od.round();
let n_objects = map.n_circles + map.n_sliders + map.n_spinners;
let slider_or_spinner_ratio = (n_objects - map.n_circles) as f32 / n_objects as f32;
if slider_or_spinner_ratio < 0.2 {
7
} else if slider_or_spinner_ratio < 0.3 || rounded_cs >= 5.0 {
6 + (rounded_od > 5.0) as u8
} else if slider_or_spinner_ratio > 0.6 {
4 + (rounded_od > 4.0) as u8
} else {
(rounded_od as u8 + 1).max(4).min(7)
}
}
other => panic!("can not calculate mania difficulty on a {:?} map", other),
};
let clock_rate = mods.clock_rate();
let strain = Strain::new(columns);
let columns = columns as f32;
let difficulty_objects = ManiaObjectIter::new(&map.hit_objects, columns, clock_rate);
Self {
idx: 0,
difficulty_objects,
strain,
curr_section_end: 0.0,
strain_peak_buf: Vec::new(),
}
}
}
impl Iterator for ManiaGradualDifficultyAttributes<'_> {
type Item = ManiaDifficultyAttributes;
fn next(&mut self) -> Option<Self::Item> {
self.idx = self.idx.saturating_add(1);
if self.idx == 1 {
return (!self.difficulty_objects.is_empty).then(ManiaDifficultyAttributes::default);
}
let h = self.difficulty_objects.next()?;
if self.idx == 2 {
self.curr_section_end = (h.start_time / SECTION_LEN).ceil() * SECTION_LEN;
} else {
while h.start_time > self.curr_section_end {
self.strain.save_current_peak();
self.strain.start_new_section_from(self.curr_section_end);
self.curr_section_end += SECTION_LEN;
}
}
self.strain.process(&h);
let missing = self.strain.strain_peaks.len() + 1 - self.strain_peak_buf.len();
self.strain_peak_buf.extend(iter::repeat(0.0).take(missing));
self.strain_peak_buf[..self.strain.strain_peaks.len()]
.copy_from_slice(&self.strain.strain_peaks);
if let Some(last) = self.strain_peak_buf.last_mut() {
*last = self.strain.curr_section_peak;
}
let stars = Strain::difficulty_value(&mut self.strain_peak_buf) * STAR_SCALING_FACTOR;
Some(ManiaDifficultyAttributes { stars })
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
let len = self.len();
(len, Some(len))
}
}
impl ExactSizeIterator for ManiaGradualDifficultyAttributes<'_> {
#[inline]
fn len(&self) -> usize {
self.difficulty_objects.len() + (self.idx == 0) as usize
}
}
#[derive(Clone, Debug)]
struct ManiaObjectIter<'map> {
hit_objects: Zip<Skip<Iter<'map, HitObject>>, Iter<'map, HitObject>>,
columns: f32,
clock_rate: f64,
is_empty: bool,
}
impl<'map> ManiaObjectIter<'map> {
fn new(hit_objects: &'map [HitObject], columns: f32, clock_rate: f64) -> Self {
let is_empty = hit_objects.is_empty();
let hit_objects = hit_objects.iter().skip(1).zip(hit_objects);
Self {
hit_objects,
columns,
clock_rate,
is_empty,
}
}
}
impl<'map> Iterator for ManiaObjectIter<'map> {
type Item = DifficultyHitObject<'map>;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
let (base, prev) = self.hit_objects.next()?;
let obj = DifficultyHitObject::new(base, prev, self.columns, self.clock_rate);
Some(obj)
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.hit_objects.size_hint()
}
}
impl ExactSizeIterator for ManiaObjectIter<'_> {
#[inline]
fn len(&self) -> usize {
self.hit_objects.len()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn empty_map() {
let map = Beatmap::default();
let mut attributes = ManiaGradualDifficultyAttributes::new(&map, 0);
assert!(attributes.next().is_none());
}
#[cfg(not(any(feature = "async_tokio", feature = "async_std")))]
#[test]
fn iter_end_eq_regular() {
let map = Beatmap::from_path("./maps/1974394.osu").expect("failed to parse map");
let mods = 64;
let regular = crate::ManiaStars::new(&map).mods(mods).calculate();
let iter_end = ManiaGradualDifficultyAttributes::new(&map, mods)
.last()
.expect("empty iter");
assert_eq!(regular, iter_end);
}
}
+3 -3
View File
@@ -140,8 +140,8 @@ fn calculate_strain(params: ManiaStars<'_>) -> Strain {
let rounded_cs = map.cs.round();
let columns = match map.mode {
GameMode::MNA => rounded_cs.max(1.0) as u8,
GameMode::STD => {
GameMode::Mania => rounded_cs.max(1.0) as u8,
GameMode::Osu => {
let rounded_od = map.od.round();
let n_objects = map.n_circles + map.n_sliders + map.n_spinners;
@@ -270,7 +270,7 @@ impl<'map> From<OsuStars<'map>> for ManiaStars<'map> {
} = osu;
Self {
map: map.convert_mode(GameMode::MNA),
map: map.convert_mode(GameMode::Mania),
mods,
passed_objects,
clock_rate,
+1 -1
View File
@@ -225,7 +225,7 @@ impl<'map> From<OsuPP<'map>> for ManiaPP<'map> {
} = osu;
Self {
map: map.convert_mode(GameMode::MNA),
map: map.convert_mode(GameMode::Mania),
stars: None,
mods,
score: None,
+4 -4
View File
@@ -71,10 +71,10 @@ impl<'map> OsuStars<'map> {
#[inline]
pub fn mode(self, mode: GameMode) -> AnyStars<'map> {
match mode {
GameMode::STD => AnyStars::Osu(self),
GameMode::TKO => AnyStars::Taiko(self.into()),
GameMode::CTB => AnyStars::Catch(self.into()),
GameMode::MNA => AnyStars::Mania(self.into()),
GameMode::Osu => AnyStars::Osu(self),
GameMode::Taiko => AnyStars::Taiko(self.into()),
GameMode::Catch => AnyStars::Catch(self.into()),
GameMode::Mania => AnyStars::Mania(self.into()),
}
}
+4 -4
View File
@@ -73,10 +73,10 @@ impl<'map> OsuPP<'map> {
#[inline]
pub fn mode(self, mode: GameMode) -> AnyPP<'map> {
match mode {
GameMode::STD => AnyPP::Osu(self),
GameMode::TKO => AnyPP::Taiko(self.into()),
GameMode::CTB => AnyPP::Catch(self.into()),
GameMode::MNA => AnyPP::Mania(self.into()),
GameMode::Osu => AnyPP::Osu(self),
GameMode::Taiko => AnyPP::Taiko(self.into()),
GameMode::Catch => AnyPP::Catch(self.into()),
GameMode::Mania => AnyPP::Mania(self.into()),
}
}
+6 -6
View File
@@ -101,10 +101,10 @@ macro_rules! parse_general_body {
if key == b"Mode" {
mode = match value {
"0" => Some(GameMode::STD),
"1" => Some(GameMode::TKO),
"2" => Some(GameMode::CTB),
"3" => Some(GameMode::MNA),
"0" => Some(GameMode::Osu),
"1" => Some(GameMode::Taiko),
"2" => Some(GameMode::Catch),
"3" => Some(GameMode::Mania),
_ => return Err(ParseError::InvalidMode),
};
}
@@ -114,7 +114,7 @@ macro_rules! parse_general_body {
}
}
$self.mode = mode.unwrap_or(GameMode::STD);
$self.mode = mode.unwrap_or(GameMode::Osu);
$self.stack_leniency = stack_leniency.unwrap_or(0.7);
Ok(empty)
@@ -456,7 +456,7 @@ macro_rules! parse_hitobjects_body {
// BUG: If [General] section comes after [HitObjects] then the mode
// won't be set yet so mania objects won't be sorted properly
if $self.mode == GameMode::MNA {
if $self.mode == GameMode::Mania {
// First a _stable_ sort by time
$self
.hit_objects
+8 -8
View File
@@ -53,10 +53,10 @@ impl<'map> AnyPP<'map> {
#[inline]
pub fn new(map: &'map Beatmap) -> Self {
match map.mode {
GameMode::CTB => Self::Catch(CatchPP::new(map)),
GameMode::MNA => Self::Mania(ManiaPP::new(map)),
GameMode::STD => Self::Osu(OsuPP::new(map)),
GameMode::TKO => Self::Taiko(TaikoPP::new(map)),
GameMode::Catch => Self::Catch(CatchPP::new(map)),
GameMode::Mania => Self::Mania(ManiaPP::new(map)),
GameMode::Osu => Self::Osu(OsuPP::new(map)),
GameMode::Taiko => Self::Taiko(TaikoPP::new(map)),
}
}
@@ -90,10 +90,10 @@ impl<'map> AnyPP<'map> {
pub fn mode(self, mode: GameMode) -> Self {
match self {
AnyPP::Osu(o) => match mode {
GameMode::STD => AnyPP::Osu(o),
GameMode::TKO => AnyPP::Taiko(o.into()),
GameMode::CTB => AnyPP::Catch(o.into()),
GameMode::MNA => AnyPP::Mania(o.into()),
GameMode::Osu => AnyPP::Osu(o),
GameMode::Taiko => AnyPP::Taiko(o.into()),
GameMode::Catch => AnyPP::Catch(o.into()),
GameMode::Mania => AnyPP::Mania(o.into()),
},
other => other,
}
+8 -8
View File
@@ -37,10 +37,10 @@ impl<'map> AnyStars<'map> {
#[inline]
pub fn new(map: &'map Beatmap) -> Self {
match map.mode {
GameMode::CTB => Self::Catch(CatchStars::new(map)),
GameMode::MNA => Self::Mania(ManiaStars::new(map)),
GameMode::STD => Self::Osu(OsuStars::new(map)),
GameMode::TKO => Self::Taiko(TaikoStars::new(map)),
GameMode::Catch => Self::Catch(CatchStars::new(map)),
GameMode::Mania => Self::Mania(ManiaStars::new(map)),
GameMode::Osu => Self::Osu(OsuStars::new(map)),
GameMode::Taiko => Self::Taiko(TaikoStars::new(map)),
}
}
@@ -49,10 +49,10 @@ impl<'map> AnyStars<'map> {
pub fn mode(self, mode: GameMode) -> Self {
match self {
AnyStars::Osu(o) => match mode {
GameMode::STD => AnyStars::Osu(o),
GameMode::TKO => AnyStars::Taiko(o.into()),
GameMode::CTB => AnyStars::Catch(o.into()),
GameMode::MNA => AnyStars::Mania(o.into()),
GameMode::Osu => AnyStars::Osu(o),
GameMode::Taiko => AnyStars::Taiko(o.into()),
GameMode::Catch => AnyStars::Catch(o.into()),
GameMode::Mania => AnyStars::Mania(o.into()),
},
other => other,
}
+1 -1
View File
@@ -362,7 +362,7 @@ impl<'map> From<OsuStars<'map>> for TaikoStars<'map> {
} = osu;
Self {
map: map.convert_mode(GameMode::TKO),
map: map.convert_mode(GameMode::Taiko),
mods,
passed_objects,
clock_rate,
+1 -1
View File
@@ -321,7 +321,7 @@ impl<'map> From<OsuPP<'map>> for TaikoPP<'map> {
} = osu;
Self {
map: map.convert_mode(GameMode::TKO),
map: map.convert_mode(GameMode::Taiko),
attributes: None,
mods,
combo,