diff options
author | hop311 <hop3114@gmail.com> | 2023-12-31 01:47:31 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-01-02 14:41:28 +0100 |
commit | 5f64f983d0cead266a28791be42162c443fd2a75 (patch) | |
tree | da5fbb48d6c01d6faedd16b46ff846c65fdb4c33 /src/openvic-simulation/scripts/ConditionalWeight.hpp | |
parent | 9988b21278dc1c8df044631bd2935a7e450a7bff (diff) |
Added framework for loading all Conditions and Effects
Diffstat (limited to 'src/openvic-simulation/scripts/ConditionalWeight.hpp')
-rw-r--r-- | src/openvic-simulation/scripts/ConditionalWeight.hpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/openvic-simulation/scripts/ConditionalWeight.hpp b/src/openvic-simulation/scripts/ConditionalWeight.hpp new file mode 100644 index 0000000..a965ae1 --- /dev/null +++ b/src/openvic-simulation/scripts/ConditionalWeight.hpp @@ -0,0 +1,44 @@ +#pragma once + +#include <variant> +#include <vector> + +#include "openvic-simulation/dataloader/NodeTools.hpp" +#include "openvic-simulation/scripts/ConditionScript.hpp" +#include "openvic-simulation/types/fixed_point/FixedPoint.hpp" + +namespace OpenVic { + struct ConditionalWeight { + using condition_weight_t = std::pair<fixed_point_t, ConditionScript>; + using condition_weight_group_t = std::vector<condition_weight_t>; + using condition_weight_item_t = std::variant<condition_weight_t, condition_weight_group_t>; + + enum class base_key_t : uint8_t { + BASE, FACTOR, MONTHS + }; + using enum base_key_t; + + private: + fixed_point_t PROPERTY(base); + std::vector<condition_weight_item_t> PROPERTY(condition_weight_items); + + struct parse_scripts_visitor_t; + + public: + ConditionalWeight() = default; + ConditionalWeight(ConditionalWeight&&) = default; + + static constexpr std::string_view base_key_to_string(base_key_t base_key) { + switch (base_key) { + case base_key_t::BASE: return "base"; + case base_key_t::FACTOR: return "factor"; + case base_key_t::MONTHS: return "months"; // TODO - add functionality for days or months or years + default: return "INVALID BASE KEY"; + } + } + + NodeTools::node_callback_t expect_conditional_weight(base_key_t base_key); + + bool parse_scripts(GameManager const& game_manager); + }; +} |