finished cli ui, end of TP

This commit is contained in:
thatscringebro 2025-03-26 10:45:20 -04:00
parent 25dbbc4f4b
commit 22149290da

View File

@ -16,6 +16,8 @@ fn main() {
while playing {
let mut message = "";
let mut user_cheated: bool = false;
let mut game_won: bool = false;
match read().unwrap() {
Event::Key(KeyEvent {
code: KeyCode::Char('q'),
@ -76,13 +78,42 @@ fn main() {
}
}
if taquin_game.is_grid_done() && !user_cheated {
message = "Yahoo! Good job!";
if taquin_game.is_grid_done() {
if !user_cheated {
message = "Yahoo! Good job!";
}
game_won = true;
}
draw_game(&taquin_game);
print!("{}\r\n", message);
let _ = io::stdout().flush();
if game_won {
print!("Press 'R' to start a new game, 'Q' to quit.");
let _ = io::stdout().flush();
let mut good_choice = false;
while !good_choice {
match read().unwrap() {
Event::Key(KeyEvent {
code: KeyCode::Char('q'),
..
}) => {
playing = false;
good_choice = true;
}
Event::Key(KeyEvent {
code: KeyCode::Char('r'),
..
}) => {
taquin_game.init_grid();
good_choice = true;
}
_ => {}
}
}
}
}
}