aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/misc/Event.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/misc/Event.hpp')
-rw-r--r--src/openvic-simulation/misc/Event.hpp27
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