summaryrefslogtreecommitdiff
path: root/universe/src
diff options
context:
space:
mode:
Diffstat (limited to 'universe/src')
-rw-r--r--universe/src/SampleRepository.cpp23
-rw-r--r--universe/src/SampleRepository.h3
2 files changed, 23 insertions, 3 deletions
diff --git a/universe/src/SampleRepository.cpp b/universe/src/SampleRepository.cpp
index 0f29073..a81c2bb 100644
--- a/universe/src/SampleRepository.cpp
+++ b/universe/src/SampleRepository.cpp
@@ -1,8 +1,9 @@
#include "SampleRepository.h"
+#include <functional>
#include <stdexcept>
#include <string>
-#include <unordered_map>
+#include <map>
#include <kurator/universe/NotFound.h>
#include <kurator/universe/ShipType.h>
@@ -15,14 +16,14 @@ namespace universe
{
-static const std::unordered_map<std::string, ShipType> ships {
+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::unordered_map<std::string, TurretType> turrets {
+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}},
@@ -49,5 +50,21 @@ catch (const std::out_of_range&) {
}
+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
diff --git a/universe/src/SampleRepository.h b/universe/src/SampleRepository.h
index 1cf4fb4..769af09 100644
--- a/universe/src/SampleRepository.h
+++ b/universe/src/SampleRepository.h
@@ -1,5 +1,6 @@
#pragma once
+#include <functional>
#include <string>
#include <kurator/universe/Repository.h>
@@ -18,6 +19,8 @@ class SampleRepository : public Repository
public:
ShipType ship_type(const std::string& id) const override;
TurretType turret_type(const std::string& id) const override;
+ void for_ship_types(std::function<void(const ShipType&)> func) const;
+ void for_turret_types(std::function<void(const TurretType&)> func) const;
};