aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/openvic-simulation/politics/Ideology.cpp4
-rw-r--r--src/openvic-simulation/politics/Ideology.hpp1
-rw-r--r--src/openvic-simulation/politics/Issue.cpp71
-rw-r--r--src/openvic-simulation/politics/Issue.hpp92
-rw-r--r--src/openvic-simulation/politics/PartyIssue.cpp33
-rw-r--r--src/openvic-simulation/politics/PartyIssue.hpp48
-rw-r--r--src/openvic-simulation/politics/PoliticalReform.cpp42
-rw-r--r--src/openvic-simulation/politics/PoliticalReform.hpp53
8 files changed, 168 insertions, 176 deletions
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 <cstddef>
+#include <string_view>
+#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<IssueType> issue_types;
+ IdentifierRegistry<IssueGroup> issue_groups;
+ IdentifierRegistry<Issue> 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<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
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 <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