mines.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /***********************************************************************
  2. *
  3. * This file is a part of Minesweeper - a computer game
  4. * Copyright (C) 2020, 2021 Andrew Tokarskiy <tokarskiy.a@keemail.me>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>
  18. *
  19. *************************************************************************/
  20. #ifndef _MINES_H
  21. #define _MINES_H
  22. #define MINE_INDEX -1
  23. #define STATUS_NULL -3
  24. #define STATUS_FLAG -2
  25. #define STATUS_MINE -1
  26. #include <stddef.h>
  27. typedef struct {
  28. // map: mine = -1, another number = amount of mines around
  29. int **map;
  30. int **statuses;
  31. size_t width;
  32. size_t height;
  33. int minesAmount;
  34. int initialized;
  35. } Game;
  36. Game* initGame(const size_t height, const size_t width, const int minesAmount);
  37. void freeGame(Game* const game);
  38. typedef enum {
  39. Click = 0,
  40. MarkMine = 1,
  41. }
  42. ActionType;
  43. typedef enum {
  44. Continue = 0,
  45. Lose = 1,
  46. Win = 2,
  47. }
  48. ActionResult;
  49. const ActionResult action(Game* const game, const size_t i, const size_t j, const ActionType actionType);
  50. #endif // _MINES_H