diff options
Diffstat (limited to 'src/openvic-simulation/modifier')
-rw-r--r-- | src/openvic-simulation/modifier/Modifier.cpp | 474 | ||||
-rw-r--r-- | src/openvic-simulation/modifier/Modifier.hpp | 12 | ||||
-rw-r--r-- | src/openvic-simulation/modifier/ModifierEffectCache.cpp | 227 | ||||
-rw-r--r-- | src/openvic-simulation/modifier/ModifierEffectCache.hpp | 303 |
4 files changed, 862 insertions, 154 deletions
diff --git a/src/openvic-simulation/modifier/Modifier.cpp b/src/openvic-simulation/modifier/Modifier.cpp index 0867c1b..4e10c76 100644 --- a/src/openvic-simulation/modifier/Modifier.cpp +++ b/src/openvic-simulation/modifier/Modifier.cpp @@ -31,14 +31,29 @@ 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, ModifierEffect::target_t targets, - std::string_view localisation_key + ModifierEffect const*& effect_cache, 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, targets, localisation_key }); + + if (effect_cache != nullptr) { + Logger::error( + "Cache variable for modifier effect \"", identifier, "\" is already filled with modifier effect \"", + effect_cache->get_identifier(), "\"" + ); + return false; + } + + const bool ret = modifier_effects.add_item({ std::move(identifier), positive_good, format, targets, localisation_key }); + + if (ret) { + effect_cache = &modifier_effects.get_items().back(); + } + + return ret; } bool ModifierManager::setup_modifier_effects() { @@ -46,252 +61,405 @@ bool ModifierManager::setup_modifier_effects() { using enum ModifierEffect::format_t; using enum ModifierEffect::target_t; + /* Tech/inventions only */ - 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"); + ret &= add_modifier_effect( + modifier_effect_cache.cb_creation_speed, "cb_creation_speed", true, PROPORTION_DECIMAL, COUNTRY, "CB_MANUFACTURE_TECH" + ); + ret &= add_modifier_effect(modifier_effect_cache.combat_width, "combat_width", false, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect( + modifier_effect_cache.plurality, "plurality", true, PERCENTAGE_DECIMAL, COUNTRY, "TECH_PLURALITY" + ); + ret &= add_modifier_effect( + modifier_effect_cache.pop_growth, "pop_growth", true, PROPORTION_DECIMAL, COUNTRY, "TECH_POP_GROWTH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.regular_experience_level, "regular_experience_level", true, RAW_DECIMAL, COUNTRY, + "REGULAR_EXP_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.reinforce_rate, "reinforce_rate", true, PROPORTION_DECIMAL, COUNTRY, "REINFORCE_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.separatism, "seperatism", // paradox typo + false, PROPORTION_DECIMAL, COUNTRY, "SEPARATISM_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.shared_prestige, "shared_prestige", true, RAW_DECIMAL, COUNTRY, "SHARED_PRESTIGE_TECH" + ); + ret &= add_modifier_effect(modifier_effect_cache.tax_eff, "tax_eff", true, PERCENTAGE_DECIMAL, COUNTRY, "TECH_TAX_EFF"); /* Country Modifier Effects */ - ret &= add_modifier_effect("administrative_efficiency", true, PROPORTION_DECIMAL, COUNTRY); - ret &= add_modifier_effect( - "administrative_efficiency_modifier", true, PROPORTION_DECIMAL, COUNTRY, - ModifierEffect::make_default_modifier_effect_localisation_key("administrative_efficiency") - ); - 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, COUNTRY, - ModifierEffect::make_default_modifier_effect_localisation_key("civilization_progress") - ); - 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, COUNTRY, + ret &= add_modifier_effect( + modifier_effect_cache.administrative_efficiency, "administrative_efficiency", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.administrative_efficiency_modifier, "administrative_efficiency_modifier", true, + PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("administrative_efficiency") + ); + ret &= add_modifier_effect(modifier_effect_cache.artisan_input, "artisan_input", false, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect(modifier_effect_cache.artisan_output, "artisan_output", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect( + modifier_effect_cache.artisan_throughput, "artisan_throughput", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect(modifier_effect_cache.badboy, "badboy", false, RAW_DECIMAL, COUNTRY); + ret &= add_modifier_effect( + modifier_effect_cache.cb_generation_speed_modifier, "cb_generation_speed_modifier", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.civilization_progress_modifier, "civilization_progress_modifier", true, PROPORTION_DECIMAL, + COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("civilization_progress") + ); + ret &= add_modifier_effect( + modifier_effect_cache.colonial_life_rating, "colonial_life_rating", false, INT, COUNTRY, "COLONIAL_LIFE_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.colonial_migration, "colonial_migration", true, PROPORTION_DECIMAL, COUNTRY, + "COLONIAL_MIGRATION_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.colonial_points, "colonial_points", true, INT, COUNTRY, "COLONIAL_POINTS_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.colonial_prestige, "colonial_prestige", true, PROPORTION_DECIMAL, COUNTRY, + "COLONIAL_PRESTIGE_MODIFIER_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.core_pop_consciousness_modifier, "core_pop_consciousness_modifier", false, RAW_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.core_pop_militancy_modifier, "core_pop_militancy_modifier", false, RAW_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect(modifier_effect_cache.dig_in_cap, "dig_in_cap", true, INT, COUNTRY, "DIGIN_FROM_TECH"); + ret &= add_modifier_effect( + modifier_effect_cache.diplomatic_points, "diplomatic_points", true, PROPORTION_DECIMAL, COUNTRY, + "DIPLOMATIC_POINTS_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.diplomatic_points_modifier, "diplomatic_points_modifier", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("diplopoints_gain") ); - ret &= add_modifier_effect("education_efficiency", true, PROPORTION_DECIMAL, COUNTRY); ret &= add_modifier_effect( - "education_efficiency_modifier", true, PROPORTION_DECIMAL, COUNTRY, - ModifierEffect::make_default_modifier_effect_localisation_key("education_efficiency") + modifier_effect_cache.education_efficiency, "education_efficiency", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.education_efficiency_modifier, "education_efficiency_modifier", true, PROPORTION_DECIMAL, + COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("education_efficiency") ); - 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(modifier_effect_cache.factory_cost, "factory_cost", false, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect(modifier_effect_cache.factory_input, "factory_input", false, PROPORTION_DECIMAL, COUNTRY); ret &= add_modifier_effect( - "global_assimilation_rate", true, PROPORTION_DECIMAL, COUNTRY, + modifier_effect_cache.factory_maintenance, "factory_maintenance", false, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect(modifier_effect_cache.factory_output, "factory_output", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect( + modifier_effect_cache.factory_owner_cost, "factory_owner_cost", false, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.factory_throughput, "factory_throughput", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.global_assimilation_rate, "global_assimilation_rate", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("assimilation_rate") ); ret &= add_modifier_effect( - "global_immigrant_attract", true, PROPORTION_DECIMAL, COUNTRY, + modifier_effect_cache.global_immigrant_attract, "global_immigrant_attract", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("immigant_attract") ); - 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, COUNTRY, + modifier_effect_cache.global_pop_consciousness_modifier, "global_pop_consciousness_modifier", false, RAW_DECIMAL, + COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.global_pop_militancy_modifier, "global_pop_militancy_modifier", false, RAW_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.global_population_growth, "global_population_growth", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("population_growth") ); - 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(modifier_effect_cache.goods_demand, "goods_demand", false, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect(modifier_effect_cache.import_cost, "import_cost", false, PROPORTION_DECIMAL, COUNTRY); ret &= add_modifier_effect( - "influence_modifier", true, PROPORTION_DECIMAL, COUNTRY, + modifier_effect_cache.increase_research, "increase_research", true, PROPORTION_DECIMAL, COUNTRY, "INC_RES_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.influence, "influence", true, PROPORTION_DECIMAL, COUNTRY, "TECH_GP_INFLUENCE" + ); + ret &= add_modifier_effect( + modifier_effect_cache.influence_modifier, "influence_modifier", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("greatpower_influence_gain") ); - ret &= add_modifier_effect("issue_change_speed", true, PROPORTION_DECIMAL, COUNTRY); ret &= add_modifier_effect( - "land_attack_modifier", true, PROPORTION_DECIMAL, COUNTRY, + modifier_effect_cache.issue_change_speed, "issue_change_speed", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.land_attack_modifier, "land_attack_modifier", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("land_attack") ); - ret &= add_modifier_effect("land_attrition", false, PROPORTION_DECIMAL, COUNTRY, "LAND_ATTRITION_TECH"); ret &= add_modifier_effect( - "land_defense_modifier", true, PROPORTION_DECIMAL, COUNTRY, + modifier_effect_cache.land_attrition, "land_attrition", false, PROPORTION_DECIMAL, COUNTRY, "LAND_ATTRITION_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.land_defense_modifier, "land_defense_modifier", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("land_defense") ); - 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, COUNTRY, + modifier_effect_cache.land_organisation, "land_organisation", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.land_unit_start_experience, "land_unit_start_experience", true, RAW_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect(modifier_effect_cache.leadership, "leadership", true, RAW_DECIMAL, COUNTRY, "LEADERSHIP"); + ret &= add_modifier_effect( + modifier_effect_cache.leadership_modifier, "leadership_modifier", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("global_leadership_modifier") ); - 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, + modifier_effect_cache.literacy_con_impact, "literacy_con_impact", false, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect(modifier_effect_cache.loan_interest, "loan_interest", false, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect( + modifier_effect_cache.max_loan_modifier, "max_loan_modifier", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::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, + ret &= add_modifier_effect( + modifier_effect_cache.max_military_spending, "max_military_spending", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.max_national_focus, "max_national_focus", true, INT, COUNTRY, "TECH_MAX_FOCUS" + ); + ret &= add_modifier_effect( + modifier_effect_cache.max_social_spending, "max_social_spending", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect(modifier_effect_cache.max_tariff, "max_tariff", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect(modifier_effect_cache.max_tax, "max_tax", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect( + modifier_effect_cache.max_war_exhaustion, "max_war_exhaustion", true, PERCENTAGE_DECIMAL, COUNTRY, "MAX_WAR_EXHAUSTION" + ); + ret &= add_modifier_effect( + modifier_effect_cache.military_tactics, "military_tactics", true, PROPORTION_DECIMAL, COUNTRY, "MIL_TACTICS_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.min_military_spending, "min_military_spending", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.min_social_spending, "min_social_spending", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect(modifier_effect_cache.min_tariff, "min_tariff", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect(modifier_effect_cache.min_tax, "min_tax", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect( + modifier_effect_cache.minimum_wage, "minimum_wage", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::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, + modifier_effect_cache.mobilisation_economy_impact, "mobilisation_economy_impact", false, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.mobilisation_size, "mobilisation_size", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.mobilization_impact, "mobilization_impact", false, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.naval_attack_modifier, "naval_attack_modifier", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::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, + modifier_effect_cache.naval_attrition, "naval_attrition", false, PROPORTION_DECIMAL, COUNTRY, "NAVAL_ATTRITION_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.naval_defense_modifier, "naval_defense_modifier", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::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, + ret &= add_modifier_effect( + modifier_effect_cache.naval_organisation, "naval_organisation", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.naval_unit_start_experience, "naval_unit_start_experience", true, RAW_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.non_accepted_pop_consciousness_modifier, "non_accepted_pop_consciousness_modifier", false, + RAW_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.non_accepted_pop_militancy_modifier, "non_accepted_pop_militancy_modifier", false, RAW_DECIMAL, + COUNTRY + ); + ret &= add_modifier_effect(modifier_effect_cache.org_regain, "org_regain", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect(modifier_effect_cache.pension_level, "pension_level", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect( + modifier_effect_cache.permanent_prestige, "permanent_prestige", true, RAW_DECIMAL, COUNTRY, "PERMANENT_PRESTIGE_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.political_reform_desire, "political_reform_desire", false, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.poor_savings_modifier, "poor_savings_modifier", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect(modifier_effect_cache.prestige, "prestige", true, RAW_DECIMAL, COUNTRY); + ret &= add_modifier_effect(modifier_effect_cache.reinforce_speed, "reinforce_speed", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect(modifier_effect_cache.research_points, "research_points", true, RAW_DECIMAL, COUNTRY); + ret &= add_modifier_effect( + modifier_effect_cache.research_points_modifier, "research_points_modifier", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.research_points_on_conquer, "research_points_on_conquer", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect(modifier_effect_cache.rgo_output, "rgo_output", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect(modifier_effect_cache.rgo_throughput, "rgo_throughput", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect( + modifier_effect_cache.ruling_party_support, "ruling_party_support", true, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.self_unciv_economic_modifier, "self_unciv_economic_modifier", false, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("self_unciv_economic") ); ret &= add_modifier_effect( - "self_unciv_military_modifier", false, PROPORTION_DECIMAL, COUNTRY, + modifier_effect_cache.self_unciv_military_modifier, "self_unciv_military_modifier", false, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("self_unciv_military") ); - 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, COUNTRY, + modifier_effect_cache.social_reform_desire, "social_reform_desire", false, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.soldier_to_pop_loss, "soldier_to_pop_loss", true, PROPORTION_DECIMAL, COUNTRY, + "SOLDIER_TO_POP_LOSS_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.supply_consumption, "supply_consumption", false, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.supply_range, "supply_range", true, PROPORTION_DECIMAL, COUNTRY, "SUPPLY_RANGE_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.suppression_points_modifier, "suppression_points_modifier", true, PROPORTION_DECIMAL, COUNTRY, + "SUPPRESSION_TECH" + ); + ret &= add_modifier_effect( + modifier_effect_cache.tariff_efficiency_modifier, "tariff_efficiency_modifier", true, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("tariff_efficiency") ); - ret &= add_modifier_effect("tax_efficiency", true, PROPORTION_DECIMAL, COUNTRY); - ret &= add_modifier_effect("unemployment_benefit", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect(modifier_effect_cache.tax_efficiency, "tax_efficiency", true, PROPORTION_DECIMAL, COUNTRY); + ret &= add_modifier_effect( + modifier_effect_cache.unemployment_benefit, "unemployment_benefit", true, PROPORTION_DECIMAL, COUNTRY + ); ret &= add_modifier_effect( - "unciv_economic_modifier", false, PROPORTION_DECIMAL, COUNTRY, + modifier_effect_cache.unciv_economic_modifier, "unciv_economic_modifier", false, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("unciv_economic") ); ret &= add_modifier_effect( - "unciv_military_modifier", false, PROPORTION_DECIMAL, COUNTRY, + modifier_effect_cache.unciv_military_modifier, "unciv_military_modifier", false, PROPORTION_DECIMAL, COUNTRY, ModifierEffect::make_default_modifier_effect_localisation_key("unciv_military") ); - ret &= add_modifier_effect("unit_recruitment_time", false, PROPORTION_DECIMAL, COUNTRY); - ret &= add_modifier_effect("war_exhaustion", false, PROPORTION_DECIMAL, COUNTRY, "WAR_EXHAUST_BATTLES"); + ret &= add_modifier_effect( + modifier_effect_cache.unit_recruitment_time, "unit_recruitment_time", false, PROPORTION_DECIMAL, COUNTRY + ); + ret &= add_modifier_effect( + modifier_effect_cache.war_exhaustion, "war_exhaustion", false, PROPORTION_DECIMAL, COUNTRY, "WAR_EXHAUST_BATTLES" + ); /* Province Modifier Effects */ - 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, PROVINCE, + modifier_effect_cache.assimilation_rate, "assimilation_rate", true, PROPORTION_DECIMAL, PROVINCE + ); + ret &= add_modifier_effect( + modifier_effect_cache.boost_strongest_party, "boost_strongest_party", false, PROPORTION_DECIMAL, PROVINCE + ); + ret &= add_modifier_effect( + modifier_effect_cache.farm_rgo_eff, "farm_rgo_eff", true, PROPORTION_DECIMAL, PROVINCE, "TECH_FARM_OUTPUT" + ); + ret &= add_modifier_effect( + modifier_effect_cache.farm_rgo_size, "farm_rgo_size", true, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("farm_size") ); ret &= add_modifier_effect( - "immigrant_attract", true, PROPORTION_DECIMAL, PROVINCE, + modifier_effect_cache.immigrant_attract, "immigrant_attract", true, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("immigant_attract") ); ret &= add_modifier_effect( - "immigrant_push", false, PROPORTION_DECIMAL, PROVINCE, + modifier_effect_cache.immigrant_push, "immigrant_push", false, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("immigant_push") ); - ret &= add_modifier_effect("life_rating", true, PROPORTION_DECIMAL, PROVINCE); + ret &= add_modifier_effect(modifier_effect_cache.life_rating, "life_rating", true, PROPORTION_DECIMAL, PROVINCE); ret &= add_modifier_effect( - "local_artisan_input", false, PROPORTION_DECIMAL, PROVINCE, + modifier_effect_cache.local_artisan_input, "local_artisan_input", false, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("artisan_input") ); ret &= add_modifier_effect( - "local_artisan_output", true, PROPORTION_DECIMAL, PROVINCE, + modifier_effect_cache.local_artisan_output, "local_artisan_output", true, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("artisan_output") ); ret &= add_modifier_effect( - "local_artisan_throughput", true, PROPORTION_DECIMAL, PROVINCE, + modifier_effect_cache.local_artisan_throughput, "local_artisan_throughput", true, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("artisan_throughput") ); ret &= add_modifier_effect( - "local_factory_input", false, PROPORTION_DECIMAL, PROVINCE, + modifier_effect_cache.local_factory_input, "local_factory_input", false, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("factory_input") ); ret &= add_modifier_effect( - "local_factory_output", true, PROPORTION_DECIMAL, PROVINCE, + modifier_effect_cache.local_factory_output, "local_factory_output", true, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("factory_output") ); ret &= add_modifier_effect( - "local_factory_throughput", true, PROPORTION_DECIMAL, PROVINCE, + modifier_effect_cache.local_factory_throughput, "local_factory_throughput", true, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("factory_throughput") ); - ret &= add_modifier_effect("local_repair", true, PROPORTION_DECIMAL, PROVINCE); + ret &= add_modifier_effect(modifier_effect_cache.local_repair, "local_repair", true, PROPORTION_DECIMAL, PROVINCE); ret &= add_modifier_effect( - "local_rgo_output", true, PROPORTION_DECIMAL, PROVINCE, + modifier_effect_cache.local_rgo_output, "local_rgo_output", true, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("rgo_output") ); ret &= add_modifier_effect( - "local_rgo_throughput", true, PROPORTION_DECIMAL, PROVINCE, + modifier_effect_cache.local_rgo_throughput, "local_rgo_throughput", true, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("rgo_throughput") ); ret &= add_modifier_effect( - "local_ruling_party_support", true, PROPORTION_DECIMAL, PROVINCE, + modifier_effect_cache.local_ruling_party_support, "local_ruling_party_support", true, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("ruling_party_support") ); - 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, PROVINCE, + modifier_effect_cache.local_ship_build, "local_ship_build", false, PROPORTION_DECIMAL, PROVINCE + ); + ret &= add_modifier_effect(modifier_effect_cache.max_attrition, "max_attrition", false, RAW_DECIMAL, PROVINCE); + ret &= add_modifier_effect( + modifier_effect_cache.mine_rgo_eff, "mine_rgo_eff", true, PROPORTION_DECIMAL, PROVINCE, "TECH_MINE_OUTPUT" + ); + ret &= add_modifier_effect( + modifier_effect_cache.mine_rgo_size, "mine_rgo_size", true, PROPORTION_DECIMAL, PROVINCE, ModifierEffect::make_default_modifier_effect_localisation_key("mine_size") ); - 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); + ret &= add_modifier_effect(modifier_effect_cache.movement_cost, "movement_cost", false, PROPORTION_DECIMAL, PROVINCE); + ret &= add_modifier_effect( + modifier_effect_cache.number_of_voters, "number_of_voters", false, PROPORTION_DECIMAL, PROVINCE + ); + ret &= add_modifier_effect( + modifier_effect_cache.pop_consciousness_modifier, "pop_consciousness_modifier", false, RAW_DECIMAL, PROVINCE + ); + ret &= add_modifier_effect( + modifier_effect_cache.pop_militancy_modifier, "pop_militancy_modifier", false, RAW_DECIMAL, PROVINCE + ); + ret &= add_modifier_effect( + modifier_effect_cache.population_growth, "population_growth", true, PROPORTION_DECIMAL, PROVINCE + ); + ret &= add_modifier_effect(modifier_effect_cache.supply_limit, "supply_limit", true, RAW_DECIMAL, PROVINCE); /* Military Modifier Effects */ - 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"); + ret &= add_modifier_effect(modifier_effect_cache.attack, "attack", true, INT, UNIT, "TRAIT_ATTACK"); + ret &= add_modifier_effect(modifier_effect_cache.attrition, "attrition", false, RAW_DECIMAL, UNIT, "ATTRITION"); + ret &= add_modifier_effect(modifier_effect_cache.defence, "defence", true, INT, UNIT, "TRAIT_DEFEND"); + ret &= add_modifier_effect( + modifier_effect_cache.experience, "experience", true, PROPORTION_DECIMAL, UNIT, "TRAIT_EXPERIENCE" + ); + ret &= add_modifier_effect(modifier_effect_cache.morale, "morale", true, PROPORTION_DECIMAL, UNIT, "TRAIT_MORALE"); + ret &= add_modifier_effect( + modifier_effect_cache.organisation, "organisation", true, PROPORTION_DECIMAL, UNIT, "TRAIT_ORGANISATION" + ); + ret &= add_modifier_effect( + modifier_effect_cache.reconnaissance, "reconnaissance", true, PROPORTION_DECIMAL, UNIT, "TRAIT_RECONAISSANCE" + ); + ret &= add_modifier_effect(modifier_effect_cache.reliability, "reliability", true, RAW_DECIMAL, UNIT, "TRAIT_RELIABILITY"); + ret &= add_modifier_effect(modifier_effect_cache.speed, "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 28e56cd..49194cd 100644 --- a/src/openvic-simulation/modifier/Modifier.hpp +++ b/src/openvic-simulation/modifier/Modifier.hpp @@ -1,6 +1,7 @@ #pragma once #include "openvic-simulation/modifier/ModifierEffect.hpp" +#include "openvic-simulation/modifier/ModifierEffectCache.hpp" #include "openvic-simulation/modifier/ModifierValue.hpp" #include "openvic-simulation/modifier/StaticModifierCache.hpp" #include "openvic-simulation/scripts/ConditionScript.hpp" @@ -74,6 +75,12 @@ namespace OpenVic { struct ModifierManager { friend struct StaticModifierCache; + friend struct BuildingTypeManager; + friend struct GoodDefinitionManager; + friend struct UnitTypeManager; + friend struct RebelManager; + friend struct PopManager; + friend struct TechnologyManager; /* Some ModifierEffects are generated mid-load, such as max/min count modifiers for each building, so * we can't lock it until loading is over. This means we can't rely on locking for pointer stability, @@ -87,6 +94,7 @@ namespace OpenVic { IdentifierRegistry<Modifier> IDENTIFIER_REGISTRY(static_modifier); IdentifierRegistry<TriggeredModifier> IDENTIFIER_REGISTRY(triggered_modifier); + ModifierEffectCache PROPERTY(modifier_effect_cache); StaticModifierCache PROPERTY(static_modifier_cache); /* effect_validator takes in ModifierEffect const& */ @@ -97,7 +105,9 @@ namespace OpenVic { public: bool add_modifier_effect( - std::string_view identifier, bool positive_good, + ModifierEffect const*& effect_cache, + 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/ModifierEffectCache.cpp b/src/openvic-simulation/modifier/ModifierEffectCache.cpp new file mode 100644 index 0000000..b5d8a31 --- /dev/null +++ b/src/openvic-simulation/modifier/ModifierEffectCache.cpp @@ -0,0 +1,227 @@ +#include "ModifierEffectCache.hpp" + +#include "openvic-simulation/economy/BuildingType.hpp" +#include "openvic-simulation/economy/GoodDefinition.hpp" +#include "openvic-simulation/politics/Rebel.hpp" +#include "openvic-simulation/research/Technology.hpp" + +using namespace OpenVic; + +ModifierEffectCache::building_type_effects_t::building_type_effects_t() + : min_level { nullptr }, + max_level { nullptr } {} + +ModifierEffectCache::good_effects_t::good_effects_t() + : artisan_goods_input { nullptr }, + artisan_goods_output { nullptr }, + artisan_goods_throughput { nullptr }, + factory_goods_input { nullptr }, + factory_goods_output { nullptr }, + factory_goods_throughput { nullptr }, + rgo_goods_output { nullptr }, + rgo_goods_throughput { nullptr }, + rgo_size { nullptr } {} + +ModifierEffectCache::unit_type_effects_t::unit_type_effects_t() + : attack { nullptr }, + defence { nullptr }, + default_organisation { nullptr }, + maximum_speed { nullptr }, + build_time { nullptr }, + supply_consumption { nullptr } {} + +ModifierEffectCache::regiment_type_effects_t::regiment_type_effects_t() + : unit_type_effects_t {}, + reconnaissance { nullptr }, + discipline { nullptr }, + support { nullptr }, + maneuver { nullptr }, + siege { nullptr } {} + +ModifierEffectCache::ship_type_effects_t::ship_type_effects_t() + : unit_type_effects_t {}, + colonial_points { nullptr }, + supply_consumption_score { nullptr }, + hull { nullptr }, + gun_power { nullptr }, + fire_range { nullptr }, + evasion { nullptr }, + torpedo_attack { nullptr } {} + +ModifierEffectCache::strata_effects_t::strata_effects_t() + : income_modifier { nullptr }, + vote { nullptr }, + life_needs { nullptr }, + everyday_needs { nullptr }, + luxury_needs { nullptr } {} + +ModifierEffectCache::ModifierEffectCache() + : /* Tech/inventions only */ + cb_creation_speed { nullptr }, + combat_width { nullptr }, + plurality { nullptr }, + pop_growth { nullptr }, + regular_experience_level { nullptr }, + reinforce_rate { nullptr }, + separatism { nullptr }, + shared_prestige { nullptr }, + tax_eff { nullptr }, + + /* Country Modifier Effects */ + administrative_efficiency { nullptr }, + administrative_efficiency_modifier { nullptr }, + artisan_input { nullptr }, + artisan_output { nullptr }, + artisan_throughput { nullptr }, + badboy { nullptr }, + cb_generation_speed_modifier { nullptr }, + civilization_progress_modifier { nullptr }, + colonial_life_rating { nullptr }, + colonial_migration { nullptr }, + colonial_points { nullptr }, + colonial_prestige { nullptr }, + core_pop_consciousness_modifier { nullptr }, + core_pop_militancy_modifier { nullptr }, + dig_in_cap { nullptr }, + diplomatic_points { nullptr }, + diplomatic_points_modifier { nullptr }, + education_efficiency { nullptr }, + education_efficiency_modifier { nullptr }, + factory_cost { nullptr }, + factory_input { nullptr }, + factory_maintenance { nullptr }, + factory_output { nullptr }, + factory_owner_cost { nullptr }, + factory_throughput { nullptr }, + global_assimilation_rate { nullptr }, + global_immigrant_attract { nullptr }, + global_pop_consciousness_modifier { nullptr }, + global_pop_militancy_modifier { nullptr }, + global_population_growth { nullptr }, + goods_demand { nullptr }, + import_cost { nullptr }, + increase_research { nullptr }, + influence { nullptr }, + influence_modifier { nullptr }, + issue_change_speed { nullptr }, + land_attack_modifier { nullptr }, + land_attrition { nullptr }, + land_defense_modifier { nullptr }, + land_organisation { nullptr }, + land_unit_start_experience { nullptr }, + leadership { nullptr }, + leadership_modifier { nullptr }, + literacy_con_impact { nullptr }, + loan_interest { nullptr }, + max_loan_modifier { nullptr }, + max_military_spending { nullptr }, + max_national_focus { nullptr }, + max_social_spending { nullptr }, + max_tariff { nullptr }, + max_tax { nullptr }, + max_war_exhaustion { nullptr }, + military_tactics { nullptr }, + min_military_spending { nullptr }, + min_social_spending { nullptr }, + min_tariff { nullptr }, + min_tax { nullptr }, + minimum_wage { nullptr }, + mobilisation_economy_impact { nullptr }, + mobilisation_size { nullptr }, + mobilization_impact { nullptr }, + naval_attack_modifier { nullptr }, + naval_attrition { nullptr }, + naval_defense_modifier { nullptr }, + naval_organisation { nullptr }, + naval_unit_start_experience { nullptr }, + non_accepted_pop_consciousness_modifier { nullptr }, + non_accepted_pop_militancy_modifier { nullptr }, + org_regain { nullptr }, + pension_level { nullptr }, + permanent_prestige { nullptr }, + political_reform_desire { nullptr }, + poor_savings_modifier { nullptr }, + prestige { nullptr }, + reinforce_speed { nullptr }, + research_points { nullptr }, + research_points_modifier { nullptr }, + research_points_on_conquer { nullptr }, + rgo_output { nullptr }, + rgo_throughput { nullptr }, + ruling_party_support { nullptr }, + self_unciv_economic_modifier { nullptr }, + self_unciv_military_modifier { nullptr }, + social_reform_desire { nullptr }, + soldier_to_pop_loss { nullptr }, + supply_consumption { nullptr }, + supply_range { nullptr }, + suppression_points_modifier { nullptr }, + tariff_efficiency_modifier { nullptr }, + tax_efficiency { nullptr }, + unemployment_benefit { nullptr }, + unciv_economic_modifier { nullptr }, + unciv_military_modifier { nullptr }, + unit_recruitment_time { nullptr }, + war_exhaustion { nullptr }, + + /* Province Modifier Effects */ + assimilation_rate { nullptr }, + boost_strongest_party { nullptr }, + farm_rgo_eff { nullptr }, + farm_rgo_size { nullptr }, + immigrant_attract { nullptr }, + immigrant_push { nullptr }, + life_rating { nullptr }, + local_artisan_input { nullptr }, + local_artisan_output { nullptr }, + local_artisan_throughput { nullptr }, + local_factory_input { nullptr }, + local_factory_output { nullptr }, + local_factory_throughput { nullptr }, + local_repair { nullptr }, + local_rgo_output { nullptr }, + local_rgo_throughput { nullptr }, + local_ruling_party_support { nullptr }, + local_ship_build { nullptr }, + max_attrition { nullptr }, + mine_rgo_eff { nullptr }, + mine_rgo_size { nullptr }, + movement_cost { nullptr }, + number_of_voters { nullptr }, + pop_consciousness_modifier { nullptr }, + pop_militancy_modifier { nullptr }, + population_growth { nullptr }, + supply_limit { nullptr }, + + /* Military Modifier Effects */ + attack { nullptr }, + attrition { nullptr }, + defence { nullptr }, + experience { nullptr }, + morale { nullptr }, + organisation { nullptr }, + reconnaissance { nullptr }, + reliability { nullptr }, + speed { nullptr }, + + /* BuildingType Effects */ + building_type_effects { nullptr }, + + /* GoodDefinition Effects */ + good_effects { nullptr }, + + /* UnitType Effects */ + army_base_effects {}, + regiment_type_effects { nullptr }, + navy_base_effects {}, + ship_type_effects { nullptr }, + + /* Rebel Effects */ + rebel_org_gain_all { nullptr }, + rebel_org_gain_effects { nullptr }, + + /* Pop Effects */ + strata_effects { nullptr }, + + /* Technology Effects */ + research_bonus_effects { nullptr } {} diff --git a/src/openvic-simulation/modifier/ModifierEffectCache.hpp b/src/openvic-simulation/modifier/ModifierEffectCache.hpp new file mode 100644 index 0000000..3c349e9 --- /dev/null +++ b/src/openvic-simulation/modifier/ModifierEffectCache.hpp @@ -0,0 +1,303 @@ +#pragma once + +#include "openvic-simulation/military/UnitType.hpp" +#include "openvic-simulation/types/IndexedMap.hpp" +#include "openvic-simulation/utility/Getters.hpp" + +namespace OpenVic { + struct ModifierEffect; + struct ModifierManager; + + struct BuildingTypeManager; + struct BuildingType; + struct GoodDefinitionManager; + struct GoodDefinition; + struct RebelManager; + struct RebelType; + struct PopManager; + struct Strata; + struct TechnologyManager; + struct TechnologyFolder; + + struct ModifierEffectCache { + friend struct ModifierManager; + friend struct BuildingTypeManager; + friend struct GoodDefinitionManager; + friend struct UnitTypeManager; + friend struct RebelManager; + friend struct PopManager; + friend struct TechnologyManager; + + private: + /* Tech/inventions only */ + ModifierEffect const* PROPERTY(cb_creation_speed); + ModifierEffect const* PROPERTY(combat_width); + ModifierEffect const* PROPERTY(plurality); + ModifierEffect const* PROPERTY(pop_growth); + ModifierEffect const* PROPERTY(regular_experience_level); + ModifierEffect const* PROPERTY(reinforce_rate); + ModifierEffect const* PROPERTY(separatism); + ModifierEffect const* PROPERTY(shared_prestige); + ModifierEffect const* PROPERTY(tax_eff); + + /* Country Modifier Effects */ + ModifierEffect const* PROPERTY(administrative_efficiency); + ModifierEffect const* PROPERTY(administrative_efficiency_modifier); + ModifierEffect const* PROPERTY(artisan_input); + ModifierEffect const* PROPERTY(artisan_output); + ModifierEffect const* PROPERTY(artisan_throughput); + ModifierEffect const* PROPERTY(badboy); + ModifierEffect const* PROPERTY(cb_generation_speed_modifier); + ModifierEffect const* PROPERTY(civilization_progress_modifier); + ModifierEffect const* PROPERTY(colonial_life_rating); + ModifierEffect const* PROPERTY(colonial_migration); + ModifierEffect const* PROPERTY(colonial_points); + ModifierEffect const* PROPERTY(colonial_prestige); + ModifierEffect const* PROPERTY(core_pop_consciousness_modifier); + ModifierEffect const* PROPERTY(core_pop_militancy_modifier); + ModifierEffect const* PROPERTY(dig_in_cap); + ModifierEffect const* PROPERTY(diplomatic_points); + ModifierEffect const* PROPERTY(diplomatic_points_modifier); + ModifierEffect const* PROPERTY(education_efficiency); + ModifierEffect const* PROPERTY(education_efficiency_modifier); + ModifierEffect const* PROPERTY(factory_cost); + ModifierEffect const* PROPERTY(factory_input); + ModifierEffect const* PROPERTY(factory_maintenance); + ModifierEffect const* PROPERTY(factory_output); + ModifierEffect const* PROPERTY(factory_owner_cost); + ModifierEffect const* PROPERTY(factory_throughput); + ModifierEffect const* PROPERTY(global_assimilation_rate); + ModifierEffect const* PROPERTY(global_immigrant_attract); + ModifierEffect const* PROPERTY(global_pop_consciousness_modifier); + ModifierEffect const* PROPERTY(global_pop_militancy_modifier); + ModifierEffect const* PROPERTY(global_population_growth); + ModifierEffect const* PROPERTY(goods_demand); + ModifierEffect const* PROPERTY(import_cost); + ModifierEffect const* PROPERTY(increase_research); + ModifierEffect const* PROPERTY(influence); + ModifierEffect const* PROPERTY(influence_modifier); + ModifierEffect const* PROPERTY(issue_change_speed); + ModifierEffect const* PROPERTY(land_attack_modifier); + ModifierEffect const* PROPERTY(land_attrition); + ModifierEffect const* PROPERTY(land_defense_modifier); + ModifierEffect const* PROPERTY(land_organisation); + ModifierEffect const* PROPERTY(land_unit_start_experience); + ModifierEffect const* PROPERTY(leadership); + ModifierEffect const* PROPERTY(leadership_modifier); + ModifierEffect const* PROPERTY(literacy_con_impact); + ModifierEffect const* PROPERTY(loan_interest); + ModifierEffect const* PROPERTY(max_loan_modifier); + ModifierEffect const* PROPERTY(max_military_spending); + ModifierEffect const* PROPERTY(max_national_focus); + ModifierEffect const* PROPERTY(max_social_spending); + ModifierEffect const* PROPERTY(max_tariff); + ModifierEffect const* PROPERTY(max_tax); + ModifierEffect const* PROPERTY(max_war_exhaustion); + ModifierEffect const* PROPERTY(military_tactics); + ModifierEffect const* PROPERTY(min_military_spending); + ModifierEffect const* PROPERTY(min_social_spending); + ModifierEffect const* PROPERTY(min_tariff); + ModifierEffect const* PROPERTY(min_tax); + ModifierEffect const* PROPERTY(minimum_wage); + ModifierEffect const* PROPERTY(mobilisation_economy_impact); + ModifierEffect const* PROPERTY(mobilisation_size); + ModifierEffect const* PROPERTY(mobilization_impact); + ModifierEffect const* PROPERTY(naval_attack_modifier); + ModifierEffect const* PROPERTY(naval_attrition); + ModifierEffect const* PROPERTY(naval_defense_modifier); + ModifierEffect const* PROPERTY(naval_organisation); + ModifierEffect const* PROPERTY(naval_unit_start_experience); + ModifierEffect const* PROPERTY(non_accepted_pop_consciousness_modifier); + ModifierEffect const* PROPERTY(non_accepted_pop_militancy_modifier); + ModifierEffect const* PROPERTY(org_regain); + ModifierEffect const* PROPERTY(pension_level); + ModifierEffect const* PROPERTY(permanent_prestige); + ModifierEffect const* PROPERTY(political_reform_desire); + ModifierEffect const* PROPERTY(poor_savings_modifier); + ModifierEffect const* PROPERTY(prestige); + ModifierEffect const* PROPERTY(reinforce_speed); + ModifierEffect const* PROPERTY(research_points); + ModifierEffect const* PROPERTY(research_points_modifier); + ModifierEffect const* PROPERTY(research_points_on_conquer); + ModifierEffect const* PROPERTY(rgo_output); + ModifierEffect const* PROPERTY(rgo_throughput); + ModifierEffect const* PROPERTY(ruling_party_support); + ModifierEffect const* PROPERTY(self_unciv_economic_modifier); + ModifierEffect const* PROPERTY(self_unciv_military_modifier); + ModifierEffect const* PROPERTY(social_reform_desire); + ModifierEffect const* PROPERTY(soldier_to_pop_loss); + ModifierEffect const* PROPERTY(supply_consumption); + ModifierEffect const* PROPERTY(supply_range); + ModifierEffect const* PROPERTY(suppression_points_modifier); + ModifierEffect const* PROPERTY(tariff_efficiency_modifier); + ModifierEffect const* PROPERTY(tax_efficiency); + ModifierEffect const* PROPERTY(unemployment_benefit); + ModifierEffect const* PROPERTY(unciv_economic_modifier); + ModifierEffect const* PROPERTY(unciv_military_modifier); + ModifierEffect const* PROPERTY(unit_recruitment_time); + ModifierEffect const* PROPERTY(war_exhaustion); + + /* Province Modifier Effects */ + ModifierEffect const* PROPERTY(assimilation_rate); + ModifierEffect const* PROPERTY(boost_strongest_party); + ModifierEffect const* PROPERTY(farm_rgo_eff); + ModifierEffect const* PROPERTY(farm_rgo_size); + ModifierEffect const* PROPERTY(immigrant_attract); + ModifierEffect const* PROPERTY(immigrant_push); + ModifierEffect const* PROPERTY(life_rating); + ModifierEffect const* PROPERTY(local_artisan_input); + ModifierEffect const* PROPERTY(local_artisan_output); + ModifierEffect const* PROPERTY(local_artisan_throughput); + ModifierEffect const* PROPERTY(local_factory_input); + ModifierEffect const* PROPERTY(local_factory_output); + ModifierEffect const* PROPERTY(local_factory_throughput); + ModifierEffect const* PROPERTY(local_repair); + ModifierEffect const* PROPERTY(local_rgo_output); + ModifierEffect const* PROPERTY(local_rgo_throughput); + ModifierEffect const* PROPERTY(local_ruling_party_support); + ModifierEffect const* PROPERTY(local_ship_build); + ModifierEffect const* PROPERTY(max_attrition); + ModifierEffect const* PROPERTY(mine_rgo_eff); + ModifierEffect const* PROPERTY(mine_rgo_size); + ModifierEffect const* PROPERTY(movement_cost); + ModifierEffect const* PROPERTY(number_of_voters); + ModifierEffect const* PROPERTY(pop_consciousness_modifier); + ModifierEffect const* PROPERTY(pop_militancy_modifier); + ModifierEffect const* PROPERTY(population_growth); + ModifierEffect const* PROPERTY(supply_limit); + + /* Military Modifier Effects */ + ModifierEffect const* PROPERTY(attack); + ModifierEffect const* PROPERTY(attrition); + ModifierEffect const* PROPERTY(defence); + ModifierEffect const* PROPERTY(experience); + ModifierEffect const* PROPERTY(morale); + ModifierEffect const* PROPERTY(organisation); + ModifierEffect const* PROPERTY(reconnaissance); + ModifierEffect const* PROPERTY(reliability); + ModifierEffect const* PROPERTY(speed); + + /* BuildingType Effects */ + public: + struct building_type_effects_t { + friend struct BuildingTypeManager; + + private: + ModifierEffect const* PROPERTY(min_level); + ModifierEffect const* PROPERTY(max_level); + + public: + building_type_effects_t(); + }; + + private: + IndexedMap<BuildingType, building_type_effects_t> PROPERTY(building_type_effects); + + /* GoodDefinition Effects */ + public: + struct good_effects_t { + friend struct GoodDefinitionManager; + + private: + ModifierEffect const* PROPERTY(artisan_goods_input); + ModifierEffect const* PROPERTY(artisan_goods_output); + ModifierEffect const* PROPERTY(artisan_goods_throughput); + ModifierEffect const* PROPERTY(factory_goods_input); + ModifierEffect const* PROPERTY(factory_goods_output); + ModifierEffect const* PROPERTY(factory_goods_throughput); + ModifierEffect const* PROPERTY(rgo_goods_output); + ModifierEffect const* PROPERTY(rgo_goods_throughput); + ModifierEffect const* PROPERTY(rgo_size); + + public: + good_effects_t(); + }; + + private: + IndexedMap<GoodDefinition, good_effects_t> PROPERTY(good_effects); + + /* UnitType Effects */ + public: + struct unit_type_effects_t { + friend struct UnitTypeManager; + + private: + ModifierEffect const* PROPERTY(attack); + ModifierEffect const* PROPERTY(defence); + ModifierEffect const* PROPERTY(default_organisation); + ModifierEffect const* PROPERTY(maximum_speed); + ModifierEffect const* PROPERTY(build_time); + ModifierEffect const* PROPERTY(supply_consumption); + + protected: + unit_type_effects_t(); + }; + + struct regiment_type_effects_t : unit_type_effects_t { + friend struct UnitTypeManager; + + private: + ModifierEffect const* PROPERTY(reconnaissance); + ModifierEffect const* PROPERTY(discipline); + ModifierEffect const* PROPERTY(support); + ModifierEffect const* PROPERTY(maneuver); + ModifierEffect const* PROPERTY(siege); + + public: + regiment_type_effects_t(); + }; + + struct ship_type_effects_t : unit_type_effects_t { + friend struct UnitTypeManager; + + private: + ModifierEffect const* PROPERTY(colonial_points); + ModifierEffect const* PROPERTY(supply_consumption_score); + ModifierEffect const* PROPERTY(hull); + ModifierEffect const* PROPERTY(gun_power); + ModifierEffect const* PROPERTY(fire_range); + ModifierEffect const* PROPERTY(evasion); + ModifierEffect const* PROPERTY(torpedo_attack); + + public: + ship_type_effects_t(); + }; + + private: + regiment_type_effects_t PROPERTY(army_base_effects); + IndexedMap<RegimentType, regiment_type_effects_t> PROPERTY(regiment_type_effects); + ship_type_effects_t PROPERTY(navy_base_effects); + IndexedMap<ShipType, ship_type_effects_t> PROPERTY(ship_type_effects); + + /* Rebel Effects */ + ModifierEffect const* PROPERTY(rebel_org_gain_all); + IndexedMap<RebelType, ModifierEffect const*> PROPERTY(rebel_org_gain_effects); + + /* Pop Effects */ + public: + struct strata_effects_t { + friend struct PopManager; + + private: + ModifierEffect const* PROPERTY(income_modifier); + ModifierEffect const* PROPERTY(vote); + ModifierEffect const* PROPERTY(life_needs); + ModifierEffect const* PROPERTY(everyday_needs); + ModifierEffect const* PROPERTY(luxury_needs); + + public: + strata_effects_t(); + }; + + private: + IndexedMap<Strata, strata_effects_t> PROPERTY(strata_effects); + + /* Technology Effects */ + IndexedMap<TechnologyFolder, ModifierEffect const*> PROPERTY(research_bonus_effects); + + ModifierEffectCache(); + + public: + ModifierEffectCache(ModifierEffectCache&&) = default; + }; +} |