return PerformanceAttributes instead of PpResult

This commit is contained in:
MaxOhn
2021-11-03 16:53:17 +01:00
parent b7caf35bb4
commit 5780559b70
16 changed files with 233 additions and 56 deletions
+24 -1
View File
@@ -261,7 +261,30 @@ fn norm(p: f32, a: f32, b: f32, c: f32) -> f32 {
/// Various data created through the star calculation.
/// This data is necessary to calculate PP.
#[derive(Clone, Debug, Default)]
#[derive(Copy, Clone, Debug, Default)]
pub struct DifficultyAttributes {
pub stars: f32,
}
/// Various data created through the pp calculation.
#[derive(Copy, Clone, Debug, Default)]
pub struct PerformanceAttributes {
pub attributes: DifficultyAttributes,
pub pp: f32,
pub pp_acc: f32,
pub pp_strain: f32,
}
impl PerformanceAttributes {
/// Return the star value.
#[inline]
pub fn stars(&self) -> f32 {
self.attributes.stars
}
/// Return the performance point value.
#[inline]
pub fn pp(&self) -> f32 {
self.pp
}
}
+20 -6
View File
@@ -1,4 +1,4 @@
use super::{stars, DifficultyAttributes};
use super::{stars, DifficultyAttributes, PerformanceAttributes};
use crate::{Beatmap, Mods, PpResult, StarResult};
/// Calculator for pp on osu!taiko maps.
@@ -136,7 +136,7 @@ impl<'m> TaikoPP<'m> {
}
/// Returns an object which contains the pp and stars.
pub fn calculate(mut self) -> PpResult {
pub fn calculate(mut self) -> PerformanceAttributes {
let stars = self
.stars
.unwrap_or_else(|| stars(self.map, self.mods, self.passed_objects).stars());
@@ -176,9 +176,11 @@ impl<'m> TaikoPP<'m> {
let pp = (strain_value.powf(1.1) + acc_value.powf(1.1)).powf(1.0 / 1.1) * multiplier;
PpResult {
PerformanceAttributes {
attributes: DifficultyAttributes { stars },
pp,
attributes: StarResult::Taiko(DifficultyAttributes { stars }),
pp_acc: acc_value,
pp_strain: strain_value,
}
}
@@ -253,11 +255,18 @@ impl TaikoAttributeProvider for DifficultyAttributes {
}
}
impl TaikoAttributeProvider for PerformanceAttributes {
#[inline]
fn attributes(self) -> Option<f32> {
Some(self.attributes.stars)
}
}
impl TaikoAttributeProvider for StarResult {
#[inline]
fn attributes(self) -> Option<f32> {
#[allow(irrefutable_let_patterns)]
if let StarResult::Taiko(attributes) = self {
if let Self::Taiko(attributes) = self {
Some(attributes.stars)
} else {
None
@@ -268,6 +277,11 @@ impl TaikoAttributeProvider for StarResult {
impl TaikoAttributeProvider for PpResult {
#[inline]
fn attributes(self) -> Option<f32> {
self.attributes.attributes()
#[allow(irrefutable_let_patterns)]
if let Self::Taiko(attributes) = self {
Some(attributes.attributes.stars)
} else {
None
}
}
}
+1 -2
View File
@@ -50,8 +50,7 @@ impl Skill {
#[inline]
pub(crate) fn process(&mut self, current: &DifficultyObject, cheese: &[bool]) {
self.current_strain *= self.strain_decay(current.delta);
self.current_strain +=
self.kind.strain_value_of(&current, cheese) * self.skill_multiplier();
self.current_strain += self.kind.strain_value_of(current, cheese) * self.skill_multiplier();
self.current_section_peak = self.current_section_peak.max(self.current_strain);
self.prev_time.replace(current.start_time);
}