diff --git a/include/elements.hpp b/include/elements.hpp index 8ed837e..4b330ee 100644 --- a/include/elements.hpp +++ b/include/elements.hpp @@ -12,7 +12,6 @@ struct Point { int m_id; char m_symbol; bool m_collided; - void to_string(); void assign(int row, int col); void move(); void check_collision(std::vector &points_list); @@ -23,7 +22,6 @@ struct Player { char m_symbol; bool m_turn; void input_tile(int col, std::vector &points); - // bool check_chain(std::array, ROW> &m_board); bool check_chain(std::array, ROW> &m_board, std::vector &points_list); }; diff --git a/include/window.hpp b/include/window.hpp index 7d90181..b3b1a7b 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -9,7 +9,6 @@ struct Window { std::array, ROW> m_board = {}; void update_display(std::vector &points_list); - bool check_chain(); }; #endif diff --git a/src/elements.cpp b/src/elements.cpp index 7fb0f6d..3f41d22 100644 --- a/src/elements.cpp +++ b/src/elements.cpp @@ -2,7 +2,6 @@ #include "globals.hpp" #include #include -#include void Point::assign(int row, int col) { m_row = row; @@ -10,15 +9,8 @@ void Point::assign(int row, int col) { } void Point::move() { - if(m_row < ROW - 1) { - m_row++; - } else { - m_collided = true; - } -} - -void Point::to_string() { - std::cout << "(" << m_row << ", " << m_col << ")"; + if(m_row < ROW - 1) m_row++; + else m_collided = true; } void Point::check_collision(std::vector &points_list) {; diff --git a/src/main.cpp b/src/main.cpp index 60f2684..de2668f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,8 +23,7 @@ int main() { if(one.check_chain(window.m_board, points_list)) { std::cout << "Player 1 wins!" << std::endl; running = false; - } - if(two.check_chain(window.m_board, points_list)) { + } else if(two.check_chain(window.m_board, points_list)) { std::cout << "Player 2 wins!" << std::endl; running = false; } diff --git a/src/window.cpp b/src/window.cpp index a244dc5..bc17ce8 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -3,7 +3,6 @@ #include #include - void Window::update_display(std::vector &points_list) { for(std::array &row : m_board) { row.fill('.'); } for(int i = 0; i < points_list.size(); i++) { @@ -19,25 +18,3 @@ void Window::update_display(std::vector &points_list) { } std::this_thread::sleep_for(std::chrono::milliseconds(200)); // 1000 / fps; 200ms = 5fps } - -bool Window::check_chain() { - char symbol = ' '; - bool d = true; - bool result = false; - for(int i = 0; i < ROW - 1; i++) { - for(int j = 0; j < COL - 1; j++) { - if(m_board[i][j] == ' ') continue; - symbol = m_board[i][j]; - d = true; - if(d) { - for(int k = 1; k <= 3; k++) { - if(m_board[i][j + k] != symbol) d = false; - } - if(d) { - result = true; - } - } - } - } - return result; -}