#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct TaikoHitResults {
pub n300: u32,
pub n100: u32,
pub misses: u32,
}
impl TaikoHitResults {
pub const fn new() -> Self {
Self {
n300: 0,
n100: 0,
misses: 0,
}
}
pub const fn total_hits(&self) -> u32 {
self.n300 + self.n100 + self.misses
}
pub fn accuracy(&self) -> f64 {
let total_hits = self.total_hits();
if total_hits == 0 {
return 0.0;
}
let numerator = 2 * self.n300 + self.n100;
let denominator = 2 * total_hits;
f64::from(numerator) / f64::from(denominator)
}
}
impl Default for TaikoHitResults {
fn default() -> Self {
Self::new()
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct TaikoScoreState {
pub max_combo: u32,
pub hitresults: TaikoHitResults,
}
impl TaikoScoreState {
pub const fn new() -> Self {
Self {
max_combo: 0,
hitresults: TaikoHitResults::new(),
}
}
}
impl Default for TaikoScoreState {
fn default() -> Self {
Self::new()
}
}