aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/modifier/ModifierManager.hpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-10-19 12:39:08 +0200
committer hop311 <hop3114@gmail.com>2024-10-19 12:39:08 +0200
commit572ac597d8b43c4c97be4b68aa40de0e7ae6bfe0 (patch)
treec529d60fe49fbcd167522c0fb21ca10139cb5cc7 /src/openvic-simulation/modifier/ModifierManager.hpp
parent35909d6e79d524f19f9b69dffd02fcf162be5093 (diff)
Require modifier type when parsing ModifierValues
Diffstat (limited to 'src/openvic-simulation/modifier/ModifierManager.hpp')
-rw-r--r--src/openvic-simulation/modifier/ModifierManager.hpp50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/openvic-simulation/modifier/ModifierManager.hpp b/src/openvic-simulation/modifier/ModifierManager.hpp
index 73d974d..f3673b0 100644
--- a/src/openvic-simulation/modifier/ModifierManager.hpp
+++ b/src/openvic-simulation/modifier/ModifierManager.hpp
@@ -36,7 +36,7 @@ namespace OpenVic {
/* effect_validator takes in ModifierEffect const& */
NodeTools::key_value_callback_t _modifier_effect_callback(
- ModifierValue& modifier, NodeTools::key_value_callback_t default_callback,
+ ModifierValue& modifier, Modifier::modifier_type_t type, NodeTools::key_value_callback_t default_callback,
ModifierEffectValidator auto effect_validator
) const;
@@ -71,56 +71,66 @@ namespace OpenVic {
bool parse_scripts(DefinitionManager const& definition_manager);
NodeTools::node_callback_t expect_validated_modifier_value_and_default(
- NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_value_callback_t default_callback,
- ModifierEffectValidator auto effect_validator
+ NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type,
+ NodeTools::key_value_callback_t default_callback, ModifierEffectValidator auto effect_validator
) const;
NodeTools::node_callback_t expect_validated_modifier_value(
- NodeTools::callback_t<ModifierValue&&> modifier_callback, ModifierEffectValidator auto effect_validator
+ NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type,
+ ModifierEffectValidator auto effect_validator
) const;
NodeTools::node_callback_t expect_modifier_value_and_default(
- NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_value_callback_t default_callback
+ NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type,
+ NodeTools::key_value_callback_t default_callback
+ ) const;
+ NodeTools::node_callback_t expect_modifier_value(
+ NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type
) const;
- NodeTools::node_callback_t expect_modifier_value(NodeTools::callback_t<ModifierValue&&> modifier_callback) const;
NodeTools::node_callback_t expect_whitelisted_modifier_value_and_default(
- NodeTools::callback_t<ModifierValue&&> modifier_callback, string_set_t const& whitelist,
- NodeTools::key_value_callback_t default_callback
+ NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type,
+ string_set_t const& whitelist, NodeTools::key_value_callback_t default_callback
) const;
NodeTools::node_callback_t expect_whitelisted_modifier_value(
- NodeTools::callback_t<ModifierValue&&> modifier_callback, string_set_t const& whitelist
+ NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type,
+ string_set_t const& whitelist
) const;
+ // In the functions below, key_map refers to a map from identifier strings to NodeTools::dictionary_entry_t,
+ // allowing any non-modifier effect keys found to be parsed in a custom way, similar to expect_dictionary_keys.
NodeTools::node_callback_t expect_modifier_value_and_key_map_and_default(
- NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_value_callback_t default_callback,
- NodeTools::key_map_t&& key_map
+ NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type,
+ NodeTools::key_value_callback_t default_callback, NodeTools::key_map_t&& key_map
) const;
NodeTools::node_callback_t expect_modifier_value_and_key_map(
- NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_map_t&& key_map
+ NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type,
+ NodeTools::key_map_t&& key_map
) const;
template<typename... Args>
NodeTools::node_callback_t expect_modifier_value_and_key_map_and_default(
- NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_value_callback_t default_callback,
- NodeTools::key_map_t&& key_map, Args... args
+ NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type,
+ NodeTools::key_value_callback_t default_callback, NodeTools::key_map_t&& key_map, Args... args
) const {
NodeTools::add_key_map_entries(key_map, args...);
- return expect_modifier_value_and_key_map_and_default(modifier_callback, default_callback, std::move(key_map));
+ return expect_modifier_value_and_key_map_and_default(
+ modifier_callback, type, default_callback, std::move(key_map)
+ );
}
template<typename... Args>
NodeTools::node_callback_t expect_modifier_value_and_keys_and_default(
- NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_value_callback_t default_callback,
- Args... args
+ NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type,
+ NodeTools::key_value_callback_t default_callback, Args... args
) const {
- return expect_modifier_value_and_key_map_and_default(modifier_callback, default_callback, {}, args...);
+ return expect_modifier_value_and_key_map_and_default(modifier_callback, type, default_callback, {}, args...);
}
template<typename... Args>
NodeTools::node_callback_t expect_modifier_value_and_keys(
- NodeTools::callback_t<ModifierValue&&> modifier_callback, Args... args
+ NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type, Args... args
) const {
return expect_modifier_value_and_key_map_and_default(
- modifier_callback, NodeTools::key_value_invalid_callback, {}, args...
+ modifier_callback, type, NodeTools::key_value_invalid_callback, {}, args...
);
}
};