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/Ideology.cpp20
-rw-r--r--src/openvic-simulation/politics/Issue.cpp46
-rw-r--r--src/openvic-simulation/politics/Issue.hpp2
-rw-r--r--src/openvic-simulation/politics/NationalFocus.cpp67
-rw-r--r--src/openvic-simulation/politics/NationalFocus.hpp14
-rw-r--r--src/openvic-simulation/politics/NationalValue.cpp10
-rw-r--r--src/openvic-simulation/politics/Rebel.cpp30
-rw-r--r--src/openvic-simulation/politics/Rebel.hpp3
8 files changed, 152 insertions, 40 deletions
diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp
index 546d16e..ca21997 100644
--- a/src/openvic-simulation/politics/Ideology.cpp
+++ b/src/openvic-simulation/politics/Ideology.cpp
@@ -83,15 +83,17 @@ bool IdeologyManager::load_ideology_file(ast::NodeCPtr root) {
IdeologyGroup const* ideology_group = get_ideology_group_by_identifier(ideology_group_key);
return expect_dictionary([this, ideology_group](std::string_view key, ast::NodeCPtr value) -> bool {
+ using enum scope_type_t;
+
colour_t colour = colour_t::null();
bool uncivilised = true, can_reduce_militancy = false;
Date spawn_date;
- ConditionalWeight add_political_reform { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };
- ConditionalWeight remove_political_reform { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };
- ConditionalWeight add_social_reform { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };
- ConditionalWeight remove_social_reform { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };
- ConditionalWeight add_military_reform { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };
- ConditionalWeight add_economic_reform { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };
+ ConditionalWeight add_political_reform { COUNTRY, COUNTRY, NO_SCOPE };
+ ConditionalWeight remove_political_reform { COUNTRY, COUNTRY, NO_SCOPE };
+ ConditionalWeight add_social_reform { COUNTRY, COUNTRY, NO_SCOPE };
+ ConditionalWeight remove_social_reform { COUNTRY, COUNTRY, NO_SCOPE };
+ ConditionalWeight add_military_reform { COUNTRY, COUNTRY, NO_SCOPE };
+ ConditionalWeight add_economic_reform { COUNTRY, COUNTRY, NO_SCOPE };
bool ret = expect_dictionary_keys(
"uncivilized", ZERO_OR_ONE, expect_bool(assign_variable_callback(uncivilised)),
@@ -99,20 +101,24 @@ bool IdeologyManager::load_ideology_file(ast::NodeCPtr root) {
"date", ZERO_OR_ONE, expect_date(assign_variable_callback(spawn_date)),
"can_reduce_militancy", ZERO_OR_ONE, expect_bool(assign_variable_callback(can_reduce_militancy)),
"add_political_reform", ONE_EXACTLY, add_political_reform.expect_conditional_weight(ConditionalWeight::BASE),
- "remove_political_reform", ONE_EXACTLY, remove_political_reform.expect_conditional_weight(ConditionalWeight::BASE),
+ "remove_political_reform", ONE_EXACTLY,
+ remove_political_reform.expect_conditional_weight(ConditionalWeight::BASE),
"add_social_reform", ONE_EXACTLY, add_social_reform.expect_conditional_weight(ConditionalWeight::BASE),
"remove_social_reform", ONE_EXACTLY, remove_social_reform.expect_conditional_weight(ConditionalWeight::BASE),
"add_military_reform", ZERO_OR_ONE, add_military_reform.expect_conditional_weight(ConditionalWeight::BASE),
"add_economic_reform", ZERO_OR_ONE, add_economic_reform.expect_conditional_weight(ConditionalWeight::BASE)
)(value);
+
ret &= add_ideology(
key, colour, ideology_group, uncivilised, can_reduce_militancy, spawn_date, std::move(add_political_reform),
std::move(remove_political_reform), std::move(add_social_reform), std::move(remove_social_reform),
std::move(add_military_reform), std::move(add_economic_reform)
);
+
return ret;
})(ideology_group_value);
})(root);
+
lock_ideologies();
return ret;
diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp
index 4a08dea..71356b6 100644
--- a/src/openvic-simulation/politics/Issue.cpp
+++ b/src/openvic-simulation/politics/Issue.cpp
@@ -1,5 +1,8 @@
#include "Issue.hpp"
+#include "openvic-simulation/modifier/ModifierManager.hpp"
+#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
+
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -7,8 +10,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 +24,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 +182,22 @@ bool IssueManager::_load_issue(
ModifierValue values;
RuleSet rules;
bool jingoism = false;
- bool ret = modifier_manager.expect_modifier_value_and_keys(move_variable_callback(values),
+
+ bool ret = NodeTools::expect_dictionary_keys_and_default(
+ modifier_manager.expect_base_country_modifier(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))
+ "rules", ZERO_OR_ONE, rule_manager.expect_rule_set(move_variable_callback(rules)),
+ "war_exhaustion_effect", ZERO_OR_ONE, [](const ast::NodeCPtr _) -> bool {
+ Logger::warning("war_exhaustion_effect does nothing (vanilla issues have it).");
+ return true;
+ }
)(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 +205,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;
}
@@ -204,16 +221,18 @@ bool IssueManager::_load_reform(
ModifierManager const& modifier_manager, RuleManager const& rule_manager, size_t ordinal, std::string_view identifier,
ReformGroup const* group, ast::NodeCPtr node
) {
+ using enum scope_type_t;
+
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 };
+ ConditionScript allow { COUNTRY, COUNTRY, NO_SCOPE };
+ ConditionScript on_execute_trigger { COUNTRY, COUNTRY, NO_SCOPE };
EffectScript on_execute_effect;
- bool ret = modifier_manager.expect_modifier_value_and_keys(
- move_variable_callback(values),
+ bool ret = NodeTools::expect_dictionary_keys_and_default(
+ modifier_manager.expect_base_country_modifier(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(),
@@ -223,11 +242,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 +293,7 @@ bool IssueManager::load_issues_file(
}
}
)(root);
+
lock_reform_types();
reserve_more_issue_groups(expected_issue_groups);
@@ -306,6 +328,7 @@ bool IssueManager::load_issues_file(
}
}
)(root);
+
lock_issue_groups();
lock_reform_groups();
@@ -356,6 +379,7 @@ bool IssueManager::load_issues_file(
}
}
)(root);
+
lock_issues();
lock_reforms();
@@ -364,8 +388,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 3132c3e..b60b3f5 100644
--- a/src/openvic-simulation/politics/NationalFocus.cpp
+++ b/src/openvic-simulation/politics/NationalFocus.cpp
@@ -1,6 +1,9 @@
#include "NationalFocus.hpp"
+#include "openvic-simulation/economy/GoodDefinition.hpp"
+#include "openvic-simulation/modifier/ModifierManager.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
+#include "openvic-simulation/pop/Pop.hpp"
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -12,20 +15,28 @@ NationalFocus::NationalFocus(
NationalFocusGroup const& new_group,
uint8_t new_icon,
bool new_has_flashpoint,
+ fixed_point_t new_flashpoint_tension,
bool new_own_provinces,
bool new_outliner_show_as_percent,
ModifierValue&& new_modifiers,
Ideology const* new_loyalty_ideology,
fixed_point_t new_loyalty_value,
+ fixed_point_t new_encourage_railroads,
+ 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 },
+ flashpoint_tension { new_flashpoint_tension },
own_provinces { new_own_provinces },
outliner_show_as_percent { new_outliner_show_as_percent },
loyalty_ideology { new_loyalty_ideology },
loyalty_value { new_loyalty_value },
+ encourage_railroads { new_encourage_railroads },
+ encourage_goods { std::move(new_encourage_goods) },
+ encourage_pop_types { std::move(new_encourage_pop_types) },
limit { std::move(new_limit) } {}
bool NationalFocus::parse_scripts(DefinitionManager const& definition_manager) {
@@ -37,6 +48,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 });
}
@@ -45,30 +57,38 @@ inline bool NationalFocusManager::add_national_focus(
NationalFocusGroup const& group,
uint8_t icon,
bool has_flashpoint,
+ fixed_point_t flashpoint_tension,
bool own_provinces,
bool outliner_show_as_percent,
ModifierValue&& modifiers,
Ideology const* loyalty_ideology,
fixed_point_t loyalty_value,
+ fixed_point_t encourage_railroads,
+ fixed_point_map_t<GoodDefinition const*>&& encourage_goods,
+ fixed_point_map_t<PopType const*>&& encourage_pop_types,
ConditionScript&& limit
) {
if (identifier.empty()) {
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, own_provinces, outliner_show_as_percent, std::move(modifiers),
- loyalty_ideology, loyalty_value, std::move(limit)
+ 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),
+ std::move(encourage_pop_types), std::move(limit)
});
}
@@ -77,12 +97,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);
@@ -95,31 +117,55 @@ bool NationalFocusManager::load_national_foci_file(
[this, &group, &pop_manager, &ideology_manager, &good_definition_manager, &modifier_manager](
std::string_view identifier, ast::NodeCPtr node
) -> bool {
+ using enum scope_type_t;
+
uint8_t icon = 0;
bool has_flashpoint = false, own_provinces = true, outliner_show_as_percent = false;
+ fixed_point_t flashpoint_tension = 0;
ModifierValue modifiers;
Ideology const* loyalty_ideology = nullptr;
fixed_point_t loyalty_value = 0;
+ fixed_point_t encourage_railroads = 0;
+ fixed_point_map_t<GoodDefinition const*> encourage_goods;
+ fixed_point_map_t<PopType const*> encourage_pop_types;
ConditionScript limit {
- scope_t::PROVINCE | scope_t::COUNTRY, scope_t::PROVINCE | scope_t::COUNTRY, scope_t::NO_SCOPE
+ PROVINCE | COUNTRY, PROVINCE | COUNTRY, NO_SCOPE
};
- bool ret = modifier_manager.expect_modifier_value_and_keys(
- move_variable_callback(modifiers),
+ const auto expect_base_province_modifier_cb = modifier_manager.expect_base_province_modifier(modifiers);
+ bool ret = NodeTools::expect_dictionary_keys_and_default(
+ [&good_definition_manager, &encourage_goods, &pop_manager, &encourage_pop_types, &expect_base_province_modifier_cb](
+ std::string_view key, ast::NodeCPtr value
+ ) -> bool {
+ GoodDefinition const* good = good_definition_manager.get_good_definition_by_identifier(key);
+ if (good != nullptr) {
+ return expect_fixed_point(map_callback(encourage_goods, good))(value);
+ }
+
+ PopType const* pop_type = pop_manager.get_pop_type_by_identifier(key);
+ if (pop_type != nullptr) {
+ return expect_fixed_point(map_callback(encourage_pop_types, pop_type))(value);
+ }
+
+ return expect_base_province_modifier_cb(key, value) || key_value_invalid_callback(key, value);
+ },
"icon", ONE_EXACTLY, expect_uint(assign_variable_callback(icon)),
"ideology", ZERO_OR_ONE,
ideology_manager.expect_ideology_identifier(assign_variable_callback_pointer(loyalty_ideology)),
"loyalty_value", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(loyalty_value)),
"limit", ZERO_OR_ONE, limit.expect_script(),
"has_flashpoint", ZERO_OR_ONE, expect_bool(assign_variable_callback(has_flashpoint)),
+ "flashpoint_tension", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(flashpoint_tension)),
"own_provinces", ZERO_OR_ONE, expect_bool(assign_variable_callback(own_provinces)),
"outliner_show_as_percent", ZERO_OR_ONE,
- expect_bool(assign_variable_callback(outliner_show_as_percent))
+ expect_bool(assign_variable_callback(outliner_show_as_percent)),
+ "railroads", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(encourage_railroads))
)(node);
ret &= add_national_focus(
- identifier, group, icon, has_flashpoint, own_provinces, outliner_show_as_percent, std::move(modifiers),
- loyalty_ideology, loyalty_value, std::move(limit)
+ 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), std::move(encourage_pop_types), std::move(limit)
);
return ret;
@@ -127,6 +173,7 @@ bool NationalFocusManager::load_national_foci_file(
)(group_node);
}
)(root);
+
lock_national_foci();
return ret;
@@ -134,8 +181,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/NationalFocus.hpp b/src/openvic-simulation/politics/NationalFocus.hpp
index 327b25b..e046c7a 100644
--- a/src/openvic-simulation/politics/NationalFocus.hpp
+++ b/src/openvic-simulation/politics/NationalFocus.hpp
@@ -16,6 +16,8 @@ namespace OpenVic {
};
struct Ideology;
+ struct GoodDefinition;
+ struct PopType;
struct NationalFocus : Modifier {
friend struct NationalFocusManager;
@@ -24,10 +26,14 @@ namespace OpenVic {
NationalFocusGroup const& PROPERTY(group);
uint8_t PROPERTY(icon);
bool PROPERTY(has_flashpoint);
+ fixed_point_t PROPERTY(flashpoint_tension);
bool PROPERTY(own_provinces);
bool PROPERTY(outliner_show_as_percent);
Ideology const* PROPERTY(loyalty_ideology);
fixed_point_t PROPERTY(loyalty_value);
+ fixed_point_t PROPERTY(encourage_railroads);
+ fixed_point_map_t<GoodDefinition const*> PROPERTY(encourage_goods);
+ fixed_point_map_t<PopType const*> PROPERTY(encourage_pop_types);
ConditionScript PROPERTY(limit);
NationalFocus(
@@ -35,11 +41,15 @@ namespace OpenVic {
NationalFocusGroup const& new_group,
uint8_t new_icon,
bool new_has_flashpoint,
+ fixed_point_t new_flashpoint_tension,
bool new_own_provinces,
bool new_outliner_show_as_percent,
ModifierValue&& new_modifiers,
Ideology const* new_loyalty_ideology,
fixed_point_t new_loyalty_value,
+ fixed_point_t new_encourage_railroads,
+ fixed_point_map_t<GoodDefinition const*>&& new_encourage_goods,
+ fixed_point_map_t<PopType const*>&& new_encourage_pop_types,
ConditionScript&& new_limit
);
@@ -66,11 +76,15 @@ namespace OpenVic {
NationalFocusGroup const& group,
uint8_t icon,
bool has_flashpoint,
+ fixed_point_t flashpoint_tension,
bool own_provinces,
bool outliner_show_as_percent,
ModifierValue&& modifiers,
Ideology const* loyalty_ideology,
fixed_point_t loyalty_value,
+ fixed_point_t encourage_railroads,
+ fixed_point_map_t<GoodDefinition const*>&& encourage_goods,
+ fixed_point_map_t<PopType const*>&& encourage_pop_types,
ConditionScript&& limit
);
diff --git a/src/openvic-simulation/politics/NationalValue.cpp b/src/openvic-simulation/politics/NationalValue.cpp
index b780195..9a30fa1 100644
--- a/src/openvic-simulation/politics/NationalValue.cpp
+++ b/src/openvic-simulation/politics/NationalValue.cpp
@@ -1,10 +1,12 @@
#include "NationalValue.hpp"
+#include "openvic-simulation/modifier/ModifierManager.hpp"
+
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()) {
@@ -20,10 +22,12 @@ bool NationalValueManager::load_national_values_file(ModifierManager const& modi
national_values,
[this, &modifier_manager](std::string_view national_value_identifier, ast::NodeCPtr value) -> bool {
ModifierValue modifiers;
-
- bool ret = modifier_manager.expect_modifier_value(move_variable_callback(modifiers))(value);
+ bool ret = NodeTools::expect_dictionary(
+ modifier_manager.expect_base_country_modifier(modifiers)
+ )(value);
ret &= add_national_value(national_value_identifier, std::move(modifiers));
+
return ret;
}
)(root);
diff --git a/src/openvic-simulation/politics/Rebel.cpp b/src/openvic-simulation/politics/Rebel.cpp
index fef61c0..ccaee5e 100644
--- a/src/openvic-simulation/politics/Rebel.cpp
+++ b/src/openvic-simulation/politics/Rebel.cpp
@@ -2,6 +2,8 @@
#include <string_view>
+#include "openvic-simulation/modifier/ModifierManager.hpp"
+
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -96,6 +98,8 @@ bool RebelManager::load_rebels_file(
bool ret = expect_dictionary_reserve_length(
rebel_types,
[this, &ideology_manager, &government_type_manager](std::string_view identifier, ast::NodeCPtr node) -> bool {
+ using enum scope_type_t;
+
RebelType::icon_t icon = 0;
RebelType::area_t area = RebelType::area_t::ALL;
RebelType::government_map_t desired_governments;
@@ -107,11 +111,11 @@ bool RebelManager::load_rebels_file(
allow_all_religions = true, allow_all_ideologies = true, resilient = true, reinforcing = true, general = true,
smart = true, unit_transfer = false;
fixed_point_t occupation_mult = 0;
- ConditionalWeight will_rise { scope_t::POP, scope_t::COUNTRY, scope_t::NO_SCOPE };
- ConditionalWeight spawn_chance { scope_t::POP, scope_t::POP, scope_t::NO_SCOPE };
- ConditionalWeight movement_evaluation { scope_t::PROVINCE, scope_t::PROVINCE, scope_t::NO_SCOPE };
- ConditionScript siege_won_trigger { scope_t::PROVINCE, scope_t::PROVINCE, scope_t::NO_SCOPE };
- ConditionScript demands_enforced_trigger { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };
+ ConditionalWeight will_rise { POP, COUNTRY, NO_SCOPE };
+ ConditionalWeight spawn_chance { POP, POP, NO_SCOPE };
+ ConditionalWeight movement_evaluation { PROVINCE, PROVINCE, NO_SCOPE };
+ ConditionScript siege_won_trigger { PROVINCE, PROVINCE, NO_SCOPE };
+ ConditionScript demands_enforced_trigger { COUNTRY, COUNTRY, NO_SCOPE };
EffectScript siege_won_effect, demands_enforced_effect;
bool ret = expect_dictionary_keys(
@@ -175,6 +179,7 @@ bool RebelManager::load_rebels_file(
bool RebelManager::generate_modifiers(ModifierManager& modifier_manager) const {
using enum ModifierEffect::format_t;
+ using enum ModifierEffect::target_t;
bool ret = true;
@@ -183,13 +188,20 @@ bool RebelManager::generate_modifiers(ModifierManager& modifier_manager) const {
ret &= modifier_manager.register_complex_modifier(identifier);
- ret &= modifier_manager.add_modifier_effect(
- ModifierManager::get_flat_identifier(identifier, "all"), is_positive_good, PROPORTION_DECIMAL, "TECH_REBEL_ORG_GAIN"
+ ret &= modifier_manager.register_technology_modifier_effect(
+ modifier_manager.modifier_effect_cache.rebel_org_gain_all, ModifierManager::get_flat_identifier(identifier, "all"),
+ is_positive_good, PROPORTION_DECIMAL, "TECH_REBEL_ORG_GAIN"
);
+ IndexedMap<RebelType, ModifierEffect const*>& rebel_org_gain_effects =
+ modifier_manager.modifier_effect_cache.rebel_org_gain_effects;
+
+ rebel_org_gain_effects.set_keys(&get_rebel_types());
+
for (RebelType const& rebel_type : get_rebel_types()) {
- ret &= modifier_manager.add_modifier_effect(
- ModifierManager::get_flat_identifier(identifier, rebel_type.get_identifier()), is_positive_good, PROPORTION_DECIMAL,
+ ret &= modifier_manager.register_technology_modifier_effect(
+ rebel_org_gain_effects[rebel_type], ModifierManager::get_flat_identifier(identifier, rebel_type.get_identifier()),
+ is_positive_good, PROPORTION_DECIMAL,
StringUtils::append_string_views("$", rebel_type.get_identifier(), "_title$ $TECH_REBEL_ORG_GAIN$")
);
}
diff --git a/src/openvic-simulation/politics/Rebel.hpp b/src/openvic-simulation/politics/Rebel.hpp
index fc82c84..b47bcbb 100644
--- a/src/openvic-simulation/politics/Rebel.hpp
+++ b/src/openvic-simulation/politics/Rebel.hpp
@@ -2,7 +2,6 @@
#include <cstdint>
-#include "openvic-simulation/modifier/Modifier.hpp"
#include "openvic-simulation/politics/Government.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
#include "openvic-simulation/scripts/ConditionalWeight.hpp"
@@ -79,6 +78,8 @@ namespace OpenVic {
RebelType(RebelType&&) = default;
};
+ struct ModifierManager;
+
struct RebelManager {
private:
IdentifierRegistry<RebelType> IDENTIFIER_REGISTRY(rebel_type);