diff options
author | Hop311 <Hop3114@gmail.com> | 2023-10-29 21:14:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-29 21:14:55 +0100 |
commit | 06cc0606156d009026930c785c62434276fbe782 (patch) | |
tree | d37fcb69766ec029ea4e3e2816c419f9d7e05f7c /src/openvic-simulation/politics/Ideology.cpp | |
parent | d8ec90f07342876e9331819bd3cc372050f78248 (diff) | |
parent | 1b5e43fa7750cc4025d32f18390593cbce3ba842 (diff) |
Merge pull request #67 from OpenVicProject/format
Formating
Diffstat (limited to 'src/openvic-simulation/politics/Ideology.cpp')
-rw-r--r-- | src/openvic-simulation/politics/Ideology.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp index 5b2c0ef..acbd82f 100644 --- a/src/openvic-simulation/politics/Ideology.cpp +++ b/src/openvic-simulation/politics/Ideology.cpp @@ -5,8 +5,10 @@ using namespace OpenVic::NodeTools; IdeologyGroup::IdeologyGroup(std::string_view new_identifier) : HasIdentifier { new_identifier } {} -Ideology::Ideology(std::string_view new_identifier, colour_t new_colour, IdeologyGroup const& new_group, bool new_uncivilised, bool new_can_reduce_militancy, Date new_spawn_date) - : HasIdentifierAndColour { new_identifier, new_colour, true, false }, group { new_group }, uncivilised { new_uncivilised }, +Ideology::Ideology( + std::string_view new_identifier, colour_t new_colour, IdeologyGroup const& new_group, bool new_uncivilised, + bool new_can_reduce_militancy, Date new_spawn_date +) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, group { new_group }, uncivilised { new_uncivilised }, can_reduce_militancy { new_can_reduce_militancy }, spawn_date { new_spawn_date } {} IdeologyGroup const& Ideology::get_group() const { @@ -36,7 +38,10 @@ bool IdeologyManager::add_ideology_group(std::string_view identifier) { return ideology_groups.add_item({ identifier }); } -bool IdeologyManager::add_ideology(std::string_view identifier, colour_t colour, IdeologyGroup const* group, bool uncivilised, bool can_reduce_militancy, Date spawn_date) { +bool IdeologyManager::add_ideology( + std::string_view identifier, colour_t colour, IdeologyGroup const* group, bool uncivilised, bool can_reduce_militancy, + Date spawn_date +) { if (identifier.empty()) { Logger::error("Invalid ideology identifier - empty!"); return false; @@ -57,11 +62,10 @@ bool IdeologyManager::add_ideology(std::string_view identifier, colour_t colour, /* REQUIREMENTS: * POL-9, POL-10, POL-11, POL-12, POL-13, POL-14, POL-15 -*/ + */ bool IdeologyManager::load_ideology_file(ast::NodeCPtr root) { size_t expected_ideologies = 0; - bool ret = expect_dictionary_reserve_length( - ideology_groups, + bool ret = expect_dictionary_reserve_length(ideology_groups, [this, &expected_ideologies](std::string_view key, ast::NodeCPtr value) -> bool { bool ret = expect_length(add_variable_callback(expected_ideologies))(value); ret &= add_ideology_group(key); @@ -71,35 +75,31 @@ bool IdeologyManager::load_ideology_file(ast::NodeCPtr root) { lock_ideology_groups(); ideologies.reserve(ideologies.size() + expected_ideologies); - ret &= expect_dictionary( - [this](std::string_view ideology_group_key, ast::NodeCPtr ideology_group_value) -> bool { - IdeologyGroup const* ideology_group = get_ideology_group_by_identifier(ideology_group_key); - - return expect_dictionary( - [this, ideology_group](std::string_view key, ast::NodeCPtr value) -> bool { - colour_t colour = NULL_COLOUR; - bool uncivilised = true, can_reduce_militancy = false; - Date spawn_date; - - bool ret = expect_dictionary_keys( - "uncivilized", ZERO_OR_ONE, expect_bool(assign_variable_callback(uncivilised)), - "color", ONE_EXACTLY, expect_colour(assign_variable_callback(colour)), - "date", ZERO_OR_ONE, expect_date(assign_variable_callback(spawn_date)), - "can_reduce_militancy", ZERO_OR_ONE, expect_bool(assign_variable_callback(can_reduce_militancy)), - "add_political_reform", ONE_EXACTLY, success_callback, - "remove_political_reform", ONE_EXACTLY, success_callback, - "add_social_reform", ONE_EXACTLY, success_callback, - "remove_social_reform", ONE_EXACTLY, success_callback, - "add_military_reform", ZERO_OR_ONE, success_callback, - "add_economic_reform", ZERO_OR_ONE, success_callback - )(value); - ret &= add_ideology(key, colour, ideology_group, uncivilised, can_reduce_militancy, spawn_date); - return ret; - } - )(ideology_group_value); - } - )(root); + ret &= expect_dictionary([this](std::string_view ideology_group_key, ast::NodeCPtr ideology_group_value) -> bool { + IdeologyGroup const* ideology_group = get_ideology_group_by_identifier(ideology_group_key); + + return expect_dictionary([this, ideology_group](std::string_view key, ast::NodeCPtr value) -> bool { + colour_t colour = NULL_COLOUR; + bool uncivilised = true, can_reduce_militancy = false; + Date spawn_date; + + bool ret = expect_dictionary_keys( + "uncivilized", ZERO_OR_ONE, expect_bool(assign_variable_callback(uncivilised)), + "color", ONE_EXACTLY, expect_colour(assign_variable_callback(colour)), + "date", ZERO_OR_ONE, expect_date(assign_variable_callback(spawn_date)), + "can_reduce_militancy", ZERO_OR_ONE, expect_bool(assign_variable_callback(can_reduce_militancy)), + "add_political_reform", ONE_EXACTLY, success_callback, + "remove_political_reform", ONE_EXACTLY, success_callback, + "add_social_reform", ONE_EXACTLY, success_callback, + "remove_social_reform", ONE_EXACTLY, success_callback, + "add_military_reform", ZERO_OR_ONE, success_callback, + "add_economic_reform", ZERO_OR_ONE, success_callback + )(value); + ret &= add_ideology(key, colour, ideology_group, uncivilised, can_reduce_militancy, spawn_date); + return ret; + })(ideology_group_value); + })(root); lock_ideologies(); return ret; -}
\ No newline at end of file +} |