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