-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAzul.cpp
More file actions
executable file
·101 lines (99 loc) · 2.82 KB
/
Azul.cpp
File metadata and controls
executable file
·101 lines (99 loc) · 2.82 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
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
#include "GameEngine.h"
#include "Saver.h"
#include "Menu.h"
#include "Saver.h"
#include <unistd.h>
int main(int argc, char const *argv[])
{
system("clear");
//GameEngine engine = new GameEngine();
Menu menu;
bool exit = false;
std::string input;
GameEngine *engine = nullptr;
Saver saver;
std::string gameState = "menu";
do
{
menu.printMenu();
input = menu.getInput();
if (input == "1")
{
gameState = "new";
menu.printMessage("Starting a New Game");
engine = new GameEngine(&menu);
exit = engine->playGame(argv[0]);
gameState = "game";
}
else if (input == "2")
{
gameState = "load";
menu.printMessage("Enter the filename from which load a game");
std::string fileName = menu.getInput();
if (fileName == "help")
{
engine->helpMenu(gameState);
}
else if (!std::cin.eof())
{
try
{
engine = saver.load(fileName, &menu);
if (engine != nullptr)
{
menu.printMessage("Azul game successfully loaded");
menu.printMessage("Press Enter to Play...");
std::cin.ignore();
std::system("clear");
exit = engine->playGame();
gameState = "game";
}
}
catch (const char *errorMessage)
{
std::string message(errorMessage);
menu.printMessage("Error reading file - " + message + "\n");
std::cout << "Press Enter to Continue... \n";
std::cin.ignore();
}
}
else
exit = true;
std::system("clear");
}
else if (input == "3")
{
menu.printCredits();
gameState = "credits";
}
else if (std::cin.eof() || input == "4")
{
exit = true;
}
else if (input == "help")
{
engine->helpMenu(gameState);
}
else
{
if (gameState == "credits")
{
system("clear");
gameState = "menu";
}
else
{
menu.printMessage("Invalid input, try again");
menu.printMessage("Loading New Menu...");
sleep(2);
system("clear");
gameState = "menu";
}
}
} while (!exit);
menu.printMessage("Goodbye");
if (engine != nullptr)
delete engine;
system("clear");
return 0;
}