aboutsummaryrefslogtreecommitdiff
path: root/frontend/main.cpp
blob: b9322eee940971e45a1bb190c34752baf6f50699 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <cstdlib>
#include <cstdio>
#include <memory>

#include "backend/Dungeon.h"
#include "Player.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());
	}

	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: {
				dungeon->update();
				break;
			}
			default: return action;
		}
	}
}

int main() {
	FollowupAction action;

	do {
		action = game_main();
		if (action == EXIT) break;
	} while (action == RESTART);

	return EXIT_SUCCESS;
}