summaryrefslogtreecommitdiffstats
path: root/modules/game/inc/game.h
blob: 6f958682e71996785ba3604d13ce8562a22bdcbc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/******************************************************************************
 *	Copyright (C) 2015	Alejandro Colomar Andrés		      *
 ******************************************************************************/


/******************************************************************************
 ******* include guard ********************************************************
 ******************************************************************************/
# ifndef		MSW_GAME_H
	# define	MSW_GAME_H


/******************************************************************************
 ******* headers **************************************************************
 ******************************************************************************/
/* Standard C ----------------------------------------------------------------*/
	#include <stdbool.h>

/* Project -------------------------------------------------------------------*/
	/* ¡ Need to include these in the Makefile ! */
	/* ROWS_MAX & COLS_MAX */
	#include "game_iface.h"


/******************************************************************************
 ******* enums ****************************************************************
 ******************************************************************************/
	enum	Game_Mine_Board {
		GAME_MINE_NO = 0,
		GAME_MINE_YES = 9
	};

	enum	Game_Usr_Board {
		GAME_USR_KBOOM = -1,
		GAME_USR_HIDDEN,
		GAME_USR_CLEAR,
		GAME_USR_FLAG,
		GAME_USR_POSSIBLE
	};

	enum	Game_Action {
		GAME_ACT_FOO = 0,
		GAME_ACT_STEP,
		GAME_ACT_FLAG,
		GAME_ACT_FLAG_POSSIBLE,
		GAME_ACT_RM_FLAG
	};

	enum	Game_State {
		GAME_STATE_PLAYING = 0,
		GAME_STATE_SAFE,
		GAME_STATE_GAMEOVER
	};



/******************************************************************************
 ******* structs **************************************************************
 ******************************************************************************/
	struct	Game_Board {
		int	rows;
		int	cols;
		int	mines;
		int	gnd [ROWS_MAX] [COLS_MAX];
		int	usr [ROWS_MAX] [COLS_MAX];
		int	flags;
		int	clr;
		int	state;
	};


/******************************************************************************
 ******* variables ************************************************************
 ******************************************************************************/
extern	struct Game_Board	game_board;


/******************************************************************************
 ******* functions ************************************************************
 ******************************************************************************/
void	game_init	(void);
void	game_init_rand	(int rows, int cols, int mines, int pos_row, int pos_col);
void	game_init_load	(int *rows, int *cols);
void	game_action	(int action, int row, int col);


/******************************************************************************
 ******* include guard ********************************************************
 ******************************************************************************/
# endif			/* game.h */


/******************************************************************************
 ******* end of file **********************************************************
 ******************************************************************************/