From b1349e8dfa0c840ca82472fb7f342de08ed8804b Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 19 Sep 2023 19:26:22 +0200 Subject: feat: added Ideology and IdeologyGroup data structures --- src/openvic-simulation/politics/Ideology.cpp | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/openvic-simulation/politics/Ideology.cpp (limited to 'src/openvic-simulation/politics/Ideology.cpp') diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp new file mode 100644 index 0000000..5430140 --- /dev/null +++ b/src/openvic-simulation/politics/Ideology.cpp @@ -0,0 +1,48 @@ +#include "Ideology.hpp" +#include "types/IdentifierRegistry.hpp" + +using namespace OpenVic; + +IdeologyGroup::IdeologyGroup(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} + +Ideology::Ideology(const std::string_view new_identifier, colour_t new_colour, IdeologyGroup const& new_group, bool uncivilised, Date spawn_date) + : HasIdentifierAndColour { new_identifier, new_colour, true, false }, group { new_group }, uncivilised { uncivilised }, + spawn_date { spawn_date } {} + +bool Ideology::is_uncivilised() const { + return uncivilised; +} + +Date const& Ideology::get_spawn_date() const { + return spawn_date; +} + +IdeologyManager::IdeologyManager() : ideology_groups { "ideology groups" }, ideologies { "ideologies" } {} + +bool IdeologyManager::add_ideology_group(const std::string_view identifier) { + if (identifier.empty()) { + Logger::error("Invalid ideology group identifier - empty!"); + return false; + } + + return ideology_groups.add_item({ identifier }); +} + +bool IdeologyManager::add_ideology(const std::string_view identifier, colour_t colour, IdeologyGroup const* group, bool uncivilised, Date spawn_date) { + if (identifier.empty()) { + Logger::error("Invalid ideology identifier - empty!"); + return false; + } + + if (colour > MAX_COLOUR_RGB) { + Logger::error("Invalid ideology colour for ", identifier, ": ", colour_to_hex_string(colour)); + return false; + } + + if (group == nullptr) { + Logger::error("Null ideology group for ", identifier); + return false; + } + + return ideologies.add_item({ identifier, colour, identifier, uncivilised, spawn_date }); +} \ No newline at end of file -- cgit v1.2.3-56-ga3b1 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 --- src/openvic-simulation/politics/Ideology.cpp | 2 +- src/openvic-simulation/politics/PartyIssue.cpp | 33 ++++++++++++++ src/openvic-simulation/politics/PartyIssue.hpp | 48 ++++++++++++++++++++ .../politics/PoliticalReform.cpp | 42 +++++++++++++++++ .../politics/PoliticalReform.hpp | 53 ++++++++++++++++++++++ 5 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 src/openvic-simulation/politics/PartyIssue.cpp create mode 100644 src/openvic-simulation/politics/PartyIssue.hpp create mode 100644 src/openvic-simulation/politics/PoliticalReform.cpp create mode 100644 src/openvic-simulation/politics/PoliticalReform.hpp (limited to 'src/openvic-simulation/politics/Ideology.cpp') 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 party_issue_groups; + IdentifierRegistry 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 +#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 political_reform_groups; + IdentifierRegistry 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 -- cgit v1.2.3-56-ga3b1 From 63e5866381234d6627174869b7a27770daef20fd Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 20 Sep 2023 11:57:59 +0200 Subject: feat: ideology loading --- src/openvic-simulation/GameManager.hpp | 8 ++-- src/openvic-simulation/dataloader/Dataloader.cpp | 5 +++ src/openvic-simulation/politics/Ideology.cpp | 50 +++++++++++++++++++++++- src/openvic-simulation/politics/Ideology.hpp | 3 +- 4 files changed, 61 insertions(+), 5 deletions(-) (limited to 'src/openvic-simulation/politics/Ideology.cpp') diff --git a/src/openvic-simulation/GameManager.hpp b/src/openvic-simulation/GameManager.hpp index d221a99..c932523 100644 --- a/src/openvic-simulation/GameManager.hpp +++ b/src/openvic-simulation/GameManager.hpp @@ -1,8 +1,9 @@ #pragma once -#include "openvic-simulation/GameAdvancementHook.hpp" -#include "openvic-simulation/economy/Good.hpp" -#include "openvic-simulation/map/Map.hpp" +#include "GameAdvancementHook.hpp" +#include "economy/Good.hpp" +#include "map/Map.hpp" +#include "politics/Ideology.hpp" namespace OpenVic { struct GameManager { @@ -12,6 +13,7 @@ namespace OpenVic { BuildingManager building_manager; GoodManager good_manager; PopManager pop_manager; + IdeologyManager ideology_manager; GameAdvancementHook clock; private: diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp index a30983b..45efaec 100644 --- a/src/openvic-simulation/dataloader/Dataloader.cpp +++ b/src/openvic-simulation/dataloader/Dataloader.cpp @@ -257,6 +257,7 @@ bool Dataloader::load_defines(GameManager& game_manager) const { static const fs::path graphical_culture_type_file = "common/graphicalculturetype.txt"; static const fs::path culture_file = "common/cultures.txt"; static const fs::path religion_file = "common/religion.txt"; + static const fs::path ideology_file = "common/ideologies.txt"; static const fs::path map_directory = "map"; bool ret = true; @@ -281,6 +282,10 @@ bool Dataloader::load_defines(GameManager& game_manager) const { Logger::error("Failed to load religions!"); ret = false; } + if (!game_manager.ideology_manager.load_ideology_file(_parse_defines(lookup_file(ideology_file)).get_file_node())) { + Logger::error("Failed to load ideologies!"); + ret = false; + } if (!_load_map_dir(game_manager, map_directory)) { Logger::error("Failed to load map!"); ret = false; diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp index be7e645..afd1de9 100644 --- a/src/openvic-simulation/politics/Ideology.cpp +++ b/src/openvic-simulation/politics/Ideology.cpp @@ -1,7 +1,7 @@ #include "Ideology.hpp" -#include "types/IdentifierRegistry.hpp" using namespace OpenVic; +using namespace OpenVic::NodeTools; IdeologyGroup::IdeologyGroup(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} @@ -45,4 +45,52 @@ bool IdeologyManager::add_ideology(const std::string_view identifier, colour_t c } return ideologies.add_item({ identifier, colour, *group, uncivilised, spawn_date }); +} + +/* 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, + [this, &expected_ideologies](std::string_view key, ast::NodeCPtr value) -> bool { + bool ret = expect_list_and_length( + [&expected_ideologies](size_t size) -> size_t { + expected_ideologies += size; + return 0; + }, + success_callback + )(value); + ret &= add_ideology_group(key); + return ret; + } + )(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; + 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)) + )(value); + ret &= add_ideology(key, colour, ideology_group, uncivilised, spawn_date); + return ret; + } + )(ideology_group_value); + } + )(root); + lock_ideologies(); + + return ret; } \ No newline at end of file diff --git a/src/openvic-simulation/politics/Ideology.hpp b/src/openvic-simulation/politics/Ideology.hpp index b3227f7..137757f 100644 --- a/src/openvic-simulation/politics/Ideology.hpp +++ b/src/openvic-simulation/politics/Ideology.hpp @@ -2,6 +2,7 @@ #include "types/Date.hpp" #include "types/IdentifierRegistry.hpp" +#include "openvic-simulation/dataloader/NodeTools.hpp" namespace OpenVic { struct IdeologyManager; @@ -48,6 +49,6 @@ namespace OpenVic { bool add_ideology(const std::string_view identifier, colour_t colour, IdeologyGroup const* group, bool uncivilised, Date spawn_date); IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_PLURAL(Ideology, ideology, ideologies) - //TODO - loaders + bool load_ideology_file(ast::NodeCPtr root); }; } \ No newline at end of file -- cgit v1.2.3-56-ga3b1 From ad17b83930d83c3bbe5d58cf30c54fe88ac5d927 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 20 Sep 2023 14:03:25 +0200 Subject: feat: merged PartyIssue and PoliticalReform into single Issue structure --- src/openvic-simulation/politics/Ideology.cpp | 4 + src/openvic-simulation/politics/Ideology.hpp | 1 + src/openvic-simulation/politics/Issue.cpp | 71 +++++++++++++++++ src/openvic-simulation/politics/Issue.hpp | 92 ++++++++++++++++++++++ src/openvic-simulation/politics/PartyIssue.cpp | 33 -------- src/openvic-simulation/politics/PartyIssue.hpp | 48 ----------- .../politics/PoliticalReform.cpp | 42 ---------- .../politics/PoliticalReform.hpp | 53 ------------- 8 files changed, 168 insertions(+), 176 deletions(-) create mode 100644 src/openvic-simulation/politics/Issue.cpp create mode 100644 src/openvic-simulation/politics/Issue.hpp delete mode 100644 src/openvic-simulation/politics/PartyIssue.cpp delete mode 100644 src/openvic-simulation/politics/PartyIssue.hpp delete mode 100644 src/openvic-simulation/politics/PoliticalReform.cpp delete mode 100644 src/openvic-simulation/politics/PoliticalReform.hpp (limited to 'src/openvic-simulation/politics/Ideology.cpp') diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp index afd1de9..43adfaa 100644 --- a/src/openvic-simulation/politics/Ideology.cpp +++ b/src/openvic-simulation/politics/Ideology.cpp @@ -9,6 +9,10 @@ Ideology::Ideology(const std::string_view new_identifier, colour_t new_colour, I : HasIdentifierAndColour { new_identifier, new_colour, true, false }, group { new_group }, uncivilised { uncivilised }, spawn_date { spawn_date } {} +IdeologyGroup const& Ideology::get_group() const { + return group; +} + bool Ideology::is_uncivilised() const { return uncivilised; } diff --git a/src/openvic-simulation/politics/Ideology.hpp b/src/openvic-simulation/politics/Ideology.hpp index 137757f..31150af 100644 --- a/src/openvic-simulation/politics/Ideology.hpp +++ b/src/openvic-simulation/politics/Ideology.hpp @@ -31,6 +31,7 @@ namespace OpenVic { public: Ideology(Ideology&&) = default; + IdeologyGroup const& get_group() const; bool is_uncivilised() const; Date const& get_spawn_date() const; }; diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp new file mode 100644 index 0000000..da151a2 --- /dev/null +++ b/src/openvic-simulation/politics/Issue.cpp @@ -0,0 +1,71 @@ +#include "Issue.hpp" +#include "types/IdentifierRegistry.hpp" + +using namespace OpenVic; + +IssueType::IssueType(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} + +IssueGroup::IssueGroup(const std::string_view new_identifier, IssueType const& new_type, bool ordered) + : HasIdentifier { new_identifier }, type { new_type }, ordered { ordered } {} + +IssueType const& IssueGroup::get_type() const { + return type; +} + +bool IssueGroup::is_ordered() const { + return ordered; +} + +Issue::Issue(const std::string_view new_identifier, IssueGroup const& new_group, size_t ordinal) + : HasIdentifier { new_identifier }, group { new_group }, ordinal { ordinal } {} + +IssueType const& Issue::get_type() const { + return group.get_type(); +} + +IssueGroup const& Issue::get_group() const { + return group; +} + +size_t Issue::get_ordinal() const { + return ordinal; +} + +IssueManager::IssueManager() : issue_types { "issue types" }, issue_groups { "issue groups" }, issues { "issues" } {} + +bool IssueManager::add_issue_type(const std::string_view identifier) { + if (identifier.empty()) { + Logger::error("Invalid issue type identifier - empty!"); + return false; + } + + return issue_types.add_item({ identifier }); +} + +bool IssueManager::add_issue_group(const std::string_view identifier, IssueType const* type, bool ordered) { + if (identifier.empty()) { + Logger::error("Invalid issue group identifier - empty!"); + return false; + } + + if (type == nullptr) { + Logger::error("Null issue type for ", identifier); + return false; + } + + return issue_groups.add_item({ identifier, *type, ordered }); +} + +bool IssueManager::add_issue(const std::string_view identifier, IssueGroup const* group, size_t ordinal) { + if (identifier.empty()) { + Logger::error("Invalid issue identifier - empty!"); + return false; + } + + if (group == nullptr) { + Logger::error("Null issue group for ", identifier); + return false; + } + + return issues.add_item({ identifier, *group, ordinal }); +} \ No newline at end of file diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp new file mode 100644 index 0000000..2001203 --- /dev/null +++ b/src/openvic-simulation/politics/Issue.hpp @@ -0,0 +1,92 @@ +#pragma once + +#include +#include +#include "types/IdentifierRegistry.hpp" + +namespace OpenVic { + struct IssueManager; + + //Issue type (i.e. political_issues) + struct IssueType : HasIdentifier { + friend struct IssueManager; + + private: + IssueType(const std::string_view new_identifier); + + public: + IssueType(IssueType&&) = default; + }; + + //Issue group (i.e. slavery) + struct IssueGroup : HasIdentifier { + friend struct IssueManager; + + private: + IssueType const& type; + const bool ordered; //next_step_only, TODO default to false + + IssueGroup(const std::string_view new_identifier, IssueType const& new_type, bool ordered); + + public: + IssueGroup(IssueGroup&&) = default; + IssueType const& get_type() const; + bool is_ordered() const; + }; + + //Issue type (i.e. yes_slavery) + struct Issue : HasIdentifier { + friend struct IssueManager; + + private: + IssueGroup const& group; + const size_t ordinal; //assigned by the parser to allow policy sorting + + //TODO - conditions to allow, policy modifiers, policy rule changes + + Issue(const std::string_view new_identifier, IssueGroup const& new_group, size_t ordinal); + + public: + Issue(Issue&&) = default; + IssueType const& get_type() const; + IssueGroup const& get_group() const; + size_t get_ordinal() const; + }; + + //Issue manager - holds the registries + struct IssueManager { + private: + IdentifierRegistry issue_types; + IdentifierRegistry issue_groups; + IdentifierRegistry issues; + + public: + IssueManager(); + + bool add_issue_type(const std::string_view identifier); + IDENTIFIER_REGISTRY_ACCESSORS(IssueType, issue_type) + + bool add_issue_group(const std::string_view identifier, IssueType const* type, bool ordered); + IDENTIFIER_REGISTRY_ACCESSORS(IssueGroup, issue_group) + + bool add_issue(const std::string_view identifier, IssueGroup const* group, size_t ordinal); + IDENTIFIER_REGISTRY_ACCESSORS(Issue, issue) + + //TODO: bool load_issues_file(ast::NodeCPtr root); + }; +} + +/* Structure is as follows: + * issue_type { (i.e. political_issues) + * issue_group{ (i.e. slavery) + * issue { (i.e. yes_slavery) + * ... + * } + * } + * } + * NOTE ON PARTY ISSUES + * Worth noting that party_issues is a special type of issue, of similar structure but used in a different way. + * Party issues can never have an "allow" condition and they are always unordered. Even if a mod decides to add + * them, OV2's behaviour should probably be to disregard them, as they are meaningless within the context. + * Conversely, lists of available reforms should make it a point to ignore the "party_issues" family. +*/ \ No newline at end of file diff --git a/src/openvic-simulation/politics/PartyIssue.cpp b/src/openvic-simulation/politics/PartyIssue.cpp deleted file mode 100644 index 04e0f2f..0000000 --- a/src/openvic-simulation/politics/PartyIssue.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#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 deleted file mode 100644 index 8b0acdc..0000000 --- a/src/openvic-simulation/politics/PartyIssue.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#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 party_issue_groups; - IdentifierRegistry 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 deleted file mode 100644 index 089e1b6..0000000 --- a/src/openvic-simulation/politics/PoliticalReform.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#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 deleted file mode 100644 index 7c778d1..0000000 --- a/src/openvic-simulation/politics/PoliticalReform.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include -#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 political_reform_groups; - IdentifierRegistry 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 -- cgit v1.2.3-56-ga3b1