aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/research/Technology.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/research/Technology.cpp')
-rw-r--r--src/openvic-simulation/research/Technology.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/openvic-simulation/research/Technology.cpp b/src/openvic-simulation/research/Technology.cpp
index a5256f3..f2df94b 100644
--- a/src/openvic-simulation/research/Technology.cpp
+++ b/src/openvic-simulation/research/Technology.cpp
@@ -1,5 +1,7 @@
#include "Technology.hpp"
+#include "openvic-simulation/modifier/ModifierManager.hpp"
+
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -141,7 +143,10 @@ bool TechnologyManager::load_technology_file_schools(
technology_schools,
[this, &modifier_manager](std::string_view school_key, ast::NodeCPtr school_value) -> bool {
ModifierValue modifiers;
- bool ret = modifier_manager.expect_modifier_value(move_variable_callback(modifiers))(school_value);
+
+ bool ret = NodeTools::expect_dictionary(
+ modifier_manager.expect_base_country_modifier(modifiers)
+ )(school_value);
ret &= add_technology_school(school_key, std::move(modifiers));
@@ -163,6 +168,8 @@ bool TechnologyManager::load_technologies_file(
return expect_dictionary_reserve_length(technologies, [this, &modifier_manager, &unit_type_manager, &building_type_manager](
std::string_view tech_key, ast::NodeCPtr tech_value
) -> bool {
+ using enum scope_type_t;
+
ModifierValue modifiers;
TechnologyArea const* area = nullptr;
Date::year_t year = 0;
@@ -171,10 +178,10 @@ bool TechnologyManager::load_technologies_file(
std::optional<CountryInstance::unit_variant_t> unit_variant;
Technology::unit_set_t activated_units;
Technology::building_set_t activated_buildings;
- ConditionalWeight ai_chance { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };
+ ConditionalWeight ai_chance { COUNTRY, COUNTRY, NO_SCOPE };
- bool ret = modifier_manager.expect_modifier_value_and_keys(
- move_variable_callback(modifiers),
+ bool ret = NodeTools::expect_dictionary_keys_and_default(
+ modifier_manager.expect_technology_modifier(modifiers),
"area", ONE_EXACTLY, expect_technology_area_identifier(assign_variable_callback_pointer(area)),
"year", ONE_EXACTLY, expect_uint(assign_variable_callback(year)),
"cost", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(cost)),
@@ -197,13 +204,21 @@ bool TechnologyManager::load_technologies_file(
bool TechnologyManager::generate_modifiers(ModifierManager& modifier_manager) const {
using enum ModifierEffect::format_t;
+ using enum ModifierEffect::target_t;
+
+ IndexedMap<TechnologyFolder, ModifierEffect const*>& research_bonus_effects =
+ modifier_manager.modifier_effect_cache.research_bonus_effects;
+
+ research_bonus_effects.set_keys(&get_technology_folders());
bool ret = true;
for (TechnologyFolder const& folder : get_technology_folders()) {
const std::string modifier_identifier = StringUtils::append_string_views(folder.get_identifier(), "_research_bonus");
- ret &= modifier_manager.add_modifier_effect(modifier_identifier, true, PROPORTION_DECIMAL, modifier_identifier);
+ ret &= modifier_manager.register_base_country_modifier_effect(
+ research_bonus_effects[folder], modifier_identifier, true, PROPORTION_DECIMAL, modifier_identifier
+ );
}
return ret;