forked from a-songac/grid-map-assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
99 lines (82 loc) · 2.78 KB
/
main.cpp
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
#define RUN_TESTS
//#define RUN_TEST_MANUAL
#include <iostream>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include "entity/Cell.h"
#include "entity/Map.h"
#include "view/MapView.h"
#include "controller/MapEditorController.h"
#include "utils/IOUtils.h"
#include "controller/EditorFacadeController.h"
#include "entity/repo/MapRepository.h"
#include "entity/repo/CharacterRepository.h"
#include "entity/repo/ItemRepository.h"
#include "entity/repo/GameRepository.h"
#include "entity/repo/CampaignRepository.h"
#include "utils/IOUtils.h"
#include "controller/GamePlayController.h"
#include "test/ShortestPathTest.h"
#include "controller/CharacterEditorController.h"
using namespace std;
int main()
{
#ifdef RUN_TESTS
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
CppUnit::TextUi::TestRunner runner;
runner.addTest(suite);
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) );
bool wasSucessful = runner.run();
if (!wasSucessful) {
return 0;
}
#endif // RUN_TESTS
MapRepository::instance();
CharacterRepository::instance();
ItemRepository::instance();
GameRepository::instance();
CampaignRepository::instance();
#ifdef RUN_TEST_MANUAL
if (readYesNoInput("Test Shortest path algorithm?[Y/n]: ", true)) {
ShortestPathTest::interactiveTest();
}
#endif // RUN_TEST_MANUAL
int choice;
bool gameLoop = true;
do {
cout << "\n\n********************* DONGONS AND DRAGONS *********************" << endl << endl;
cout << "Please select an action: " << endl;
cout << "1. Play Game" << endl;
cout << "2. Edit Game Elements" << endl;
cout << "3. Exit :(" << endl;
choice = readIntegerInputWithRange("Your choice[1]: ", 1, 1, 3);
switch (choice) {
case 1:
{
GamePlayController gameController;
cout << "********* PLAY GAME *********" << endl;
cout << "1. Start a new game" << endl;
cout << "2. Load previous game" << endl;
int choice = readIntegerInputWithRange("Your choice[1]: ", 1, 1, 2);
if (1 == choice)
gameController.newGame();
else
gameController.loadGame();
break;
}
case 2:
{
EditorFacadeController::editorMenu();
break;
}
case 3:
{
gameLoop = false;
cout << "Good bye!" << endl;
break;
}
}
} while (gameLoop);
return 0;
}