made bunch of functions const
This commit is contained in:
@@ -30,11 +30,11 @@ pub struct Difficulty<'map> {
|
|||||||
|
|
||||||
impl<'map> Difficulty<'map> {
|
impl<'map> Difficulty<'map> {
|
||||||
/// Create a new difficulty calculator for the given beatmap.
|
/// Create a new difficulty calculator for the given beatmap.
|
||||||
pub fn new(map: &'map Beatmap) -> Self {
|
pub const fn new(map: &'map Beatmap) -> Self {
|
||||||
Self::new_with_is_convert(Cow::Borrowed(map), false)
|
Self::new_with_is_convert(Cow::Borrowed(map), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_is_convert(map: Cow<'map, Beatmap>, is_convert: bool) -> Self {
|
const fn new_with_is_convert(map: Cow<'map, Beatmap>, is_convert: bool) -> Self {
|
||||||
Self {
|
Self {
|
||||||
map,
|
map,
|
||||||
is_convert,
|
is_convert,
|
||||||
|
|||||||
@@ -14,8 +14,12 @@ pub struct ModeDifficulty {
|
|||||||
|
|
||||||
impl ModeDifficulty {
|
impl ModeDifficulty {
|
||||||
/// Create a new difficulty calculator.
|
/// Create a new difficulty calculator.
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self::default()
|
Self {
|
||||||
|
mods: 0,
|
||||||
|
passed_objects: None,
|
||||||
|
clock_rate: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specify mods through their bit values.
|
/// Specify mods through their bit values.
|
||||||
|
|||||||
@@ -30,10 +30,11 @@ pub enum Performance<'map> {
|
|||||||
|
|
||||||
impl<'map> Performance<'map> {
|
impl<'map> Performance<'map> {
|
||||||
/// Create a new performance calculator for maps of any mode.
|
/// Create a new performance calculator for maps of any mode.
|
||||||
pub fn new(map: &'map Beatmap) -> Self {
|
pub const fn new(map: &'map Beatmap) -> Self {
|
||||||
|
let mode = map.mode;
|
||||||
let map = Cow::Borrowed(map);
|
let map = Cow::Borrowed(map);
|
||||||
|
|
||||||
match map.mode {
|
match mode {
|
||||||
GameMode::Osu => Self::Osu(OsuPerformance::new(Converted::new(map, false))),
|
GameMode::Osu => Self::Osu(OsuPerformance::new(Converted::new(map, false))),
|
||||||
GameMode::Taiko => Self::Taiko(TaikoPerformance::new(Converted::new(map, false))),
|
GameMode::Taiko => Self::Taiko(TaikoPerformance::new(Converted::new(map, false))),
|
||||||
GameMode::Catch => Self::Catch(CatchPerformance::new(Converted::new(map, false))),
|
GameMode::Catch => Self::Catch(CatchPerformance::new(Converted::new(map, false))),
|
||||||
@@ -274,7 +275,7 @@ impl<'map> Performance<'map> {
|
|||||||
|
|
||||||
impl<A: AttributeProvider> From<A> for Performance<'_> {
|
impl<A: AttributeProvider> From<A> for Performance<'_> {
|
||||||
fn from(attrs: A) -> Self {
|
fn from(attrs: A) -> Self {
|
||||||
fn inner(attrs: DifficultyAttributes) -> Performance<'static> {
|
const fn inner(attrs: DifficultyAttributes) -> Performance<'static> {
|
||||||
match attrs {
|
match attrs {
|
||||||
DifficultyAttributes::Osu(attrs) => Performance::Osu(attrs.performance()),
|
DifficultyAttributes::Osu(attrs) => Performance::Osu(attrs.performance()),
|
||||||
DifficultyAttributes::Taiko(attrs) => Performance::Taiko(attrs.performance()),
|
DifficultyAttributes::Taiko(attrs) => Performance::Taiko(attrs.performance()),
|
||||||
@@ -309,11 +310,20 @@ impl_from_converted!(Catch);
|
|||||||
impl_from_converted!(Mania);
|
impl_from_converted!(Mania);
|
||||||
|
|
||||||
/// While generating remaining hitresults, decide how they should be distributed.
|
/// While generating remaining hitresults, decide how they should be distributed.
|
||||||
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum HitResultPriority {
|
pub enum HitResultPriority {
|
||||||
/// Prioritize good hitresults over bad ones
|
/// Prioritize good hitresults over bad ones
|
||||||
#[default]
|
|
||||||
BestCase,
|
BestCase,
|
||||||
/// Prioritize bad hitresults over good ones
|
/// Prioritize bad hitresults over good ones
|
||||||
WorstCase,
|
WorstCase,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl HitResultPriority {
|
||||||
|
pub(crate) const DEFAULT: Self = Self::BestCase;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for HitResultPriority {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::DEFAULT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+17
-3
@@ -5,7 +5,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Aggregation for a score's current state.
|
/// Aggregation for a score's current state.
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct ScoreState {
|
pub struct ScoreState {
|
||||||
/// Maximum combo that the score has had so far. **Not** the maximum
|
/// Maximum combo that the score has had so far. **Not** the maximum
|
||||||
/// possible combo of the map so far.
|
/// possible combo of the map so far.
|
||||||
@@ -32,8 +32,16 @@ pub struct ScoreState {
|
|||||||
|
|
||||||
impl ScoreState {
|
impl ScoreState {
|
||||||
/// Create a new empty score state.
|
/// Create a new empty score state.
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self::default()
|
Self {
|
||||||
|
max_combo: 0,
|
||||||
|
n_geki: 0,
|
||||||
|
n_katu: 0,
|
||||||
|
n300: 0,
|
||||||
|
n100: 0,
|
||||||
|
n50: 0,
|
||||||
|
misses: 0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the total amount of hits by adding everything up based on the
|
/// Return the total amount of hits by adding everything up based on the
|
||||||
@@ -158,3 +166,9 @@ impl From<ManiaScoreState> for ScoreState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for ScoreState {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ impl CatchDifficultyAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a builder for performance calculation.
|
/// Returns a builder for performance calculation.
|
||||||
pub fn performance<'a>(self) -> CatchPerformance<'a> {
|
pub const fn performance<'a>(self) -> CatchPerformance<'a> {
|
||||||
self.into()
|
CatchPerformance::from_catch_attributes(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_object_count(&mut self, count: &ObjectCount) {
|
pub(crate) fn set_object_count(&mut self, count: &ObjectCount) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ 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 check_convert(map: &Beatmap) -> ConvertStatus {
|
pub const fn check_convert(map: &Beatmap) -> ConvertStatus {
|
||||||
match map.mode {
|
match map.mode {
|
||||||
GameMode::Osu => ConvertStatus::Conversion,
|
GameMode::Osu => ConvertStatus::Conversion,
|
||||||
GameMode::Catch => ConvertStatus::Noop,
|
GameMode::Catch => ConvertStatus::Noop,
|
||||||
|
|||||||
@@ -33,8 +33,32 @@ pub struct CatchPerformance<'map> {
|
|||||||
|
|
||||||
impl<'map> CatchPerformance<'map> {
|
impl<'map> CatchPerformance<'map> {
|
||||||
/// Create a new performance calculator for osu!catch maps.
|
/// Create a new performance calculator for osu!catch maps.
|
||||||
pub fn new(map: CatchBeatmap<'map>) -> Self {
|
pub const fn new(map: CatchBeatmap<'map>) -> Self {
|
||||||
map.into()
|
Self {
|
||||||
|
map_or_attrs: MapOrAttrs::Map(map),
|
||||||
|
difficulty: ModeDifficulty::new(),
|
||||||
|
acc: None,
|
||||||
|
combo: None,
|
||||||
|
fruits: None,
|
||||||
|
droplets: None,
|
||||||
|
tiny_droplets: None,
|
||||||
|
tiny_droplet_misses: None,
|
||||||
|
misses: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) const fn from_catch_attributes(attrs: CatchDifficultyAttributes) -> Self {
|
||||||
|
Self {
|
||||||
|
map_or_attrs: MapOrAttrs::Attrs(attrs),
|
||||||
|
difficulty: ModeDifficulty::new(),
|
||||||
|
acc: None,
|
||||||
|
combo: None,
|
||||||
|
fruits: None,
|
||||||
|
droplets: None,
|
||||||
|
tiny_droplets: None,
|
||||||
|
tiny_droplet_misses: None,
|
||||||
|
misses: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Provide the result of a previous difficulty or performance calculation.
|
/// Provide the result of a previous difficulty or performance calculation.
|
||||||
@@ -406,39 +430,19 @@ impl<'map> TryFrom<OsuPerformance<'map>> for CatchPerformance<'map> {
|
|||||||
|
|
||||||
impl<'map> From<CatchBeatmap<'map>> for CatchPerformance<'map> {
|
impl<'map> From<CatchBeatmap<'map>> for CatchPerformance<'map> {
|
||||||
fn from(map: CatchBeatmap<'map>) -> Self {
|
fn from(map: CatchBeatmap<'map>) -> Self {
|
||||||
Self {
|
Self::new(map)
|
||||||
map_or_attrs: MapOrAttrs::Map(map),
|
|
||||||
difficulty: ModeDifficulty::new(),
|
|
||||||
acc: None,
|
|
||||||
combo: None,
|
|
||||||
fruits: None,
|
|
||||||
droplets: None,
|
|
||||||
tiny_droplets: None,
|
|
||||||
tiny_droplet_misses: None,
|
|
||||||
misses: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CatchDifficultyAttributes> for CatchPerformance<'_> {
|
impl From<CatchDifficultyAttributes> for CatchPerformance<'_> {
|
||||||
fn from(attrs: CatchDifficultyAttributes) -> Self {
|
fn from(attrs: CatchDifficultyAttributes) -> Self {
|
||||||
Self {
|
Self::from_catch_attributes(attrs)
|
||||||
map_or_attrs: MapOrAttrs::Attrs(attrs),
|
|
||||||
difficulty: ModeDifficulty::new(),
|
|
||||||
acc: None,
|
|
||||||
combo: None,
|
|
||||||
fruits: None,
|
|
||||||
droplets: None,
|
|
||||||
tiny_droplets: None,
|
|
||||||
tiny_droplet_misses: None,
|
|
||||||
misses: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CatchPerformanceAttributes> for CatchPerformance<'_> {
|
impl From<CatchPerformanceAttributes> for CatchPerformance<'_> {
|
||||||
fn from(attrs: CatchPerformanceAttributes) -> Self {
|
fn from(attrs: CatchPerformanceAttributes) -> Self {
|
||||||
attrs.difficulty.into()
|
Self::from_catch_attributes(attrs.difficulty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/// Aggregation for a score's current state.
|
/// Aggregation for a score's current state.
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct CatchScoreState {
|
pub struct CatchScoreState {
|
||||||
/// Maximum combo that the score has had so far.
|
/// Maximum combo that the score has had so far.
|
||||||
/// **Not** the maximum possible combo of the map so far.
|
/// **Not** the maximum possible combo of the map so far.
|
||||||
@@ -20,8 +20,15 @@ pub struct CatchScoreState {
|
|||||||
|
|
||||||
impl CatchScoreState {
|
impl CatchScoreState {
|
||||||
/// Create a new empty score state.
|
/// Create a new empty score state.
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self::default()
|
Self {
|
||||||
|
max_combo: 0,
|
||||||
|
n_fruits: 0,
|
||||||
|
n_droplets: 0,
|
||||||
|
n_tiny_droplets: 0,
|
||||||
|
n_tiny_droplet_misses: 0,
|
||||||
|
misses: 0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the total amount of hits by adding everything up.
|
/// Return the total amount of hits by adding everything up.
|
||||||
@@ -47,3 +54,9 @@ impl CatchScoreState {
|
|||||||
f64::from(numerator) / f64::from(denominator)
|
f64::from(numerator) / f64::from(denominator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for CatchScoreState {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ impl ManiaDifficultyAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a builder for performance calculation.
|
/// Returns a builder for performance calculation.
|
||||||
pub fn performance<'a>(self) -> ManiaPerformance<'a> {
|
pub const fn performance<'a>(self) -> ManiaPerformance<'a> {
|
||||||
self.into()
|
ManiaPerformance::from_mania_attributes(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ pub type ManiaBeatmap<'a> = Converted<'a, Mania>;
|
|||||||
|
|
||||||
const MAX_NOTES_FOR_DENSITY: usize = 7;
|
const MAX_NOTES_FOR_DENSITY: usize = 7;
|
||||||
|
|
||||||
pub fn check_convert(map: &Beatmap) -> ConvertStatus {
|
pub const fn check_convert(map: &Beatmap) -> ConvertStatus {
|
||||||
match map.mode {
|
match map.mode {
|
||||||
GameMode::Osu => ConvertStatus::Conversion,
|
GameMode::Osu => ConvertStatus::Conversion,
|
||||||
GameMode::Mania => ConvertStatus::Noop,
|
GameMode::Mania => ConvertStatus::Noop,
|
||||||
|
|||||||
@@ -34,8 +34,34 @@ pub struct ManiaPerformance<'map> {
|
|||||||
|
|
||||||
impl<'map> ManiaPerformance<'map> {
|
impl<'map> ManiaPerformance<'map> {
|
||||||
/// Create a new performance calculator for osu!mania maps.
|
/// Create a new performance calculator for osu!mania maps.
|
||||||
pub fn new(map: ManiaBeatmap<'map>) -> Self {
|
pub const fn new(map: ManiaBeatmap<'map>) -> Self {
|
||||||
map.into()
|
Self {
|
||||||
|
map_or_attrs: MapOrAttrs::Map(map),
|
||||||
|
difficulty: ModeDifficulty::new(),
|
||||||
|
n320: None,
|
||||||
|
n300: None,
|
||||||
|
n200: None,
|
||||||
|
n100: None,
|
||||||
|
n50: None,
|
||||||
|
misses: None,
|
||||||
|
acc: None,
|
||||||
|
hitresult_priority: HitResultPriority::DEFAULT,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) const fn from_mania_attributes(attrs: ManiaDifficultyAttributes) -> Self {
|
||||||
|
Self {
|
||||||
|
map_or_attrs: MapOrAttrs::Attrs(attrs),
|
||||||
|
difficulty: ModeDifficulty::new(),
|
||||||
|
n320: None,
|
||||||
|
n300: None,
|
||||||
|
n200: None,
|
||||||
|
n100: None,
|
||||||
|
n50: None,
|
||||||
|
misses: None,
|
||||||
|
acc: None,
|
||||||
|
hitresult_priority: HitResultPriority::DEFAULT,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Provide the result of a previous difficulty or performance calculation.
|
/// Provide the result of a previous difficulty or performance calculation.
|
||||||
@@ -796,41 +822,19 @@ impl<'map> TryFrom<OsuPerformance<'map>> for ManiaPerformance<'map> {
|
|||||||
|
|
||||||
impl<'map> From<ManiaBeatmap<'map>> for ManiaPerformance<'map> {
|
impl<'map> From<ManiaBeatmap<'map>> for ManiaPerformance<'map> {
|
||||||
fn from(map: ManiaBeatmap<'map>) -> Self {
|
fn from(map: ManiaBeatmap<'map>) -> Self {
|
||||||
Self {
|
Self::new(map)
|
||||||
map_or_attrs: MapOrAttrs::Map(map),
|
|
||||||
difficulty: ModeDifficulty::new(),
|
|
||||||
n320: None,
|
|
||||||
n300: None,
|
|
||||||
n200: None,
|
|
||||||
n100: None,
|
|
||||||
n50: None,
|
|
||||||
misses: None,
|
|
||||||
acc: None,
|
|
||||||
hitresult_priority: HitResultPriority::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ManiaDifficultyAttributes> for ManiaPerformance<'_> {
|
impl From<ManiaDifficultyAttributes> for ManiaPerformance<'_> {
|
||||||
fn from(attrs: ManiaDifficultyAttributes) -> Self {
|
fn from(attrs: ManiaDifficultyAttributes) -> Self {
|
||||||
Self {
|
Self::from_mania_attributes(attrs)
|
||||||
map_or_attrs: MapOrAttrs::Attrs(attrs),
|
|
||||||
difficulty: ModeDifficulty::new(),
|
|
||||||
n320: None,
|
|
||||||
n300: None,
|
|
||||||
n200: None,
|
|
||||||
n100: None,
|
|
||||||
n50: None,
|
|
||||||
misses: None,
|
|
||||||
acc: None,
|
|
||||||
hitresult_priority: HitResultPriority::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ManiaPerformanceAttributes> for ManiaPerformance<'_> {
|
impl From<ManiaPerformanceAttributes> for ManiaPerformance<'_> {
|
||||||
fn from(attrs: ManiaPerformanceAttributes) -> Self {
|
fn from(attrs: ManiaPerformanceAttributes) -> Self {
|
||||||
attrs.difficulty.into()
|
Self::from_mania_attributes(attrs.difficulty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/// Aggregation for a score's current state.
|
/// Aggregation for a score's current state.
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct ManiaScoreState {
|
pub struct ManiaScoreState {
|
||||||
/// Amount of current 320s.
|
/// Amount of current 320s.
|
||||||
pub n320: u32,
|
pub n320: u32,
|
||||||
@@ -17,8 +17,15 @@ pub struct ManiaScoreState {
|
|||||||
|
|
||||||
impl ManiaScoreState {
|
impl ManiaScoreState {
|
||||||
/// Create a new empty score state.
|
/// Create a new empty score state.
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self::default()
|
Self {
|
||||||
|
n320: 0,
|
||||||
|
n300: 0,
|
||||||
|
n200: 0,
|
||||||
|
n100: 0,
|
||||||
|
n50: 0,
|
||||||
|
misses: 0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the total amount of hits by adding everything up.
|
/// Return the total amount of hits by adding everything up.
|
||||||
@@ -40,3 +47,9 @@ impl ManiaScoreState {
|
|||||||
f64::from(numerator) / f64::from(denominator)
|
f64::from(numerator) / f64::from(denominator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for ManiaScoreState {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -71,12 +71,12 @@ impl Beatmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a difficulty calculator for this [`Beatmap`].
|
/// Create a difficulty calculator for this [`Beatmap`].
|
||||||
pub fn difficulty(&self) -> Difficulty<'_> {
|
pub const fn difficulty(&self) -> Difficulty<'_> {
|
||||||
Difficulty::new(self)
|
Difficulty::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a performance calculator for this [`Beatmap`].
|
/// Create a performance calculator for this [`Beatmap`].
|
||||||
pub fn performance(&self) -> Performance<'_> {
|
pub const fn performance(&self) -> Performance<'_> {
|
||||||
Performance::new(self)
|
Performance::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,8 +150,8 @@ impl Beatmap {
|
|||||||
|
|
||||||
/// Returns a [`BeatmapAttributesBuilder`] to calculate modified beatmap
|
/// Returns a [`BeatmapAttributesBuilder`] to calculate modified beatmap
|
||||||
/// attributes.
|
/// attributes.
|
||||||
pub fn attributes(&self) -> BeatmapAttributesBuilder {
|
pub const fn attributes(&self) -> BeatmapAttributesBuilder {
|
||||||
self.into()
|
BeatmapAttributesBuilder::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The beats per minute of the map.
|
/// The beats per minute of the map.
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ impl OsuDifficultyAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a builder for performance calculation.
|
/// Returns a builder for performance calculation.
|
||||||
pub fn performance<'a>(self) -> OsuPerformance<'a> {
|
pub const fn performance<'a>(self) -> OsuPerformance<'a> {
|
||||||
self.into()
|
OsuPerformance::from_osu_attributes(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ mod osu_objects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl OsuObjects {
|
impl OsuObjects {
|
||||||
pub(super) fn new(objects: Box<[OsuObject]>) -> Self {
|
pub(super) const fn new(objects: Box<[OsuObject]>) -> Self {
|
||||||
Self { objects }
|
Self { objects }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+29
-25
@@ -37,8 +37,32 @@ pub struct OsuPerformance<'map> {
|
|||||||
|
|
||||||
impl<'map> OsuPerformance<'map> {
|
impl<'map> OsuPerformance<'map> {
|
||||||
/// Create a new performance calculator for osu!standard maps.
|
/// Create a new performance calculator for osu!standard maps.
|
||||||
pub fn new(map: OsuBeatmap<'map>) -> Self {
|
pub const fn new(map: OsuBeatmap<'map>) -> Self {
|
||||||
map.into()
|
Self {
|
||||||
|
map_or_attrs: MapOrAttrs::Map(map),
|
||||||
|
difficulty: ModeDifficulty::new(),
|
||||||
|
acc: None,
|
||||||
|
combo: None,
|
||||||
|
n300: None,
|
||||||
|
n100: None,
|
||||||
|
n50: None,
|
||||||
|
misses: None,
|
||||||
|
hitresult_priority: HitResultPriority::DEFAULT,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) const fn from_osu_attributes(attrs: OsuDifficultyAttributes) -> Self {
|
||||||
|
Self {
|
||||||
|
map_or_attrs: MapOrAttrs::Attrs(attrs),
|
||||||
|
difficulty: ModeDifficulty::new(),
|
||||||
|
acc: None,
|
||||||
|
combo: None,
|
||||||
|
n300: None,
|
||||||
|
n100: None,
|
||||||
|
n50: None,
|
||||||
|
misses: None,
|
||||||
|
hitresult_priority: HitResultPriority::DEFAULT,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempt to convert the map to the specified mode.
|
/// Attempt to convert the map to the specified mode.
|
||||||
@@ -449,39 +473,19 @@ impl<'map> OsuPerformance<'map> {
|
|||||||
|
|
||||||
impl<'map> From<OsuBeatmap<'map>> for OsuPerformance<'map> {
|
impl<'map> From<OsuBeatmap<'map>> for OsuPerformance<'map> {
|
||||||
fn from(map: OsuBeatmap<'map>) -> Self {
|
fn from(map: OsuBeatmap<'map>) -> Self {
|
||||||
Self {
|
Self::new(map)
|
||||||
map_or_attrs: MapOrAttrs::Map(map),
|
|
||||||
difficulty: ModeDifficulty::new(),
|
|
||||||
acc: None,
|
|
||||||
combo: None,
|
|
||||||
n300: None,
|
|
||||||
n100: None,
|
|
||||||
n50: None,
|
|
||||||
misses: None,
|
|
||||||
hitresult_priority: HitResultPriority::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<OsuDifficultyAttributes> for OsuPerformance<'_> {
|
impl From<OsuDifficultyAttributes> for OsuPerformance<'_> {
|
||||||
fn from(attrs: OsuDifficultyAttributes) -> Self {
|
fn from(attrs: OsuDifficultyAttributes) -> Self {
|
||||||
Self {
|
Self::from_osu_attributes(attrs)
|
||||||
map_or_attrs: MapOrAttrs::Attrs(attrs),
|
|
||||||
difficulty: ModeDifficulty::new(),
|
|
||||||
acc: None,
|
|
||||||
combo: None,
|
|
||||||
n300: None,
|
|
||||||
n100: None,
|
|
||||||
n50: None,
|
|
||||||
misses: None,
|
|
||||||
hitresult_priority: HitResultPriority::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<OsuPerformanceAttributes> for OsuPerformance<'_> {
|
impl From<OsuPerformanceAttributes> for OsuPerformance<'_> {
|
||||||
fn from(attrs: OsuPerformanceAttributes) -> Self {
|
fn from(attrs: OsuPerformanceAttributes) -> Self {
|
||||||
attrs.difficulty.into()
|
Self::from_osu_attributes(attrs.difficulty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-3
@@ -1,5 +1,5 @@
|
|||||||
/// Aggregation for a score's current state.
|
/// Aggregation for a score's current state.
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct OsuScoreState {
|
pub struct OsuScoreState {
|
||||||
/// Maximum combo that the score has had so far.
|
/// Maximum combo that the score has had so far.
|
||||||
/// **Not** the maximum possible combo of the map so far.
|
/// **Not** the maximum possible combo of the map so far.
|
||||||
@@ -16,8 +16,14 @@ pub struct OsuScoreState {
|
|||||||
|
|
||||||
impl OsuScoreState {
|
impl OsuScoreState {
|
||||||
/// Create a new empty score state.
|
/// Create a new empty score state.
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self::default()
|
Self {
|
||||||
|
max_combo: 0,
|
||||||
|
n300: 0,
|
||||||
|
n100: 0,
|
||||||
|
n50: 0,
|
||||||
|
misses: 0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the total amount of hits by adding everything up.
|
/// Return the total amount of hits by adding everything up.
|
||||||
@@ -39,3 +45,9 @@ impl OsuScoreState {
|
|||||||
f64::from(numerator) / f64::from(denominator)
|
f64::from(numerator) / f64::from(denominator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for OsuScoreState {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ impl TaikoDifficultyAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a builder for performance calculation.
|
/// Returns a builder for performance calculation.
|
||||||
pub fn performance<'a>(self) -> TaikoPerformance<'a> {
|
pub const fn performance<'a>(self) -> TaikoPerformance<'a> {
|
||||||
self.into()
|
TaikoPerformance::from_taiko_attributes(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ 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 check_convert(map: &Beatmap) -> ConvertStatus {
|
pub const fn check_convert(map: &Beatmap) -> ConvertStatus {
|
||||||
match map.mode {
|
match map.mode {
|
||||||
GameMode::Osu => ConvertStatus::Conversion,
|
GameMode::Osu => ConvertStatus::Conversion,
|
||||||
GameMode::Taiko => ConvertStatus::Noop,
|
GameMode::Taiko => ConvertStatus::Noop,
|
||||||
|
|||||||
@@ -32,8 +32,30 @@ pub struct TaikoPerformance<'map> {
|
|||||||
|
|
||||||
impl<'map> TaikoPerformance<'map> {
|
impl<'map> TaikoPerformance<'map> {
|
||||||
/// Create a new performance calculator for osu!taiko maps.
|
/// Create a new performance calculator for osu!taiko maps.
|
||||||
pub fn new(map: TaikoBeatmap<'map>) -> Self {
|
pub const fn new(map: TaikoBeatmap<'map>) -> Self {
|
||||||
map.into()
|
Self {
|
||||||
|
map_or_attrs: MapOrAttrs::Map(map),
|
||||||
|
difficulty: ModeDifficulty::new(),
|
||||||
|
combo: None,
|
||||||
|
acc: None,
|
||||||
|
misses: None,
|
||||||
|
n300: None,
|
||||||
|
n100: None,
|
||||||
|
hitresult_priority: HitResultPriority::DEFAULT,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) const fn from_taiko_attributes(attrs: TaikoDifficultyAttributes) -> Self {
|
||||||
|
Self {
|
||||||
|
map_or_attrs: MapOrAttrs::Attrs(attrs),
|
||||||
|
difficulty: ModeDifficulty::new(),
|
||||||
|
combo: None,
|
||||||
|
acc: None,
|
||||||
|
misses: None,
|
||||||
|
n300: None,
|
||||||
|
n100: None,
|
||||||
|
hitresult_priority: HitResultPriority::DEFAULT,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Provide the result of a previous difficulty or performance calculation.
|
/// Provide the result of a previous difficulty or performance calculation.
|
||||||
@@ -336,37 +358,19 @@ impl<'map> TryFrom<OsuPerformance<'map>> for TaikoPerformance<'map> {
|
|||||||
|
|
||||||
impl<'map> From<TaikoBeatmap<'map>> for TaikoPerformance<'map> {
|
impl<'map> From<TaikoBeatmap<'map>> for TaikoPerformance<'map> {
|
||||||
fn from(map: TaikoBeatmap<'map>) -> Self {
|
fn from(map: TaikoBeatmap<'map>) -> Self {
|
||||||
Self {
|
Self::new(map)
|
||||||
map_or_attrs: MapOrAttrs::Map(map),
|
|
||||||
difficulty: ModeDifficulty::new(),
|
|
||||||
combo: None,
|
|
||||||
acc: None,
|
|
||||||
misses: None,
|
|
||||||
n300: None,
|
|
||||||
n100: None,
|
|
||||||
hitresult_priority: HitResultPriority::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TaikoDifficultyAttributes> for TaikoPerformance<'_> {
|
impl From<TaikoDifficultyAttributes> for TaikoPerformance<'_> {
|
||||||
fn from(attrs: TaikoDifficultyAttributes) -> Self {
|
fn from(attrs: TaikoDifficultyAttributes) -> Self {
|
||||||
Self {
|
Self::from_taiko_attributes(attrs)
|
||||||
map_or_attrs: MapOrAttrs::Attrs(attrs),
|
|
||||||
difficulty: ModeDifficulty::new(),
|
|
||||||
combo: None,
|
|
||||||
acc: None,
|
|
||||||
misses: None,
|
|
||||||
n300: None,
|
|
||||||
n100: None,
|
|
||||||
hitresult_priority: HitResultPriority::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TaikoPerformanceAttributes> for TaikoPerformance<'_> {
|
impl From<TaikoPerformanceAttributes> for TaikoPerformance<'_> {
|
||||||
fn from(attrs: TaikoPerformanceAttributes) -> Self {
|
fn from(attrs: TaikoPerformanceAttributes) -> Self {
|
||||||
attrs.difficulty.into()
|
Self::from_taiko_attributes(attrs.difficulty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/// Aggregation for a score's current state.
|
/// Aggregation for a score's current state.
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct TaikoScoreState {
|
pub struct TaikoScoreState {
|
||||||
/// Maximum combo that the score has had so far.
|
/// Maximum combo that the score has had so far.
|
||||||
/// **Not** the maximum possible combo of the map so far.
|
/// **Not** the maximum possible combo of the map so far.
|
||||||
@@ -14,8 +14,13 @@ pub struct TaikoScoreState {
|
|||||||
|
|
||||||
impl TaikoScoreState {
|
impl TaikoScoreState {
|
||||||
/// Create a new empty score state.
|
/// Create a new empty score state.
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self::default()
|
Self {
|
||||||
|
max_combo: 0,
|
||||||
|
n300: 0,
|
||||||
|
n100: 0,
|
||||||
|
misses: 0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the total amount of hits by adding everything up.
|
/// Return the total amount of hits by adding everything up.
|
||||||
@@ -37,3 +42,9 @@ impl TaikoScoreState {
|
|||||||
f64::from(numerator) / f64::from(denominator)
|
f64::from(numerator) / f64::from(denominator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for TaikoScoreState {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user