fix: input not targetting the correct tile

This commit is contained in:
DarthMooMancer
2025-09-02 12:09:52 -04:00
parent 000bc7811a
commit 18773da6c4
+8 -11
View File
@@ -1,5 +1,5 @@
#include "input.hpp"
#include <ncurses.h> #include <ncurses.h>
#include "input.hpp"
void _switch_turn(int favor, Player &player_one, Player &player_two) { void _switch_turn(int favor, Player &player_one, Player &player_two) {
if(favor == 1) { if(favor == 1) {
@@ -22,20 +22,17 @@ void Input::get_input(bool &running, Tile (&tile_list)[9], Player &player_one, P
endwin(); endwin();
if(m_getch == 113) { if(m_getch == 113) {
running = false; running = false;
} if(player_one.m_turn) { }
if(!tile_list[m_getch - 48]._delete) { if(!tile_list[m_getch - 49]._delete) {
tile_list[m_getch - 48].m_symbol = player_one.m_symbol; if(player_one.m_turn) {
m_getch = 48; tile_list[m_getch - 49].m_symbol = player_one.m_symbol;
_switch_turn(2, player_one, player_two); _switch_turn(2, player_one, player_two);
tile_list[m_getch - 48]._delete = true;
}
} else if(player_two.m_turn) { } else if(player_two.m_turn) {
if(!tile_list[m_getch - 48]._delete) { tile_list[m_getch - 49].m_symbol = player_two.m_symbol;
tile_list[m_getch - 48].m_symbol = player_two.m_symbol;
m_getch = 48;
_switch_turn(1, player_one, player_two); _switch_turn(1, player_one, player_two);
tile_list[m_getch - 48]._delete = true;
} }
tile_list[m_getch - 49]._delete = true;
m_getch = 48;
} }
} }
} }