aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/politics
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/politics')
-rw-r--r--src/openvic-simulation/politics/Issue.cpp24
-rw-r--r--src/openvic-simulation/politics/Issue.hpp2
-rw-r--r--src/openvic-simulation/politics/NationalFocus.cpp11
-rw-r--r--src/openvic-simulation/politics/NationalValue.cpp2
4 files changed, 32 insertions, 7 deletions
diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp
index 4a08dea..3174e23 100644
--- a/src/openvic-simulation/politics/Issue.cpp
+++ b/src/openvic-simulation/politics/Issue.cpp
@@ -7,8 +7,8 @@ IssueGroup::IssueGroup(std::string_view new_identifier) : HasIdentifier { new_id
Issue::Issue(
std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, IssueGroup const& new_group,
- RuleSet&& new_rules, bool new_jingoism
-) : Modifier { new_identifier, std::move(new_values) }, HasColour { new_colour, false }, group { new_group },
+ RuleSet&& new_rules, bool new_jingoism, modifier_type_t new_type
+) : Modifier { new_identifier, std::move(new_values), new_type }, HasColour { new_colour, false }, group { new_group },
rules { std::move(new_rules) }, jingoism { new_jingoism } {}
ReformType::ReformType(std::string_view new_identifier, bool new_uncivilised)
@@ -21,16 +21,19 @@ Reform::Reform(
std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, ReformGroup const& new_group,
size_t new_ordinal, fixed_point_t new_administrative_multiplier, RuleSet&& new_rules, tech_cost_t new_technology_cost,
ConditionScript&& new_allow, ConditionScript&& new_on_execute_trigger, EffectScript&& new_on_execute_effect
-) : Issue { new_identifier, new_colour, std::move(new_values), new_group, std::move(new_rules), false },
- reform_group { new_group }, ordinal { new_ordinal }, administrative_multiplier { new_administrative_multiplier },
+) : Issue {
+ new_identifier, new_colour, std::move(new_values), new_group, std::move(new_rules), false, modifier_type_t::REFORM
+ }, reform_group { new_group }, ordinal { new_ordinal }, administrative_multiplier { new_administrative_multiplier },
technology_cost { new_technology_cost }, allow { std::move(new_allow) },
on_execute_trigger { std::move(new_on_execute_trigger) }, on_execute_effect { std::move(new_on_execute_effect) } {}
bool Reform::parse_scripts(DefinitionManager const& definition_manager) {
bool ret = true;
+
ret &= allow.parse_script(true, definition_manager);
ret &= on_execute_trigger.parse_script(true, definition_manager);
ret &= on_execute_effect.parse_script(true, definition_manager);
+
return ret;
}
@@ -176,14 +179,17 @@ bool IssueManager::_load_issue(
ModifierValue values;
RuleSet rules;
bool jingoism = false;
+
bool ret = modifier_manager.expect_modifier_value_and_keys(move_variable_callback(values),
"is_jingoism", ZERO_OR_ONE, expect_bool(assign_variable_callback(jingoism)),
"rules", ZERO_OR_ONE, rule_manager.expect_rule_set(move_variable_callback(rules))
)(node);
+
ret &= add_issue(
identifier, create_issue_reform_colour(get_issue_count() + get_reform_count()), std::move(values), group,
std::move(rules), jingoism
);
+
return ret;
}
@@ -191,12 +197,15 @@ bool IssueManager::_load_reform_group(
size_t& expected_reforms, std::string_view identifier, ReformType const* type, ast::NodeCPtr node
) {
bool ordered = false, administrative = false;
+
bool ret = expect_dictionary_keys_and_default(
increment_callback(expected_reforms),
"next_step_only", ZERO_OR_ONE, expect_bool(assign_variable_callback(ordered)),
"administrative", ZERO_OR_ONE, expect_bool(assign_variable_callback(administrative))
)(node);
+
ret &= add_reform_group(identifier, type, ordered, administrative);
+
return ret;
}
@@ -223,11 +232,13 @@ bool IssueManager::_load_reform(
"effect", ONE_EXACTLY, on_execute_effect.expect_script()
)
)(node);
+
ret &= add_reform(
identifier, create_issue_reform_colour(get_issue_count() + get_reform_count()), std::move(values), group, ordinal,
administrative_multiplier, std::move(rules), technology_cost, std::move(allow), std::move(on_execute_trigger),
std::move(on_execute_effect)
);
+
return ret;
}
@@ -272,6 +283,7 @@ bool IssueManager::load_issues_file(
}
}
)(root);
+
lock_reform_types();
reserve_more_issue_groups(expected_issue_groups);
@@ -306,6 +318,7 @@ bool IssueManager::load_issues_file(
}
}
)(root);
+
lock_issue_groups();
lock_reform_groups();
@@ -356,6 +369,7 @@ bool IssueManager::load_issues_file(
}
}
)(root);
+
lock_issues();
lock_reforms();
@@ -364,8 +378,10 @@ bool IssueManager::load_issues_file(
bool IssueManager::parse_scripts(DefinitionManager const& definition_manager) {
bool ret = true;
+
for (Reform& reform : reforms.get_items()) {
ret &= reform.parse_scripts(definition_manager);
}
+
return ret;
}
diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp
index 9f2d842..c0ab86c 100644
--- a/src/openvic-simulation/politics/Issue.hpp
+++ b/src/openvic-simulation/politics/Issue.hpp
@@ -32,7 +32,7 @@ namespace OpenVic {
protected:
Issue(
std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, IssueGroup const& new_group,
- RuleSet&& new_rules, bool new_jingoism
+ RuleSet&& new_rules, bool new_jingoism, modifier_type_t new_type = modifier_type_t::ISSUE
);
public:
diff --git a/src/openvic-simulation/politics/NationalFocus.cpp b/src/openvic-simulation/politics/NationalFocus.cpp
index bf5d728..4887ed6 100644
--- a/src/openvic-simulation/politics/NationalFocus.cpp
+++ b/src/openvic-simulation/politics/NationalFocus.cpp
@@ -24,7 +24,7 @@ NationalFocus::NationalFocus(
fixed_point_map_t<GoodDefinition const*>&& new_encourage_goods,
fixed_point_map_t<PopType const*>&& new_encourage_pop_types,
ConditionScript&& new_limit
-) : Modifier { new_identifier, std::move(new_modifiers) },
+) : Modifier { new_identifier, std::move(new_modifiers), modifier_type_t::NATIONAL_FOCUS },
group { new_group },
icon { new_icon },
has_flashpoint { new_has_flashpoint },
@@ -47,6 +47,7 @@ inline bool NationalFocusManager::add_national_focus_group(std::string_view iden
Logger::error("No identifier for national focus group!");
return false;
}
+
return national_focus_groups.add_item({ identifier });
}
@@ -70,16 +71,19 @@ inline bool NationalFocusManager::add_national_focus(
Logger::error("No identifier for national focus!");
return false;
}
+
if (icon < 1) {
Logger::error("Invalid icon ", icon, " for national focus ", identifier);
return false;
}
+
if ((loyalty_ideology == nullptr) != (loyalty_value == 0)) {
Logger::warning(
"Party loyalty incorrectly defined for national focus ", identifier, ": ideology = ", loyalty_ideology,
", value = ", loyalty_value
);
}
+
return national_foci.add_item({
identifier, group, icon, has_flashpoint, flashpoint_tension, own_provinces, outliner_show_as_percent,
std::move(modifiers), loyalty_ideology, loyalty_value, encourage_railroads, std::move(encourage_goods),
@@ -92,12 +96,14 @@ bool NationalFocusManager::load_national_foci_file(
GoodDefinitionManager const& good_definition_manager, ModifierManager const& modifier_manager, ast::NodeCPtr root
) {
size_t expected_national_foci = 0;
+
bool ret = expect_dictionary_reserve_length(
national_focus_groups,
[this, &expected_national_foci](std::string_view identifier, ast::NodeCPtr node) -> bool {
return expect_length(add_variable_callback(expected_national_foci))(node) & add_national_focus_group(identifier);
}
)(root);
+
lock_national_focus_groups();
reserve_more_national_foci(expected_national_foci);
@@ -164,6 +170,7 @@ bool NationalFocusManager::load_national_foci_file(
)(group_node);
}
)(root);
+
lock_national_foci();
return ret;
@@ -171,8 +178,10 @@ bool NationalFocusManager::load_national_foci_file(
bool NationalFocusManager::parse_scripts(DefinitionManager const& definition_manager) {
bool ret = true;
+
for (NationalFocus& national_focus : national_foci.get_items()) {
ret &= national_focus.parse_scripts(definition_manager);
}
+
return ret;
}
diff --git a/src/openvic-simulation/politics/NationalValue.cpp b/src/openvic-simulation/politics/NationalValue.cpp
index b780195..e9f7f2a 100644
--- a/src/openvic-simulation/politics/NationalValue.cpp
+++ b/src/openvic-simulation/politics/NationalValue.cpp
@@ -4,7 +4,7 @@ using namespace OpenVic;
using namespace OpenVic::NodeTools;
NationalValue::NationalValue(std::string_view new_identifier, ModifierValue&& new_modifiers)
- : Modifier { new_identifier, std::move(new_modifiers) } {}
+ : Modifier { new_identifier, std::move(new_modifiers), modifier_type_t::NATIONAL_VALUE } {}
bool NationalValueManager::add_national_value(std::string_view identifier, ModifierValue&& modifiers) {
if (identifier.empty()) {