aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/ProvinceInstance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/map/ProvinceInstance.cpp')
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp
index 06b3f1e..e2e4921 100644
--- a/src/openvic-simulation/map/ProvinceInstance.cpp
+++ b/src/openvic-simulation/map/ProvinceInstance.cpp
@@ -2,7 +2,10 @@
#include "openvic-simulation/country/CountryInstance.hpp"
#include "openvic-simulation/history/ProvinceHistory.hpp"
+#include "openvic-simulation/map/Crime.hpp"
#include "openvic-simulation/map/ProvinceDefinition.hpp"
+#include "openvic-simulation/map/Region.hpp"
+#include "openvic-simulation/map/TerrainType.hpp"
#include "openvic-simulation/military/UnitInstanceGroup.hpp"
#include "openvic-simulation/misc/Define.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
@@ -21,6 +24,9 @@ ProvinceInstance::ProvinceInstance(
owner { nullptr },
controller { nullptr },
cores {},
+ base_modifier_sum {},
+ event_modifiers {},
+ static_modifiers {},
slave { false },
crime { nullptr },
rgo { nullptr },
@@ -185,6 +191,44 @@ void ProvinceInstance::_update_pops(DefineManager const& define_manager) {
}
}
+void ProvinceInstance::update_base_modifier_sum(Date today) {
+ std::erase_if(event_modifiers, [today](ModifierInstance const& modifier) -> bool {
+ return modifier.get_expiry_date() < today;
+ });
+
+ // TODO - add/remove static modifiers
+
+ base_modifier_sum.clear();
+
+ for (ModifierInstance const& event_modifier : event_modifiers) {
+ base_modifier_sum += *event_modifier.get_modifier();
+ }
+
+ for (Modifier const* static_modifier : static_modifiers) {
+ base_modifier_sum += *static_modifier;
+ }
+
+ for (BuildingInstance const& building : buildings.get_items()) {
+ base_modifier_sum += building.get_building_type();
+ }
+
+ if (crime != nullptr) {
+ base_modifier_sum += *crime;
+ }
+
+ if (province_definition.get_continent() != nullptr) {
+ base_modifier_sum += *province_definition.get_continent();
+ }
+
+ if (province_definition.get_climate() != nullptr) {
+ base_modifier_sum += *province_definition.get_climate();
+ }
+
+ if (terrain_type != nullptr) {
+ base_modifier_sum += *terrain_type;
+ }
+}
+
void ProvinceInstance::update_gamestate(Date today, DefineManager const& define_manager) {
for (BuildingInstance& building : buildings.get_items()) {
building.update_gamestate(today);