From 3daebe5db14949f55be2c50220323138260dbaea Mon Sep 17 00:00:00 2001 From: wvpm <24685035+wvpm@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:09:40 +0200 Subject: contextual modifier parsing --- src/openvic-simulation/research/Invention.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/openvic-simulation/research/Invention.cpp') diff --git a/src/openvic-simulation/research/Invention.cpp b/src/openvic-simulation/research/Invention.cpp index 808dad4..1076a62 100644 --- a/src/openvic-simulation/research/Invention.cpp +++ b/src/openvic-simulation/research/Invention.cpp @@ -62,8 +62,6 @@ bool InventionManager::load_inventions_file( inventions, [this, &modifier_manager, &unit_type_manager, &building_type_manager, &crime_manager]( std::string_view identifier, ast::NodeCPtr value ) -> bool { - using enum Modifier::modifier_type_t; - // TODO - use the same variable for all modifiers rather than combining them at the end? ModifierValue loose_modifiers; ModifierValue modifiers; @@ -79,15 +77,13 @@ bool InventionManager::load_inventions_file( ConditionScript limit { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE }; ConditionalWeight chance { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE }; - bool ret = modifier_manager.expect_modifier_value_and_keys( - move_variable_callback(loose_modifiers), - INVENTION, + bool ret = NodeTools::expect_dictionary_keys_and_default( + modifier_manager.expect_base_country_modifier(loose_modifiers), "news", ZERO_OR_ONE, expect_bool(assign_variable_callback(news)), "limit", ONE_EXACTLY, limit.expect_script(), "chance", ONE_EXACTLY, chance.expect_conditional_weight(ConditionalWeight::BASE), - "effect", ZERO_OR_ONE, modifier_manager.expect_modifier_value_and_keys( - move_variable_callback(modifiers), - INVENTION, + "effect", ZERO_OR_ONE, NodeTools::expect_dictionary_keys_and_default( + modifier_manager.expect_technology_modifier(modifiers), "gas_attack", ZERO_OR_ONE, expect_bool(assign_variable_callback(unlock_gas_attack)), "gas_defence", ZERO_OR_ONE, expect_bool(assign_variable_callback(unlock_gas_defence)), "activate_unit", ZERO_OR_MORE, -- cgit v1.2.3-56-ga3b1