aboutsummaryrefslogtreecommitdiff
path: root/frontend/generate_dungeon.cpp
blob: 7ce17540a4975031903a9ebb1739172230bca77f (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
#include <memory>

#include "backend/Dungeon.h"
#include "backend/print.h"
#include "backend/Exception.h"

#include "rl.h"
#include "generate_dungeon.h"
#include "GameData.h"

using namespace std;

unique_ptr<Dungeon> generate_dungeon() {
	unique_ptr<Dungeon> dungeon = make_unique<Dungeon>();
	GameData & gd = GameData::get_instance();

	lprtf("Hoeveel locaties moet de kerker hebben?\n");
	unsigned location_count = 1;
	try {
		string filename = rl();
		location_count = stoul(filename);
	} catch (...) {
		throw Exception("geen geldig aantal ingevoerd");
	}
	if (location_count < 1)
		throw Exception("meer dan 1 locatie nodig");

	vector<string> locations = gd.random_locations(location_count);
	for (const string & name : locations) {
		Location * location = gd.create_location(name);
		dungeon->add_location(location);
	}

	// TODO: connect locations
	// TODO: optionally add enemy
	// TODO: generate items

	return dungeon;
}