From f981159689aaff401a1bb9461fcb37b598730ab5 Mon Sep 17 00:00:00 2001 From: BrickPi <49528459+BrickPi@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:33:23 -0500 Subject: Generic Event Loading --- src/openvic-simulation/misc/Event.hpp | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/openvic-simulation/misc/Event.hpp (limited to 'src/openvic-simulation/misc/Event.hpp') diff --git a/src/openvic-simulation/misc/Event.hpp b/src/openvic-simulation/misc/Event.hpp new file mode 100644 index 0000000..6d0829e --- /dev/null +++ b/src/openvic-simulation/misc/Event.hpp @@ -0,0 +1,84 @@ +#pragma once + +#include "openvic-simulation/types/IdentifierRegistry.hpp" + +namespace OpenVic { + struct EventManager; + struct IssueGroup; + struct IssueManager; + + struct Event : HasIdentifier { + friend struct EventManager; + + enum struct event_type_t : uint8_t { COUNTRY, PROVINCE }; + + struct EventOption { + friend struct EventManager; + + private: + std::string PROPERTY(title); + // TODO: option effects + + EventOption(std::string_view new_title); + + public: + EventOption(EventOption const&) = delete; + EventOption(EventOption&&) = default; + EventOption& operator=(EventOption const&) = delete; + EventOption& operator=(EventOption&&) = delete; + }; + + private: + std::string PROPERTY(title); + std::string PROPERTY(description); + std::string PROPERTY(image); + event_type_t PROPERTY(type); + bool PROPERTY_CUSTOM_PREFIX(triggered_only, is); + bool PROPERTY_CUSTOM_PREFIX(major, is); + bool PROPERTY(fire_only_once); + bool PROPERTY(allows_multiple_instances); + + bool PROPERTY_CUSTOM_PREFIX(news, is); + std::string PROPERTY(news_title); + std::string PROPERTY(news_desc_long); + std::string PROPERTY(news_desc_medium); + std::string PROPERTY(news_desc_short); + + bool PROPERTY_CUSTOM_PREFIX(election, is); + IssueGroup const* PROPERTY(election_issue_group); + + std::vector PROPERTY(options); + + // TODO: triggers, MTTH, immediate effects + + 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&& new_options + ); + + public: + Event(Event&&) = default; + }; + + struct EventManager { + private: + IdentifierRegistry events; + + public: + EventManager(); + + bool register_event( + 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&& options + ); + IDENTIFIER_REGISTRY_ACCESSORS(event); + + bool load_event_file(IssueManager const& issue_manager, ast::NodeCPtr root); + }; +} // namespace OpenVic -- cgit v1.2.3-56-ga3b1