1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Prints out the game board
use Cursor;
use GameBoard;
use GameMode;
use TileStatus;

impl GameBoard {
    pub fn draw_game_board(&self, game_mode: &GameMode) {
        println!(
            "{}|{}|{}",
            self.row_one[0].x_or_0(game_mode),
            self.row_one[1].x_or_0(game_mode),
            self.row_one[2].x_or_0(game_mode)
        );
        println!("_ _ _");
        println!(
            "{}|{}|{}",
            self.row_two[0].x_or_0(game_mode),
            self.row_two[1].x_or_0(game_mode),
            self.row_two[2].x_or_0(game_mode)
        );
        println!("_ _ _");
        println!(
            "{}|{}|{}",
            self.row_three[0].x_or_0(game_mode),
            self.row_three[1].x_or_0(game_mode),
            self.row_three[2].x_or_0(game_mode)
        );
    }
}

impl TileStatus {
    fn x_or_0(self, game_mode: &GameMode) -> String {
        match self {
            TileStatus::Nought(cursor) => match game_mode {
                GameMode::Spectate => ("O").to_string(),
                _ => match cursor {
                    Cursor::True => ("O*").to_string(),
                    Cursor::None => ("O").to_string(),
                },
            },
            TileStatus::Cross(cursor) => match game_mode {
                GameMode::Spectate => ("X").to_string(),
                _ => match cursor {
                    Cursor::True => ("X*").to_string(),
                    Cursor::None => ("X").to_string(),
                },
            },
            TileStatus::Cursor => match game_mode {
                GameMode::Spectate => (" ").to_string(),
                _ => ("*").to_string(),
            },
            TileStatus::None => (" ").to_string(),
        }
    }
}