diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-29 15:02:57 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-29 15:02:57 +0100 |
commit | 953f18fe681a2f120dab5be9e9884bf35765e21e (patch) | |
tree | d0cc4812c2f8c95a773e938bf7c3576af40cd98d /frontend/main.cpp | |
parent | 3562802cacc8dbd0c155146acfdb8d04c6440009 (diff) |
more WIP (command handling moved to player)
Diffstat (limited to 'frontend/main.cpp')
-rw-r--r-- | frontend/main.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/frontend/main.cpp b/frontend/main.cpp index 2d66888..776525c 100644 --- a/frontend/main.cpp +++ b/frontend/main.cpp @@ -3,25 +3,51 @@ #include <memory> #include "backend/Dungeon.h" +#include "Player.h" -#include "cli.h" +#include "rl.h" #include "strings.h" #include "print.h" using namespace std; -int main() { +FollowupAction game_main() { auto dungeon = make_unique<Dungeon>(); print_string(strings::INTRO); - string filename = cli_readline(); + string filename = rl(); if (filename.size() == 0) { lprtf("TODO: generate dungeon\n"); } else { lprtf("TODO: load %s\n", filename.c_str()); } - cli_main(); + Player player { *dungeon }; + + while (1) { + string line = rl(); + if (line.length() == 0) continue; + vector<string> argv = split_string(line, " "); + FollowupAction action = player.cmd(argv); + + switch (action) { + case NONE: break; + case UPDATE: { + printf("TODO: update!\n"); + break; + } + default: return action; + } + } +} + +int main() { + FollowupAction action; + + do { + action = game_main(); + if (action == EXIT) break; + } while (action == RESTART); return EXIT_SUCCESS; } |