diff options
author | zaaarf <zaaarf@proton.me> | 2023-09-19 21:58:29 +0200 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-09-19 21:58:29 +0200 |
commit | 33787f89686cd03a6ae7305bc51add5ac47fbde2 (patch) | |
tree | e9f370f392839f0315b01722a61e09085c49458e /src/openvic-simulation | |
parent | b1349e8dfa0c840ca82472fb7f342de08ed8804b (diff) |
feat: added PartyIssue and PoliticalReform structs
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r-- | src/openvic-simulation/politics/Ideology.cpp | 2 | ||||
-rw-r--r-- | src/openvic-simulation/politics/PartyIssue.cpp | 33 | ||||
-rw-r--r-- | src/openvic-simulation/politics/PartyIssue.hpp | 48 | ||||
-rw-r--r-- | src/openvic-simulation/politics/PoliticalReform.cpp | 42 | ||||
-rw-r--r-- | src/openvic-simulation/politics/PoliticalReform.hpp | 53 |
5 files changed, 177 insertions, 1 deletions
diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp index 5430140..be7e645 100644 --- a/src/openvic-simulation/politics/Ideology.cpp +++ b/src/openvic-simulation/politics/Ideology.cpp @@ -44,5 +44,5 @@ bool IdeologyManager::add_ideology(const std::string_view identifier, colour_t c return false; } - return ideologies.add_item({ identifier, colour, identifier, uncivilised, spawn_date }); + return ideologies.add_item({ identifier, colour, *group, uncivilised, spawn_date }); }
\ No newline at end of file diff --git a/src/openvic-simulation/politics/PartyIssue.cpp b/src/openvic-simulation/politics/PartyIssue.cpp new file mode 100644 index 0000000..04e0f2f --- /dev/null +++ b/src/openvic-simulation/politics/PartyIssue.cpp @@ -0,0 +1,33 @@ +#include "PartyIssue.hpp" + +using namespace OpenVic; + +PartyIssueGroup::PartyIssueGroup(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} + +PartyIssue::PartyIssue(const std::string_view new_identifier, PartyIssueGroup const& new_group) + : HasIdentifier { new_identifier }, group { new_group } {} + +PartyIssueManager::PartyIssueManager() : party_issue_groups { "party issue groups" }, party_issues { "party issues" } {} + +bool PartyIssueManager::add_party_issue_group(const std::string_view identifier) { + if (identifier.empty()) { + Logger::error("Invalid party issue group identifier - empty!"); + return false; + } + + return party_issue_groups.add_item({ identifier }); +} + +bool PartyIssueManager::add_party_issue(const std::string_view identifier, PartyIssueGroup const* group) { + if (identifier.empty()) { + Logger::error("Invalid party issue identifier - empty!"); + return false; + } + + if (group == nullptr) { + Logger::error("Null party issue group for ", identifier); + return false; + } + + return party_issues.add_item({ identifier, *group }); +}
\ No newline at end of file diff --git a/src/openvic-simulation/politics/PartyIssue.hpp b/src/openvic-simulation/politics/PartyIssue.hpp new file mode 100644 index 0000000..8b0acdc --- /dev/null +++ b/src/openvic-simulation/politics/PartyIssue.hpp @@ -0,0 +1,48 @@ +#pragma once + +#include "types/IdentifierRegistry.hpp" + +namespace OpenVic { + struct PartyIssueManager; + + struct PartyIssueGroup : HasIdentifier { + friend struct PartyIssueManager; + + private: + PartyIssueGroup(const std::string_view new_identifier); + + public: + PartyIssueGroup(PartyIssueGroup&&) = default; + }; + + struct PartyIssue : HasIdentifier { + friend struct PartyIssueManager; + + private: + PartyIssueGroup const& group; + + //TODO - modifiers when party with issue is in power + + PartyIssue(const std::string_view new_identifier, PartyIssueGroup const& new_group); + + public: + PartyIssue(PartyIssue&&) = default; + }; + + struct PartyIssueManager { + private: + IdentifierRegistry<PartyIssueGroup> party_issue_groups; + IdentifierRegistry<PartyIssue> party_issues; + + public: + PartyIssueManager(); + + bool add_party_issue_group(const std::string_view identifier); + IDENTIFIER_REGISTRY_ACCESSORS(PartyIssueGroup, party_issue_group) + + bool add_party_issue(const std::string_view identifier, PartyIssueGroup const* group); + IDENTIFIER_REGISTRY_ACCESSORS(PartyIssue, party_issue) + + //TODO - loaders + }; +}
\ No newline at end of file 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 diff --git a/src/openvic-simulation/politics/PoliticalReform.hpp b/src/openvic-simulation/politics/PoliticalReform.hpp new file mode 100644 index 0000000..7c778d1 --- /dev/null +++ b/src/openvic-simulation/politics/PoliticalReform.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include <cstddef> +#include "types/IdentifierRegistry.hpp" + +namespace OpenVic { + struct PoliticalReformManager; + + struct PoliticalReformGroup : HasIdentifier { + friend struct PoliticalReformManager; + + private: + PoliticalReformGroup(const std::string_view new_identifier, bool ordered); + const bool ordered; //next_step_only, TODO default to false + + public: + PoliticalReformGroup(PoliticalReformGroup&&) = default; + bool is_ordered() const; + }; + + struct PoliticalReform : HasIdentifier { + friend struct PoliticalReformManager; + + private: + PoliticalReformGroup const& group; + const size_t ordinal; //assigned by the parser to allow policy sorting + + //TODO - conditions to allow, policy modifiers, policy rule changes + + PoliticalReform(const std::string_view new_identifier, PoliticalReformGroup const& new_group, size_t ordinal); + + public: + PoliticalReform(PoliticalReform&&) = default; + size_t get_ordinal() const; + }; + + struct PoliticalReformManager { + private: + IdentifierRegistry<PoliticalReformGroup> political_reform_groups; + IdentifierRegistry<PoliticalReform> political_reforms; + + public: + PoliticalReformManager(); + + bool add_political_reform_group(const std::string_view identifier, bool ordered); + IDENTIFIER_REGISTRY_ACCESSORS(PoliticalReformGroup, political_reform_group) + + bool add_political_reform(const std::string_view identifier, PoliticalReformGroup const* group, size_t ordinal); + IDENTIFIER_REGISTRY_ACCESSORS(PoliticalReform, political_reform) + + //TODO - loaders + }; +}
\ No newline at end of file |