summaryrefslogtreecommitdiff
path: root/battles/src
diff options
context:
space:
mode:
Diffstat (limited to 'battles/src')
-rw-r--r--battles/src/BaseBattle.cpp17
-rw-r--r--battles/src/Scenario.cpp23
2 files changed, 24 insertions, 16 deletions
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