From 9a5468ceb4361059fcefae1a383a7c29b4f4e7be Mon Sep 17 00:00:00 2001 From: hop311 Date: Sun, 27 Oct 2024 11:56:46 +0000 Subject: Rename `scope_t` enum to `scope_type_t` --- src/openvic-simulation/misc/Decision.cpp | 11 ++++++++--- src/openvic-simulation/misc/Event.cpp | 14 ++++++++------ src/openvic-simulation/misc/SongChance.cpp | 4 +++- 3 files changed, 19 insertions(+), 10 deletions(-) (limited to 'src/openvic-simulation/misc') diff --git a/src/openvic-simulation/misc/Decision.cpp b/src/openvic-simulation/misc/Decision.cpp index 41d4f81..7812fc1 100644 --- a/src/openvic-simulation/misc/Decision.cpp +++ b/src/openvic-simulation/misc/Decision.cpp @@ -55,12 +55,15 @@ bool DecisionManager::load_decision_file(ast::NodeCPtr root) { "political_decisions", ZERO_OR_ONE, expect_dictionary_reserve_length( decisions, [this](std::string_view identifier, ast::NodeCPtr node) -> bool { + using enum scope_type_t; + bool alert = true, news = false; std::string_view news_title, news_desc_long, news_desc_medium, news_desc_short, picture; - ConditionScript potential { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE }; - ConditionScript allow { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE }; - ConditionalWeight ai_will_do { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE }; + ConditionScript potential { COUNTRY, COUNTRY, NO_SCOPE }; + ConditionScript allow { COUNTRY, COUNTRY, NO_SCOPE }; + ConditionalWeight ai_will_do { COUNTRY, COUNTRY, NO_SCOPE }; EffectScript effect; + bool ret = expect_dictionary_keys( "alert", ZERO_OR_ONE, expect_bool(assign_variable_callback(alert)), "news", ZERO_OR_ONE, expect_bool(assign_variable_callback(news)), @@ -74,10 +77,12 @@ bool DecisionManager::load_decision_file(ast::NodeCPtr root) { "effect", ONE_EXACTLY, effect.expect_script(), "ai_will_do", ZERO_OR_ONE, ai_will_do.expect_conditional_weight(ConditionalWeight::FACTOR) )(node); + ret &= add_decision( identifier, alert, news, news_title, news_desc_long, news_desc_medium, news_desc_short, picture, std::move(potential), std::move(allow), std::move(ai_will_do), std::move(effect) ); + return ret; } ) diff --git a/src/openvic-simulation/misc/Event.cpp b/src/openvic-simulation/misc/Event.cpp index 5bfc929..3c85afb 100644 --- a/src/openvic-simulation/misc/Event.cpp +++ b/src/openvic-simulation/misc/Event.cpp @@ -119,15 +119,17 @@ bool EventManager::load_event_file(IssueManager const& issue_manager, ast::NodeC return expect_dictionary_reserve_length( events, [this, &issue_manager](std::string_view key, ast::NodeCPtr value) -> bool { + using enum scope_type_t; + Event::event_type_t type; - scope_t initial_scope; + scope_type_t initial_scope; if (key == "country_event") { type = Event::event_type_t::COUNTRY; - initial_scope = scope_t::COUNTRY; + initial_scope = COUNTRY; } else if (key == "province_event") { type = Event::event_type_t::PROVINCE; - initial_scope = scope_t::PROVINCE; + initial_scope = PROVINCE; } else { Logger::error("Invalid event type: ", key); return false; @@ -138,8 +140,8 @@ bool EventManager::load_event_file(IssueManager const& issue_manager, ast::NodeC bool triggered_only = false, major = false, fire_only_once = false, allows_multiple_instances = false, news = false, election = false; IssueGroup const* election_issue_group = nullptr; - ConditionScript trigger { initial_scope, initial_scope, scope_t::NO_SCOPE }; - ConditionalWeight mean_time_to_happen { initial_scope, initial_scope, scope_t::NO_SCOPE }; + ConditionScript trigger { initial_scope, initial_scope, NO_SCOPE }; + ConditionalWeight mean_time_to_happen { initial_scope, initial_scope, NO_SCOPE }; EffectScript immediate; std::vector options; @@ -166,7 +168,7 @@ bool EventManager::load_event_file(IssueManager const& issue_manager, ast::NodeC ConditionalWeight ai_chance { initial_scope, initial_scope, - scope_t::COUNTRY | scope_t::PROVINCE + COUNTRY | PROVINCE // TODO - decide which to use? }; bool ret = expect_dictionary_keys_and_default( diff --git a/src/openvic-simulation/misc/SongChance.cpp b/src/openvic-simulation/misc/SongChance.cpp index 94fb571..d05afdf 100644 --- a/src/openvic-simulation/misc/SongChance.cpp +++ b/src/openvic-simulation/misc/SongChance.cpp @@ -17,12 +17,14 @@ bool SongChanceManager::load_songs_file(ast::NodeCPtr root) { ret &= expect_dictionary_reserve_length( song_chances, [this](std::string_view key, ast::NodeCPtr value) -> bool { + using enum scope_type_t; + if (key != "song") { Logger::error("Invalid song declaration ", key); return false; } std::string_view name {}; - ConditionalWeight chance { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE }; + ConditionalWeight chance { COUNTRY, COUNTRY, NO_SCOPE }; bool ret = expect_dictionary_keys( "name", ONE_EXACTLY, expect_string(assign_variable_callback(name)), -- cgit v1.2.3-56-ga3b1