This commit is contained in:
DarthMooMancer
2025-10-05 21:06:33 -04:00
parent b96acc766e
commit d8a3fee987
9 changed files with 138 additions and 129 deletions
+11 -21
View File
@@ -1,17 +1,18 @@
#include <ncurses.h>
#include "input.hpp"
void _switch_turn(int favor, Player &player_one, Player &player_two) {
if(favor == 1) {
player_one.m_turn = true;
player_two.m_turn = false;
} else if(favor == 2) {
player_one.m_turn = false;
player_two.m_turn = true;
}
}
// void _switch_turn(int favor, Player &player_one, Player &player_two) {
// if(favor == 1) {
// player_one.m_turn = true;
// player_two.m_turn = false;
// } else if(favor == 2) {
// player_one.m_turn = false;
// player_two.m_turn = true;
// }
// }
void Input::get_input(bool &running, Tile (&tile_list)[9], Player &player_one, Player &player_two) {
// void Input::get_input(bool &running, Tile (&tile_list)[9], Player &player_one, Player &player_two) {
void Input::get_input(bool &running) {
while(running) {
initscr();
cbreak();
@@ -23,16 +24,5 @@ void Input::get_input(bool &running, Tile (&tile_list)[9], Player &player_one, P
if(_getch == 113) {
running = false;
}
if(!tile_list[_getch - 49]._delete) {
if(player_one.m_turn) {
tile_list[_getch - 49].m_symbol = player_one.m_symbol;
_switch_turn(2, player_one, player_two);
} else if(player_two.m_turn) {
tile_list[_getch - 49].m_symbol = player_two.m_symbol;
_switch_turn(1, player_one, player_two);
}
tile_list[_getch - 49]._delete = true;
_getch = 48;
}
}
}