This commit is contained in:
PoliEcho 2024-06-14 09:07:39 +02:00
parent 35b39215c8
commit 987fff4381
6 changed files with 35 additions and 14 deletions

View File

@ -46,4 +46,8 @@ void printBoard(const std::vector<std::vector<char>>& 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<std::vector<char>> &board) {
}

View File

@ -1,3 +1,4 @@
#include <vector>
void printBoard(const std::vector<std::vector<char>> &board);
void check_if_point(const std::vector<std::vector<char>> &board);

View File

@ -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;
extern int points_en;
extern int sel[2];

View File

@ -1,7 +1,7 @@
#include <string.h>
#include <iostream>
#include <string>
#include<array>
#include <array>
#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<int,2> 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<int,2> choise_check() {
break;
}
}
std::array<int,2> loc={x_cord,y_cord};
return loc;
sel[0] = x_cord;
sel[1] = y_cord;
}

View File

@ -5,4 +5,4 @@ void length_check();
void port_check();
void ip_check();
void points_requied();
extern std::array<int,2> choise_check();
void choise_check();

View File

@ -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;
}