diff options
author | BrickPi <49528459+BrickPi@users.noreply.github.com> | 2023-10-03 17:17:08 +0200 |
---|---|---|
committer | Joel Machens <ajmach6@gmail.com> | 2023-10-03 23:55:53 +0200 |
commit | 3a691705be925011fac5172c5f2b374262ec2122 (patch) | |
tree | 16a62a1f34b1fca3614985119aee87bce93de5dc /src/openvic-simulation/politics/Government.cpp | |
parent | c7eac74bb550c28be9eb75742f25d974b7742634 (diff) |
Finish Government Type Loading
Diffstat (limited to 'src/openvic-simulation/politics/Government.cpp')
-rw-r--r-- | src/openvic-simulation/politics/Government.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/openvic-simulation/politics/Government.cpp b/src/openvic-simulation/politics/Government.cpp index 50f20e6..2874b42 100644 --- a/src/openvic-simulation/politics/Government.cpp +++ b/src/openvic-simulation/politics/Government.cpp @@ -52,9 +52,9 @@ bool GovernmentTypeManager::add_government_type(std::string_view identifier, std return government_types.add_item({ identifier, ideologies, elections, appoint_ruling_party, election_duration, flag_type }); } -bool GovernmentTypeManager::load_government_types_file(ast::NodeCPtr root) { +bool GovernmentTypeManager::load_government_types_file(IdeologyManager& ideology_manager, ast::NodeCPtr root) { bool ret = expect_dictionary( - [this](std::string_view government_type_identifier, ast::NodeCPtr value) -> bool { + [this, &ideology_manager](std::string_view government_type_identifier, ast::NodeCPtr value) -> bool { std::vector<std::string> ideologies; bool elections = false, appoint_ruling_party = false; uint16_t election_duration = 0; @@ -70,14 +70,15 @@ bool GovernmentTypeManager::load_government_types_file(ast::NodeCPtr root) { )(value); ret &= expect_dictionary( - [this, ideologies](std::string_view key, ast::NodeCPtr value) -> bool { + [this, &ideology_manager, &ideologies](std::string_view key, ast::NodeCPtr value) -> bool { static const std::set<std::string, std::less<void>> reserved_keys = { "election", "duration", "appoint_ruling_party", "flagType" }; if (reserved_keys.find(key) != reserved_keys.end()) return true; return expect_assign( - [this, ideologies](std::string_view ideology_key, ast::NodeCPtr value) -> bool { - // TODO: grab reference to ideology and shove in vector + [this, &ideology_manager, &ideologies](std::string_view ideology_key, ast::NodeCPtr value) -> bool { + if (ideology_manager.get_ideology_by_identifier(ideology_key) == nullptr) { return false; } + ideologies.push_back(std::string{ideology_key}); return true; } )(value); |