From b20f46c15dce8b196dbb8890890978947745e094 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 1 Nov 2024 17:32:53 +0100 Subject: change flow architecture --- frontend/main.cpp | 57 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 55 deletions(-) (limited to 'frontend/main.cpp') 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 -#include -#include - #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 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 = 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; } -- cgit v1.2.3