#include #include #include #include "backend/print.h" #include "backend/Dungeon.h" #include "Player.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(); Player player { *dungeon }; while (1) { string line = rl(); if (line.length() == 0) continue; FollowupAction action = player.cmd(line); switch (action) { case NONE: break; case UPDATE: { dungeon->update(); break; } default: return action; } } } int main() { FollowupAction action; do { action = game_main(); if (action == EXIT) break; } while (action == RESTART); return EXIT_SUCCESS; }