summaryrefslogtreecommitdiff
path: root/battles/src
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-11-17 00:15:33 +0100
committerAki <please@ignore.pl>2022-11-17 00:15:33 +0100
commit068d56e95ab3a96c25ec3a2d2e8fff74e527a6eb (patch)
treee8d565c61ba20fa5d88ee9514e64a70b5f5ae006 /battles/src
parentda8efebc3b17041e962d9d2d577a053734843121 (diff)
downloadkurator-068d56e95ab3a96c25ec3a2d2e8fff74e527a6eb.zip
kurator-068d56e95ab3a96c25ec3a2d2e8fff74e527a6eb.tar.gz
kurator-068d56e95ab3a96c25ec3a2d2e8fff74e527a6eb.tar.bz2
Moved total teams to Scenario
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