Skip to main content

rosu_pp/taiko/performance/
inspect.rs

1use std::cmp;
2
3use crate::{
4    Difficulty,
5    any::{HitResultPriority, InspectablePerformance},
6    taiko::{Taiko, TaikoDifficultyAttributes},
7};
8
9/// Inspectable [`TaikoPerformance`] to expose all of its internal details.
10///
11/// [`TaikoPerformance`]: crate::taiko::performance::TaikoPerformance
12#[derive(Clone, Debug)]
13pub struct InspectTaikoPerformance<'a> {
14    pub attrs: &'a TaikoDifficultyAttributes,
15    pub difficulty: &'a Difficulty,
16    pub combo: Option<u32>,
17    pub acc: Option<f64>,
18    pub n300: Option<u32>,
19    pub n100: Option<u32>,
20    pub misses: Option<u32>,
21    pub hitresult_priority: HitResultPriority,
22}
23
24impl InspectTaikoPerformance<'_> {
25    pub const fn max_combo(&self) -> u32 {
26        self.attrs.max_combo()
27    }
28
29    pub fn total_hits(&self) -> u32 {
30        cmp::min(
31            self.difficulty.get_passed_objects() as u32,
32            self.max_combo(),
33        )
34    }
35
36    pub fn misses(&self) -> u32 {
37        self.misses.map_or(0, |n| cmp::min(n, self.total_hits()))
38    }
39}
40
41impl InspectablePerformance for Taiko {
42    type InspectPerformance<'a> = InspectTaikoPerformance<'a>;
43
44    fn inspect_performance<'a>(
45        perf: &'a Self::Performance<'_>,
46        attrs: &'a Self::DifficultyAttributes,
47    ) -> Self::InspectPerformance<'a> {
48        InspectTaikoPerformance {
49            attrs,
50            difficulty: &perf.difficulty,
51            combo: perf.combo,
52            acc: perf.acc,
53            n300: perf.n300,
54            n100: perf.n100,
55            misses: perf.misses,
56            hitresult_priority: perf.hitresult_priority,
57        }
58    }
59}