diff options
author | Hop311 <Hop3114@gmail.com> | 2024-01-02 15:40:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-02 15:40:00 +0100 |
commit | 4c8da86c3bede8834f381fa63edaa3e140131f69 (patch) | |
tree | ff3433a63e91b9239eb7226e75054314182d6c1f /src/openvic-simulation/misc/Event.hpp | |
parent | 66b80459c9d49895de902432bce11176b1270878 (diff) | |
parent | 5f64f983d0cead266a28791be42162c443fd2a75 (diff) |
Merge pull request #112 from OpenVicProject/script-framework
Added framework for loading all Conditions and Effects
Diffstat (limited to 'src/openvic-simulation/misc/Event.hpp')
-rw-r--r-- | src/openvic-simulation/misc/Event.hpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/openvic-simulation/misc/Event.hpp b/src/openvic-simulation/misc/Event.hpp index c41ef3f..37f9270 100644 --- a/src/openvic-simulation/misc/Event.hpp +++ b/src/openvic-simulation/misc/Event.hpp @@ -1,5 +1,7 @@ #pragma once +#include "openvic-simulation/scripts/ConditionalWeight.hpp" +#include "openvic-simulation/scripts/EffectScript.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" #include "openvic-simulation/types/OrderedContainers.hpp" @@ -15,12 +17,16 @@ namespace OpenVic { struct EventOption { friend struct EventManager; + friend struct Event; private: std::string PROPERTY(title); - // TODO: option effects + EffectScript PROPERTY(effect); + ConditionalWeight PROPERTY(ai_chance); - EventOption(std::string_view new_title); + EventOption(std::string_view new_title, EffectScript&& new_effect, ConditionalWeight&& new_ai_chance); + + bool parse_scripts(GameManager& game_manager); public: EventOption(EventOption const&) = delete; @@ -48,18 +54,23 @@ namespace OpenVic { bool PROPERTY_CUSTOM_PREFIX(election, is); IssueGroup const* PROPERTY(election_issue_group); - std::vector<EventOption> PROPERTY(options); + ConditionScript PROPERTY(trigger); + ConditionalWeight PROPERTY(mean_time_to_happen); + EffectScript PROPERTY(immediate); - // TODO: triggers, MTTH, immediate effects + std::vector<EventOption> PROPERTY(options); Event( std::string_view new_identifier, std::string_view new_title, std::string_view new_description, std::string_view new_image, event_type_t new_type, bool new_triggered_only, bool new_major, bool new_fire_only_once, bool new_allows_multiple_instances, bool new_news, std::string_view new_news_title, std::string_view new_news_desc_long, std::string_view new_news_desc_medium, std::string_view new_news_desc_short, - bool new_election, IssueGroup const* new_election_issue_group, std::vector<EventOption>&& new_options + bool new_election, IssueGroup const* new_election_issue_group, ConditionScript&& new_trigger, + ConditionalWeight&& new_mean_time_to_happen, EffectScript&& new_immediate, std::vector<EventOption>&& new_options ); + bool parse_scripts(GameManager& game_manager); + public: Event(Event&&) = default; }; @@ -88,13 +99,15 @@ namespace OpenVic { std::string_view identifier, std::string_view title, std::string_view description, std::string_view image, Event::event_type_t type, bool triggered_only, bool major, bool fire_only_once, bool allows_multiple_instances, bool news, std::string_view news_title, std::string_view news_desc_long, std::string_view news_desc_medium, - std::string_view news_desc_short, bool election, IssueGroup const* election_issue_group, - std::vector<Event::EventOption>&& options + std::string_view news_desc_short, bool election, IssueGroup const* election_issue_group, ConditionScript&& trigger, + ConditionalWeight&& mean_time_to_happen, EffectScript&& immediate, std::vector<Event::EventOption>&& options ); bool add_on_action(std::string_view identifier, OnAction::weight_map_t&& new_weighted_events); bool load_event_file(IssueManager const& issue_manager, ast::NodeCPtr root); bool load_on_action_file(ast::NodeCPtr root); + + bool parse_scripts(GameManager& game_manager); }; } // namespace OpenVic |