use the same StarResult type for all modes
This commit is contained in:
+6
-4
@@ -16,7 +16,7 @@ use skill::Skill;
|
||||
use skill_kind::SkillKind;
|
||||
use stamina_cheese::StaminaCheeseDetector;
|
||||
|
||||
use crate::{Beatmap, Mods};
|
||||
use crate::{Beatmap, Mods, StarResult};
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::f32::consts::PI;
|
||||
@@ -30,11 +30,11 @@ const STAMINA_SKILL_MULTIPLIER: f32 = 0.02;
|
||||
/// Star calculation for osu!taiko maps.
|
||||
///
|
||||
/// In case of a partial play, e.g. a fail, one can specify the amount of passed objects.
|
||||
pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> f32 {
|
||||
pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> StarResult {
|
||||
let take = passed_objects.unwrap_or_else(|| map.hit_objects.len());
|
||||
|
||||
if take < 2 {
|
||||
return 0.0;
|
||||
return StarResult::Taiko { stars: 0.0 };
|
||||
}
|
||||
|
||||
// True if the object at that index is stamina cheese
|
||||
@@ -112,7 +112,9 @@ pub fn stars(map: &Beatmap, mods: impl Mods, passed_objects: Option<usize>) -> f
|
||||
let combined_rating = locally_combined_difficulty(&skills, stamina_penalty);
|
||||
let separate_rating = norm(1.5, color_rating, rhythm_rating, stamina_rating);
|
||||
|
||||
rescale(1.4 * separate_rating + 0.5 * combined_rating)
|
||||
let stars = rescale(1.4 * separate_rating + 0.5 * combined_rating);
|
||||
|
||||
StarResult::Taiko { stars }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
+15
-6
@@ -1,4 +1,4 @@
|
||||
use crate::{Beatmap, Mods, PpResult};
|
||||
use crate::{Beatmap, Mods, PpResult, StarResult};
|
||||
|
||||
pub trait TaikoStarProvider {
|
||||
fn attributes(self) -> Option<f32>;
|
||||
@@ -10,9 +10,9 @@ impl TaikoStarProvider for f32 {
|
||||
}
|
||||
}
|
||||
|
||||
impl TaikoStarProvider for PpResult {
|
||||
impl TaikoStarProvider for StarResult {
|
||||
fn attributes(self) -> Option<f32> {
|
||||
if let PpResult::Taiko { stars, .. } = self {
|
||||
if let StarResult::Taiko { stars } = self {
|
||||
Some(stars)
|
||||
} else {
|
||||
None
|
||||
@@ -20,6 +20,12 @@ impl TaikoStarProvider for PpResult {
|
||||
}
|
||||
}
|
||||
|
||||
impl TaikoStarProvider for PpResult {
|
||||
fn attributes(self) -> Option<f32> {
|
||||
self.attributes.attributes()
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculator for pp on osu!taiko maps.
|
||||
pub struct TaikoPP<'m> {
|
||||
map: &'m Beatmap,
|
||||
@@ -50,7 +56,7 @@ impl<'m> TaikoPP<'m> {
|
||||
}
|
||||
}
|
||||
|
||||
/// [`TaikoStarProvider`] is implemented by `f32`
|
||||
/// [`TaikoStarProvider`] is implemented by `f32`, [`StarResult`](crate::StarResult),
|
||||
/// and by [`PpResult`](crate::PpResult) meaning you can give the
|
||||
/// result of a star calculation or a pp calculation.
|
||||
/// If you already calculated the stars for the current map-mod combination,
|
||||
@@ -110,7 +116,7 @@ impl<'m> TaikoPP<'m> {
|
||||
pub fn calculate(self) -> PpResult {
|
||||
let stars = self
|
||||
.stars
|
||||
.unwrap_or_else(|| super::stars(self.map, self.mods, self.passed_objects));
|
||||
.unwrap_or_else(|| super::stars(self.map, self.mods, self.passed_objects).stars());
|
||||
|
||||
let mut multiplier = 1.1;
|
||||
|
||||
@@ -127,7 +133,10 @@ impl<'m> TaikoPP<'m> {
|
||||
|
||||
let pp = (strain_value.powf(1.1) + acc_value.powf(1.1)).powf(1.0 / 1.1) * multiplier;
|
||||
|
||||
PpResult::Taiko { stars, pp }
|
||||
PpResult {
|
||||
pp,
|
||||
attributes: StarResult::Taiko { stars },
|
||||
}
|
||||
}
|
||||
|
||||
fn compute_strain_value(&self, stars: f32) -> f32 {
|
||||
|
||||
Reference in New Issue
Block a user