aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r--src/openvic-simulation/map/MapInstance.cpp6
-rw-r--r--src/openvic-simulation/map/MapInstance.hpp1
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp44
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.hpp5
4 files changed, 56 insertions, 0 deletions
diff --git a/src/openvic-simulation/map/MapInstance.cpp b/src/openvic-simulation/map/MapInstance.cpp
index 0ce8cea..4df755e 100644
--- a/src/openvic-simulation/map/MapInstance.cpp
+++ b/src/openvic-simulation/map/MapInstance.cpp
@@ -118,6 +118,12 @@ bool MapInstance::apply_history_to_provinces(
return ret;
}
+void MapInstance::update_base_modifier_sums(Date today) {
+ for (ProvinceInstance& province : province_instances.get_items()) {
+ province.update_base_modifier_sum(today);
+ }
+}
+
void MapInstance::update_gamestate(Date today, DefineManager const& define_manager) {
for (ProvinceInstance& province : province_instances.get_items()) {
province.update_gamestate(today, define_manager);
diff --git a/src/openvic-simulation/map/MapInstance.hpp b/src/openvic-simulation/map/MapInstance.hpp
index 99c13d3..f7a85fb 100644
--- a/src/openvic-simulation/map/MapInstance.hpp
+++ b/src/openvic-simulation/map/MapInstance.hpp
@@ -52,6 +52,7 @@ namespace OpenVic {
IssueManager const& issue_manager
);
+ void update_base_modifier_sums(Date today);
void update_gamestate(Date today, DefineManager const& define_manager);
void tick(Date today);
};
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);
diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp
index fa0be98..8201483 100644
--- a/src/openvic-simulation/map/ProvinceInstance.hpp
+++ b/src/openvic-simulation/map/ProvinceInstance.hpp
@@ -68,6 +68,10 @@ namespace OpenVic {
CountryInstance* PROPERTY(controller);
ordered_set<CountryInstance*> PROPERTY(cores);
+ ModifierValue PROPERTY(base_modifier_sum);
+ std::vector<ModifierInstance> PROPERTY(event_modifiers);
+ std::vector<Modifier const*> PROPERTY(static_modifiers);
+
bool PROPERTY(slave);
Crime const* PROPERTY_RW(crime);
// TODO - change this into a factory-like structure
@@ -124,6 +128,7 @@ namespace OpenVic {
bool add_pop_vec(std::vector<PopBase> const& pop_vec);
size_t get_pop_count() const;
+ void update_base_modifier_sum(Date today);
void update_gamestate(Date today, DefineManager const& define_manager);
void tick(Date today);