From d9f43036c3ecf5c01a194241bf7c7719da0e9fb9 Mon Sep 17 00:00:00 2001 From: Dmitry Fedotov Date: Mon, 7 Apr 2025 02:11:09 +0300 Subject: [PATCH] improve board visuals --- game/entity.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/game/entity.rs b/game/entity.rs index 99b9107..201900f 100644 --- a/game/entity.rs +++ b/game/entity.rs @@ -12,7 +12,7 @@ pub enum Cell { impl std::fmt::Display for Cell { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - let mut s: &str = ""; + let s: &str; match *self { Cell::CellX => s = "X", Cell::CellO => s = "O", @@ -116,9 +116,9 @@ impl std::fmt::Display for Board { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { let mut s = String::new(); - s.push_str(" 1 2 3 \n"); + s.push_str(" 1 2 3 \n"); - s.push_str(" ┌─┬─┬─┐\n"); + s.push_str(" ┌───┬───┬───┐\n"); for i in 0..3 { match i { 0 => s.push_str("a "), @@ -127,16 +127,16 @@ impl std::fmt::Display for Board { _ => {} } s.push_str(&format!( - "│{}│{}│{}│\n", + "│ {} │ {} │ {} │\n", self.cells[i * 3], self.cells[i * 3 + 1], self.cells[i * 3 + 2] )); if i < 2 { - s.push_str(" ├─┼─┼─┤\n"); + s.push_str(" ├───┼───┼───┤\n"); } } - s.push_str(" └─┴─┴─┘\n"); + s.push_str(" └───┴───┴───┘\n"); match self.has_winner() { Some(w) => s.push_str(&format!("The winner is {w}")),