diff options
Diffstat (limited to 'src/openvic-simulation/politics')
-rw-r--r-- | src/openvic-simulation/politics/Issue.cpp | 21 | ||||
-rw-r--r-- | src/openvic-simulation/politics/NationalFocus.cpp | 11 | ||||
-rw-r--r-- | src/openvic-simulation/politics/NationalValue.cpp | 7 | ||||
-rw-r--r-- | src/openvic-simulation/politics/Rebel.cpp | 8 |
4 files changed, 21 insertions, 26 deletions
diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp index 1faa345..8da09fc 100644 --- a/src/openvic-simulation/politics/Issue.cpp +++ b/src/openvic-simulation/politics/Issue.cpp @@ -1,6 +1,7 @@ #include "Issue.hpp" #include "openvic-simulation/modifier/ModifierManager.hpp" +#include "openvic-simulation/types/fixed_point/FixedPoint.hpp" using namespace OpenVic; using namespace OpenVic::NodeTools; @@ -178,17 +179,18 @@ bool IssueManager::_load_issue( ModifierManager const& modifier_manager, RuleManager const& rule_manager, std::string_view identifier, IssueGroup const* group, ast::NodeCPtr node ) { - using enum Modifier::modifier_type_t; - ModifierValue values; RuleSet rules; bool jingoism = false; - bool ret = modifier_manager.expect_modifier_value_and_keys( - move_variable_callback(values), - ISSUE, + bool ret = NodeTools::expect_dictionary_keys_and_default( + modifier_manager.expect_base_country_modifier(values), "is_jingoism", ZERO_OR_ONE, expect_bool(assign_variable_callback(jingoism)), - "rules", ZERO_OR_ONE, rule_manager.expect_rule_set(move_variable_callback(rules)) + "rules", ZERO_OR_ONE, rule_manager.expect_rule_set(move_variable_callback(rules)), + "war_exhaustion_effect", ZERO_OR_ONE, [](const ast::NodeCPtr _) -> bool { + Logger::warning("war_exhaustion_effect does nothing (vanilla issues have it)."); + return true; + } )(node); ret &= add_issue( @@ -219,8 +221,6 @@ bool IssueManager::_load_reform( ModifierManager const& modifier_manager, RuleManager const& rule_manager, size_t ordinal, std::string_view identifier, ReformGroup const* group, ast::NodeCPtr node ) { - using enum Modifier::modifier_type_t; - ModifierValue values; RuleSet rules; fixed_point_t administrative_multiplier = 0; @@ -229,9 +229,8 @@ bool IssueManager::_load_reform( ConditionScript on_execute_trigger { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE }; EffectScript on_execute_effect; - bool ret = modifier_manager.expect_modifier_value_and_keys( - move_variable_callback(values), - REFORM, + bool ret = NodeTools::expect_dictionary_keys_and_default( + modifier_manager.expect_base_country_modifier(values), "administrative_multiplier", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(administrative_multiplier)), "technology_cost", ZERO_OR_ONE, expect_uint(assign_variable_callback(technology_cost)), "allow", ZERO_OR_ONE, allow.expect_script(), diff --git a/src/openvic-simulation/politics/NationalFocus.cpp b/src/openvic-simulation/politics/NationalFocus.cpp index 4d1546c..2427d7c 100644 --- a/src/openvic-simulation/politics/NationalFocus.cpp +++ b/src/openvic-simulation/politics/NationalFocus.cpp @@ -117,8 +117,6 @@ bool NationalFocusManager::load_national_foci_file( [this, &group, &pop_manager, &ideology_manager, &good_definition_manager, &modifier_manager]( std::string_view identifier, ast::NodeCPtr node ) -> bool { - using enum Modifier::modifier_type_t; - uint8_t icon = 0; bool has_flashpoint = false, own_provinces = true, outliner_show_as_percent = false; fixed_point_t flashpoint_tension = 0; @@ -132,10 +130,9 @@ bool NationalFocusManager::load_national_foci_file( scope_t::PROVINCE | scope_t::COUNTRY, scope_t::PROVINCE | scope_t::COUNTRY, scope_t::NO_SCOPE }; - bool ret = modifier_manager.expect_modifier_value_and_keys_and_default( - move_variable_callback(modifiers), - NATIONAL_FOCUS, - [&good_definition_manager, &encourage_goods, &pop_manager, &encourage_pop_types]( + const auto expect_base_province_modifier_cb = modifier_manager.expect_base_province_modifier(modifiers); + bool ret = NodeTools::expect_dictionary_keys_and_default( + [&good_definition_manager, &encourage_goods, &pop_manager, &encourage_pop_types, &expect_base_province_modifier_cb]( std::string_view key, ast::NodeCPtr value ) -> bool { GoodDefinition const* good = good_definition_manager.get_good_definition_by_identifier(key); @@ -148,7 +145,7 @@ bool NationalFocusManager::load_national_foci_file( return expect_fixed_point(map_callback(encourage_pop_types, pop_type))(value); } - return key_value_invalid_callback(key, value); + return expect_base_province_modifier_cb(key, value) || key_value_invalid_callback(key, value); }, "icon", ONE_EXACTLY, expect_uint(assign_variable_callback(icon)), "ideology", ZERO_OR_ONE, diff --git a/src/openvic-simulation/politics/NationalValue.cpp b/src/openvic-simulation/politics/NationalValue.cpp index 16f723b..9a30fa1 100644 --- a/src/openvic-simulation/politics/NationalValue.cpp +++ b/src/openvic-simulation/politics/NationalValue.cpp @@ -21,11 +21,10 @@ bool NationalValueManager::load_national_values_file(ModifierManager const& modi bool ret = expect_dictionary_reserve_length( national_values, [this, &modifier_manager](std::string_view national_value_identifier, ast::NodeCPtr value) -> bool { - using enum Modifier::modifier_type_t; - ModifierValue modifiers; - - bool ret = modifier_manager.expect_modifier_value(move_variable_callback(modifiers), NATIONAL_VALUE)(value); + bool ret = NodeTools::expect_dictionary( + modifier_manager.expect_base_country_modifier(modifiers) + )(value); ret &= add_national_value(national_value_identifier, std::move(modifiers)); diff --git a/src/openvic-simulation/politics/Rebel.cpp b/src/openvic-simulation/politics/Rebel.cpp index 9bba1b9..9b2927c 100644 --- a/src/openvic-simulation/politics/Rebel.cpp +++ b/src/openvic-simulation/politics/Rebel.cpp @@ -186,9 +186,9 @@ bool RebelManager::generate_modifiers(ModifierManager& modifier_manager) const { ret &= modifier_manager.register_complex_modifier(identifier); - ret &= modifier_manager.add_modifier_effect( + ret &= modifier_manager.register_technology_modifier_effect( modifier_manager.modifier_effect_cache.rebel_org_gain_all, ModifierManager::get_flat_identifier(identifier, "all"), - is_positive_good, PROPORTION_DECIMAL, COUNTRY, "TECH_REBEL_ORG_GAIN" + is_positive_good, PROPORTION_DECIMAL, "TECH_REBEL_ORG_GAIN" ); IndexedMap<RebelType, ModifierEffect const*>& rebel_org_gain_effects = @@ -197,9 +197,9 @@ bool RebelManager::generate_modifiers(ModifierManager& modifier_manager) const { rebel_org_gain_effects.set_keys(&get_rebel_types()); for (RebelType const& rebel_type : get_rebel_types()) { - ret &= modifier_manager.add_modifier_effect( + ret &= modifier_manager.register_technology_modifier_effect( rebel_org_gain_effects[rebel_type], ModifierManager::get_flat_identifier(identifier, rebel_type.get_identifier()), - is_positive_good, PROPORTION_DECIMAL, COUNTRY, + is_positive_good, PROPORTION_DECIMAL, StringUtils::append_string_views("$", rebel_type.get_identifier(), "_title$ $TECH_REBEL_ORG_GAIN$") ); } |