aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/politics/Issue.hpp
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-09-23 15:01:36 +0200
committer zaaarf <zaaarf@proton.me>2023-09-23 15:01:36 +0200
commit08eb9c4b73f94296479ec498a7c0bf6bf18f6144 (patch)
tree237f965390e282d936ceb405a0d20b403315c469 /src/openvic-simulation/politics/Issue.hpp
parent13aff4b4eacecf565a2c9ff948f02cda1eac1903 (diff)
feat: separated once more Issue and Reform
Diffstat (limited to 'src/openvic-simulation/politics/Issue.hpp')
-rw-r--r--src/openvic-simulation/politics/Issue.hpp112
1 files changed, 74 insertions, 38 deletions
diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp
index f002f45..4b096ee 100644
--- a/src/openvic-simulation/politics/Issue.hpp
+++ b/src/openvic-simulation/politics/Issue.hpp
@@ -2,89 +2,125 @@
#include <cstddef>
#include <string_view>
-#include "types/IdentifierRegistry.hpp"
-#include "dataloader/NodeTools.hpp"
+#include "openvic-simulation/types/IdentifierRegistry.hpp"
+#include "openvic-simulation/dataloader/NodeTools.hpp"
+#include "openvic-dataloader/v2script/AbstractSyntaxTree.hpp"
namespace OpenVic {
struct IssueManager;
- //Issue type (i.e. political_issues)
- struct IssueType : HasIdentifier {
+ //Issue group (i.e. trade_policy)
+ struct IssueGroup : HasIdentifier {
+ friend struct IssueManager;
+
+ protected:
+ IssueGroup(const std::string_view identifier);
+
+ public:
+ IssueGroup(IssueGroup&&) = default;
+ };
+
+ //Issue (i.e. protectionism)
+ struct Issue : HasIdentifier {
+ friend struct IssueManager;
+
+ private:
+ IssueGroup const& group;
+
+ //TODO: policy modifiers, policy rule changes
+
+ protected:
+ Issue(const std::string_view identifier, IssueGroup const& group);
+
+ public:
+ Issue(Issue&&) = default;
+ IssueGroup const& get_group() const;
+ };
+
+ //Reform type (i.e. political_issues)
+ struct ReformType : HasIdentifier {
friend struct IssueManager;
private:
- IssueType(const std::string_view new_identifier);
+ bool uncivilised; //whether this group is available to non-westernised countries
+ //in vanilla education, military and economic reforms are hardcoded to true and the rest to false
+
+ ReformType(const std::string_view new_identifier, bool uncivilised);
public:
- IssueType(IssueType&&) = default;
+ ReformType(ReformType&&) = default;
};
- //Issue group (i.e. slavery)
- struct IssueGroup : HasIdentifier {
+ //Reform group (i.e. slavery)
+ struct ReformGroup : IssueGroup {
friend struct IssueManager;
private:
- IssueType const& type;
- const bool ordered, administrative;
+ ReformType const& type;
+ const bool ordered; //next_step_only
+ const bool administrative;
- IssueGroup(const std::string_view new_identifier, IssueType const& new_type, bool new_ordered, bool new_administrative);
+ ReformGroup(const std::string_view identifier, ReformType const& type, bool ordered, bool administrative);
public:
- IssueGroup(IssueGroup&&) = default;
- IssueType const& get_type() const;
+ ReformGroup(ReformGroup&&) = default;
+ ReformType const& get_type() const;
bool is_ordered() const;
bool is_administrative() const;
};
- //Issue type (i.e. yes_slavery)
- struct Issue : HasIdentifier {
+ //Reform (i.e. yes_slavery)
+ struct Reform : Issue {
friend struct IssueManager;
private:
- IssueGroup const& group;
+ ReformGroup const& reform_group; //stores an already casted reference
const size_t ordinal; //assigned by the parser to allow policy sorting
- //TODO: conditions to allow, policy modifiers, policy rule changes
+ Reform(const std::string_view new_identifier, ReformGroup const& group, size_t ordinal);
- Issue(const std::string_view new_identifier, IssueGroup const& new_group, size_t ordinal);
+ //TODO: conditions to allow,
public:
- Issue(Issue&&) = default;
- IssueType const& get_type() const;
- IssueGroup const& get_group() const;
+ Reform(Reform&&) = default;
+ ReformGroup const& get_reform_group() const;
+ ReformType const& get_type() 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;
+ IdentifierRegistry<ReformType> reform_types;
+ IdentifierRegistry<ReformGroup> reform_groups;
+ IdentifierRegistry<Reform> reforms;
- bool _load_issue_group(size_t& expected_issues, const std::string_view identifier, IssueType const* type, ast::NodeCPtr node);
- bool _load_issue(size_t& ordinal, const std::string_view identifier, IssueGroup const* group, ast::NodeCPtr node);
+ bool _load_issue_group(size_t& expected_issues, const std::string_view identifier, ast::NodeCPtr node);
+ bool _load_issue(const std::string_view identifier, IssueGroup const* group, ast::NodeCPtr node);
+ bool _load_reform_group(size_t& expected_reforms, const std::string_view identifier, ReformType const* type,
+ ast::NodeCPtr node);
+ bool _load_reform(size_t& ordinal, const std::string_view identifier, ReformGroup const* group, ast::NodeCPtr node);
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, bool administrative);
+ bool add_issue_group(const std::string_view identifier);
IDENTIFIER_REGISTRY_ACCESSORS(IssueGroup, issue_group)
- bool add_issue(const std::string_view identifier, IssueGroup const* group, size_t ordinal);
+ bool add_issue(const std::string_view identifier, IssueGroup const* group);
IDENTIFIER_REGISTRY_ACCESSORS(Issue, issue)
+ bool add_reform_type(const std::string_view identifier, bool uncivilised);
+ IDENTIFIER_REGISTRY_ACCESSORS(ReformType, reform_type)
+
+ bool add_reform_group(const std::string_view identifier, ReformType const* type, bool ordered, bool administrative);
+ IDENTIFIER_REGISTRY_ACCESSORS(ReformGroup, reform_group)
+
+ bool add_reform(const std::string_view identifier, ReformGroup const* group, size_t ordinal);
+ IDENTIFIER_REGISTRY_ACCESSORS(Reform, reform)
+
bool load_issues_file(ast::NodeCPtr root);
};
-}
-
-/* A NOTE ON PARTY ISSUES
- * It's 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 are always unordered. Even if a mod was to specify
- * those clauses, OV2's behaviour should be to simply disregard them, as they are meaningless to the context of
- * party issues.
- * Conversely, every attempt to read the list of reform types should skip over "party_issues".
-*/ \ No newline at end of file
+} \ No newline at end of file