Skip to content

Commit

Permalink
refactor(ui): more in the ui
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Mauran <thomasmauran@yahoo.com>
  • Loading branch information
thomas-mauran committed Nov 24, 2024

Verified

This commit was signed with the committer’s verified signature.
thomas-mauran Thomas Mauran
1 parent d3fbcd1 commit 25484ff
Showing 7 changed files with 436 additions and 345 deletions.
23 changes: 11 additions & 12 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ impl App {

pub fn go_to_home(&mut self) {
self.current_page = Pages::Home;
self.restart();
}

/// Handles the tick event of the terminal.
@@ -124,18 +125,16 @@ impl App {
}

pub fn restart(&mut self) {
if self.game.is_draw || self.game.is_checkmate {
let is_bot_starting = self.game.is_bot_starting;
let engine = self.game.engine.clone();
let game_is_against_bot = self.game.is_game_against_bot;
self.game = Game::default();
self.game.engine = engine;
self.game.is_game_against_bot = game_is_against_bot;
if is_bot_starting {
self.game.is_bot_starting = true;
self.game.bot_move();
self.game.player_turn = PieceColor::Black;
}
let is_bot_starting = self.game.is_bot_starting;
let engine = self.game.engine.clone();
let game_is_against_bot = self.game.is_game_against_bot;
self.game = Game::default();
self.game.engine = engine;
self.game.is_game_against_bot = game_is_against_bot;
if is_bot_starting {
self.game.is_bot_starting = true;
self.game.bot_move();
self.game.player_turn = PieceColor::Black;
}
}

1 change: 1 addition & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ pub const TITLE: &str = r"
β•šβ•β•β•β•β•β•β•šβ•β• β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β• β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β•
";

#[derive(Debug, Clone, Copy)]
pub enum DisplayMode {
DEFAULT,
ASCII,
Loading

0 comments on commit 25484ff

Please sign in to comment.