use rosu_map::section::general::GameMode;
use crate::{
catch::CatchScoreState, mania::ManiaScoreState, osu::OsuScoreState, taiko::TaikoScoreState,
};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ScoreState {
pub max_combo: u32,
pub n_geki: u32,
pub n_katu: u32,
pub n300: u32,
pub n100: u32,
pub n50: u32,
pub misses: u32,
}
impl ScoreState {
pub const fn new() -> Self {
Self {
max_combo: 0,
n_geki: 0,
n_katu: 0,
n300: 0,
n100: 0,
n50: 0,
misses: 0,
}
}
pub fn total_hits(&self, mode: GameMode) -> u32 {
let mut amount = self.n300 + self.n100 + self.misses;
if mode != GameMode::Taiko {
amount += self.n50;
if mode != GameMode::Osu {
amount += self.n_katu;
amount += u32::from(mode != GameMode::Catch) * self.n_geki;
}
}
amount
}
}
impl From<ScoreState> for OsuScoreState {
fn from(state: ScoreState) -> Self {
Self {
max_combo: state.max_combo,
n300: state.n300,
n100: state.n100,
n50: state.n50,
misses: state.misses,
}
}
}
impl From<ScoreState> for TaikoScoreState {
fn from(state: ScoreState) -> Self {
Self {
max_combo: state.max_combo,
n300: state.n300,
n100: state.n100,
misses: state.misses,
}
}
}
impl From<ScoreState> for CatchScoreState {
fn from(state: ScoreState) -> Self {
Self {
max_combo: state.max_combo,
fruits: state.n300,
droplets: state.n100,
tiny_droplets: state.n50,
tiny_droplet_misses: state.n_katu,
misses: state.misses,
}
}
}
impl From<ScoreState> for ManiaScoreState {
fn from(state: ScoreState) -> Self {
Self {
n320: state.n_geki,
n300: state.n300,
n200: state.n_katu,
n100: state.n100,
n50: state.n50,
misses: state.misses,
}
}
}
impl From<OsuScoreState> for ScoreState {
fn from(state: OsuScoreState) -> Self {
Self {
max_combo: state.max_combo,
n_geki: 0,
n_katu: 0,
n300: state.n300,
n100: state.n100,
n50: state.n50,
misses: state.misses,
}
}
}
impl From<TaikoScoreState> for ScoreState {
fn from(state: TaikoScoreState) -> Self {
Self {
max_combo: state.max_combo,
n_geki: 0,
n_katu: 0,
n300: state.n300,
n100: state.n100,
n50: 0,
misses: state.misses,
}
}
}
impl From<CatchScoreState> for ScoreState {
fn from(state: CatchScoreState) -> Self {
Self {
max_combo: state.max_combo,
n_geki: 0,
n_katu: state.tiny_droplet_misses,
n300: state.fruits,
n100: state.droplets,
n50: state.tiny_droplets,
misses: state.misses,
}
}
}
impl From<ManiaScoreState> for ScoreState {
fn from(state: ManiaScoreState) -> Self {
Self {
max_combo: 0,
n_geki: state.n320,
n_katu: state.n200,
n300: state.n300,
n100: state.n100,
n50: state.n50,
misses: state.misses,
}
}
}
impl Default for ScoreState {
fn default() -> Self {
Self::new()
}
}