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