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