12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- /*
- * File: game.h
- * Author: Arthur Brandao
- *
- * Created on 28 novembre 2018
- */
- #ifndef GAME_H
- #define GAME_H
- /* --- Include --- */
- #include <pthread.h>
- #include "constante.h"
- #include "player.h"
- #include "json.h"
- #include "object.h"
- /* --- Constante --- */
- #define WIDTH 0
- #define HEIGHT 1
- /* --- Struct --- */
- typedef struct{
- boolean active;
- int index;
- char* name; //Nom
- int nbPlayer; //Nombre de joueur
- char* mapName; //Nom de la map
- char* mapContent; //La map en string
- int width; //Largeur de la map
- int height; //Hauteur de la map
- char** map; //Map
- Player* player[MAXPLAYER]; //Les joueurs actuels
- Object* object; //Les objets sur la map
- }Game;
- /* --- Extern --- */
- extern Game game[MAXGAME];
- extern int nbGame;
- extern pthread_mutex_t gameMutex[MAXGAME];
- extern pthread_mutex_t playerMutex[MAXGAME * MAXPLAYER];
- /* --- Fonctions --- */
- /**
- * Initialise les structures des parties
- */
- boolean ini_games();
- /**
- * Liste le nom de toutes les maps sous forme de JSON
- * @param JsonArray* Structure de reponse pour les maps existantes
- */
- void list_map(JsonArray*);
- /**
- * Liste les game en cours en JSON
- * @param JsonArray* Structure de reponse pour les games existantes
- * @return int Le nombre de game active
- */
- int list_game(JsonArray*);
- /**
- * Donne les dimension d'une carte
- * @param char* La carte
- * @return int* Tableau de resultat
- */
- int* map_size(char*);
- int create_game(char*, char*);
- int add_player(Game*, int);
- void describe_game(Game*, int, JsonEncoder*);
- boolean notify_player(Game*, char*, char*, JsonEncoder*, int);
- boolean player_collision(Game*, int, int);
- boolean player_collision_index(Game*, int, int, int*);
- boolean bomb_explode(Game*, int, int, int, JsonEncoder*);
- void bomb_chain(Game*, int, int, int, JsonArray*);
- int spawn_object(Game*, int, int, JsonEncoder*);
- void remove_player(Game*, int);
- void stop_game(Game*);
- void clean_games();
- #endif /* GAME_H */
|