summaryrefslogtreecommitdiff
path: root/universe/src/SampleRepository.cpp
blob: a81c2bbda7cac3b39684844635c964802b9f4787 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "SampleRepository.h"

#include <functional>
#include <stdexcept>
#include <string>
#include <map>

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


namespace kurator
{
namespace universe
{


static const std::map<std::string, ShipType> ships {
	{"Anvil", {"Anvil", 600.0, 218.0}},
	{"Eclipse", {"Eclipse", 600.0, 263.0}},
	{"Warbringer", {"Warbringer", 600.0, 336.0}},
};


static const std::map<std::string, TurretType> turrets {
	{"ChargeLaser", {"ChargeLaser", 1, 85.0, 4.5, 0.0, 7000.0, 0.05}},
	{"BurstLaser", {"BurstLaser", 3, 21.0, 0.25, 2.75, 3500.0, 0.05}},
	{"GaussCannon", {"GaussCannon", 2, 55.0, 0.0, 5.5, 12000.0, 0.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);
}


void
SampleRepository::for_ship_types(std::function<void(const ShipType&)> func) const
{
	for (const auto& [_, type] : ships)
		func(type);
}


void
SampleRepository::for_turret_types(std::function<void(const TurretType&)> func) const
{
	for (const auto& [_, type] : turrets)
		func(type);
}


}  // namespace universe
}  // namespace kurator