diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-29 20:01:27 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-29 20:01:27 +0100 |
commit | 9283e1eb66d6ff96b02f317e28cb6ff060953cdf (patch) | |
tree | c03d853ef620216f1c2299936004f56c6c3cee04 /frontend/main.cpp | |
parent | 7285f9f2c2622acff734e31314f92df9b25cae16 (diff) |
WIP load XML
Diffstat (limited to 'frontend/main.cpp')
-rw-r--r-- | frontend/main.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/frontend/main.cpp b/frontend/main.cpp index b9322ee..c421d9e 100644 --- a/frontend/main.cpp +++ b/frontend/main.cpp @@ -3,25 +3,35 @@ #include <memory> #include "backend/Dungeon.h" -#include "Player.h" +#include "Player.h" +#include "Exception.h" +#include "frontend/print.h" +#include "load_dungeon.h" +#include "generate_dungeon.h" #include "rl.h" #include "strings.h" -#include "print.h" using namespace std; -FollowupAction game_main() { - auto dungeon = make_unique<Dungeon>(); - - print_string(strings::INTRO); - string filename = rl(); - if (filename.size() == 0) { - lprtf("TODO: generate dungeon\n"); - } else { - lprtf("TODO: load %s\n", filename.c_str()); +static unique_ptr<Dungeon> make_dungeon() noexcept { + while (1) { + print_string(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(); Player player { *dungeon }; while (1) { |