summaryrefslogtreecommitdiff
path: root/universe/src/SampleRepository.cpp
blob: 1d875e758f1419173c31c3e923050cfe2d8f6176 (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
#include "SampleRepository.h"

#include <stdexcept>
#include <string>
#include <unordered_map>

#include <kurator/universe/NotFound.h>
#include <kurator/universe/ShipType.h>
#include <kurator/universe/TurretType.h>


namespace kurator
{
namespace universe
{


static const std::unordered_map<std::string, ShipType> ships {
	{"cube", {"Cube", 10.0}},
	{"halo", {"Halo", 4.0}},
	{"bell", {"Bell", 18.0}},
};


static const std::unordered_map<std::string, TurretType> turrets {
	{"cannon", {"Cannon", 1.0, 1.0, 1.2}},
};


ShipType
SampleRepository::ship_type(const std::string& id) const
try {
	return ships.at(id);
}
catch (const std::out_of_range&) {
	throw NotFound(id);
}


TurretType
SampleRepository::turret_type(const std::string& id) const
try {
	return turrets.at(id);
}
catch (const std::out_of_range&) {
	throw NotFound(id);
}


}  // namespace universe
}  // namespace kurator