diff options
author | Aki <please@ignore.pl> | 2022-11-17 00:15:33 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-11-17 00:15:33 +0100 |
commit | 068d56e95ab3a96c25ec3a2d2e8fff74e527a6eb (patch) | |
tree | e8d565c61ba20fa5d88ee9514e64a70b5f5ae006 | |
parent | da8efebc3b17041e962d9d2d577a053734843121 (diff) | |
download | kurator-068d56e95ab3a96c25ec3a2d2e8fff74e527a6eb.zip kurator-068d56e95ab3a96c25ec3a2d2e8fff74e527a6eb.tar.gz kurator-068d56e95ab3a96c25ec3a2d2e8fff74e527a6eb.tar.bz2 |
Moved total teams to Scenario
-rw-r--r-- | battles/CMakeLists.txt | 1 | ||||
-rw-r--r-- | battles/include/kurator/battles/Scenario.h | 1 | ||||
-rw-r--r-- | battles/src/BaseBattle.cpp | 17 | ||||
-rw-r--r-- | battles/src/Scenario.cpp | 23 |
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 |