Skip to content

Commit

Permalink
Minor cleanup to CLI app
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattsi-Jansky committed Feb 24, 2024
1 parent 42074f4 commit 5a38997
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@ fn main() {
term.clear_screen().unwrap();
let mut game = Game::new();
let mut input = String::new();
render(&term, &game, game.generate_fen().unwrap());

loop {
ask_for_next_move(&mut term, &mut input);
game = game.make_move_san(&*input);
match &game {
Game::Ongoing { .. } => {
render(&term, &game, game.generate_fen().unwrap());
ask_for_next_move(&mut term, &mut input);
game = game.make_move_san(&*input);
}
Game::IllegalMove { state: inner_game } => {
println!("Sorry, that isn't a legal move. Make sure you write your move using Standard Algebraic Notation.");
println!("The following moves are available: {:?}",
inner_game.get_available_moves().iter()
.map(|m| m.generate_san())
.collect::<Vec<String>>());
ask_for_next_move(&mut term, &mut input);
game = game.make_move_san(&*input);
}
Game::Draw { state: inner_game }
| Game::Win {
Expand Down

0 comments on commit 5a38997

Please sign in to comment.