rosu_pattern_detector/mania/
structs.rs

1use crate::structs::CommonMeasure;
2
3#[derive(Debug, Clone)]
4pub struct Notes {
5    pub(crate) timestamp: i32,
6    pub(crate) notes: Vec<bool>,
7    pub(crate) pattern: BasePattern,
8}
9impl Notes {
10    pub fn to_display_string(&self) -> String {
11        self.notes
12            .iter()
13            .map(|&active| if active { 'O' } else { 'X' })
14            .collect()
15    }
16}
17#[derive(Debug, PartialEq, Eq, Hash, Clone)]
18pub enum BasePattern {
19    Single,
20    Jump,
21    Hand,
22    Quad,
23    Chord,
24    None
25}
26
27#[derive(Debug, PartialEq, Clone,Hash,Eq)]
28pub enum SecondaryPattern
29{
30    Jack(JackPattern),
31    Handstream(HandstreamPattern),
32    Jumpstream(JumpstreamPattern),
33    Singlestream(SinglestreamPattern),
34    None,
35}
36#[derive(Debug, PartialEq, Clone, Hash, Eq)]
37pub enum JackPattern {
38    Chordjack,
39    DenseChordjack,
40    ChordStream,
41    Speedjack,
42    All,
43}
44
45#[derive(Debug, PartialEq, Clone, Hash, Eq)]
46pub enum JumpstreamPattern {
47    LightJs,
48    AnchorJs,
49    JS,
50    JT,
51    All,
52}
53#[derive(Debug, PartialEq, Clone, Hash, Eq)]
54pub enum HandstreamPattern {
55    LightHs,
56    AnchorHs,
57    DenseHs,
58    HS,
59    All,
60}
61
62#[derive(Debug, PartialEq, Clone, Hash, Eq)]
63pub enum SinglestreamPattern {
64    Singlestream,
65    All,
66}
67
68impl SecondaryPattern {
69    pub fn to_all(&self) -> SecondaryPattern {
70        match self {
71            SecondaryPattern::Jack(_) => SecondaryPattern::Jack(JackPattern::All),
72            SecondaryPattern::Handstream(_) => SecondaryPattern::Handstream(HandstreamPattern::All),
73            SecondaryPattern::Jumpstream(_) => SecondaryPattern::Jumpstream(JumpstreamPattern::All),
74            SecondaryPattern::Singlestream(_) => SecondaryPattern::Singlestream(SinglestreamPattern::All),
75            SecondaryPattern::None => SecondaryPattern::None,
76        }
77    }
78}
79
80
81#[derive(Debug)]
82pub struct ManiaMeasure {
83    pub(crate) measure: CommonMeasure,
84    pub(crate) notes: Vec<Notes>,
85    pub(crate) secondary_pattern: SecondaryPattern,
86}
87
88impl ManiaMeasure {
89    pub(crate) fn notes(&self) -> &Vec<Notes> {
90        &self.notes
91    }
92
93    pub fn print_notes(&self) {
94        for note in &self.notes {
95            let line = note.to_display_string();
96            println!("{}", line);
97        }
98    }
99
100    pub fn tNotes(&self) -> i32 {
101        self.notes
102            .iter()
103            .flat_map(|v| v.notes.iter())
104            .filter(|&&b| b)
105            .count() as i32
106    }
107
108    // Helper pour accéder aux détails spécifiques si nécessaire
109    pub fn get_jack_pattern(&self) -> Option<&JackPattern> {
110        match &self.secondary_pattern {
111            SecondaryPattern::Jack(pattern) => Some(pattern),
112            _ => None,
113        }
114    }
115}
116
117