summaryrefslogtreecommitdiff
path: root/battles
diff options
context:
space:
mode:
Diffstat (limited to 'battles')
-rw-r--r--battles/CMakeLists.txt1
-rw-r--r--battles/include/kurator/battles/Scenario.h1
-rw-r--r--battles/src/BaseBattle.cpp17
-rw-r--r--battles/src/Scenario.cpp23
4 files changed, 26 insertions, 16 deletions
diff --git a/battles/CMakeLists.txt b/battles/CMakeLists.txt
index 4484670..f7478e3 100644
--- a/battles/CMakeLists.txt
+++ b/battles/CMakeLists.txt
@@ -6,6 +6,7 @@ add_library(
src/Builder.cpp
src/Point.cpp
src/RandomSpawner.cpp
+ src/Scenario.cpp
src/scenarios.cpp
src/TeamManager.cpp
)
diff --git a/battles/include/kurator/battles/Scenario.h b/battles/include/kurator/battles/Scenario.h
index b9bcc09..afbb74c 100644
--- a/battles/include/kurator/battles/Scenario.h
+++ b/battles/include/kurator/battles/Scenario.h
@@ -16,6 +16,7 @@ struct Scenario
{
std::string name;
std::vector<ShipConfig> ships;
+ int total_teams() const;
};
diff --git a/battles/src/BaseBattle.cpp b/battles/src/BaseBattle.cpp
index f12a944..e7d70c2 100644
--- a/battles/src/BaseBattle.cpp
+++ b/battles/src/BaseBattle.cpp
@@ -15,12 +15,9 @@ namespace battles
{
-int total_teams_in(const Scenario& scenario);
-
-
BaseBattle::BaseBattle(const Scenario& scenario) :
_registry {},
- spawner {total_teams_in(scenario), 2.5, 0.1}
+ spawner {scenario.total_teams(), 2.5, 0.1}
{
const auto repo = universe::load_sample();
Builder build {_registry, spawner};
@@ -130,17 +127,5 @@ BaseBattle::kill_off_dead()
}
-int
-total_teams_in(const Scenario& scenario)
-{
- int last_team = 0;
- for (const auto& ship : scenario.ships) {
- if (ship.team > last_team)
- last_team = ship.team;
- }
- return last_team + 1;
-}
-
-
} // namespace battles
} // namespace kurator
diff --git a/battles/src/Scenario.cpp b/battles/src/Scenario.cpp
new file mode 100644
index 0000000..49a9c7c
--- /dev/null
+++ b/battles/src/Scenario.cpp
@@ -0,0 +1,23 @@
+#include <kurator/battles/Scenario.h>
+
+
+namespace kurator
+{
+namespace battles
+{
+
+
+int
+Scenario::total_teams() const
+{
+ int last_team = 0;
+ for (const auto& ship : ships) {
+ if (ship.team > last_team)
+ last_team = ship.team;
+ }
+ return last_team + 1;
+}
+
+
+} // namespace battles
+} // namespace kurator