aboutsummaryrefslogtreecommitdiff
path: root/frontend/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/main.cpp')
-rw-r--r--frontend/main.cpp57
1 files changed, 2 insertions, 55 deletions
diff --git a/frontend/main.cpp b/frontend/main.cpp
index f8e2526..64b4474 100644
--- a/frontend/main.cpp
+++ b/frontend/main.cpp
@@ -1,70 +1,17 @@
-#include <cstdlib>
-#include <cstdio>
-#include <memory>
-
#include "backend/print.h"
-#include "backend/Dungeon.h"
-#include "GameData.h"
#include "GameController.h"
#include "Exception.h"
-#include "load_dungeon.h"
-#include "generate_dungeon.h"
-#include "rl.h"
-#include "strings.h"
using namespace std;
-static unique_ptr<Dungeon> make_dungeon() noexcept {
- while (1) {
- str_print(strings::INTRO);
- string filename = rl();
- try {
- if (filename.size() == 0) {
- return generate_dungeon();
- } else {
- return load_dungeon(filename);
- }
- } catch (Exception & e) {
- lprtf("FOUT: %s\n", e.what());
- }
- }
-}
-
-FollowupAction game_main() {
- unique_ptr<Dungeon> dungeon = make_dungeon();
- GameController game { *dungeon };
-
- while (1) {
- string line = rl();
- if (line.length() == 0) continue;
- FollowupAction action = game.cmd(line);
-
- switch (action) {
- case NONE: break;
- case UPDATE: {
- dungeon->update();
- break;
- }
- default: return action;
- }
- }
-}
-
int main() {
try {
- GameData::get_instance(); // pre-load DB
+ GameController game;
+ return game.main();
} catch (Exception & e) {
lprtf("FOUT: %s\n", e.what());
return EXIT_FAILURE;
}
-
- FollowupAction action;
- do {
- action = game_main();
- if (action == EXIT) break;
- } while (action == RESTART);
-
- return EXIT_SUCCESS;
}