game.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * File: game.h
  3. * Author: Arthur Brandao
  4. *
  5. * Created on 28 novembre 2018
  6. */
  7. #ifndef GAME_H
  8. #define GAME_H
  9. /* --- Include --- */
  10. #include "constante.h"
  11. #include "player.h"
  12. #include "json.h"
  13. /* --- Constante --- */
  14. #define WIDTH 0
  15. #define HEIGHT 1
  16. /* --- Struct --- */
  17. typedef struct{
  18. boolean active;
  19. char* name; //Nom
  20. int nbPlayer; //Nombre de joueur
  21. char* mapName; //Nom de la map
  22. char* mapContent; //La map en string
  23. int width; //Largeur de la map
  24. int height; //Hauteur de la map
  25. char** map; //Map
  26. Player* player[MAXPLAYER]; //Les joueurs actuels
  27. }Game;
  28. /* --- Extern --- */
  29. extern Game game[MAXGAME];
  30. extern int nbGame;
  31. /* --- Fonctions --- */
  32. /**
  33. * Initialise les structures des parties
  34. */
  35. void ini_games();
  36. /**
  37. * Liste le nom de toutes les maps sous forme de JSON
  38. * @return JsonArray* Les maps existantes
  39. */
  40. JsonArray* list_map();
  41. /**
  42. * Liste les game en cours en JSON
  43. * @return JsonArray* Les games existantes
  44. */
  45. JsonArray* list_game();
  46. /**
  47. * Donne les dimension d'une carte
  48. * @param char* La carte
  49. * @return int* Tableau de resultat
  50. */
  51. int* map_size(char*);
  52. int create_game(char*, char*);
  53. int add_player(Game*, int);
  54. JsonEncoder* describe_game(Game*, int);
  55. boolean notify_player(Game*, char*, char*, JsonEncoder*, int);
  56. void stop_game(Game*);
  57. void clean_games();
  58. #endif /* GAME_H */