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.cpp32
-rw-r--r--src/openvic-simulation/politics/Issue.hpp10
-rw-r--r--src/openvic-simulation/politics/Rule.cpp14
-rw-r--r--src/openvic-simulation/politics/Rule.hpp4
4 files changed, 45 insertions, 15 deletions
diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp
index a03ffa3..1dca176 100644
--- a/src/openvic-simulation/politics/Issue.cpp
+++ b/src/openvic-simulation/politics/Issue.cpp
@@ -19,10 +19,11 @@ ReformGroup::ReformGroup(std::string_view new_identifier, ReformType const& new_
Reform::Reform(
std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, ReformGroup const& new_group,
- size_t new_ordinal, 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 }, ordinal { new_ordinal },
- reform_group { new_group }, technology_cost { new_technology_cost }, allow { std::move(new_allow) },
+ 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 },
+ 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) {
@@ -84,8 +85,8 @@ bool IssueManager::add_reform_group(std::string_view identifier, ReformType cons
bool IssueManager::add_reform(
std::string_view identifier, colour_t new_colour, ModifierValue&& values, ReformGroup const* group, size_t ordinal,
- RuleSet&& rules, Reform::tech_cost_t technology_cost, ConditionScript&& allow, ConditionScript&& on_execute_trigger,
- EffectScript&& on_execute_effect
+ fixed_point_t administrative_multiplier, RuleSet&& rules, Reform::tech_cost_t technology_cost, ConditionScript&& allow,
+ ConditionScript&& on_execute_trigger, EffectScript&& on_execute_effect
) {
if (identifier.empty()) {
Logger::error("Invalid issue identifier - empty!");
@@ -116,9 +117,16 @@ bool IssueManager::add_reform(
Logger::warning("Non-zero technology cost ", technology_cost, " found in civilised reform ", identifier, "!");
}
+ if (administrative_multiplier != 0 && !group->is_administrative()) {
+ Logger::warning(
+ "Non-zero administrative multiplier ", administrative_multiplier, " found in reform ", identifier,
+ " belonging to non-administrative group ", group->get_identifier(), "!"
+ );
+ }
+
return reforms.add_item({
- identifier, new_colour, std::move(values), *group, ordinal, std::move(rules), technology_cost, std::move(allow),
- std::move(on_execute_trigger), std::move(on_execute_effect)
+ identifier, new_colour, 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)
});
}
@@ -198,12 +206,15 @@ bool IssueManager::_load_reform(
) {
ModifierValue values;
RuleSet rules;
+ fixed_point_t administrative_multiplier = 0;
Reform::tech_cost_t technology_cost = 0;
ConditionScript allow { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };
ConditionScript on_execute_trigger { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };
EffectScript on_execute_effect;
- bool ret = modifier_manager.expect_modifier_value_and_keys(move_variable_callback(values),
+ bool ret = modifier_manager.expect_modifier_value_and_keys(
+ move_variable_callback(values),
+ "administrative_multiplier", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(administrative_multiplier)),
"technology_cost", ZERO_OR_ONE, expect_uint(assign_variable_callback(technology_cost)),
"allow", ZERO_OR_ONE, allow.expect_script(),
"rules", ZERO_OR_ONE, rule_manager.expect_rule_set(move_variable_callback(rules)),
@@ -214,7 +225,8 @@ bool IssueManager::_load_reform(
)(node);
ret &= add_reform(
identifier, create_issue_reform_colour(get_issue_count() + get_reform_count()), std::move(values), group, ordinal,
- std::move(rules), technology_cost, std::move(allow), std::move(on_execute_trigger), std::move(on_execute_effect)
+ administrative_multiplier, std::move(rules), technology_cost, std::move(allow), std::move(on_execute_trigger),
+ std::move(on_execute_effect)
);
return ret;
}
diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp
index 70f082d..d49f897 100644
--- a/src/openvic-simulation/politics/Issue.hpp
+++ b/src/openvic-simulation/politics/Issue.hpp
@@ -76,6 +76,7 @@ namespace OpenVic {
private:
ReformGroup const& PROPERTY(reform_group); // stores an already casted reference
const size_t PROPERTY(ordinal); // assigned by the parser to allow policy sorting
+ const fixed_point_t PROPERTY(administrative_multiplier);
const tech_cost_t PROPERTY(technology_cost);
ConditionScript PROPERTY(allow);
ConditionScript PROPERTY(on_execute_trigger);
@@ -83,8 +84,9 @@ namespace OpenVic {
Reform(
std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, ReformGroup const& new_group,
- size_t new_ordinal, RuleSet&& new_rules, tech_cost_t new_technology_cost, ConditionScript&& new_allow,
- ConditionScript&& new_on_execute_trigger, EffectScript&& new_on_execute_effect
+ 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
);
bool parse_scripts(DefinitionManager const& definition_manager);
@@ -125,8 +127,8 @@ namespace OpenVic {
bool add_reform_group(std::string_view identifier, ReformType const* type, bool ordered, bool administrative);
bool add_reform(
std::string_view identifier, colour_t new_colour, ModifierValue&& values, ReformGroup const* group, size_t ordinal,
- RuleSet&& rules, Reform::tech_cost_t technology_cost, ConditionScript&& allow, ConditionScript&& on_execute_trigger,
- EffectScript&& on_execute_effect
+ fixed_point_t administrative_multiplier, RuleSet&& rules, Reform::tech_cost_t technology_cost,
+ ConditionScript&& allow, ConditionScript&& on_execute_trigger, EffectScript&& on_execute_effect
);
bool load_issues_file(ModifierManager const& modifier_manager, RuleManager const& rule_manager, ast::NodeCPtr root);
diff --git a/src/openvic-simulation/politics/Rule.cpp b/src/openvic-simulation/politics/Rule.cpp
index 37aa22a..1d61652 100644
--- a/src/openvic-simulation/politics/Rule.cpp
+++ b/src/openvic-simulation/politics/Rule.cpp
@@ -62,6 +62,20 @@ size_t RuleSet::get_rule_count() const {
return ret;
}
+void RuleSet::clear() {
+ rule_groups.clear();
+}
+
+bool RuleSet::empty() const {
+ for (auto const& [group, rule_map] : rule_groups) {
+ if (!rule_map.empty()) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
RuleSet::rule_map_t const& RuleSet::get_rule_group(Rule::rule_group_t group, bool* successful) const {
const rule_group_map_t::const_iterator it = rule_groups.find(group);
if (it != rule_groups.end()) {
diff --git a/src/openvic-simulation/politics/Rule.hpp b/src/openvic-simulation/politics/Rule.hpp
index 518c555..db0c926 100644
--- a/src/openvic-simulation/politics/Rule.hpp
+++ b/src/openvic-simulation/politics/Rule.hpp
@@ -42,7 +42,7 @@ namespace OpenVic {
using rule_group_map_t = ordered_map<Rule::rule_group_t, rule_map_t>;
private:
- rule_group_map_t rule_groups;
+ rule_group_map_t PROPERTY(rule_groups);
public:
RuleSet() = default;
@@ -59,6 +59,8 @@ namespace OpenVic {
bool trim_and_resolve_conflicts(bool log);
size_t get_rule_group_count() const;
size_t get_rule_count() const;
+ void clear();
+ bool empty() const;
rule_map_t const& get_rule_group(Rule::rule_group_t group, bool* successful = nullptr) const;
bool get_rule(Rule const* rule, bool* successful = nullptr) const;