blob: ac04203d44833e42333a9426f1fd1aedd442ed22 (
plain)
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
|
#include "Game.hpp"
#include "Utils.hpp"
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <string>
void Game::initDiff(int diff) {
switch (diff) {
case 0:
boardWidth = 9;
boardHeight = 9;
mines = 9;
break;
case 1:
boardWidth = 16;
boardHeight = 16;
mines = 12;
break;
case 2:
boardWidth = 30;
boardHeight = 16;
mines = 16;
break;
case 3:
std::cout << "Editing game parameters\n";
break;
}
}
void Game::initBoard() {
for (int i = 0; i < boardHeight; i++) {
for (int j = 0; j < boardWidth; j++) {
bombMap[i][j] = rand() % 2;
}
}
for (int i = 0; i < boardHeight; i++) {
for (int j = 0; j < boardWidth; j++) {
tileMap[i][j] = 0;
}
}
}
int Game::editDiff(){
Utils util;
std::cout << "Now editing custom difficulty" << std::endl;
std::cout << "Board width: ";
if(util.catchReturn(util.catchInputInt(&boardWidth)) != 0) return 1;
std::cout << Game::boardWidth;
std::cout << "Board height: ";
if(util.catchReturn(util.catchInputInt(&boardHeight)) != 0) return 1;
std::cout << "Mines: ";
if(util.catchReturn(util.catchInputInt(&mines)) != 0) return 1;
return 0;
}
void Game::displayBoard() {
for (int i = 0; i < boardHeight; i++) {
for (int j = 0; j < boardWidth; j++)
putchar(tileMap[i][j]);
putchar('\n');
}
}
|