mania & fruits: inlined methods

This commit is contained in:
MaxOhn
2021-01-09 11:07:22 +01:00
parent 15fc4c6d12
commit 3c51dc3ba5
2 changed files with 16 additions and 0 deletions
+10
View File
@@ -311,6 +311,7 @@ pub trait PpProvider {
}
impl PpProvider for Beatmap {
#[inline]
fn pp(&self) -> PpCalculator {
PpCalculator::new(self)
}
@@ -331,6 +332,7 @@ pub struct PpCalculator<'m> {
}
impl<'m> PpCalculator<'m> {
#[inline]
pub fn new(map: &'m Beatmap) -> Self {
Self {
map,
@@ -346,48 +348,56 @@ impl<'m> PpCalculator<'m> {
}
}
#[inline]
pub fn attributes(mut self, attributes: DifficultyAttributes) -> Self {
self.attributes.replace(attributes);
self
}
#[inline]
pub fn mods(mut self, mods: u32) -> Self {
self.mods = mods;
self
}
#[inline]
pub fn combo(mut self, combo: usize) -> Self {
self.combo.replace(combo);
self
}
#[inline]
pub fn fruits(mut self, n_fruits: usize) -> Self {
self.n_fruits.replace(n_fruits);
self
}
#[inline]
pub fn droplets(mut self, n_droplets: usize) -> Self {
self.n_droplets.replace(n_droplets);
self
}
#[inline]
pub fn tiny_droplets(mut self, n_tiny_droplets: usize) -> Self {
self.n_tiny_droplets.replace(n_tiny_droplets);
self
}
#[inline]
pub fn tiny_droplet_misses(mut self, n_tiny_droplet_misses: usize) -> Self {
self.n_tiny_droplet_misses.replace(n_tiny_droplet_misses);
self
}
#[inline]
pub fn misses(mut self, n_misses: usize) -> Self {
self.n_misses = n_misses;
+6
View File
@@ -74,6 +74,7 @@ pub trait PpProvider {
}
impl PpProvider for Beatmap {
#[inline]
fn pp(&self) -> PpCalculator {
PpCalculator::new(self)
}
@@ -88,6 +89,7 @@ pub struct PpCalculator<'m> {
}
impl<'m> PpCalculator<'m> {
#[inline]
pub fn new(map: &'m Beatmap) -> Self {
Self {
map,
@@ -97,18 +99,21 @@ impl<'m> PpCalculator<'m> {
}
}
#[inline]
pub fn stars(mut self, stars: f32) -> Self {
self.stars.replace(stars);
self
}
#[inline]
pub fn mods(mut self, mods: u32) -> Self {
self.mods = mods;
self
}
#[inline]
pub fn score(mut self, score: u32) -> Self {
self.score = score as f32;
@@ -178,6 +183,7 @@ impl<'m> PpCalculator<'m> {
strain_value
}
#[inline]
fn compute_accuracy_value(&self, score: f32, strain: f32, hit_window: f32) -> f32 {
(0.2 - (hit_window - 34.0) * 0.006667).max(0.0)
* strain