some formatting
This commit is contained in:
parent
d65978c891
commit
a42744434d
42
src/game.rs
42
src/game.rs
|
@ -5,6 +5,7 @@ pub enum Kanas {
|
||||||
Hiragana,
|
Hiragana,
|
||||||
Katakana
|
Katakana
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Hieroglyph {syllable: String, row: usize, column: usize}
|
pub struct Hieroglyph {syllable: String, row: usize, column: usize}
|
||||||
|
|
||||||
impl std::fmt::Display for Hieroglyph {
|
impl std::fmt::Display for Hieroglyph {
|
||||||
|
@ -63,21 +64,21 @@ const KATAKANA: [[&str; 5]; 11] = [
|
||||||
|
|
||||||
pub fn get_kana_pair_for_hieroglyph(k: Kanas, h: &Hieroglyph) -> Hieroglyph {
|
pub fn get_kana_pair_for_hieroglyph(k: Kanas, h: &Hieroglyph) -> Hieroglyph {
|
||||||
match k {
|
match k {
|
||||||
Kanas::Hiragana => Hieroglyph{
|
Kanas::Hiragana => Hieroglyph {
|
||||||
syllable: HIRAGANA[h.row][h.column].to_string(),
|
syllable: HIRAGANA[h.row][h.column].to_string(),
|
||||||
row: h.row,
|
row: h.row,
|
||||||
column: h.column
|
column: h.column
|
||||||
},
|
},
|
||||||
Kanas::Katakana => Hieroglyph{
|
Kanas::Katakana => Hieroglyph {
|
||||||
syllable: KATAKANA[h.row][h.column].to_string(),
|
syllable: KATAKANA[h.row][h.column].to_string(),
|
||||||
row: h.row,
|
row: h.row,
|
||||||
column: h.column
|
column: h.column
|
||||||
},
|
},
|
||||||
Kanas::Romaji => Hieroglyph{
|
Kanas::Romaji => Hieroglyph {
|
||||||
syllable: ROMAJI[h.row][h.column].to_string(),
|
syllable: ROMAJI[h.row][h.column].to_string(),
|
||||||
row: h.row,
|
row: h.row,
|
||||||
column: h.column
|
column: h.column
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,13 +86,12 @@ pub fn generate_random_hieroglyph(k: Kanas) -> Hieroglyph {
|
||||||
let row: usize = rand::thread_rng().gen_range(0..ROMAJI.len()-1);
|
let row: usize = rand::thread_rng().gen_range(0..ROMAJI.len()-1);
|
||||||
let column: usize = rand::thread_rng().gen_range(0..ROMAJI[0].len()-1);
|
let column: usize = rand::thread_rng().gen_range(0..ROMAJI[0].len()-1);
|
||||||
|
|
||||||
let generated: String = {
|
let generated: String = match k {
|
||||||
match k {
|
Kanas::Romaji => ROMAJI[row][column].to_string(),
|
||||||
Kanas::Romaji => ROMAJI[row][column].to_string(),
|
Kanas::Hiragana => HIRAGANA[row][column].to_string(),
|
||||||
Kanas::Hiragana => HIRAGANA[row][column].to_string(),
|
Kanas::Katakana => KATAKANA[row][column].to_string()
|
||||||
Kanas::Katakana => KATAKANA[row][column].to_string()
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if generated == "0" {
|
if generated == "0" {
|
||||||
return generate_random_hieroglyph(k);
|
return generate_random_hieroglyph(k);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue