added some convenience methods
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::{
|
||||
mania::{ManiaBeatmap, ManiaGradualDifficulty},
|
||||
osu::{OsuBeatmap, OsuGradualDifficulty},
|
||||
taiko::{TaikoBeatmap, TaikoGradualDifficulty},
|
||||
Beatmap, Converted, ModeDifficulty,
|
||||
Beatmap, ModeDifficulty,
|
||||
};
|
||||
|
||||
/// Gradually calculate the difficulty attributes on maps of any mode.
|
||||
@@ -48,10 +48,10 @@ pub enum GradualDifficulty {
|
||||
}
|
||||
|
||||
macro_rules! from_converted {
|
||||
( $fn:ident, $mode:ident, $converted:ident, $gradual:ident ) => {
|
||||
( $fn:ident, $mode:ident, $converted:ident ) => {
|
||||
#[doc = concat!("Create a [`GradualDifficulty`] for a [`", stringify!($converted), "`]")]
|
||||
pub fn $fn(difficulty: &ModeDifficulty, converted: &$converted<'_>) -> Self {
|
||||
Self::$mode($gradual::new(difficulty, converted))
|
||||
Self::$mode(difficulty.gradual_difficulty(converted))
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -62,29 +62,23 @@ impl GradualDifficulty {
|
||||
let map = Cow::Borrowed(map);
|
||||
|
||||
match map.mode {
|
||||
GameMode::Osu => Self::Osu(OsuGradualDifficulty::new(
|
||||
difficulty,
|
||||
&Converted::new(map, false),
|
||||
)),
|
||||
GameMode::Taiko => Self::Taiko(TaikoGradualDifficulty::new(
|
||||
difficulty,
|
||||
&Converted::new(map, false),
|
||||
)),
|
||||
GameMode::Catch => Self::Catch(CatchGradualDifficulty::new(
|
||||
difficulty,
|
||||
&Converted::new(map, false),
|
||||
)),
|
||||
GameMode::Mania => Self::Mania(ManiaGradualDifficulty::new(
|
||||
difficulty,
|
||||
&Converted::new(map, false),
|
||||
)),
|
||||
GameMode::Osu => Self::Osu(difficulty.gradual_difficulty(&OsuBeatmap::new(map, false))),
|
||||
GameMode::Taiko => {
|
||||
Self::Taiko(difficulty.gradual_difficulty(&TaikoBeatmap::new(map, false)))
|
||||
}
|
||||
GameMode::Catch => {
|
||||
Self::Catch(difficulty.gradual_difficulty(&CatchBeatmap::new(map, false)))
|
||||
}
|
||||
GameMode::Mania => {
|
||||
Self::Mania(difficulty.gradual_difficulty(&ManiaBeatmap::new(map, false)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
from_converted!(from_osu_map, Osu, OsuBeatmap, OsuGradualDifficulty);
|
||||
from_converted!(from_taiko_map, Taiko, TaikoBeatmap, TaikoGradualDifficulty);
|
||||
from_converted!(from_catch_map, Catch, CatchBeatmap, CatchGradualDifficulty);
|
||||
from_converted!(from_mania_map, Mania, ManiaBeatmap, ManiaGradualDifficulty);
|
||||
from_converted!(from_osu_map, Osu, OsuBeatmap);
|
||||
from_converted!(from_taiko_map, Taiko, TaikoBeatmap);
|
||||
from_converted!(from_catch_map, Catch, CatchBeatmap);
|
||||
from_converted!(from_mania_map, Mania, ManiaBeatmap);
|
||||
}
|
||||
|
||||
impl Iterator for GradualDifficulty {
|
||||
|
||||
@@ -56,6 +56,19 @@ impl ModeDifficulty {
|
||||
M::strains(self, map)
|
||||
}
|
||||
|
||||
/// Create a gradual difficulty calculator for a [`Converted`] beatmap.
|
||||
pub fn gradual_difficulty<M: IGameMode>(&self, map: &Converted<'_, M>) -> M::GradualDifficulty {
|
||||
M::gradual_difficulty(self, map)
|
||||
}
|
||||
|
||||
/// Create a gradual performance calculator for a [`Converted`] beatmap.
|
||||
pub fn gradual_performance<M: IGameMode>(
|
||||
&self,
|
||||
map: &Converted<'_, M>,
|
||||
) -> M::GradualPerformance {
|
||||
M::gradual_performance(self, map)
|
||||
}
|
||||
|
||||
pub(crate) const fn get_mods(&self) -> u32 {
|
||||
self.mods
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
mania::{ManiaBeatmap, ManiaGradualPerformance},
|
||||
osu::{OsuBeatmap, OsuGradualPerformance},
|
||||
taiko::{TaikoBeatmap, TaikoGradualPerformance},
|
||||
Beatmap, Converted, ModeDifficulty,
|
||||
Beatmap, ModeDifficulty,
|
||||
};
|
||||
|
||||
/// Gradually calculate the performance attributes on maps of any mode.
|
||||
@@ -97,10 +97,10 @@ pub enum GradualPerformance {
|
||||
}
|
||||
|
||||
macro_rules! from_converted {
|
||||
( $fn:ident, $mode:ident, $converted:ident, $gradual:ident ) => {
|
||||
( $fn:ident, $mode:ident, $converted:ident ) => {
|
||||
#[doc = concat!("Create a [`GradualPerformance`] for a [`", stringify!($converted), "`]")]
|
||||
pub fn $fn(difficulty: &ModeDifficulty, converted: &$converted<'_>) -> Self {
|
||||
Self::$mode($gradual::new(difficulty, converted))
|
||||
Self::$mode(difficulty.gradual_performance(converted))
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -111,29 +111,25 @@ impl GradualPerformance {
|
||||
let map = Cow::Borrowed(map);
|
||||
|
||||
match map.mode {
|
||||
GameMode::Osu => Self::Osu(OsuGradualPerformance::new(
|
||||
difficulty,
|
||||
&Converted::new(map, false),
|
||||
)),
|
||||
GameMode::Taiko => Self::Taiko(TaikoGradualPerformance::new(
|
||||
difficulty,
|
||||
&Converted::new(map, false),
|
||||
)),
|
||||
GameMode::Catch => Self::Catch(CatchGradualPerformance::new(
|
||||
difficulty,
|
||||
&Converted::new(map, false),
|
||||
)),
|
||||
GameMode::Mania => Self::Mania(ManiaGradualPerformance::new(
|
||||
difficulty,
|
||||
&Converted::new(map, false),
|
||||
)),
|
||||
GameMode::Osu => {
|
||||
Self::Osu(difficulty.gradual_performance(&OsuBeatmap::new(map, false)))
|
||||
}
|
||||
GameMode::Taiko => {
|
||||
Self::Taiko(difficulty.gradual_performance(&TaikoBeatmap::new(map, false)))
|
||||
}
|
||||
GameMode::Catch => {
|
||||
Self::Catch(difficulty.gradual_performance(&CatchBeatmap::new(map, false)))
|
||||
}
|
||||
GameMode::Mania => {
|
||||
Self::Mania(difficulty.gradual_performance(&ManiaBeatmap::new(map, false)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
from_converted!(from_osu_map, Osu, OsuBeatmap, OsuGradualPerformance);
|
||||
from_converted!(from_taiko_map, Taiko, TaikoBeatmap, TaikoGradualPerformance);
|
||||
from_converted!(from_catch_map, Catch, CatchBeatmap, CatchGradualPerformance);
|
||||
from_converted!(from_mania_map, Mania, ManiaBeatmap, ManiaGradualPerformance);
|
||||
from_converted!(from_osu_map, Osu, OsuBeatmap);
|
||||
from_converted!(from_taiko_map, Taiko, TaikoBeatmap);
|
||||
from_converted!(from_catch_map, Catch, CatchBeatmap);
|
||||
from_converted!(from_mania_map, Mania, ManiaBeatmap);
|
||||
|
||||
/// Process the next hit object and calculate the performance attributes
|
||||
/// for the resulting score state.
|
||||
|
||||
@@ -288,25 +288,25 @@ impl<A: AttributeProvider> From<A> for Performance<'_> {
|
||||
}
|
||||
|
||||
macro_rules! impl_from_converted {
|
||||
( $mode:ident: $performance:ident ) => {
|
||||
( $mode:ident ) => {
|
||||
impl<'a> From<Converted<'a, $mode>> for Performance<'a> {
|
||||
fn from(converted: Converted<'a, $mode>) -> Self {
|
||||
Self::$mode($performance::new(converted))
|
||||
Self::$mode(converted.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b: 'a> From<&'b Converted<'a, $mode>> for Performance<'a> {
|
||||
fn from(converted: &'b Converted<'a, $mode>) -> Self {
|
||||
Self::$mode($performance::new(converted.as_owned()))
|
||||
Self::$mode(converted.as_owned().into())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl_from_converted!(Osu: OsuPerformance);
|
||||
impl_from_converted!(Taiko: TaikoPerformance);
|
||||
impl_from_converted!(Catch: CatchPerformance);
|
||||
impl_from_converted!(Mania: ManiaPerformance);
|
||||
impl_from_converted!(Osu);
|
||||
impl_from_converted!(Taiko);
|
||||
impl_from_converted!(Catch);
|
||||
impl_from_converted!(Mania);
|
||||
|
||||
/// While generating remaining hitresults, decide how they should be distributed.
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
|
||||
|
||||
Reference in New Issue
Block a user