adjusted IGameMode trait
This commit is contained in:
+11
-5
@@ -1,5 +1,3 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use rosu_map::section::{general::GameMode, hit_objects::CurveBuffers};
|
||||
|
||||
use crate::{
|
||||
@@ -28,12 +26,20 @@ const RNG_SEED: i32 = 1337;
|
||||
/// A [`Beatmap`] for [`Catch`] calculations.
|
||||
pub type CatchBeatmap<'a> = Converted<'a, Catch>;
|
||||
|
||||
pub fn try_convert(map: &mut Cow<'_, Beatmap>) -> ConvertStatus {
|
||||
pub fn check_convert(map: &Beatmap) -> ConvertStatus {
|
||||
match map.mode {
|
||||
GameMode::Osu => ConvertStatus::Conversion,
|
||||
GameMode::Catch => ConvertStatus::Noop,
|
||||
GameMode::Taiko | GameMode::Mania => ConvertStatus::Incompatible,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_convert(map: &mut Beatmap) -> ConvertStatus {
|
||||
match map.mode {
|
||||
GameMode::Osu => {
|
||||
map.to_mut().mode = GameMode::Catch;
|
||||
map.mode = GameMode::Catch;
|
||||
|
||||
ConvertStatus::Done
|
||||
ConvertStatus::Conversion
|
||||
}
|
||||
GameMode::Catch => ConvertStatus::Noop,
|
||||
GameMode::Taiko | GameMode::Mania => ConvertStatus::Incompatible,
|
||||
|
||||
+5
-3
@@ -1,5 +1,3 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::{
|
||||
any::ModeDifficulty,
|
||||
model::{
|
||||
@@ -40,7 +38,11 @@ impl IGameMode for Catch {
|
||||
type GradualDifficulty = CatchGradualDifficulty;
|
||||
type GradualPerformance = CatchGradualPerformance;
|
||||
|
||||
fn try_convert(map: &mut Cow<'_, Beatmap>) -> ConvertStatus {
|
||||
fn check_convert(map: &Beatmap) -> ConvertStatus {
|
||||
convert::check_convert(map)
|
||||
}
|
||||
|
||||
fn try_convert(map: &mut Beatmap) -> ConvertStatus {
|
||||
convert::try_convert(map)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use rosu_map::{
|
||||
section::{general::GameMode, hit_objects::CurveBuffers},
|
||||
util::Pos,
|
||||
@@ -34,12 +32,20 @@ pub type ManiaBeatmap<'a> = Converted<'a, Mania>;
|
||||
|
||||
const MAX_NOTES_FOR_DENSITY: usize = 7;
|
||||
|
||||
pub fn try_convert(map: &mut Cow<'_, Beatmap>) -> ConvertStatus {
|
||||
pub fn check_convert(map: &Beatmap) -> ConvertStatus {
|
||||
match map.mode {
|
||||
GameMode::Osu => ConvertStatus::Conversion,
|
||||
GameMode::Mania => ConvertStatus::Noop,
|
||||
GameMode::Taiko | GameMode::Catch => ConvertStatus::Incompatible,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_convert(map: &mut Beatmap) -> ConvertStatus {
|
||||
match map.mode {
|
||||
GameMode::Osu => {
|
||||
convert(map.to_mut());
|
||||
convert(map);
|
||||
|
||||
ConvertStatus::Done
|
||||
ConvertStatus::Conversion
|
||||
}
|
||||
GameMode::Mania => ConvertStatus::Noop,
|
||||
GameMode::Taiko | GameMode::Catch => ConvertStatus::Incompatible,
|
||||
|
||||
+5
-3
@@ -1,5 +1,3 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::{
|
||||
any::ModeDifficulty,
|
||||
model::{
|
||||
@@ -37,7 +35,11 @@ impl IGameMode for Mania {
|
||||
type GradualDifficulty = ManiaGradualDifficulty;
|
||||
type GradualPerformance = ManiaGradualPerformance;
|
||||
|
||||
fn try_convert(map: &mut Cow<'_, Beatmap>) -> ConvertStatus {
|
||||
fn check_convert(map: &Beatmap) -> ConvertStatus {
|
||||
convert::check_convert(map)
|
||||
}
|
||||
|
||||
fn try_convert(map: &mut Beatmap) -> ConvertStatus {
|
||||
convert::try_convert(map)
|
||||
}
|
||||
|
||||
|
||||
+10
-9
@@ -1,5 +1,3 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
pub use rosu_map::section::general::GameMode;
|
||||
|
||||
use crate::any::ModeDifficulty;
|
||||
@@ -31,11 +29,14 @@ pub trait IGameMode: Sized {
|
||||
/// The type of a gradual performance calculator.
|
||||
type GradualPerformance;
|
||||
|
||||
/// Check whether the map's mode can be converted to the current type.
|
||||
fn check_convert(map: &Beatmap) -> ConvertStatus;
|
||||
|
||||
/// Attempt to convert a beatmap.
|
||||
///
|
||||
/// In case [`ConvertStatus::Incompatible`] is returned, the map should
|
||||
/// **not** be modified.
|
||||
fn try_convert(map: &mut Cow<'_, Beatmap>) -> ConvertStatus;
|
||||
/// In case [`ConvertStatus::Incompatible`] is returned, the map is not
|
||||
/// modified.
|
||||
fn try_convert(map: &mut Beatmap) -> ConvertStatus;
|
||||
|
||||
/// Perform a difficulty calculation for a [`Converted`] beatmap and
|
||||
/// process the final skill values.
|
||||
@@ -67,10 +68,10 @@ pub trait IGameMode: Sized {
|
||||
/// The status of a conversion through [`IGameMode::try_convert`].
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ConvertStatus {
|
||||
/// Conversion was not necessary.
|
||||
/// Conversion not necessary.
|
||||
Noop,
|
||||
/// Conversion was successful.
|
||||
Done,
|
||||
/// Conversion was not possible.
|
||||
/// Conversion possible.
|
||||
Conversion,
|
||||
/// Conversion not possible.
|
||||
Incompatible,
|
||||
}
|
||||
|
||||
+5
-3
@@ -1,5 +1,3 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use rosu_map::section::{general::GameMode, hit_objects::CurveBuffers};
|
||||
|
||||
use crate::model::{
|
||||
@@ -17,7 +15,7 @@ use super::{
|
||||
/// A [`Beatmap`] for [`Osu`] calculations.
|
||||
pub type OsuBeatmap<'a> = Converted<'a, Osu>;
|
||||
|
||||
pub fn try_convert(map: &mut Cow<'_, Beatmap>) -> ConvertStatus {
|
||||
pub fn check_convert(map: &Beatmap) -> ConvertStatus {
|
||||
if map.mode == GameMode::Osu {
|
||||
ConvertStatus::Noop
|
||||
} else {
|
||||
@@ -25,6 +23,10 @@ pub fn try_convert(map: &mut Cow<'_, Beatmap>) -> ConvertStatus {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_convert(map: &mut Beatmap) -> ConvertStatus {
|
||||
check_convert(map)
|
||||
}
|
||||
|
||||
pub fn convert_objects(
|
||||
converted: &OsuBeatmap<'_>,
|
||||
scaling_factor: &ScalingFactor,
|
||||
|
||||
+5
-3
@@ -1,5 +1,3 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use rosu_map::util::Pos;
|
||||
|
||||
use crate::{
|
||||
@@ -41,7 +39,11 @@ impl IGameMode for Osu {
|
||||
type GradualDifficulty = OsuGradualDifficulty;
|
||||
type GradualPerformance = OsuGradualPerformance;
|
||||
|
||||
fn try_convert(map: &mut Cow<'_, Beatmap>) -> ConvertStatus {
|
||||
fn check_convert(map: &Beatmap) -> ConvertStatus {
|
||||
convert::check_convert(map)
|
||||
}
|
||||
|
||||
fn try_convert(map: &mut Beatmap) -> ConvertStatus {
|
||||
convert::try_convert(map)
|
||||
}
|
||||
|
||||
|
||||
+12
-4
@@ -1,4 +1,4 @@
|
||||
use std::{borrow::Cow, cmp};
|
||||
use std::cmp;
|
||||
|
||||
use rosu_map::{
|
||||
section::{general::GameMode, hit_objects::CurveBuffers},
|
||||
@@ -23,12 +23,20 @@ pub type TaikoBeatmap<'a> = Converted<'a, Taiko>;
|
||||
const LEGACY_TAIKO_VELOCITY_MULTIPLIER: f32 = 1.4;
|
||||
const OSU_BASE_SCORING_DIST: f32 = 100.0;
|
||||
|
||||
pub fn try_convert(map: &mut Cow<'_, Beatmap>) -> ConvertStatus {
|
||||
pub fn check_convert(map: &Beatmap) -> ConvertStatus {
|
||||
match map.mode {
|
||||
GameMode::Osu => ConvertStatus::Conversion,
|
||||
GameMode::Taiko => ConvertStatus::Noop,
|
||||
GameMode::Catch | GameMode::Mania => ConvertStatus::Incompatible,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_convert(map: &mut Beatmap) -> ConvertStatus {
|
||||
match map.mode {
|
||||
GameMode::Osu => {
|
||||
convert(map.to_mut());
|
||||
convert(map);
|
||||
|
||||
ConvertStatus::Done
|
||||
ConvertStatus::Conversion
|
||||
}
|
||||
GameMode::Taiko => ConvertStatus::Noop,
|
||||
GameMode::Catch | GameMode::Mania => ConvertStatus::Incompatible,
|
||||
|
||||
+5
-3
@@ -1,5 +1,3 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::{
|
||||
any::ModeDifficulty,
|
||||
model::{
|
||||
@@ -37,7 +35,11 @@ impl IGameMode for Taiko {
|
||||
type GradualDifficulty = TaikoGradualDifficulty;
|
||||
type GradualPerformance = TaikoGradualPerformance;
|
||||
|
||||
fn try_convert(map: &mut Cow<'_, Beatmap>) -> ConvertStatus {
|
||||
fn check_convert(map: &Beatmap) -> ConvertStatus {
|
||||
convert::check_convert(map)
|
||||
}
|
||||
|
||||
fn try_convert(map: &mut Beatmap) -> ConvertStatus {
|
||||
convert::try_convert(map)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user