diff --git a/src/gameplay.cpp b/src/gameplay.cpp index f04768d..385e2dd 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -46,4 +46,8 @@ void printBoard(const std::vector>& board) { void print_gameinfo() { cout << "\npoint info:\nyou: " << BLUE << points_my << RESET << "\nenemy: " << RED << points_en << RESET << "\n"; +} + +void check_if_point(const std::vector> &board) { + } \ No newline at end of file diff --git a/src/gameplay.hpp b/src/gameplay.hpp index 234929c..fd29237 100644 --- a/src/gameplay.hpp +++ b/src/gameplay.hpp @@ -1,3 +1,4 @@ #include void printBoard(const std::vector> &board); +void check_if_point(const std::vector> &board); \ No newline at end of file diff --git a/src/global.hpp b/src/global.hpp index 20428ae..98c8dba 100644 --- a/src/global.hpp +++ b/src/global.hpp @@ -7,4 +7,5 @@ extern int points_req; extern std::string serverIp_str; extern int points_req; extern int points_my; -extern int points_en; \ No newline at end of file +extern int points_en; +extern int sel[2]; \ No newline at end of file diff --git a/src/input.cpp b/src/input.cpp index 0f41dda..f088584 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include "global.hpp" #include "input.hpp" #include "net.hpp" @@ -16,7 +16,9 @@ int points_req; bool ishost; unsigned short port; std::string serverIp_str; +int sel[2]; bool repeat = true; + void ishost_check() { char charishost; @@ -147,22 +149,26 @@ void ip_check() { } } -std::array choise_check() { +void choise_check() { int x_cord; int y_cord; char sure; while (true) { - cout << "\nchoose x(e.g. horisontal) cordinates of you target square:"; - cin >> x_cord; - if (x_cord < board_size && x_cord >= 0) { - break; + while (true) { + cout << "\nchoose x(e.g. horisontal) cordinates of you target square:"; + cin >> x_cord; + if (x_cord < board_size && x_cord >= 0) { + break; + } } - cout << "\nchoose y(e.g. vertical) cordinates of you target square:"; - cin >> y_cord; - if (y_cord < board_size && y_cord >= 0) { - break; + while (true) { + cout << "\nchoose y(e.g. vertical) cordinates of you target square:"; + cin >> y_cord; + if (y_cord < board_size && y_cord >= 0) { + break; + } } cout << "\nare you sure [Y/n]"; @@ -171,6 +177,6 @@ std::array choise_check() { break; } } - std::array loc={x_cord,y_cord}; - return loc; + sel[0] = x_cord; + sel[1] = y_cord; } \ No newline at end of file diff --git a/src/input.hpp b/src/input.hpp index 6438add..dadab10 100644 --- a/src/input.hpp +++ b/src/input.hpp @@ -5,4 +5,4 @@ void length_check(); void port_check(); void ip_check(); void points_requied(); -extern std::array choise_check(); \ No newline at end of file +void choise_check(); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 1562e6e..e38458d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,7 @@ #include "net.hpp" #include "input.hpp" #include "gameplay.hpp" +#include "color.hpp" using std::cout; @@ -73,6 +74,14 @@ int main() { printBoard(board); + while (true){ + choise_check(); + if(board[sel[0]][sel[1]] == '_') { + break; + } + cerr << RED << "\ninvalid selection" << RESET; + } + check_if_point(board); return 0; }