diff options
Diffstat (limited to 'src/openvic-simulation/research/Invention.cpp')
-rw-r--r-- | src/openvic-simulation/research/Invention.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/openvic-simulation/research/Invention.cpp b/src/openvic-simulation/research/Invention.cpp index 299cefb..4351337 100644 --- a/src/openvic-simulation/research/Invention.cpp +++ b/src/openvic-simulation/research/Invention.cpp @@ -3,6 +3,7 @@ #include "openvic-simulation/economy/BuildingType.hpp" #include "openvic-simulation/map/Crime.hpp" #include "openvic-simulation/military/UnitType.hpp" +#include "openvic-simulation/modifier/ModifierManager.hpp" using namespace OpenVic; using namespace OpenVic::NodeTools; @@ -54,12 +55,16 @@ bool InventionManager::add_invention( } bool InventionManager::load_inventions_file( - ModifierManager const& modifier_manager, UnitTypeManager const& unit_type_manager, BuildingTypeManager const& building_type_manager, - CrimeManager const& crime_manager, ast::NodeCPtr root + ModifierManager const& modifier_manager, UnitTypeManager const& unit_type_manager, + BuildingTypeManager const& building_type_manager, CrimeManager const& crime_manager, ast::NodeCPtr root ) { return expect_dictionary_reserve_length( inventions, [this, &modifier_manager, &unit_type_manager, &building_type_manager, &crime_manager]( - std::string_view identifier, ast::NodeCPtr value) -> bool { + std::string_view identifier, ast::NodeCPtr value + ) -> bool { + using enum scope_type_t; + + // TODO - use the same variable for all modifiers rather than combining them at the end? ModifierValue loose_modifiers; ModifierValue modifiers; @@ -71,18 +76,20 @@ bool InventionManager::load_inventions_file( bool unlock_gas_defence = false; bool news = true; //defaults to true! - ConditionScript limit { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE }; - ConditionalWeight chance { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE }; + ConditionScript limit { COUNTRY, COUNTRY, NO_SCOPE }; + ConditionalWeight chance { COUNTRY, COUNTRY, NO_SCOPE }; - bool ret = modifier_manager.expect_modifier_value_and_keys(move_variable_callback(loose_modifiers), + 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), + "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, unit_type_manager.expect_unit_type_identifier(set_callback_pointer(activated_units)), + "activate_unit", ZERO_OR_MORE, + unit_type_manager.expect_unit_type_identifier(set_callback_pointer(activated_units)), "activate_building", ZERO_OR_MORE, building_type_manager.expect_building_type_identifier( set_callback_pointer(activated_buildings) ), |