aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/politics
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-11-22 23:11:42 +0100
committer GitHub <noreply@github.com>2023-11-22 23:11:42 +0100
commita54898b7770e0d66b729216173960686c67e58bb (patch)
treeaf8ed836a4789ef94c5bfed27abb713922f45af3 /src/openvic-simulation/politics
parente76336cd92639f4ec71088fc4c80aea4c25528cd (diff)
parent738a203e0d8b4df87c42888043b99c13d5d97511 (diff)
Merge pull request #78 from OpenVicProject/property-macro
Refactoring (*mostly* related to the property macro)
Diffstat (limited to 'src/openvic-simulation/politics')
-rw-r--r--src/openvic-simulation/politics/Government.cpp20
-rw-r--r--src/openvic-simulation/politics/Government.hpp14
-rw-r--r--src/openvic-simulation/politics/Ideology.cpp16
-rw-r--r--src/openvic-simulation/politics/Ideology.hpp12
-rw-r--r--src/openvic-simulation/politics/Issue.cpp28
-rw-r--r--src/openvic-simulation/politics/Issue.hpp19
-rw-r--r--src/openvic-simulation/politics/NationalValue.cpp4
-rw-r--r--src/openvic-simulation/politics/NationalValue.hpp4
8 files changed, 16 insertions, 101 deletions
diff --git a/src/openvic-simulation/politics/Government.cpp b/src/openvic-simulation/politics/Government.cpp
index 3b0f28d..0d1d063 100644
--- a/src/openvic-simulation/politics/Government.cpp
+++ b/src/openvic-simulation/politics/Government.cpp
@@ -16,26 +16,6 @@ bool GovernmentType::is_ideology_compatible(Ideology const* ideology) const {
return std::find(ideologies.begin(), ideologies.end(), ideology) != ideologies.end();
}
-std::vector<Ideology const*> const& GovernmentType::get_ideologies() const {
- return ideologies;
-}
-
-bool GovernmentType::holds_elections() const {
- return elections;
-}
-
-bool GovernmentType::can_appoint_ruling_party() const {
- return appoint_ruling_party;
-}
-
-Timespan GovernmentType::get_term_duration() const {
- return term_duration;
-}
-
-std::string_view GovernmentType::get_flag_type() const {
- return flag_type_identifier;
-}
-
GovernmentTypeManager::GovernmentTypeManager() : government_types { "government types" } {}
bool GovernmentTypeManager::add_government_type(
diff --git a/src/openvic-simulation/politics/Government.hpp b/src/openvic-simulation/politics/Government.hpp
index 9fff111..fde7d32 100644
--- a/src/openvic-simulation/politics/Government.hpp
+++ b/src/openvic-simulation/politics/Government.hpp
@@ -9,10 +9,11 @@ namespace OpenVic {
friend struct GovernmentTypeManager;
private:
- const std::vector<Ideology const*> ideologies;
- const bool elections, appoint_ruling_party;
- const Timespan term_duration;
- const std::string flag_type_identifier;
+ const std::vector<Ideology const*> PROPERTY(ideologies);
+ const bool PROPERTY_CUSTOM_NAME(elections, holds_elections);
+ const bool PROPERTY_CUSTOM_NAME(appoint_ruling_party, can_appoint_ruling_party);
+ const Timespan PROPERTY(term_duration);
+ const std::string PROPERTY_CUSTOM_NAME(flag_type_identifier, get_flag_type);
GovernmentType(
std::string_view new_identifier, std::vector<Ideology const*>&& new_ideologies, bool new_elections,
@@ -23,11 +24,6 @@ namespace OpenVic {
GovernmentType(GovernmentType&&) = default;
bool is_ideology_compatible(Ideology const* ideology) const;
- std::vector<Ideology const*> const& get_ideologies() const;
- bool holds_elections() const;
- bool can_appoint_ruling_party() const;
- Timespan get_term_duration() const;
- std::string_view get_flag_type() const;
};
struct GovernmentTypeManager {
diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp
index 148d6ac..569f834 100644
--- a/src/openvic-simulation/politics/Ideology.cpp
+++ b/src/openvic-simulation/politics/Ideology.cpp
@@ -11,22 +11,6 @@ Ideology::Ideology(
) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, group { new_group }, uncivilised { new_uncivilised },
can_reduce_militancy { new_can_reduce_militancy }, spawn_date { new_spawn_date } {}
-IdeologyGroup const& Ideology::get_group() const {
- return group;
-}
-
-bool Ideology::is_uncivilised() const {
- return uncivilised;
-}
-
-bool Ideology::get_can_reduce_militancy() const {
- return can_reduce_militancy;
-}
-
-Date Ideology::get_spawn_date() const {
- return spawn_date;
-}
-
IdeologyManager::IdeologyManager() : ideology_groups { "ideology groups" }, ideologies { "ideologies" } {}
bool IdeologyManager::add_ideology_group(std::string_view identifier) {
diff --git a/src/openvic-simulation/politics/Ideology.hpp b/src/openvic-simulation/politics/Ideology.hpp
index bdf9f91..47ae45b 100644
--- a/src/openvic-simulation/politics/Ideology.hpp
+++ b/src/openvic-simulation/politics/Ideology.hpp
@@ -19,9 +19,10 @@ namespace OpenVic {
friend struct IdeologyManager;
private:
- IdeologyGroup const& group;
- const bool uncivilised, can_reduce_militancy;
- const Date spawn_date;
+ IdeologyGroup const& PROPERTY(group);
+ const bool PROPERTY_CUSTOM_NAME(uncivilised, is_uncivilised);
+ const bool PROPERTY(can_reduce_militancy);
+ const Date PROPERTY(spawn_date);
// TODO - willingness to repeal/pass reforms (and its modifiers)
@@ -32,11 +33,6 @@ namespace OpenVic {
public:
Ideology(Ideology&&) = default;
-
- IdeologyGroup const& get_group() const;
- bool is_uncivilised() const;
- bool get_can_reduce_militancy() const;
- Date get_spawn_date() const;
};
struct IdeologyManager {
diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp
index cc3c12b..9164831 100644
--- a/src/openvic-simulation/politics/Issue.cpp
+++ b/src/openvic-simulation/politics/Issue.cpp
@@ -7,43 +7,15 @@ IssueGroup::IssueGroup(std::string_view new_identifier) : HasIdentifier { new_id
Issue::Issue(std::string_view identifier, IssueGroup const& group) : HasIdentifier { identifier }, group { group } {}
-IssueGroup const& Issue::get_group() const {
- return group;
-}
-
ReformType::ReformType(std::string_view new_identifier, bool uncivilised)
: HasIdentifier { new_identifier }, uncivilised { uncivilised } {}
ReformGroup::ReformGroup(std::string_view identifier, ReformType const& type, bool ordered, bool administrative)
: IssueGroup { identifier }, type { type }, ordered { ordered }, administrative { administrative } {}
-ReformType const& ReformGroup::get_type() const {
- return type;
-}
-
-bool ReformGroup::is_ordered() const {
- return ordered;
-}
-
-bool ReformGroup::is_administrative() const {
- return administrative;
-}
-
Reform::Reform(std::string_view identifier, ReformGroup const& group, size_t ordinal)
: Issue { identifier, group }, ordinal { ordinal }, reform_group { group } {}
-ReformGroup const& Reform::get_reform_group() const {
- return reform_group;
-}
-
-ReformType const& Reform::get_type() const {
- return get_reform_group().get_type();
-}
-
-size_t Reform::get_ordinal() const {
- return ordinal;
-}
-
IssueManager::IssueManager()
: issue_groups { "issue groups" }, issues { "issues" }, reform_types { "reform types" }, reform_groups { "reform groups" },
reforms { "reforms" } {}
diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp
index 84aa886..0dceae9 100644
--- a/src/openvic-simulation/politics/Issue.hpp
+++ b/src/openvic-simulation/politics/Issue.hpp
@@ -25,7 +25,7 @@ namespace OpenVic {
friend struct IssueManager;
private:
- IssueGroup const& group;
+ IssueGroup const& PROPERTY(group);
// TODO: policy modifiers, policy rule changes
@@ -34,7 +34,6 @@ namespace OpenVic {
public:
Issue(Issue&&) = default;
- IssueGroup const& get_group() const;
};
// Reform type (i.e. political_issues)
@@ -56,17 +55,14 @@ namespace OpenVic {
friend struct IssueManager;
private:
- ReformType const& type;
- const bool ordered; // next_step_only
- const bool administrative;
+ ReformType const& PROPERTY(type);
+ const bool PROPERTY_CUSTOM_NAME(ordered, is_ordered); // next_step_only
+ const bool PROPERTY_CUSTOM_NAME(administrative, is_administrative);
ReformGroup(std::string_view identifier, ReformType const& type, bool ordered, bool administrative);
public:
ReformGroup(ReformGroup&&) = default;
- ReformType const& get_type() const;
- bool is_ordered() const;
- bool is_administrative() const;
};
// Reform (i.e. yes_slavery)
@@ -74,8 +70,8 @@ namespace OpenVic {
friend struct IssueManager;
private:
- ReformGroup const& reform_group; // stores an already casted reference
- const size_t ordinal; // assigned by the parser to allow policy sorting
+ ReformGroup const& PROPERTY(reform_group); // stores an already casted reference
+ const size_t PROPERTY(ordinal); // assigned by the parser to allow policy sorting
Reform(std::string_view new_identifier, ReformGroup const& group, size_t ordinal);
@@ -83,9 +79,6 @@ namespace OpenVic {
public:
Reform(Reform&&) = default;
- ReformGroup const& get_reform_group() const;
- ReformType const& get_type() const;
- size_t get_ordinal() const;
};
// Issue manager - holds the registries
diff --git a/src/openvic-simulation/politics/NationalValue.cpp b/src/openvic-simulation/politics/NationalValue.cpp
index f1d8a3b..3760eec 100644
--- a/src/openvic-simulation/politics/NationalValue.cpp
+++ b/src/openvic-simulation/politics/NationalValue.cpp
@@ -6,10 +6,6 @@ using namespace OpenVic::NodeTools;
NationalValue::NationalValue(std::string_view new_identifier, ModifierValue&& new_modifiers)
: HasIdentifier { new_identifier }, modifiers { std::move(new_modifiers) } {}
-ModifierValue const& NationalValue::get_modifiers() const {
- return modifiers;
-}
-
NationalValueManager::NationalValueManager() : national_values { "national values" } {}
bool NationalValueManager::add_national_value(std::string_view identifier, ModifierValue&& modifiers) {
diff --git a/src/openvic-simulation/politics/NationalValue.hpp b/src/openvic-simulation/politics/NationalValue.hpp
index 625be36..824da7e 100644
--- a/src/openvic-simulation/politics/NationalValue.hpp
+++ b/src/openvic-simulation/politics/NationalValue.hpp
@@ -10,14 +10,12 @@ namespace OpenVic {
friend struct NationalValueManager;
private:
- const ModifierValue modifiers;
+ const ModifierValue PROPERTY(modifiers);
NationalValue(std::string_view new_identifier, ModifierValue&& new_modifiers);
public:
NationalValue(NationalValue&&) = default;
-
- ModifierValue const& get_modifiers() const;
};
struct NationalValueManager {