provided a way for partial plays
This commit is contained in:
+8
-3
@@ -27,9 +27,13 @@ const COLOR_SKILL_MULTIPLIER: f32 = 0.01;
|
||||
const RHYTHM_SKILL_MULTIPLIER: f32 = 0.014;
|
||||
const STAMINA_SKILL_MULTIPLIER: f32 = 0.02;
|
||||
|
||||
/// Star calculation for osu!taiko maps
|
||||
pub fn stars(map: &Beatmap, mods: impl Mods) -> f32 {
|
||||
if map.hit_objects.len() < 2 {
|
||||
/// 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 {
|
||||
let take = passed_objects.unwrap_or_else(|| map.hit_objects.len());
|
||||
|
||||
if take < 2 {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@@ -53,6 +57,7 @@ pub fn stars(map: &Beatmap, mods: impl Mods) -> f32 {
|
||||
let mut hit_objects = map
|
||||
.hit_objects
|
||||
.iter()
|
||||
.take(take)
|
||||
.enumerate()
|
||||
.skip(2)
|
||||
.zip(map.hit_objects.iter().skip(1))
|
||||
|
||||
+11
-2
@@ -16,7 +16,6 @@ impl PpProvider for Beatmap {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Allow partial plays
|
||||
pub struct PpCalculator<'m> {
|
||||
map: &'m Beatmap,
|
||||
stars: Option<f32>,
|
||||
@@ -25,6 +24,7 @@ pub struct PpCalculator<'m> {
|
||||
combo: Option<usize>,
|
||||
acc: f32,
|
||||
n_misses: usize,
|
||||
passed_objects: Option<usize>,
|
||||
}
|
||||
|
||||
impl<'m> PpCalculator<'m> {
|
||||
@@ -40,6 +40,7 @@ impl<'m> PpCalculator<'m> {
|
||||
combo: None,
|
||||
acc: 1.0,
|
||||
n_misses: 0,
|
||||
passed_objects: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,10 +80,18 @@ impl<'m> PpCalculator<'m> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Amount of passed objects for partial plays, e.g. a fail.
|
||||
#[inline]
|
||||
pub fn passed_objects(mut self, passed_objects: usize) -> Self {
|
||||
self.passed_objects.replace(passed_objects);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn calculate(self) -> PpResult {
|
||||
let stars = self
|
||||
.stars
|
||||
.unwrap_or_else(|| super::stars(self.map, self.mods));
|
||||
.unwrap_or_else(|| super::stars(self.map, self.mods, self.passed_objects));
|
||||
|
||||
let mut multiplier = 1.1;
|
||||
|
||||
|
||||
+15
-8
@@ -4,6 +4,15 @@ use std::cmp::Ordering;
|
||||
|
||||
const DECAY_WEIGHT: f32 = 0.9;
|
||||
|
||||
const COLOR_SKILL_MULTIPLIER: f32 = 1.0;
|
||||
const COLOR_STRAIN_DECAY_BASE: f32 = 0.4;
|
||||
|
||||
const RHYTHM_SKILL_MULTIPLIER: f32 = 10.0;
|
||||
const RHYTHM_STRAIN_DECAY_BASE: f32 = 0.0;
|
||||
|
||||
const STAMINA_SKILL_MULTIPLIER: f32 = 1.0;
|
||||
const STAMINA_STRAIN_DECAY_BASE: f32 = 0.4;
|
||||
|
||||
pub(crate) struct Skill {
|
||||
pub current_strain: f32,
|
||||
current_section_peak: f32,
|
||||
@@ -65,21 +74,19 @@ impl Skill {
|
||||
|
||||
#[inline]
|
||||
fn skill_multiplier(&self) -> f32 {
|
||||
// TODO: Use constants
|
||||
match self.kind {
|
||||
SkillKind::Color { .. } => 1.0,
|
||||
SkillKind::Rhythm { .. } => 10.0,
|
||||
SkillKind::Stamina { .. } => 1.0,
|
||||
SkillKind::Color { .. } => COLOR_SKILL_MULTIPLIER,
|
||||
SkillKind::Rhythm { .. } => RHYTHM_SKILL_MULTIPLIER,
|
||||
SkillKind::Stamina { .. } => STAMINA_SKILL_MULTIPLIER,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn strain_decay_base(&self) -> f32 {
|
||||
// TODO: Use constants
|
||||
match self.kind {
|
||||
SkillKind::Color { .. } => 0.4,
|
||||
SkillKind::Rhythm { .. } => 0.0,
|
||||
SkillKind::Stamina { .. } => 0.4,
|
||||
SkillKind::Color { .. } => COLOR_STRAIN_DECAY_BASE,
|
||||
SkillKind::Rhythm { .. } => RHYTHM_STRAIN_DECAY_BASE,
|
||||
SkillKind::Stamina { .. } => STAMINA_STRAIN_DECAY_BASE,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user