rosu_pp/catch/performance/
inspect.rs1use std::cmp;
2
3use crate::{
4 Difficulty,
5 any::InspectablePerformance,
6 catch::{Catch, CatchDifficultyAttributes},
7};
8
9#[derive(Clone, Debug)]
13pub struct InspectCatchPerformance<'a> {
14 pub attrs: &'a CatchDifficultyAttributes,
15 pub difficulty: &'a Difficulty,
16 pub acc: Option<f64>,
17 pub combo: Option<u32>,
18 pub fruits: Option<u32>,
19 pub droplets: Option<u32>,
20 pub tiny_droplets: Option<u32>,
21 pub tiny_droplet_misses: Option<u32>,
22 pub misses: Option<u32>,
23}
24
25impl InspectCatchPerformance<'_> {
26 pub fn misses(&self) -> u32 {
28 self.misses.map_or(0, |n| {
29 cmp::min(n, self.attrs.n_fruits + self.attrs.n_droplets)
30 })
31 }
32
33 pub const fn total_objects(&self) -> u32 {
35 self.attrs.n_fruits + self.attrs.n_droplets + self.attrs.n_tiny_droplets
36 }
37}
38
39impl InspectablePerformance for Catch {
40 type InspectPerformance<'a> = InspectCatchPerformance<'a>;
41
42 fn inspect_performance<'a>(
43 perf: &'a Self::Performance<'_>,
44 attrs: &'a Self::DifficultyAttributes,
45 ) -> Self::InspectPerformance<'a> {
46 InspectCatchPerformance {
47 attrs,
48 difficulty: &perf.difficulty,
49 acc: perf.acc,
50 combo: perf.combo,
51 fruits: perf.fruits,
52 droplets: perf.droplets,
53 tiny_droplets: perf.tiny_droplets,
54 tiny_droplet_misses: perf.tiny_droplet_misses,
55 misses: perf.misses,
56 }
57 }
58}