-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminesweeper.js
52 lines (38 loc) · 1.03 KB
/
minesweeper.js
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
const mine_value = -1;
const hidden_value = null;
const marked_value = 10;
const wrong_marked_value = 11;
var difficulty = "medium";
var interval_ref = null;
/** Starts a game.
*
* @param {number} rows
* @param {number} cols
* @param {number} num_mines
*/
function start_game() {
const easy = [10, 10, 10];
const medium = [15, 13, 40];
const hard = [30, 16, 99];
let rows, cols, num_mines;
if (difficulty === "easy") {
[rows, cols, num_mines] = easy;
}
else if (difficulty === "medium") {
[rows, cols, num_mines] = medium;
}
else if (difficulty === "hard") {
[rows, cols, num_mines] = hard;
}
let game = new Game(rows, cols, num_mines);
let gui = new Html_GUI(rows, cols);
let controller = new Controller(game, gui);
}
function set_difficulty() {
difficulty = document.getElementById("game_difficulty").value;
start_game();
}
start_game();
//var board = new Board(20, 20, 100);
//console.table(board.get_board());
//console.log(board.get_board());