blob: 3394293076155dc9699d772ce4b0db70c0fc835a (
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/******************************************************************************
* Copyright (C) 2015 Alejandro Colomar Andrés *
******************************************************************************/
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
/* * * * * * * * * *
* * * Standard * * * * * *
* * * * * * * * * */
#include <math.h>
#include <stdbool.h>
/* * * * * * * * * *
* * * Other * * * * * * *
* * * * * * * * * */
#include "game_iface.h"
#include "start.h"
#include "menu_clui.h"
#include "menu_tui.h"
#include "menu_iface.h"
/******************************************************************************
******* variables ************************************************************
******************************************************************************/
bool flag_exit;
int menu_iface_mode;
struct Menu_Iface_Variables menu_iface_variables;
/******************************************************************************
******* main *****************************************************************
******************************************************************************/
void menu_iface_init (void)
{
menu_iface_variables.level = GAME_IFACE_LEVEL_BEGINNER;
menu_iface_variables.rows = 8;
menu_iface_variables.cols = 8;
menu_iface_variables.p = 0.16;
}
void menu_iface_board (int *level, int *rows, int *cols, int *mines)
{
*level = menu_iface_variables.level;
/* size & number of mines */
switch (*level) {
case GAME_IFACE_LEVEL_BEGINNER:
*rows = GAME_IFACE_LEVEL_BEGINNER_ROWS;
*cols = GAME_IFACE_LEVEL_BEGINNER_COLS;
*mines = GAME_IFACE_LEVEL_BEGINNER_MINES;
break;
case GAME_IFACE_LEVEL_INTERMEDIATE:
*rows = GAME_IFACE_LEVEL_INTERMEDIATE_ROWS;
*cols = GAME_IFACE_LEVEL_INTERMEDIATE_COLS;
*mines = GAME_IFACE_LEVEL_INTERMEDIATE_MINES;
break;
case GAME_IFACE_LEVEL_EXPERT:
*rows = GAME_IFACE_LEVEL_EXPERT_ROWS;
*cols = GAME_IFACE_LEVEL_EXPERT_COLS;
*mines = GAME_IFACE_LEVEL_EXPERT_MINES;
break;
case GAME_IFACE_LEVEL_EXPERT_INV:
*rows = GAME_IFACE_LEVEL_EXPERT_COLS;
*cols = GAME_IFACE_LEVEL_EXPERT_ROWS;
*mines = GAME_IFACE_LEVEL_EXPERT_MINES;
break;
case GAME_IFACE_LEVEL_CUSTOM:
*rows = menu_iface_variables.rows;
*cols = menu_iface_variables.cols;
*mines = menu_iface_variables.p * (*rows) * (*cols);
/* at least one safe field */
if ((*mines) == (*rows) * (*cols)) {
(*mines)--;
}
break;
}
}
void menu_iface (void)
{
start_mode = START_RAND;
if (!flag_exit) {
switch (menu_iface_mode) {
case MENU_IFACE_FOO:
break;
case MENU_IFACE_CLUI:
menu_clui();
break;
case MENU_IFACE_TUI:
menu_tui();
break;
case MENU_IFACE_GUI:
break;
}
}
}
/******************************************************************************
******* end of file **********************************************************
******************************************************************************/
|