aboutsummaryrefslogtreecommitdiff
path: root/src/openvic/map/Province.cpp
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-07-26 22:37:25 +0200
committer Hop311 <hop3114@gmail.com>2023-07-26 22:37:25 +0200
commit532c9be36ca03ee13c92ca7d895aaf5b42eeb034 (patch)
treea91587787bf6742168279ac41f77b9ebabe0dffe /src/openvic/map/Province.cpp
parent0422f9fbb06e911a7cf6da11045b47cdda0d2d06 (diff)
Added pops to provinces
Diffstat (limited to 'src/openvic/map/Province.cpp')
-rw-r--r--src/openvic/map/Province.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/openvic/map/Province.cpp b/src/openvic/map/Province.cpp
index 06f1c98..75612ad 100644
--- a/src/openvic/map/Province.cpp
+++ b/src/openvic/map/Province.cpp
@@ -30,8 +30,8 @@ Province::life_rating_t Province::get_life_rating() const {
return life_rating;
}
-return_t Province::add_building(BuildingType const& type) {
- return buildings.add_item({ type });
+return_t Province::add_building(Building&& building) {
+ return buildings.add_item(std::move(building));
}
void Province::lock_buildings() {
@@ -66,9 +66,28 @@ std::string Province::to_string() const {
return stream.str();
}
+void Province::add_pop(Pop&& pop) {
+ pops.push_back(std::move(pop));
+}
+
+/* REQUIREMENTS:
+ * MAP-65
+ */
+void Province::update_total_population() {
+ total_population = 0;
+ for (Pop const& pop : pops) {
+ total_population += pop.get_size();
+ }
+}
+
+Pop::pop_size_t Province::get_total_population() const {
+ return total_population;
+}
+
void Province::update_state(Date const& today) {
for (Building& building : buildings.get_items())
building.update_state(today);
+ update_total_population();
}
void Province::tick(Date const& today) {