aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/openvic-simulation/economy/BuildingType.cpp5
-rw-r--r--src/openvic-simulation/economy/GoodDefinition.cpp3
-rw-r--r--src/openvic-simulation/military/UnitType.cpp7
-rw-r--r--src/openvic-simulation/modifier/Modifier.cpp346
-rw-r--r--src/openvic-simulation/modifier/Modifier.hpp20
-rw-r--r--src/openvic-simulation/modifier/ModifierSum.cpp38
-rw-r--r--src/openvic-simulation/modifier/ModifierSum.hpp18
-rw-r--r--src/openvic-simulation/politics/Rebel.cpp7
-rw-r--r--src/openvic-simulation/pop/Pop.cpp6
-rw-r--r--src/openvic-simulation/research/Technology.cpp5
10 files changed, 273 insertions, 182 deletions
diff --git a/src/openvic-simulation/economy/BuildingType.cpp b/src/openvic-simulation/economy/BuildingType.cpp
index e7c0d59..d75f1b2 100644
--- a/src/openvic-simulation/economy/BuildingType.cpp
+++ b/src/openvic-simulation/economy/BuildingType.cpp
@@ -114,16 +114,17 @@ bool BuildingTypeManager::load_buildings_file(
for (BuildingType const& building_type : building_types.get_items()) {
using enum ModifierEffect::format_t;
+ using enum ModifierEffect::target_t;
static constexpr std::string_view max_prefix = "max_";
static constexpr std::string_view min_prefix = "min_build_";
ret &= modifier_manager.add_modifier_effect(
- StringUtils::append_string_views(max_prefix, building_type.get_identifier()), true, INT,
+ StringUtils::append_string_views(max_prefix, building_type.get_identifier()), true, INT, PROVINCE,
StringUtils::append_string_views("$", building_type.get_identifier(), "$ $TECH_MAX_LEVEL$")
);
// TODO - add custom localisation for "min_build_$building_type$" modifiers
ret &= modifier_manager.add_modifier_effect(
- StringUtils::append_string_views(min_prefix, building_type.get_identifier()), false, INT
+ StringUtils::append_string_views(min_prefix, building_type.get_identifier()), false, INT, PROVINCE
);
if (building_type.is_in_province()) {
diff --git a/src/openvic-simulation/economy/GoodDefinition.cpp b/src/openvic-simulation/economy/GoodDefinition.cpp
index ed24549..97396f2 100644
--- a/src/openvic-simulation/economy/GoodDefinition.cpp
+++ b/src/openvic-simulation/economy/GoodDefinition.cpp
@@ -89,6 +89,7 @@ bool GoodDefinitionManager::load_goods_file(ast::NodeCPtr root) {
bool GoodDefinitionManager::generate_modifiers(ModifierManager& modifier_manager) const {
using enum ModifierEffect::format_t;
+ using enum ModifierEffect::target_t;
bool ret = true;
@@ -100,7 +101,7 @@ bool GoodDefinitionManager::generate_modifiers(ModifierManager& modifier_manager
for (GoodDefinition const& good : get_good_definitions()) {
ret &= modifier_manager.add_modifier_effect(
ModifierManager::get_flat_identifier(name, good.get_identifier()), is_positive_good, PROPORTION_DECIMAL,
- make_localisation_suffix(good.get_identifier())
+ COUNTRY, make_localisation_suffix(good.get_identifier())
);
}
};
diff --git a/src/openvic-simulation/military/UnitType.cpp b/src/openvic-simulation/military/UnitType.cpp
index 71bc5c3..bb227fb 100644
--- a/src/openvic-simulation/military/UnitType.cpp
+++ b/src/openvic-simulation/military/UnitType.cpp
@@ -321,17 +321,18 @@ bool UnitTypeManager::generate_modifiers(ModifierManager& modifier_manager) cons
const auto generate_stat_modifiers = [&modifier_manager, &ret](
std::string_view identifier, UnitType::branch_t branch
) -> void {
+ using enum ModifierEffect::format_t;
+ using enum ModifierEffect::target_t;
+
const auto stat_modifier = [&modifier_manager, &ret, &identifier](
std::string_view suffix, bool is_positive_good, ModifierEffect::format_t format, std::string_view localisation_key
) -> void {
ret &= modifier_manager.add_modifier_effect(
- ModifierManager::get_flat_identifier(identifier, suffix), is_positive_good, format,
+ ModifierManager::get_flat_identifier(identifier, suffix), is_positive_good, format, COUNTRY,
StringUtils::append_string_views("$", identifier, "$: $", localisation_key, "$")
);
};
- using enum ModifierEffect::format_t;
-
ret &= modifier_manager.register_complex_modifier(identifier);
stat_modifier("attack", true, RAW_DECIMAL, "ATTACK");
diff --git a/src/openvic-simulation/modifier/Modifier.cpp b/src/openvic-simulation/modifier/Modifier.cpp
index 10e32a4..73b30ce 100644
--- a/src/openvic-simulation/modifier/Modifier.cpp
+++ b/src/openvic-simulation/modifier/Modifier.cpp
@@ -17,8 +17,9 @@ static std::string make_default_modifier_effect_localisation_key(std::string_vie
}
ModifierEffect::ModifierEffect(
- std::string_view new_identifier, bool new_positive_good, format_t new_format, std::string_view new_localisation_key
-) : HasIdentifier { new_identifier }, positive_good { new_positive_good }, format { new_format },
+ std::string_view new_identifier, bool new_positive_good, format_t new_format, target_t new_targets,
+ std::string_view new_localisation_key
+) : HasIdentifier { new_identifier }, positive_good { new_positive_good }, format { new_format }, targets { new_targets },
localisation_key {
new_localisation_key.empty() ? make_default_modifier_effect_localisation_key(new_identifier) : new_localisation_key
} {}
@@ -115,12 +116,29 @@ ModifierValue ModifierValue::operator*(fixed_point_t const& right) const {
return copy *= right;
}
-void ModifierValue::multiply_add(ModifierValue const& other, fixed_point_t multiplier) {
- if (multiplier == fixed_point_t::_1()) {
+void ModifierValue::apply_target_filter(ModifierEffect::target_t targets) {
+ using enum ModifierEffect::target_t;
+
+ erase_if(
+ values,
+ [targets](effect_map_t::value_type const& value) -> bool {
+ return (value.first->get_targets() & targets) == NO_TARGETS;
+ }
+ );
+}
+
+void ModifierValue::multiply_add_filter(
+ ModifierValue const& other, fixed_point_t multiplier, ModifierEffect::target_t targets
+) {
+ using enum ModifierEffect::target_t;
+
+ if (multiplier == fixed_point_t::_1() && targets == ALL_TARGETS) {
*this += other;
- } else if (multiplier != fixed_point_t::_0()) {
+ } else if (multiplier != fixed_point_t::_0() && targets != NO_TARGETS) {
for (effect_map_t::value_type const& value : other.values) {
- values[value.first] += value.second * multiplier;
+ if ((value.first->get_targets() & targets) != NO_TARGETS) {
+ values[value.first] += value.second * multiplier;
+ }
}
}
}
@@ -145,247 +163,261 @@ ModifierInstance::ModifierInstance(Modifier const& new_modifier, Date new_expiry
: modifier { &new_modifier }, expiry_date { new_expiry_date } {}
bool ModifierManager::add_modifier_effect(
- std::string_view identifier, bool positive_good, ModifierEffect::format_t format, std::string_view localisation_key
+ std::string_view identifier, bool positive_good, ModifierEffect::format_t format, ModifierEffect::target_t targets,
+ std::string_view localisation_key
) {
if (identifier.empty()) {
Logger::error("Invalid modifier effect identifier - empty!");
return false;
}
- return modifier_effects.add_item({ std::move(identifier), positive_good, format, localisation_key });
+ return modifier_effects.add_item({ std::move(identifier), positive_good, format, targets, localisation_key });
}
bool ModifierManager::setup_modifier_effects() {
bool ret = true;
using enum ModifierEffect::format_t;
+ using enum ModifierEffect::target_t;
/* Tech/inventions only */
- ret &= add_modifier_effect("cb_creation_speed", true, PROPORTION_DECIMAL, "CB_MANUFACTURE_TECH");
- ret &= add_modifier_effect("combat_width", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("plurality", true, PERCENTAGE_DECIMAL, "TECH_PLURALITY");
- ret &= add_modifier_effect("pop_growth", true, PROPORTION_DECIMAL, "TECH_POP_GROWTH");
- ret &= add_modifier_effect("regular_experience_level", true, RAW_DECIMAL, "REGULAR_EXP_TECH");
- ret &= add_modifier_effect("reinforce_rate", true, PROPORTION_DECIMAL, "REINFORCE_TECH");
- ret &= add_modifier_effect("seperatism", false, PROPORTION_DECIMAL, "SEPARATISM_TECH"); // paradox typo
- ret &= add_modifier_effect("shared_prestige", true, RAW_DECIMAL, "SHARED_PRESTIGE_TECH");
- ret &= add_modifier_effect("tax_eff", true, PROPORTION_DECIMAL, "TECH_TAX_EFF");
+ ret &= add_modifier_effect("cb_creation_speed", true, PROPORTION_DECIMAL, COUNTRY, "CB_MANUFACTURE_TECH");
+ ret &= add_modifier_effect("combat_width", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("plurality", true, PERCENTAGE_DECIMAL, COUNTRY, "TECH_PLURALITY");
+ ret &= add_modifier_effect("pop_growth", true, PROPORTION_DECIMAL, COUNTRY, "TECH_POP_GROWTH");
+ ret &= add_modifier_effect("regular_experience_level", true, RAW_DECIMAL, COUNTRY, "REGULAR_EXP_TECH");
+ ret &= add_modifier_effect("reinforce_rate", true, PROPORTION_DECIMAL, COUNTRY, "REINFORCE_TECH");
+ ret &= add_modifier_effect("seperatism", false, PROPORTION_DECIMAL, COUNTRY, "SEPARATISM_TECH"); // paradox typo
+ ret &= add_modifier_effect("shared_prestige", true, RAW_DECIMAL, COUNTRY, "SHARED_PRESTIGE_TECH");
+ ret &= add_modifier_effect("tax_eff", true, PERCENTAGE_DECIMAL, COUNTRY, "TECH_TAX_EFF");
/* Country Modifier Effects */
- ret &= add_modifier_effect("administrative_efficiency", true, PROPORTION_DECIMAL);
+ ret &= add_modifier_effect("administrative_efficiency", true, PROPORTION_DECIMAL, COUNTRY);
ret &= add_modifier_effect(
- "administrative_efficiency_modifier", true, PROPORTION_DECIMAL,
+ "administrative_efficiency_modifier", true, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("administrative_efficiency")
);
- ret &= add_modifier_effect("artisan_input", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("artisan_output", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("artisan_throughput", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("badboy", false, RAW_DECIMAL);
- ret &= add_modifier_effect("cb_generation_speed_modifier", true, PROPORTION_DECIMAL);
+ ret &= add_modifier_effect("artisan_input", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("artisan_output", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("artisan_throughput", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("badboy", false, RAW_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("cb_generation_speed_modifier", true, PROPORTION_DECIMAL, COUNTRY);
ret &= add_modifier_effect(
- "civilization_progress_modifier", true, PROPORTION_DECIMAL,
+ "civilization_progress_modifier", true, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("civilization_progress")
);
- ret &= add_modifier_effect("colonial_life_rating", false, INT, "COLONIAL_LIFE_TECH");
- ret &= add_modifier_effect("colonial_migration", true, PROPORTION_DECIMAL, "COLONIAL_MIGRATION_TECH");
- ret &= add_modifier_effect("colonial_points", true, INT, "COLONIAL_POINTS_TECH");
- ret &= add_modifier_effect("colonial_prestige", true, PROPORTION_DECIMAL, "COLONIAL_PRESTIGE_MODIFIER_TECH");
- ret &= add_modifier_effect("core_pop_consciousness_modifier", false, RAW_DECIMAL);
- ret &= add_modifier_effect("core_pop_militancy_modifier", false, RAW_DECIMAL);
- ret &= add_modifier_effect("dig_in_cap", true, INT, "DIGIN_FROM_TECH");
- ret &= add_modifier_effect("diplomatic_points", true, PROPORTION_DECIMAL, "DIPLOMATIC_POINTS_TECH");
+ ret &= add_modifier_effect("colonial_life_rating", false, INT, COUNTRY, "COLONIAL_LIFE_TECH");
+ ret &= add_modifier_effect("colonial_migration", true, PROPORTION_DECIMAL, COUNTRY, "COLONIAL_MIGRATION_TECH");
+ ret &= add_modifier_effect("colonial_points", true, INT, COUNTRY, "COLONIAL_POINTS_TECH");
+ ret &= add_modifier_effect("colonial_prestige", true, PROPORTION_DECIMAL, COUNTRY, "COLONIAL_PRESTIGE_MODIFIER_TECH");
+ ret &= add_modifier_effect("core_pop_consciousness_modifier", false, RAW_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("core_pop_militancy_modifier", false, RAW_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("dig_in_cap", true, INT, COUNTRY, "DIGIN_FROM_TECH");
+ ret &= add_modifier_effect("diplomatic_points", true, PROPORTION_DECIMAL, COUNTRY, "DIPLOMATIC_POINTS_TECH");
ret &= add_modifier_effect(
- "diplomatic_points_modifier", true, PROPORTION_DECIMAL,
+ "diplomatic_points_modifier", true, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("diplopoints_gain")
);
- ret &= add_modifier_effect("education_efficiency", true, PROPORTION_DECIMAL);
+ ret &= add_modifier_effect("education_efficiency", true, PROPORTION_DECIMAL, COUNTRY);
ret &= add_modifier_effect(
- "education_efficiency_modifier", true, PROPORTION_DECIMAL,
+ "education_efficiency_modifier", true, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("education_efficiency")
);
- ret &= add_modifier_effect("factory_cost", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("factory_input", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("factory_maintenance", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("factory_output", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("factory_owner_cost", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("factory_throughput", true, PROPORTION_DECIMAL);
+ ret &= add_modifier_effect("factory_cost", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("factory_input", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("factory_maintenance", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("factory_output", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("factory_owner_cost", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("factory_throughput", true, PROPORTION_DECIMAL, COUNTRY);
ret &= add_modifier_effect(
- "global_assimilation_rate", true, PROPORTION_DECIMAL,
+ "global_assimilation_rate", true, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("assimilation_rate")
);
ret &= add_modifier_effect(
- "global_immigrant_attract", true, PROPORTION_DECIMAL,
+ "global_immigrant_attract", true, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("immigant_attract")
);
- ret &= add_modifier_effect("global_pop_consciousness_modifier", false, RAW_DECIMAL);
- ret &= add_modifier_effect("global_pop_militancy_modifier", false, RAW_DECIMAL);
+ ret &= add_modifier_effect("global_pop_consciousness_modifier", false, RAW_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("global_pop_militancy_modifier", false, RAW_DECIMAL, COUNTRY);
ret &= add_modifier_effect(
- "global_population_growth", true, PROPORTION_DECIMAL,
+ "global_population_growth", true, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("population_growth")
);
- ret &= add_modifier_effect("goods_demand", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("import_cost", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("increase_research", true, PROPORTION_DECIMAL, "INC_RES_TECH");
- ret &= add_modifier_effect("influence", true, PROPORTION_DECIMAL, "TECH_GP_INFLUENCE");
+ ret &= add_modifier_effect("goods_demand", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("import_cost", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("increase_research", true, PROPORTION_DECIMAL, COUNTRY, "INC_RES_TECH");
+ ret &= add_modifier_effect("influence", true, PROPORTION_DECIMAL, COUNTRY, "TECH_GP_INFLUENCE");
ret &= add_modifier_effect(
- "influence_modifier", true, PROPORTION_DECIMAL,
+ "influence_modifier", true, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("greatpower_influence_gain")
);
- ret &= add_modifier_effect("issue_change_speed", true, PROPORTION_DECIMAL);
+ ret &= add_modifier_effect("issue_change_speed", true, PROPORTION_DECIMAL, COUNTRY);
ret &= add_modifier_effect(
- "land_attack_modifier", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("land_attack")
+ "land_attack_modifier", true, PROPORTION_DECIMAL, COUNTRY, make_default_modifier_effect_localisation_key("land_attack")
);
- ret &= add_modifier_effect("land_attrition", false, PROPORTION_DECIMAL, "LAND_ATTRITION_TECH");
+ ret &= add_modifier_effect("land_attrition", false, PROPORTION_DECIMAL, COUNTRY, "LAND_ATTRITION_TECH");
ret &= add_modifier_effect(
- "land_defense_modifier", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("land_defense")
+ "land_defense_modifier", true, PROPORTION_DECIMAL, COUNTRY,
+ make_default_modifier_effect_localisation_key("land_defense")
);
- ret &= add_modifier_effect("land_organisation", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("land_unit_start_experience", true, RAW_DECIMAL);
- ret &= add_modifier_effect("leadership", true, RAW_DECIMAL, "LEADERSHIP");
+ ret &= add_modifier_effect("land_organisation", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("land_unit_start_experience", true, RAW_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("leadership", true, RAW_DECIMAL, COUNTRY, "LEADERSHIP");
ret &= add_modifier_effect(
- "leadership_modifier", true, PROPORTION_DECIMAL,
+ "leadership_modifier", true, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("global_leadership_modifier")
);
- ret &= add_modifier_effect("literacy_con_impact", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("loan_interest", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect(
- "max_loan_modifier", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("max_loan_amount")
- );
- ret &= add_modifier_effect("max_military_spending", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("max_national_focus", true, INT, "TECH_MAX_FOCUS");
- ret &= add_modifier_effect("max_social_spending", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("max_tariff", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("max_tax", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("max_war_exhaustion", true, PERCENTAGE_DECIMAL, "MAX_WAR_EXHAUSTION");
- ret &= add_modifier_effect("military_tactics", true, PROPORTION_DECIMAL, "MIL_TACTICS_TECH");
- ret &= add_modifier_effect("min_military_spending", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("min_social_spending", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("min_tariff", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("min_tax", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect(
- "minimum_wage", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("minimun_wage")
- );
- ret &= add_modifier_effect("mobilisation_economy_impact", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("mobilisation_size", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("mobilization_impact", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect(
- "naval_attack_modifier", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("naval_attack")
- );
- ret &= add_modifier_effect("naval_attrition", false, PROPORTION_DECIMAL, "NAVAL_ATTRITION_TECH");
- ret &= add_modifier_effect(
- "naval_defense_modifier", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("naval_defense")
- );
- ret &= add_modifier_effect("naval_organisation", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("naval_unit_start_experience", true, RAW_DECIMAL);
- ret &= add_modifier_effect("non_accepted_pop_consciousness_modifier", false, RAW_DECIMAL);
- ret &= add_modifier_effect("non_accepted_pop_militancy_modifier", false, RAW_DECIMAL);
- ret &= add_modifier_effect("org_regain", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("pension_level", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("permanent_prestige", true, RAW_DECIMAL, "PERMANENT_PRESTIGE_TECH");
- ret &= add_modifier_effect("political_reform_desire", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("poor_savings_modifier", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("prestige", true, RAW_DECIMAL);
- ret &= add_modifier_effect("reinforce_speed", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("research_points", true, RAW_DECIMAL);
- ret &= add_modifier_effect("research_points_modifier", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("research_points_on_conquer", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("rgo_output", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("rgo_throughput", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("ruling_party_support", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect(
- "self_unciv_economic_modifier", false, PROPORTION_DECIMAL,
+ ret &= add_modifier_effect("literacy_con_impact", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("loan_interest", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect(
+ "max_loan_modifier", true, PROPORTION_DECIMAL, COUNTRY,
+ make_default_modifier_effect_localisation_key("max_loan_amount")
+ );
+ ret &= add_modifier_effect("max_military_spending", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("max_national_focus", true, INT, COUNTRY, "TECH_MAX_FOCUS");
+ ret &= add_modifier_effect("max_social_spending", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("max_tariff", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("max_tax", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("max_war_exhaustion", true, PERCENTAGE_DECIMAL, COUNTRY, "MAX_WAR_EXHAUSTION");
+ ret &= add_modifier_effect("military_tactics", true, PROPORTION_DECIMAL, COUNTRY, "MIL_TACTICS_TECH");
+ ret &= add_modifier_effect("min_military_spending", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("min_social_spending", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("min_tariff", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("min_tax", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect(
+ "minimum_wage", true, PROPORTION_DECIMAL, COUNTRY, make_default_modifier_effect_localisation_key("minimun_wage")
+ );
+ ret &= add_modifier_effect("mobilisation_economy_impact", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("mobilisation_size", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("mobilization_impact", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect(
+ "naval_attack_modifier", true, PROPORTION_DECIMAL, COUNTRY,
+ make_default_modifier_effect_localisation_key("naval_attack")
+ );
+ ret &= add_modifier_effect("naval_attrition", false, PROPORTION_DECIMAL, COUNTRY, "NAVAL_ATTRITION_TECH");
+ ret &= add_modifier_effect(
+ "naval_defense_modifier", true, PROPORTION_DECIMAL, COUNTRY,
+ make_default_modifier_effect_localisation_key("naval_defense")
+ );
+ ret &= add_modifier_effect("naval_organisation", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("naval_unit_start_experience", true, RAW_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("non_accepted_pop_consciousness_modifier", false, RAW_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("non_accepted_pop_militancy_modifier", false, RAW_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("org_regain", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("pension_level", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("permanent_prestige", true, RAW_DECIMAL, COUNTRY, "PERMANENT_PRESTIGE_TECH");
+ ret &= add_modifier_effect("political_reform_desire", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("poor_savings_modifier", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("prestige", true, RAW_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("reinforce_speed", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("research_points", true, RAW_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("research_points_modifier", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("research_points_on_conquer", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("rgo_output", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("rgo_throughput", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("ruling_party_support", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect(
+ "self_unciv_economic_modifier", false, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("self_unciv_economic")
);
ret &= add_modifier_effect(
- "self_unciv_military_modifier", false, PROPORTION_DECIMAL,
+ "self_unciv_military_modifier", false, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("self_unciv_military")
);
- ret &= add_modifier_effect("social_reform_desire", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("soldier_to_pop_loss", true, PROPORTION_DECIMAL, "SOLDIER_TO_POP_LOSS_TECH");
- ret &= add_modifier_effect("supply_consumption", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("supply_range", true, PROPORTION_DECIMAL, "SUPPLY_RANGE_TECH");
- ret &= add_modifier_effect("suppression_points_modifier", true, PROPORTION_DECIMAL, "SUPPRESSION_TECH");
+ ret &= add_modifier_effect("social_reform_desire", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("soldier_to_pop_loss", true, PROPORTION_DECIMAL, COUNTRY, "SOLDIER_TO_POP_LOSS_TECH");
+ ret &= add_modifier_effect("supply_consumption", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("supply_range", true, PROPORTION_DECIMAL, COUNTRY, "SUPPLY_RANGE_TECH");
+ ret &= add_modifier_effect("suppression_points_modifier", true, PROPORTION_DECIMAL, COUNTRY, "SUPPRESSION_TECH");
ret &= add_modifier_effect(
- "tariff_efficiency_modifier", true, PROPORTION_DECIMAL,
+ "tariff_efficiency_modifier", true, PROPORTION_DECIMAL, COUNTRY,
make_default_modifier_effect_localisation_key("tariff_efficiency")
);
- ret &= add_modifier_effect("tax_efficiency", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("unemployment_benefit", true, PROPORTION_DECIMAL);
+ ret &= add_modifier_effect("tax_efficiency", true, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("unemployment_benefit", true, PROPORTION_DECIMAL, COUNTRY);
ret &= add_modifier_effect(
- "unciv_economic_modifier", false, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("unciv_economic")
+ "unciv_economic_modifier", false, PROPORTION_DECIMAL, COUNTRY,
+ make_default_modifier_effect_localisation_key("unciv_economic")
);
ret &= add_modifier_effect(
- "unciv_military_modifier", false, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("unciv_military")
+ "unciv_military_modifier", false, PROPORTION_DECIMAL, COUNTRY,
+ make_default_modifier_effect_localisation_key("unciv_military")
);
- ret &= add_modifier_effect("unit_recruitment_time", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("war_exhaustion", false, PROPORTION_DECIMAL, "WAR_EXHAUST_BATTLES");
+ ret &= add_modifier_effect("unit_recruitment_time", false, PROPORTION_DECIMAL, COUNTRY);
+ ret &= add_modifier_effect("war_exhaustion", false, PROPORTION_DECIMAL, COUNTRY, "WAR_EXHAUST_BATTLES");
/* Province Modifier Effects */
- ret &= add_modifier_effect("assimilation_rate", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("boost_strongest_party", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("farm_rgo_eff", true, PROPORTION_DECIMAL, "TECH_FARM_OUTPUT");
+ ret &= add_modifier_effect("assimilation_rate", true, PROPORTION_DECIMAL, PROVINCE);
+ ret &= add_modifier_effect("boost_strongest_party", false, PROPORTION_DECIMAL, PROVINCE);
+ ret &= add_modifier_effect("farm_rgo_eff", true, PROPORTION_DECIMAL, PROVINCE, "TECH_FARM_OUTPUT");
ret &= add_modifier_effect(
- "farm_rgo_size", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("farm_size")
+ "farm_rgo_size", true, PROPORTION_DECIMAL, PROVINCE, make_default_modifier_effect_localisation_key("farm_size")
);
ret &= add_modifier_effect(
- "immigrant_attract", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("immigant_attract")
+ "immigrant_attract", true, PROPORTION_DECIMAL, PROVINCE,
+ make_default_modifier_effect_localisation_key("immigant_attract")
);
ret &= add_modifier_effect(
- "immigrant_push", false, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("immigant_push")
+ "immigrant_push", false, PROPORTION_DECIMAL, PROVINCE, make_default_modifier_effect_localisation_key("immigant_push")
);
- ret &= add_modifier_effect("life_rating", true, PROPORTION_DECIMAL);
+ ret &= add_modifier_effect("life_rating", true, PROPORTION_DECIMAL, PROVINCE);
ret &= add_modifier_effect(
- "local_artisan_input", false, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("artisan_input")
+ "local_artisan_input", false, PROPORTION_DECIMAL, PROVINCE,
+ make_default_modifier_effect_localisation_key("artisan_input")
);
ret &= add_modifier_effect(
- "local_artisan_output", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("artisan_output")
+ "local_artisan_output", true, PROPORTION_DECIMAL, PROVINCE,
+ make_default_modifier_effect_localisation_key("artisan_output")
);
ret &= add_modifier_effect(
- "local_artisan_throughput", true, PROPORTION_DECIMAL,
+ "local_artisan_throughput", true, PROPORTION_DECIMAL, PROVINCE,
make_default_modifier_effect_localisation_key("artisan_throughput")
);
ret &= add_modifier_effect(
- "local_factory_input", false, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("factory_input")
+ "local_factory_input", false, PROPORTION_DECIMAL, PROVINCE,
+ make_default_modifier_effect_localisation_key("factory_input")
);
ret &= add_modifier_effect(
- "local_factory_output", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("factory_output")
+ "local_factory_output", true, PROPORTION_DECIMAL, PROVINCE,
+ make_default_modifier_effect_localisation_key("factory_output")
);
ret &= add_modifier_effect(
- "local_factory_throughput", true, PROPORTION_DECIMAL,
+ "local_factory_throughput", true, PROPORTION_DECIMAL, PROVINCE,
make_default_modifier_effect_localisation_key("factory_throughput")
);
- ret &= add_modifier_effect("local_repair", true, PROPORTION_DECIMAL);
+ ret &= add_modifier_effect("local_repair", true, PROPORTION_DECIMAL, PROVINCE);
ret &= add_modifier_effect(
- "local_rgo_output", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("rgo_output")
+ "local_rgo_output", true, PROPORTION_DECIMAL, PROVINCE, make_default_modifier_effect_localisation_key("rgo_output")
);
ret &= add_modifier_effect(
- "local_rgo_throughput", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("rgo_throughput")
+ "local_rgo_throughput", true, PROPORTION_DECIMAL, PROVINCE,
+ make_default_modifier_effect_localisation_key("rgo_throughput")
);
ret &= add_modifier_effect(
- "local_ruling_party_support", true, PROPORTION_DECIMAL,
+ "local_ruling_party_support", true, PROPORTION_DECIMAL, PROVINCE,
make_default_modifier_effect_localisation_key("ruling_party_support")
);
- ret &= add_modifier_effect("local_ship_build", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("max_attrition", false, RAW_DECIMAL);
- ret &= add_modifier_effect("mine_rgo_eff", true, PROPORTION_DECIMAL, "TECH_MINE_OUTPUT");
+ ret &= add_modifier_effect("local_ship_build", false, PROPORTION_DECIMAL, PROVINCE);
+ ret &= add_modifier_effect("max_attrition", false, RAW_DECIMAL, PROVINCE);
+ ret &= add_modifier_effect("mine_rgo_eff", true, PROPORTION_DECIMAL, PROVINCE, "TECH_MINE_OUTPUT");
ret &= add_modifier_effect(
- "mine_rgo_size", true, PROPORTION_DECIMAL, make_default_modifier_effect_localisation_key("mine_size")
+ "mine_rgo_size", true, PROPORTION_DECIMAL, PROVINCE, make_default_modifier_effect_localisation_key("mine_size")
);
- ret &= add_modifier_effect("movement_cost", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("number_of_voters", false, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("pop_consciousness_modifier", false, RAW_DECIMAL);
- ret &= add_modifier_effect("pop_militancy_modifier", false, RAW_DECIMAL);
- ret &= add_modifier_effect("population_growth", true, PROPORTION_DECIMAL);
- ret &= add_modifier_effect("supply_limit", true, RAW_DECIMAL);
+ ret &= add_modifier_effect("movement_cost", false, PROPORTION_DECIMAL, PROVINCE);
+ ret &= add_modifier_effect("number_of_voters", false, PROPORTION_DECIMAL, PROVINCE);
+ ret &= add_modifier_effect("pop_consciousness_modifier", false, RAW_DECIMAL, PROVINCE);
+ ret &= add_modifier_effect("pop_militancy_modifier", false, RAW_DECIMAL, PROVINCE);
+ ret &= add_modifier_effect("population_growth", true, PROPORTION_DECIMAL, PROVINCE);
+ ret &= add_modifier_effect("supply_limit", true, RAW_DECIMAL, PROVINCE);
/* Military Modifier Effects */
- ret &= add_modifier_effect("attack", true, INT, "TRAIT_ATTACK");
- ret &= add_modifier_effect("attrition", false, RAW_DECIMAL, "ATTRITION");
- ret &= add_modifier_effect("defence", true, INT, "TRAIT_DEFEND");
- ret &= add_modifier_effect("experience", true, PROPORTION_DECIMAL, "TRAIT_EXPERIENCE");
- ret &= add_modifier_effect("morale", true, PROPORTION_DECIMAL, "TRAIT_MORALE");
- ret &= add_modifier_effect("organisation", true, PROPORTION_DECIMAL, "TRAIT_ORGANISATION");
- ret &= add_modifier_effect("reconnaissance", true, PROPORTION_DECIMAL, "TRAIT_RECONAISSANCE");
- ret &= add_modifier_effect("reliability", true, RAW_DECIMAL, "TRAIT_RELIABILITY");
- ret &= add_modifier_effect("speed", true, PROPORTION_DECIMAL, "TRAIT_SPEED");
+ ret &= add_modifier_effect("attack", true, INT, UNIT, "TRAIT_ATTACK");
+ ret &= add_modifier_effect("attrition", false, RAW_DECIMAL, UNIT, "ATTRITION");
+ ret &= add_modifier_effect("defence", true, INT, UNIT, "TRAIT_DEFEND");
+ ret &= add_modifier_effect("experience", true, PROPORTION_DECIMAL, UNIT, "TRAIT_EXPERIENCE");
+ ret &= add_modifier_effect("morale", true, PROPORTION_DECIMAL, UNIT, "TRAIT_MORALE");
+ ret &= add_modifier_effect("organisation", true, PROPORTION_DECIMAL, UNIT, "TRAIT_ORGANISATION");
+ ret &= add_modifier_effect("reconnaissance", true, PROPORTION_DECIMAL, UNIT, "TRAIT_RECONAISSANCE");
+ ret &= add_modifier_effect("reliability", true, RAW_DECIMAL, UNIT, "TRAIT_RELIABILITY");
+ ret &= add_modifier_effect("speed", true, PROPORTION_DECIMAL, UNIT, "TRAIT_SPEED");
return ret;
}
diff --git a/src/openvic-simulation/modifier/Modifier.hpp b/src/openvic-simulation/modifier/Modifier.hpp
index 4b032c0..a848cb8 100644
--- a/src/openvic-simulation/modifier/Modifier.hpp
+++ b/src/openvic-simulation/modifier/Modifier.hpp
@@ -10,31 +10,43 @@ namespace OpenVic {
struct ModifierEffect : HasIdentifier {
friend struct ModifierManager;
- enum class format_t {
+ enum class format_t : uint8_t {
PROPORTION_DECIMAL, /* An unscaled fraction/ratio, with 1 being "full"/"whole" */
PERCENTAGE_DECIMAL, /* A fraction/ratio scaled so that 100 is "full"/"whole" */
RAW_DECIMAL, /* A continuous quantity, e.g. attack strength */
INT /* A discrete quantity, e.g. building count limit */
};
+ enum class target_t : uint8_t {
+ NO_TARGETS = 0,
+ COUNTRY = 1 << 0,
+ PROVINCE = 1 << 1,
+ UNIT = 1 << 2,
+ ALL_TARGETS = (1 << 3) - 1
+ };
+
private:
/* If true, positive values will be green and negative values will be red.
* If false, the colours will be switced.
*/
const bool PROPERTY_CUSTOM_PREFIX(positive_good, is);
const format_t PROPERTY(format);
+ const target_t PROPERTY(targets);
std::string PROPERTY(localisation_key);
// TODO - format/precision, e.g. 80% vs 0.8 vs 0.800, 2 vs 2.0 vs 200%
ModifierEffect(
- std::string_view new_identifier, bool new_positive_good, format_t new_format, std::string_view new_localisation_key
+ std::string_view new_identifier, bool new_positive_good, format_t new_format, target_t mew_targets,
+ std::string_view new_localisation_key
);
public:
ModifierEffect(ModifierEffect&&) = default;
};
+ template<> struct enable_bitfield<ModifierEffect::target_t> : std::true_type {};
+
struct ModifierValue {
friend struct ModifierManager;
@@ -70,7 +82,8 @@ namespace OpenVic {
ModifierValue& operator*=(fixed_point_t const& right);
ModifierValue operator*(fixed_point_t const& right) const;
- void multiply_add(ModifierValue const& other, fixed_point_t multiplier);
+ void apply_target_filter(ModifierEffect::target_t targets);
+ void multiply_add_filter(ModifierValue const& other, fixed_point_t multiplier, ModifierEffect::target_t targets);
friend std::ostream& operator<<(std::ostream& stream, ModifierValue const& value);
};
@@ -167,6 +180,7 @@ namespace OpenVic {
bool add_modifier_effect(
std::string_view identifier, bool positive_good,
ModifierEffect::format_t format,
+ ModifierEffect::target_t targets,
std::string_view localisation_key = {}
);
diff --git a/src/openvic-simulation/modifier/ModifierSum.cpp b/src/openvic-simulation/modifier/ModifierSum.cpp
index f603a5b..312432a 100644
--- a/src/openvic-simulation/modifier/ModifierSum.cpp
+++ b/src/openvic-simulation/modifier/ModifierSum.cpp
@@ -19,9 +19,15 @@ bool ModifierSum::has_effect(ModifierEffect const& effect) const {
return value_sum.has_effect(effect);
}
-void ModifierSum::add_modifier(Modifier const& modifier, modifier_source_t source, fixed_point_t multiplier) {
- modifiers.emplace_back(&modifier, multiplier, source);
- value_sum.multiply_add(modifier, multiplier);
+void ModifierSum::add_modifier(
+ Modifier const& modifier, modifier_source_t const& source, fixed_point_t multiplier, ModifierEffect::target_t targets
+) {
+ using enum ModifierEffect::target_t;
+
+ if (multiplier != fixed_point_t::_0() && targets != NO_TARGETS) {
+ modifiers.emplace_back(&modifier, multiplier, source, targets);
+ value_sum.multiply_add_filter(modifier, multiplier, targets);
+ }
}
void ModifierSum::add_modifier_sum(ModifierSum const& modifier_sum) {
@@ -29,10 +35,22 @@ void ModifierSum::add_modifier_sum(ModifierSum const& modifier_sum) {
value_sum += modifier_sum.value_sum;
}
+void ModifierSum::add_modifier_sum_filter_targets(ModifierSum const& modifier_sum, ModifierEffect::target_t targets) {
+ using enum ModifierEffect::target_t;
+
+ for (modifier_entry_t const& modifier_entry : modifier_sum.modifiers) {
+ ModifierEffect::target_t new_targets = modifier_entry.targets & targets;
+
+ if (new_targets != NO_TARGETS) {
+ add_modifier(*modifier_entry.modifier, modifier_entry.source, modifier_entry.multiplier, new_targets);
+ }
+ }
+}
+
void ModifierSum::add_modifier_sum_exclude_source(ModifierSum const& modifier_sum, modifier_source_t const& excluded_source) {
for (modifier_entry_t const& modifier_entry : modifier_sum.modifiers) {
if (modifier_entry.source != excluded_source) {
- add_modifier(*modifier_entry.modifier, modifier_entry.source, modifier_entry.multiplier);
+ add_modifier(*modifier_entry.modifier, modifier_entry.source, modifier_entry.multiplier, modifier_entry.targets);
}
}
}
@@ -41,14 +59,18 @@ void ModifierSum::add_modifier_sum_exclude_source(ModifierSum const& modifier_su
std::vector<ModifierSum::modifier_entry_t> ModifierSum::get_contributing_modifiers(
ModifierEffect const& effect
) const {
+ using enum ModifierEffect::target_t;
+
std::vector<modifier_entry_t> ret;
for (modifier_entry_t const& modifier_entry : modifiers) {
- bool effect_found = false;
- const fixed_point_t value = modifier_entry.modifier->get_effect(effect, &effect_found);
+ if ((modifier_entry.targets & effect.get_targets()) != NO_TARGETS) {
+ bool effect_found = false;
+ const fixed_point_t value = modifier_entry.modifier->get_effect(effect, &effect_found);
- if (effect_found) {
- ret.push_back(modifier_entry);
+ if (effect_found) {
+ ret.push_back(modifier_entry);
+ }
}
}
diff --git a/src/openvic-simulation/modifier/ModifierSum.hpp b/src/openvic-simulation/modifier/ModifierSum.hpp
index 81ae871..b982ed1 100644
--- a/src/openvic-simulation/modifier/ModifierSum.hpp
+++ b/src/openvic-simulation/modifier/ModifierSum.hpp
@@ -1,6 +1,9 @@
#pragma once
+#include <variant>
+
#include "openvic-simulation/modifier/Modifier.hpp"
+#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
namespace OpenVic {
struct CountryInstance;
@@ -13,10 +16,12 @@ namespace OpenVic {
Modifier const* modifier;
fixed_point_t multiplier;
modifier_source_t source;
+ ModifierEffect::target_t targets;
constexpr modifier_entry_t(
- Modifier const* new_modifier, fixed_point_t new_multiplier, modifier_source_t const& new_source
- ) : modifier { new_modifier }, multiplier { new_multiplier }, source { new_source } {}
+ Modifier const* new_modifier, fixed_point_t new_multiplier, modifier_source_t const& new_source,
+ ModifierEffect::target_t new_targets
+ ) : modifier { new_modifier }, multiplier { new_multiplier }, source { new_source }, targets { new_targets } {}
};
private:
@@ -25,7 +30,10 @@ namespace OpenVic {
public:
ModifierSum() = default;
+ ModifierSum(ModifierSum const&) = default;
ModifierSum(ModifierSum&&) = default;
+ ModifierSum& operator=(ModifierSum const&) = default;
+ ModifierSum& operator=(ModifierSum&&) = default;
void clear();
bool empty();
@@ -33,8 +41,12 @@ namespace OpenVic {
fixed_point_t get_effect(ModifierEffect const& effect, bool* effect_found = nullptr) const;
bool has_effect(ModifierEffect const& effect) const;
- void add_modifier(Modifier const& modifier, modifier_source_t source, fixed_point_t multiplier = fixed_point_t::_1());
+ void add_modifier(
+ Modifier const& modifier, modifier_source_t const& source, fixed_point_t multiplier = fixed_point_t::_1(),
+ ModifierEffect::target_t targets = ModifierEffect::target_t::ALL_TARGETS
+ );
void add_modifier_sum(ModifierSum const& modifier_sum);
+ void add_modifier_sum_filter_targets(ModifierSum const& modifier_sum, ModifierEffect::target_t targets);
void add_modifier_sum_exclude_source(ModifierSum const& modifier_sum, modifier_source_t const& excluded_source);
std::vector<modifier_entry_t> get_contributing_modifiers(ModifierEffect const& effect) const;
diff --git a/src/openvic-simulation/politics/Rebel.cpp b/src/openvic-simulation/politics/Rebel.cpp
index fef61c0..395df49 100644
--- a/src/openvic-simulation/politics/Rebel.cpp
+++ b/src/openvic-simulation/politics/Rebel.cpp
@@ -175,6 +175,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;
@@ -184,12 +185,14 @@ 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"
+ ModifierManager::get_flat_identifier(identifier, "all"), is_positive_good, PROPORTION_DECIMAL, COUNTRY,
+ "TECH_REBEL_ORG_GAIN"
);
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,
+ ModifierManager::get_flat_identifier(identifier, rebel_type.get_identifier()), is_positive_good,
+ PROPORTION_DECIMAL, COUNTRY,
StringUtils::append_string_views("$", rebel_type.get_identifier(), "_title$ $TECH_REBEL_ORG_GAIN$")
);
}
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp
index e89d510..aeaeef5 100644
--- a/src/openvic-simulation/pop/Pop.cpp
+++ b/src/openvic-simulation/pop/Pop.cpp
@@ -654,6 +654,7 @@ bool PopManager::load_pop_bases_into_vector(
bool PopManager::generate_modifiers(ModifierManager& modifier_manager) const {
using enum ModifierEffect::format_t;
+ using enum ModifierEffect::target_t;
bool ret = true;
@@ -662,11 +663,12 @@ bool PopManager::generate_modifiers(ModifierManager& modifier_manager) const {
std::string_view suffix, bool is_positive_good
) -> void {
ret &= modifier_manager.add_modifier_effect(
- StringUtils::append_string_views(strata.get_identifier(), suffix), is_positive_good, PROPORTION_DECIMAL
+ StringUtils::append_string_views(strata.get_identifier(), suffix), is_positive_good, PROPORTION_DECIMAL,
+ COUNTRY
);
};
- strata_modifier("_income_modifier", true);
+ strata_modifier("_income_modifier", true); // Has no effect in game
strata_modifier("_vote", true);
strata_modifier("_life_needs", false);
diff --git a/src/openvic-simulation/research/Technology.cpp b/src/openvic-simulation/research/Technology.cpp
index a5256f3..3284193 100644
--- a/src/openvic-simulation/research/Technology.cpp
+++ b/src/openvic-simulation/research/Technology.cpp
@@ -197,13 +197,16 @@ bool TechnologyManager::load_technologies_file(
bool TechnologyManager::generate_modifiers(ModifierManager& modifier_manager) const {
using enum ModifierEffect::format_t;
+ using enum ModifierEffect::target_t;
bool ret = true;
for (TechnologyFolder const& folder : get_technology_folders()) {
const std::string modifier_identifier = StringUtils::append_string_views(folder.get_identifier(), "_research_bonus");
- ret &= modifier_manager.add_modifier_effect(modifier_identifier, true, PROPORTION_DECIMAL, modifier_identifier);
+ ret &= modifier_manager.add_modifier_effect(
+ modifier_identifier, true, PROPORTION_DECIMAL, COUNTRY, modifier_identifier
+ );
}
return ret;