From 33787f89686cd03a6ae7305bc51add5ac47fbde2 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 19 Sep 2023 21:58:29 +0200 Subject: feat: added PartyIssue and PoliticalReform structs --- .../politics/PoliticalReform.cpp | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/openvic-simulation/politics/PoliticalReform.cpp (limited to 'src/openvic-simulation/politics/PoliticalReform.cpp') diff --git a/src/openvic-simulation/politics/PoliticalReform.cpp b/src/openvic-simulation/politics/PoliticalReform.cpp new file mode 100644 index 0000000..089e1b6 --- /dev/null +++ b/src/openvic-simulation/politics/PoliticalReform.cpp @@ -0,0 +1,42 @@ +#include "PoliticalReform.hpp" + +using namespace OpenVic; + +PoliticalReformGroup::PoliticalReformGroup(const std::string_view new_identifier, bool ordered) + : HasIdentifier { new_identifier }, ordered { ordered } {} + +bool PoliticalReformGroup::is_ordered() const { + return ordered; +} + +PoliticalReform::PoliticalReform(const std::string_view new_identifier, PoliticalReformGroup const& new_group, size_t ordinal) + : HasIdentifier { new_identifier }, group { new_group }, ordinal { ordinal } {} + +size_t PoliticalReform::get_ordinal() const { + return ordinal; +} + +PoliticalReformManager::PoliticalReformManager() : political_reform_groups { "political reform groups" }, political_reforms { "political reforms" } {} + +bool PoliticalReformManager::add_political_reform_group(const std::string_view identifier, bool ordered) { + if (identifier.empty()) { + Logger::error("Invalid political reform group identifier - empty!"); + return false; + } + + return political_reform_groups.add_item({ identifier, ordered }); +} + +bool PoliticalReformManager::add_political_reform(const std::string_view identifier, PoliticalReformGroup const* group, size_t ordinal) { + if (identifier.empty()) { + Logger::error("Invalid political reform identifier - empty!"); + return false; + } + + if (group == nullptr) { + Logger::error("Null political reform group for ", identifier); + return false; + } + + return political_reforms.add_item({ identifier, *group, ordinal }); +} \ No newline at end of file -- cgit v1.2.3-56-ga3b1