fix: game can tie and also refactored element.cpp

This commit is contained in:
DarthMooMancer
2025-09-02 14:27:18 -04:00
parent 9546b47d82
commit b96acc766e
6 changed files with 43 additions and 41 deletions
+16 -1
View File
@@ -3,6 +3,22 @@
#include <chrono>
#include <thread>
void Window::terminate(Tile (&tile_list)[9], bool &running) {
if(tile_list[0]._delete && tile_list[0].m_symbol != ' '
&& tile_list[1]._delete && tile_list[1].m_symbol != ' '
&& tile_list[2]._delete && tile_list[2].m_symbol != ' '
&& tile_list[3]._delete && tile_list[3].m_symbol != ' '
&& tile_list[4]._delete && tile_list[4].m_symbol != ' '
&& tile_list[5]._delete && tile_list[5].m_symbol != ' '
&& tile_list[6]._delete && tile_list[6].m_symbol != ' '
&& tile_list[7]._delete && tile_list[7].m_symbol != ' '
&& tile_list[8]._delete && tile_list[8].m_symbol != ' ') {
std::cout << "Game Over! Tie" << std::endl;
running = false;
}
}
void Window::update_display(Tile (&tile_list)[9], Border (&border_list)[16]) {
for(std::array<char, COL> &row : m_board) { row.fill('.'); }
@@ -13,7 +29,6 @@ void Window::update_display(Tile (&tile_list)[9], Border (&border_list)[16]) {
m_board[border_list[i].m_pos.m_row][border_list[i].m_pos.m_col] = border_list[i].m_symbol;
}
// Refresh and draw screen
std::cout << "\033[H" << std::flush;
for(std::array<char, COL> &row : m_board) {
for(char &col : row) {