Zappy - Year end project 2
This is a project that Epitech asked us to create in order to allow us to reveiw the notions of the current year.
Loading...
Searching...
No Matches
server_handler.h
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** my_zappy
4** File description:
5** struct
6*/
7
8#ifndef SERVER_HANDLER_H
9 #define SERVER_HANDLER_H
10
11 #include <sys/select.h>
12
13 #include "arg_parse.h"
14
15/* Important informations:
16** - Ressources spawns every 20 units of times
17** - Ressource quantity formula: map_width * map_height * density
18** - A player time life start is 1260 / f
19** - One food add to the time life of a player 126 units of time
20** - A player starts with a random direction
21*/
22
23
24// An enum type to enum every ressources in the game
34
35// An enum type to enum every player directions in the game
43
62
85
95
108
128
144
145// A constant to set a "ressource_t" structure to default values
146static const ressources_t DEFAULT_RESSOURCES = {
147 0, // Food
148 0, // Linemate
149 0, // Deraumere
150 0, // Sibur
151 0, // Mendiane
152 0, // Phiras
153 0 // Thystame
154};
155
156// A constant to set a "cli_t" structure to default values
157static const cli_t DEFAULT_CLIENT = {
158 UNKNOWN, // Fd
159 false, // Is_connected
160 NULL, // Team name
161 UNKNOWN, // Client num
162 UNKNOWN, // Level
163 { UNKNOWN, UNKNOWN }, // Pos
164 { 0, 0, 0, 0, 0, 0, 0}, // Inventory
165 UNKNOWN, // Time life
166 UNDEFINED // Direction
167};
168
175int init_game_data(server_handler_t *server, struct arg_s **arguments);
176
183int server_initialization(server_handler_t *server, struct arg_s **arguments);
184
189void server_loop(server_handler_t *server);
190
196void command_handling(server_handler_t *server, const int fd);
197
198#endif
#define MAX_CLIENT
Definition constants.h:15
#define UNKNOWN
Definition constants.h:16
int server_initialization(server_handler_t *server, struct arg_s **arguments)
The function to initialize every server data.
void server_loop(server_handler_t *server)
The server loop where communication client/server can be done.
Definition server_loop.c:67
enum ressources_type_s ressources_type_t
struct server_handler_s server_handler_t
A structure to store server general data.
enum direction_s direction_t
struct ressources_s ressources_t
A structure to count ressources in the game.
direction_s
@ UNDEFINED
@ DOWN
@ UP
@ LEFT
@ RIGHT
struct team_s team_t
A structure to store every team data.
ressources_type_s
@ SIBUR
@ MENDIANE
@ PHIRAS
@ LINEMATE
@ FOOD
@ THYSTAME
@ DERAUMERE
int init_game_data(server_handler_t *server, struct arg_s **arguments)
The function to initialize every game data.
struct game_data_s game_data_t
A structure to store the game data.
struct cli_s cli_t
A structure to store every client/player data.
void command_handling(server_handler_t *server, const int fd)
Handle client message/command.
struct map_s map_t
A structure to store every tiles content (Must be an 2D array)
A structure to store every client/player data.
int client_num
int pos[2]
char * team_name
bool is_connected
direction_t direction
int time_life
ressources_t ressources
A structure to store the game data.
ressources_t total_ressources
cli_t clients[MAX_CLIENT]
ressources_t ressources_quantity
A structure to store every tiles content (Must be an 2D array)
int player_nb
ressources_t ressources
A structure to count ressources in the game.
A structure to store server general data.
int fd_queue[MAX_CLIENT]
game_data_t game_data
A structure to store every team data.
int client_num_list[MAX_CLIENT]
char * team_name
int client_total