-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
42 lines (41 loc) · 1.46 KB
/
Copy pathmain.cpp
File metadata and controls
42 lines (41 loc) · 1.46 KB
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
#include "game/minesweeper.h"
#include <iostream>
int main() {
Minesweeper minesweeper(0, 0, 0);
std::cout << "Starting new game..." << std::endl;
std::cout << "Enter difficulty: Easy/Medium/Hard" << std::endl;
std::string command;
std::cin >> command;
if (command == "Easy") {
minesweeper.NewGame(5, 5, 5);
} else if (command == "Medium") {
minesweeper.NewGame(10, 10, 30);
} else if (command == "Hard") {
minesweeper.NewGame(20, 30, 50);
} else {
std::cout << "Incorrect command." << std::endl;
return 1;
}
while (minesweeper.GetGameStatus() != Minesweeper::GameStatus::VICTORY &&
minesweeper.GetGameStatus() != Minesweeper::GameStatus::DEFEAT) {
std::cout << "Type 'open [x] [y]' to open (x, y) cell, type 'mark [x] [y]' to mark (x, y) cell:" << std::endl;
std::cin >> command;
size_t x, y;
std::cin >> x >> y;
if (command == "open") {
minesweeper.OpenCell({x, y});
} else {
minesweeper.MarkCell({x, y});
}
Minesweeper::RenderedField field = minesweeper.RenderField();
for (const std::string& line : field) {
std::cout << line << std::endl;
}
}
if (minesweeper.GetGameStatus() == Minesweeper::GameStatus::VICTORY) {
std::cout << "Congratulations, you are win!" << std::endl;
} else {
std::cout << "BOOM! You are lose." << std::endl;
}
return 0;
}