diff --git a/Makefile b/Makefile index dcb50ce..2c2fddb 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ CC = g++ -CC_FLAGS = +CC_FLAGS = -s +#debug flags: +#CC_FLAGS = -ggdb all: build/bin/over_the_network_tic_tac_toe diff --git a/src/global.hpp b/src/global.hpp index bdc86c2..39cee33 100644 --- a/src/global.hpp +++ b/src/global.hpp @@ -3,4 +3,5 @@ extern int board_size; extern bool ishost; extern unsigned short port; extern int length; -extern std::string serverIp_str; \ No newline at end of file +extern std::string serverIp_str; +extern int points_req; \ No newline at end of file diff --git a/src/input.cpp b/src/input.cpp index 9fa6aa3..468ad84 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1,4 +1,6 @@ +#include #include +#include #include "global.hpp" #include "input.hpp" @@ -8,6 +10,7 @@ using std::cerr; int length; int board_size; +int points_req; bool ishost; unsigned short port; std::string serverIp_str; @@ -80,6 +83,32 @@ void length_check() { } } +void points_requied() { + repeat = true; + + while (repeat) { + cout << "\nhow many points will be requied to beat game: "; + + cin >> points_req; + if (cin.fail()) { + cerr << "integer please\n"; + cin.clear(); + cin.ignore(256, '\n'); + } else { + if (points_req > 0) { + if (points_req * length < board_size * board_size) { + repeat = false; + } else { + cerr << "too large number max number is " << (((board_size * board_size) / length) - 1) << "\n"; + } + } else { + cerr << "positive integer please\n"; + } + } + } +} + + void port_check() { repeat = true; @@ -114,4 +143,33 @@ void ip_check() { repeat = false; } } +} + +std::string 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; + } + + 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]"; + std::cin.get(sure); + if (sure != 'n') { + break; + } + } + std::string loc; + loc = std::to_string(x_cord) + " " + std::to_string(y_cord); + return loc; } \ No newline at end of file diff --git a/src/input.hpp b/src/input.hpp index 80670d9..0b36f0d 100644 --- a/src/input.hpp +++ b/src/input.hpp @@ -2,4 +2,5 @@ void ishost_check(); void board_size_check(); void length_check(); void port_check(); -void ip_check(); \ No newline at end of file +void ip_check(); +void points_requied(); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 24ba63f..1562e6e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,6 +51,7 @@ int main() { if (ishost) { board_size_check(); length_check(); + points_requied(); } else { ip_check(); }