1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use rosu_map::util::Pos;

use crate::{
    model::{
        beatmap::Beatmap,
        mode::{ConvertStatus, IGameMode},
    },
    Difficulty,
};

pub use self::{
    attributes::{OsuDifficultyAttributes, OsuPerformanceAttributes},
    convert::OsuBeatmap,
    difficulty::gradual::OsuGradualDifficulty,
    performance::{gradual::OsuGradualPerformance, OsuPerformance},
    score_state::OsuScoreState,
    strains::OsuStrains,
};

mod attributes;
mod convert;
mod difficulty;
mod object;
mod performance;
mod score_state;
mod strains;

const PLAYFIELD_BASE_SIZE: Pos = Pos::new(512.0, 384.0);

/// Marker type for [`GameMode::Osu`].
///
/// [`GameMode::Osu`]: rosu_map::section::general::GameMode::Osu
pub struct Osu;

impl IGameMode for Osu {
    type DifficultyAttributes = OsuDifficultyAttributes;
    type Strains = OsuStrains;
    type Performance<'map> = OsuPerformance<'map>;
    type GradualDifficulty = OsuGradualDifficulty;
    type GradualPerformance = OsuGradualPerformance;

    fn check_convert(map: &Beatmap) -> ConvertStatus {
        convert::check_convert(map)
    }

    fn try_convert(map: &mut Beatmap) -> ConvertStatus {
        convert::try_convert(map)
    }

    fn difficulty(
        difficulty: &Difficulty,
        converted: &OsuBeatmap<'_>,
    ) -> Self::DifficultyAttributes {
        difficulty::difficulty(difficulty, converted)
    }

    fn strains(difficulty: &Difficulty, converted: &OsuBeatmap<'_>) -> Self::Strains {
        strains::strains(difficulty, converted)
    }

    fn performance(map: OsuBeatmap<'_>) -> Self::Performance<'_> {
        OsuPerformance::new(map)
    }

    fn gradual_difficulty(difficulty: Difficulty, map: &OsuBeatmap<'_>) -> Self::GradualDifficulty {
        OsuGradualDifficulty::new(difficulty, map)
    }

    fn gradual_performance(
        difficulty: Difficulty,
        map: &OsuBeatmap<'_>,
    ) -> Self::GradualPerformance {
        OsuGradualPerformance::new(difficulty, map)
    }
}