aboutsummaryrefslogtreecommitdiff
path: root/src/openvic/map/Province.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-07-28 00:10:46 +0200
committer GitHub <noreply@github.com>2023-07-28 00:10:46 +0200
commit8a08be3e7e8477973e243716d431ad7117acfa43 (patch)
treea91587787bf6742168279ac41f77b9ebabe0dffe /src/openvic/map/Province.cpp
parent420c2dce47e74c01ff46be991058d543e0c70a6b (diff)
parent532c9be36ca03ee13c92ca7d895aaf5b42eeb034 (diff)
Merge pull request #9 from OpenVicProject/pops
Pops and other bits
Diffstat (limited to 'src/openvic/map/Province.cpp')
-rw-r--r--src/openvic/map/Province.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/openvic/map/Province.cpp b/src/openvic/map/Province.cpp
index d2a5ecf..75612ad 100644
--- a/src/openvic/map/Province.cpp
+++ b/src/openvic/map/Province.cpp
@@ -8,7 +8,7 @@ using namespace OpenVic;
Province::Province(index_t new_index, std::string const& new_identifier, colour_t new_colour)
: HasIdentifier { new_identifier },
- HasColour { new_colour },
+ HasColour { new_colour, false },
index { new_index },
buildings { "buildings" } {
assert(index != NULL_INDEX);
@@ -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) {