fix: game can tie and also refactored element.cpp
This commit is contained in:
+9
-15
@@ -1,30 +1,16 @@
|
||||
#ifndef ELEMENTS_HPP
|
||||
#define ELEMENTS_HPP
|
||||
|
||||
struct Player;
|
||||
struct Point;
|
||||
struct Tile;
|
||||
struct Border;
|
||||
|
||||
struct Point {
|
||||
Point();
|
||||
Point(int row, int col) : m_row(row), m_col(col) {};
|
||||
int m_row;
|
||||
int m_col;
|
||||
void assign(int row, int col);
|
||||
void to_string();
|
||||
};
|
||||
|
||||
struct Player {
|
||||
Player(char symbol, bool turn) : m_symbol(symbol), m_turn(turn), m_win(false) {};
|
||||
char m_symbol;
|
||||
bool m_turn;
|
||||
bool m_win;
|
||||
void check_line(Tile (&tile_list)[9]);
|
||||
};
|
||||
|
||||
struct Tile {
|
||||
Tile(int row, int col) : m_pos(row, col), m_symbol(' '), _delete(false) {};
|
||||
Tile(int row, int col, char symbol) : m_pos(row, col), m_symbol(symbol), _delete(false) {};
|
||||
char m_symbol;
|
||||
Point m_pos;
|
||||
bool _delete;
|
||||
@@ -36,4 +22,12 @@ struct Border {
|
||||
Point m_pos;
|
||||
};
|
||||
|
||||
struct Player {
|
||||
Player(char symbol, bool turn) : m_symbol(symbol), m_turn(turn), m_win(false) {};
|
||||
char m_symbol;
|
||||
bool m_turn;
|
||||
bool m_win;
|
||||
void check_line(Tile (&tile_list)[9]);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -7,4 +7,4 @@ struct Input {
|
||||
void get_input(bool &running, Tile (&tile_list)[9], Player &player_one, Player &player_two);
|
||||
};
|
||||
|
||||
#endif // INPUT_HPP
|
||||
#endif
|
||||
|
||||
@@ -8,5 +8,7 @@
|
||||
struct Window {
|
||||
std::array<std::array<char, COL>, ROW> m_board = {};
|
||||
void update_display(Tile (&tile_list)[9], Border (&border_list)[16]);
|
||||
void terminate(Tile (&tile_list)[9], bool &running);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user