diff options
Diffstat (limited to 'src/openvic-simulation/pop')
-rw-r--r-- | src/openvic-simulation/pop/Pop.cpp | 44 | ||||
-rw-r--r-- | src/openvic-simulation/pop/Pop.hpp | 5 |
2 files changed, 34 insertions, 15 deletions
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp index 85730e3..0f0de69 100644 --- a/src/openvic-simulation/pop/Pop.cpp +++ b/src/openvic-simulation/pop/Pop.cpp @@ -5,9 +5,11 @@ #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" +#include "openvic-simulation/utility/Logger.hpp" #include "openvic-simulation/utility/TslHelper.hpp" using namespace OpenVic; @@ -114,14 +116,15 @@ void Pop::setup_pop_test_values(IssueManager const& issue_manager) { luxury_needs_fulfilled = test_range(); } -void Pop::convert_to_equivalent() { +bool Pop::convert_to_equivalent() { PopType const* const equivalent = get_type()->get_equivalent(); - if(equivalent == nullptr) { - //error? - } - else { - type = equivalent; + if (equivalent == nullptr) { + Logger::error("Tried to convert pop of type ", get_type()->get_identifier(), " to equivalent, but there is no equivalent."); + return false; } + + type = equivalent; + return true; } void Pop::set_location(ProvinceInstance const& new_location) { @@ -154,6 +157,10 @@ void Pop::update_gamestate( } } +//TODO store income +void Pop::add_rgo_owner_income(const fixed_point_t income) {} +void Pop::add_rgo_worker_income(const fixed_point_t income) {} + Strata::Strata(std::string_view new_identifier) : HasIdentifier { new_identifier } {} PopType::PopType( @@ -664,24 +671,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 + ret &= modifier_manager.register_base_country_modifier_effect( + effect_cache, StringUtils::append_string_views(strata.get_identifier(), suffix), is_positive_good, + PROPORTION_DECIMAL ); }; - 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; diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp index ec8b955..88c397a 100644 --- a/src/openvic-simulation/pop/Pop.hpp +++ b/src/openvic-simulation/pop/Pop.hpp @@ -95,7 +95,7 @@ namespace OpenVic { Pop& operator=(Pop&&) = delete; void setup_pop_test_values(IssueManager const& issue_manager); - void convert_to_equivalent(); + bool convert_to_equivalent(); void set_location(ProvinceInstance const& new_location); @@ -103,6 +103,9 @@ namespace OpenVic { DefineManager const& define_manager, CountryInstance const* owner, fixed_point_t const& pop_size_per_regiment_multiplier ); + + void add_rgo_owner_income(const fixed_point_t income); + void add_rgo_worker_income(const fixed_point_t income); }; struct Strata : HasIdentifier { |