aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-04-19 20:28:30 +0200
committer hop311 <hop3114@gmail.com>2024-04-19 20:28:30 +0200
commit4284b73b82c02fb5d2d86fbfd966c03caab8dce4 (patch)
tree2e855a0b277f30ea645f88b5107e4253f24ce948 /src/openvic-simulation/map
parent4dca4f6538a3f82746ca4d8b3e66cdb6f9d0dff6 (diff)
Menu reqs: country index, flag type set, province set total populationmenu-reqs
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r--src/openvic-simulation/map/Region.cpp16
-rw-r--r--src/openvic-simulation/map/Region.hpp5
2 files changed, 13 insertions, 8 deletions
diff --git a/src/openvic-simulation/map/Region.cpp b/src/openvic-simulation/map/Region.cpp
index c735279..9b31d0f 100644
--- a/src/openvic-simulation/map/Region.cpp
+++ b/src/openvic-simulation/map/Region.cpp
@@ -95,12 +95,18 @@ ProvinceSet::provinces_t const& ProvinceSet::get_provinces() const {
return provinces;
}
-Region::Region(std::string_view new_identifier, colour_t new_colour, bool new_meta)
- : HasIdentifierAndColour { new_identifier, new_colour, false }, meta { new_meta } {}
+Pop::pop_size_t ProvinceSet::calculate_total_population() const {
+ Pop::pop_size_t total_population = 0;
+
+ for (Province const* province : provinces) {
+ total_population += province->get_total_population();
+ }
+
+ return total_population;
+}
ProvinceSetModifier::ProvinceSetModifier(std::string_view new_identifier, ModifierValue&& new_values)
: Modifier { new_identifier, std::move(new_values), 0 } {}
-bool Region::get_meta() const {
- return meta;
-}
+Region::Region(std::string_view new_identifier, colour_t new_colour, bool new_meta)
+ : HasIdentifierAndColour { new_identifier, new_colour, false }, meta { new_meta } {}
diff --git a/src/openvic-simulation/map/Region.hpp b/src/openvic-simulation/map/Region.hpp
index 420d221..f12e14a 100644
--- a/src/openvic-simulation/map/Region.hpp
+++ b/src/openvic-simulation/map/Region.hpp
@@ -26,6 +26,7 @@ namespace OpenVic {
void reserve_more(size_t size);
bool contains_province(Province const* province) const;
provinces_t const& get_provinces() const;
+ Pop::pop_size_t calculate_total_population() const;
};
struct ProvinceSetModifier : Modifier, ProvinceSet {
@@ -47,13 +48,11 @@ namespace OpenVic {
* Any region containing a province already listed in a
* previously defined region is considered a meta region.
*/
- const bool meta;
+ const bool PROPERTY(meta);
Region(std::string_view new_identifier, colour_t new_colour, bool new_meta);
public:
Region(Region&&) = default;
-
- bool get_meta() const;
};
}