Initial commit

This commit is contained in:
2025-04-29 17:45:27 +03:00
commit cc1bb79633
10 changed files with 441 additions and 0 deletions

21
include/client.hpp Normal file
View File

@@ -0,0 +1,21 @@
#ifndef CLIENT
#define CLIENT
#include <iostream>
#include <cstring>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
const int PORT = 8080;
class Client{
private:
int sock;
public:
Client() : sock(0){};
void run();
int ping(struct sockaddr_in);
};
#endif

38
include/maze.hpp Normal file
View File

@@ -0,0 +1,38 @@
#ifndef MAZE_HPP
#define MAZE_HPP
#include <vector>
#include <unordered_map>
#include <ctime>
#include <climits>
#include <random>
const int MAZE_SIZE = 9;
const int DIRECTIONS = 4;
const int MIN_WALLS = 3;
const int MAX_WALLS = 5;
const int DEFAULT_MOVES = 10;
class Maze{
private:
std::unordered_map<int, std::vector<bool>> graph;
int moves_left;
bool is_path_exists(int, int);
struct Edge {
int node1, dir1;
int node2, dir2;
};
public:
Maze(bool);
bool test_mode;
int get_moves_left() const;
bool is_wall(int, int) const;
void set_moves_left(int);
//void generate_maze();
//void print_maze_info();
//void play_game();
};
#endif

26
include/server.hpp Normal file
View File

@@ -0,0 +1,26 @@
#ifndef SERVER_HPP
#define SERVER_HPP
#include "maze.hpp"
#include <iostream>
#include <thread>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <cstring>
const int PORT = 8080;
const int MAX_CLIENTS = 100;
class Server {
private:
bool service_mode;
void handle_client(int client_socket, bool _mode); // Принимает клиентский сокет
bool check_status(Maze& maze);
public:
Server() : service_mode(false){};
void start(); // Запуск сервера
};
#endif