aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/pop/Pop.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-10-20 20:44:51 +0200
committer GitHub <noreply@github.com>2024-10-20 20:44:51 +0200
commit6527f832a5e14a28fc1f5b85628541038eb90141 (patch)
treeaca829171be7b1144cb3ca29510593fa8a84af24 /src/openvic-simulation/pop/Pop.cpp
parent9a84e7af70f2528578b00879e568bca285563e9b (diff)
parent5194a3d043db66b81470111a94f3b1cdf8d42176 (diff)
Merge pull request #198 from OpenVicProject/resultant-modifier
Calculate country and province modifier sums
Diffstat (limited to 'src/openvic-simulation/pop/Pop.cpp')
-rw-r--r--src/openvic-simulation/pop/Pop.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp
index dd829d9..885903a 100644
--- a/src/openvic-simulation/pop/Pop.cpp
+++ b/src/openvic-simulation/pop/Pop.cpp
@@ -5,6 +5,7 @@
#include "openvic-simulation/map/ProvinceInstance.hpp"
#include "openvic-simulation/military/UnitType.hpp"
#include "openvic-simulation/misc/Define.hpp"
+#include "openvic-simulation/modifier/ModifierManager.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
#include "openvic-simulation/politics/Issue.hpp"
#include "openvic-simulation/politics/Rebel.hpp"
@@ -654,24 +655,33 @@ bool PopManager::load_pop_bases_into_vector(
bool PopManager::generate_modifiers(ModifierManager& modifier_manager) const {
using enum ModifierEffect::format_t;
+ using enum ModifierEffect::target_t;
+
+ IndexedMap<Strata, ModifierEffectCache::strata_effects_t>& strata_effects =
+ modifier_manager.modifier_effect_cache.strata_effects;
+
+ strata_effects.set_keys(&get_stratas());
bool ret = true;
for (Strata const& strata : get_stratas()) {
const auto strata_modifier = [&modifier_manager, &ret, &strata](
- std::string_view suffix, bool is_positive_good
+ ModifierEffect const*& effect_cache, std::string_view suffix, bool is_positive_good
) -> void {
ret &= modifier_manager.add_modifier_effect(
- StringUtils::append_string_views(strata.get_identifier(), suffix), is_positive_good
+ effect_cache, StringUtils::append_string_views(strata.get_identifier(), suffix), is_positive_good,
+ PROPORTION_DECIMAL, COUNTRY
);
};
- strata_modifier("_income_modifier", true);
- strata_modifier("_vote", true);
+ ModifierEffectCache::strata_effects_t& this_strata_effects = strata_effects[strata];
+
+ strata_modifier(this_strata_effects.income_modifier, "_income_modifier", true); // Has no effect in game
+ strata_modifier(this_strata_effects.vote, "_vote", true);
- strata_modifier("_life_needs", false);
- strata_modifier("_everyday_needs", false);
- strata_modifier("_luxury_needs", false);
+ strata_modifier(this_strata_effects.life_needs, "_life_needs", false);
+ strata_modifier(this_strata_effects.everyday_needs, "_everyday_needs", false);
+ strata_modifier(this_strata_effects.luxury_needs, "_luxury_needs", false);
}
return ret;