aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/politics
diff options
context:
space:
mode:
author zaaarf <me@zaaarf.foo>2023-12-10 23:15:41 +0100
committer zaaarf <me@zaaarf.foo>2023-12-10 23:15:41 +0100
commit4ef33d4df6198e613b0f27406d49978c8ea2fb97 (patch)
tree7f07835485b877f3c01c52c188892499e5812f9b /src/openvic-simulation/politics
parent1eb28bd4fb959b69a30013f6438f0257a2ee7b03 (diff)
feat: improved identifier registry macro
Diffstat (limited to 'src/openvic-simulation/politics')
-rw-r--r--src/openvic-simulation/politics/Government.cpp4
-rw-r--r--src/openvic-simulation/politics/Government.hpp5
-rw-r--r--src/openvic-simulation/politics/Ideology.cpp2
-rw-r--r--src/openvic-simulation/politics/Ideology.hpp8
-rw-r--r--src/openvic-simulation/politics/Issue.cpp4
-rw-r--r--src/openvic-simulation/politics/Issue.hpp17
-rw-r--r--src/openvic-simulation/politics/NationalFocus.cpp2
-rw-r--r--src/openvic-simulation/politics/NationalFocus.hpp8
-rw-r--r--src/openvic-simulation/politics/NationalValue.cpp2
-rw-r--r--src/openvic-simulation/politics/NationalValue.hpp5
-rw-r--r--src/openvic-simulation/politics/Rebel.cpp2
-rw-r--r--src/openvic-simulation/politics/Rebel.hpp5
12 files changed, 12 insertions, 52 deletions
diff --git a/src/openvic-simulation/politics/Government.cpp b/src/openvic-simulation/politics/Government.cpp
index b18432c..a226518 100644
--- a/src/openvic-simulation/politics/Government.cpp
+++ b/src/openvic-simulation/politics/Government.cpp
@@ -1,7 +1,5 @@
#include "Government.hpp"
-#include "openvic-simulation/GameManager.hpp"
-
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -16,8 +14,6 @@ bool GovernmentType::is_ideology_compatible(Ideology const* ideology) const {
return std::find(ideologies.begin(), ideologies.end(), ideology) != ideologies.end();
}
-GovernmentTypeManager::GovernmentTypeManager() : government_types { "government types" } {}
-
bool GovernmentTypeManager::add_government_type(
std::string_view identifier, std::vector<Ideology const*>&& ideologies, bool elections, bool appoint_ruling_party,
Timespan term_duration, std::string_view flag_type
diff --git a/src/openvic-simulation/politics/Government.hpp b/src/openvic-simulation/politics/Government.hpp
index 025e238..4682bbf 100644
--- a/src/openvic-simulation/politics/Government.hpp
+++ b/src/openvic-simulation/politics/Government.hpp
@@ -28,17 +28,14 @@ namespace OpenVic {
struct GovernmentTypeManager {
private:
- IdentifierRegistry<GovernmentType> government_types;
+ IdentifierRegistry<GovernmentType> IDENTIFIER_REGISTRY(government_type);
std::vector<std::string> PROPERTY(flag_types);
public:
- GovernmentTypeManager();
-
bool add_government_type(
std::string_view identifier, std::vector<Ideology const*>&& ideologies, bool elections, bool appoint_ruling_party,
Timespan term_duration, std::string_view flag_type
);
- IDENTIFIER_REGISTRY_ACCESSORS(government_type)
bool load_government_types_file(IdeologyManager const& ideology_manager, ast::NodeCPtr root);
};
diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp
index 569f834..fd5005d 100644
--- a/src/openvic-simulation/politics/Ideology.cpp
+++ b/src/openvic-simulation/politics/Ideology.cpp
@@ -11,8 +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 } {}
-IdeologyManager::IdeologyManager() : ideology_groups { "ideology groups" }, ideologies { "ideologies" } {}
-
bool IdeologyManager::add_ideology_group(std::string_view identifier) {
if (identifier.empty()) {
Logger::error("Invalid ideology group identifier - empty!");
diff --git a/src/openvic-simulation/politics/Ideology.hpp b/src/openvic-simulation/politics/Ideology.hpp
index dd3f07a..8039dbd 100644
--- a/src/openvic-simulation/politics/Ideology.hpp
+++ b/src/openvic-simulation/politics/Ideology.hpp
@@ -37,20 +37,16 @@ namespace OpenVic {
struct IdeologyManager {
private:
- IdentifierRegistry<IdeologyGroup> ideology_groups;
- IdentifierRegistry<Ideology> ideologies;
+ IdentifierRegistry<IdeologyGroup> IDENTIFIER_REGISTRY(ideology_group);
+ IdentifierRegistry<Ideology> IDENTIFIER_REGISTRY_CUSTOM_PLURAL(ideology, ideologies);
public:
- IdeologyManager();
-
bool add_ideology_group(std::string_view identifier);
- IDENTIFIER_REGISTRY_ACCESSORS(ideology_group)
bool add_ideology(
std::string_view identifier, colour_t colour, IdeologyGroup const* group, bool uncivilised,
bool can_reduce_militancy, Date spawn_date
);
- IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_PLURAL(ideology, ideologies)
bool load_ideology_file(ast::NodeCPtr root);
};
diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp
index 9164831..ad37ac6 100644
--- a/src/openvic-simulation/politics/Issue.cpp
+++ b/src/openvic-simulation/politics/Issue.cpp
@@ -16,10 +16,6 @@ ReformGroup::ReformGroup(std::string_view identifier, ReformType const& type, bo
Reform::Reform(std::string_view identifier, ReformGroup const& group, size_t ordinal)
: Issue { identifier, group }, ordinal { ordinal }, reform_group { group } {}
-IssueManager::IssueManager()
- : issue_groups { "issue groups" }, issues { "issues" }, reform_types { "reform types" }, reform_groups { "reform groups" },
- reforms { "reforms" } {}
-
bool IssueManager::add_issue_group(std::string_view identifier) {
if (identifier.empty()) {
Logger::error("Invalid issue group identifier - empty!");
diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp
index e9d154f..0b3d4d3 100644
--- a/src/openvic-simulation/politics/Issue.hpp
+++ b/src/openvic-simulation/politics/Issue.hpp
@@ -84,11 +84,11 @@ namespace OpenVic {
// Issue manager - holds the registries
struct IssueManager {
private:
- IdentifierRegistry<IssueGroup> issue_groups;
- IdentifierRegistry<Issue> issues;
- IdentifierRegistry<ReformType> reform_types;
- IdentifierRegistry<ReformGroup> reform_groups;
- IdentifierRegistry<Reform> reforms;
+ IdentifierRegistry<IssueGroup> IDENTIFIER_REGISTRY(issue_group);
+ IdentifierRegistry<Issue> IDENTIFIER_REGISTRY(issue);
+ IdentifierRegistry<ReformType> IDENTIFIER_REGISTRY(reform_type);
+ IdentifierRegistry<ReformGroup> IDENTIFIER_REGISTRY(reform_group);
+ IdentifierRegistry<Reform> IDENTIFIER_REGISTRY(reform);
bool _load_issue_group(size_t& expected_issues, std::string_view identifier, ast::NodeCPtr node);
bool _load_issue(std::string_view identifier, IssueGroup const* group, ast::NodeCPtr node);
@@ -98,22 +98,15 @@ namespace OpenVic {
bool _load_reform(size_t& ordinal, std::string_view identifier, ReformGroup const* group, ast::NodeCPtr node);
public:
- IssueManager();
-
bool add_issue_group(std::string_view identifier);
- IDENTIFIER_REGISTRY_ACCESSORS(issue_group)
bool add_issue(std::string_view identifier, IssueGroup const* group);
- IDENTIFIER_REGISTRY_ACCESSORS(issue)
bool add_reform_type(std::string_view identifier, bool uncivilised);
- IDENTIFIER_REGISTRY_ACCESSORS(reform_type)
bool add_reform_group(std::string_view identifier, ReformType const* type, bool ordered, bool administrative);
- IDENTIFIER_REGISTRY_ACCESSORS(reform_group)
bool add_reform(std::string_view identifier, ReformGroup const* group, size_t ordinal);
- IDENTIFIER_REGISTRY_ACCESSORS(reform)
bool load_issues_file(ast::NodeCPtr root);
};
diff --git a/src/openvic-simulation/politics/NationalFocus.cpp b/src/openvic-simulation/politics/NationalFocus.cpp
index 6f25c3e..a2003eb 100644
--- a/src/openvic-simulation/politics/NationalFocus.cpp
+++ b/src/openvic-simulation/politics/NationalFocus.cpp
@@ -23,8 +23,6 @@ NationalFocus::NationalFocus(
encouraged_loyalty { std::move(new_encouraged_loyalty) },
encouraged_production { std::move(new_encouraged_production) } {}
-NationalFocusManager::NationalFocusManager() : national_focus_groups { "national focus groups" }, national_foci { "national foci" } {}
-
inline bool NationalFocusManager::add_national_focus_group(std::string_view identifier) {
if (identifier.empty()) {
Logger::error("No identifier for national focus group!");
diff --git a/src/openvic-simulation/politics/NationalFocus.hpp b/src/openvic-simulation/politics/NationalFocus.hpp
index abf6deb..0fe0ddc 100644
--- a/src/openvic-simulation/politics/NationalFocus.hpp
+++ b/src/openvic-simulation/politics/NationalFocus.hpp
@@ -51,14 +51,11 @@ namespace OpenVic {
struct NationalFocusManager {
private:
- IdentifierRegistry<NationalFocusGroup> national_focus_groups;
- IdentifierRegistry<NationalFocus> national_foci;
+ IdentifierRegistry<NationalFocusGroup> IDENTIFIER_REGISTRY(national_focus_group);
+ IdentifierRegistry<NationalFocus> IDENTIFIER_REGISTRY_CUSTOM_PLURAL(national_focus, national_foci);
public:
- NationalFocusManager();
-
inline bool add_national_focus_group(std::string_view identifier);
- IDENTIFIER_REGISTRY_ACCESSORS(national_focus_group)
inline bool add_national_focus(
std::string_view identifier,
@@ -69,7 +66,6 @@ namespace OpenVic {
NationalFocus::party_loyalty_map_t&& encouraged_loyalty,
NationalFocus::production_map_t&& encouraged_production
);
- IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_PLURAL(national_focus, national_foci)
bool load_national_foci_file(PopManager const& pop_manager, IdeologyManager const& ideology_manager, GoodManager const& good_manager, ModifierManager const& modifier_manager, ast::NodeCPtr root);
};
diff --git a/src/openvic-simulation/politics/NationalValue.cpp b/src/openvic-simulation/politics/NationalValue.cpp
index 3760eec..57c5652 100644
--- a/src/openvic-simulation/politics/NationalValue.cpp
+++ b/src/openvic-simulation/politics/NationalValue.cpp
@@ -6,8 +6,6 @@ using namespace OpenVic::NodeTools;
NationalValue::NationalValue(std::string_view new_identifier, ModifierValue&& new_modifiers)
: HasIdentifier { new_identifier }, modifiers { std::move(new_modifiers) } {}
-NationalValueManager::NationalValueManager() : national_values { "national values" } {}
-
bool NationalValueManager::add_national_value(std::string_view identifier, ModifierValue&& modifiers) {
if (identifier.empty()) {
Logger::error("Invalid national value identifier - empty!");
diff --git a/src/openvic-simulation/politics/NationalValue.hpp b/src/openvic-simulation/politics/NationalValue.hpp
index 824da7e..3b92f4d 100644
--- a/src/openvic-simulation/politics/NationalValue.hpp
+++ b/src/openvic-simulation/politics/NationalValue.hpp
@@ -20,13 +20,10 @@ namespace OpenVic {
struct NationalValueManager {
private:
- IdentifierRegistry<NationalValue> national_values;
+ IdentifierRegistry<NationalValue> IDENTIFIER_REGISTRY(national_value);
public:
- NationalValueManager();
-
bool add_national_value(std::string_view identifier, ModifierValue&& modifiers);
- IDENTIFIER_REGISTRY_ACCESSORS(national_value)
bool load_national_values_file(ModifierManager const& modifier_manager, ast::NodeCPtr root);
};
diff --git a/src/openvic-simulation/politics/Rebel.cpp b/src/openvic-simulation/politics/Rebel.cpp
index ec39c9e..a00b4a8 100644
--- a/src/openvic-simulation/politics/Rebel.cpp
+++ b/src/openvic-simulation/politics/Rebel.cpp
@@ -16,8 +16,6 @@ RebelType::RebelType(
allow_all_ideologies { allow_all_ideologies }, resilient { resilient }, reinforcing { reinforcing }, general { general },
smart { smart }, unit_transfer { unit_transfer }, occupation_mult { occupation_mult } {}
-RebelManager::RebelManager() : rebel_types { "rebel types" } {}
-
bool RebelManager::add_rebel_type(
std::string_view new_identifier, RebelType::icon_t icon, RebelType::area_t area, bool break_alliance_on_win,
RebelType::government_map_t&& desired_governments, RebelType::defection_t defection,
diff --git a/src/openvic-simulation/politics/Rebel.hpp b/src/openvic-simulation/politics/Rebel.hpp
index ba7b33f..c0fc9ff 100644
--- a/src/openvic-simulation/politics/Rebel.hpp
+++ b/src/openvic-simulation/politics/Rebel.hpp
@@ -65,12 +65,9 @@ namespace OpenVic {
struct RebelManager {
private:
- IdentifierRegistry<RebelType> rebel_types;
+ IdentifierRegistry<RebelType> IDENTIFIER_REGISTRY(rebel_type);
public:
- RebelManager();
-
- IDENTIFIER_REGISTRY_ACCESSORS(rebel_type)
bool add_rebel_type(
std::string_view new_identifier, RebelType::icon_t icon, RebelType::area_t area, bool break_alliance_on_win,
RebelType::government_map_t&& desired_governments, RebelType::defection_t defection,