fix: players now alternate after input
This commit is contained in:
+28
-8
@@ -8,30 +8,50 @@ void Input::get_input(bool &running, Player &one, Player &two, std::vector<Point
|
||||
cbreak();
|
||||
noecho();
|
||||
|
||||
|
||||
_getch = getch();
|
||||
endwin();
|
||||
Player *active = nullptr;
|
||||
Player *inactive = nullptr;
|
||||
if(one.m_turn) active = &one;
|
||||
else if(two.m_turn) active = &two;
|
||||
if(active == &one) inactive = &two;
|
||||
else if(active == &two) inactive = &one;
|
||||
|
||||
switch (_getch) {
|
||||
case 49:
|
||||
one.input_tile(0, points);
|
||||
active->input_tile(0, points);
|
||||
active->m_turn = false;
|
||||
inactive->m_turn = true;
|
||||
break;
|
||||
case 50:
|
||||
one.input_tile(1, points);
|
||||
active->input_tile(1, points);
|
||||
active->m_turn = false;
|
||||
inactive->m_turn = true;
|
||||
break;
|
||||
case 51:
|
||||
one.input_tile(2, points);
|
||||
active->input_tile(2, points);
|
||||
active->m_turn = false;
|
||||
inactive->m_turn = true;
|
||||
break;
|
||||
case 52:
|
||||
one.input_tile(3, points);
|
||||
active->input_tile(3, points);
|
||||
active->m_turn = false;
|
||||
inactive->m_turn = true;
|
||||
break;
|
||||
case 53:
|
||||
one.input_tile(4, points);
|
||||
active->input_tile(4, points);
|
||||
active->m_turn = false;
|
||||
inactive->m_turn = true;
|
||||
break;
|
||||
case 54:
|
||||
one.input_tile(5, points);
|
||||
active->input_tile(5, points);
|
||||
active->m_turn = false;
|
||||
inactive->m_turn = true;
|
||||
break;
|
||||
case 55:
|
||||
one.input_tile(6, points);
|
||||
active->input_tile(6, points);
|
||||
active->m_turn = false;
|
||||
inactive->m_turn = true;
|
||||
break;
|
||||
case 113:
|
||||
running = false;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
void Window::update_display(std::vector<Point> &points_list) {
|
||||
for(std::array<char, COL> &row : m_board) { row.fill('.'); }
|
||||
for(int i = 0; i < points_list.size(); i++) {
|
||||
m_board[points_list[i].m_row][points_list[i].m_col] = '*';
|
||||
m_board[points_list[i].m_row][points_list[i].m_col] = points_list[i].m_symbol;
|
||||
}
|
||||
|
||||
std::cout << "\033[H" << std::flush;
|
||||
|
||||
Reference in New Issue
Block a user