From 3f59ead985c5598eee74423139a4789ebca57e13 Mon Sep 17 00:00:00 2001 From: Joel Machens Date: Mon, 16 Oct 2023 19:31:55 -0500 Subject: Add Vanilla Modifier Effects --- src/openvic-simulation/Modifier.cpp | 141 ++++++++++++++++++++++++++++-------- 1 file changed, 109 insertions(+), 32 deletions(-) (limited to 'src/openvic-simulation/Modifier.cpp') diff --git a/src/openvic-simulation/Modifier.cpp b/src/openvic-simulation/Modifier.cpp index 8910715..912b805 100644 --- a/src/openvic-simulation/Modifier.cpp +++ b/src/openvic-simulation/Modifier.cpp @@ -29,7 +29,7 @@ void ModifierValue::trim() { } size_t ModifierValue::get_effect_count() const { - return values.size(); + return values.size(); } fixed_point_t ModifierValue::get_effect(ModifierEffect const* effect, bool* successful) { @@ -96,7 +96,7 @@ Date const& ModifierInstance::get_expiry_date() const { } ModifierManager::ModifierManager() - : modifier_effects { "modifier effects"}, modifiers { "modifiers" } {} + : modifier_effects { "modifier effects" }, modifiers { "modifiers" } {} bool ModifierManager::add_modifier_effect(std::string_view identifier, bool positive_good, ModifierEffect::format_t format) { if (identifier.empty()) { @@ -123,34 +123,116 @@ bool ModifierManager::setup_modifier_effects() { using enum ModifierEffect::format_t; - /* Generic Modifier Effects */ - ret &= add_modifier_effect("assimilation_rate", true); - ret &= add_modifier_effect("attack", true, INT); - ret &= add_modifier_effect("attrition", false, RAW_DECIMAL); + /* Country Modifier Effects */ + ret &= add_modifier_effect("administrative_efficiency_modifier", true); ret &= add_modifier_effect("badboy", false, RAW_DECIMAL); - ret &= add_modifier_effect("combat_width", false); - ret &= add_modifier_effect("defence", true, INT); - ret &= add_modifier_effect("experience", true); - ret &= add_modifier_effect("farm_rgo_eff", true); - ret &= add_modifier_effect("farm_rgo_size", true); + ret &= add_modifier_effect("cb_generation_speed_modifier", true); + 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("diplomatic_points_modifier", true); + ret &= add_modifier_effect("education_efficiency_modifier", true); + ret &= add_modifier_effect("factory_cost", false); + ret &= add_modifier_effect("factory_input", false); + ret &= add_modifier_effect("factory_output", true); + ret &= add_modifier_effect("factory_owner_cost", false); + ret &= add_modifier_effect("factory_throughput", true); + ret &= add_modifier_effect("global_assimilation_rate", true); + ret &= add_modifier_effect("global_immigrant_attract", true); + 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_population_growth", true); + ret &= add_modifier_effect("goods_demand", false); + ret &= add_modifier_effect("import_cost", false); + ret &= add_modifier_effect("influence_modifier", true); + ret &= add_modifier_effect("issue_change_speed", true); + ret &= add_modifier_effect("land_organisation", true); + ret &= add_modifier_effect("land_unit_start_experience", true); // weird, land_unit_start_experience = 15 would give a 15% boost + ret &= add_modifier_effect("leadership_modifier", true); + ret &= add_modifier_effect("loan_interest", false); + ret &= add_modifier_effect("max_loan_modifier", true); + ret &= add_modifier_effect("max_military_spending", true); + ret &= add_modifier_effect("max_social_spending", true); + ret &= add_modifier_effect("max_tariff", true); + ret &= add_modifier_effect("max_tax", true); + ret &= add_modifier_effect("middle_income_modifier", true); + ret &= add_modifier_effect("middle_life_needs", true); + ret &= add_modifier_effect("middle_everyday_needs", true); + ret &= add_modifier_effect("middle_luxury_needs", true); + ret &= add_modifier_effect("middle_vote", true); + ret &= add_modifier_effect("min_military_spending", true); + ret &= add_modifier_effect("min_social_spending", true); + ret &= add_modifier_effect("min_tariff", true); + ret &= add_modifier_effect("min_tax", true); + ret &= add_modifier_effect("mobilisation_economy_impact", false); + ret &= add_modifier_effect("mobilisation_impact", false); + ret &= add_modifier_effect("mobilisation_size", true); + ret &= add_modifier_effect("naval_organisation", true); + ret &= add_modifier_effect("naval_unit_start_experience", true); // weird, naval_unit_start_experience = 15 would give a 15% boost + 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); + ret &= add_modifier_effect("political_reform_desire", false); + ret &= add_modifier_effect("poor_income_modifier", true); + ret &= add_modifier_effect("poor_life_needs", true); + ret &= add_modifier_effect("poor_everyday_needs", true); + ret &= add_modifier_effect("poor_luxury_needs", true); + ret &= add_modifier_effect("poor_vote", true); + ret &= add_modifier_effect("prestige", true, RAW_DECIMAL); + ret &= add_modifier_effect("research_points", true, RAW_DECIMAL); + ret &= add_modifier_effect("research_points_modifier", true); + ret &= add_modifier_effect("research_points_on_conquer", true); + ret &= add_modifier_effect("rgo_output", true); + ret &= add_modifier_effect("rgo_throughput", true); + ret &= add_modifier_effect("rich_income_modifier", true); + ret &= add_modifier_effect("rich_life_needs", true); + ret &= add_modifier_effect("rich_everyday_needs", true); + ret &= add_modifier_effect("rich_luxury_needs", true); + ret &= add_modifier_effect("rich_vote", true); + ret &= add_modifier_effect("ruling_party_support", true); + ret &= add_modifier_effect("social_reform_desire", false); + ret &= add_modifier_effect("supply_consumption", false); + ret &= add_modifier_effect("army_tech_research_bonus", true); + ret &= add_modifier_effect("commerce_tech_research_bonus", true); + ret &= add_modifier_effect("culture_tech_research_bonus", true); + ret &= add_modifier_effect("industry_tech_research_bonus", true); + ret &= add_modifier_effect("naval_tech_research_bonus", true); + ret &= add_modifier_effect("unit_start_experience", true); // weird, naval_unit_start_experience = 15 would give a 15% boost + ret &= add_modifier_effect("war_exhaustion", false); + + /* Province Modifier Effects */ + ret &= add_modifier_effect("assimilation_rate", true); + ret &= add_modifier_effect("immigrant_attract", true); ret &= add_modifier_effect("immigrant_push", false); + ret &= add_modifier_effect("life_rating", true); + ret &= add_modifier_effect("local_factory_input", true); + ret &= add_modifier_effect("local_factory_output", true); + ret &= add_modifier_effect("local_factory_throughput", true); + ret &= add_modifier_effect("local_repair", true); ret &= add_modifier_effect("local_rgo_output", true); ret &= add_modifier_effect("local_RGO_throughput", true); + ret &= add_modifier_effect("local_ruling_party_support", true); ret &= add_modifier_effect("local_ship_build", false); + 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); + ret &= add_modifier_effect("farm_rgo_eff", true); + ret &= add_modifier_effect("farm_rgo_size", true); ret &= add_modifier_effect("mine_rgo_eff", true); ret &= add_modifier_effect("mine_rgo_size", true); - ret &= add_modifier_effect("mobilisation_size", true); - ret &= add_modifier_effect("mobilisation_economy_impact", false); - ret &= add_modifier_effect("mobilisation_impact", false); - ret &= add_modifier_effect("morale", true); ret &= add_modifier_effect("movement_cost", false); + ret &= add_modifier_effect("supply_limit", true, RAW_DECIMAL); + + /* Military Modifier Effects */ + ret &= add_modifier_effect("attack", true, INT); + ret &= add_modifier_effect("attrition", false, RAW_DECIMAL); + ret &= add_modifier_effect("combat_width", false); + ret &= add_modifier_effect("defence", true, INT); + ret &= add_modifier_effect("experience", true); + ret &= add_modifier_effect("morale", true); ret &= add_modifier_effect("organisation", true); - ret &= add_modifier_effect("population_growth", true); ret &= add_modifier_effect("reconnaissance", true); ret &= add_modifier_effect("reliability", true, RAW_DECIMAL); - ret &= add_modifier_effect("research_points_modifier", true); ret &= add_modifier_effect("speed", true); - ret &= add_modifier_effect("supply_limit", true, RAW_DECIMAL); /* These should be added automatically for each Building loaded (or at least * non-factories), however currently we need modifier effects locked before we @@ -173,7 +255,8 @@ bool ModifierManager::setup_modifier_effects() { key_value_callback_t ModifierManager::_modifier_effect_callback( ModifierValue& modifier, key_value_callback_t default_callback, - ModifierEffectValidator auto effect_validator) const { + ModifierEffectValidator auto effect_validator +) const { return [this, &modifier, default_callback, effect_validator](std::string_view key, ast::NodeCPtr value) -> bool { ModifierEffect const* effect = get_modifier_effect_by_identifier(key); @@ -196,8 +279,7 @@ key_value_callback_t ModifierManager::_modifier_effect_callback( }; } -node_callback_t ModifierManager::expect_validated_modifier_value_and_default(callback_t modifier_callback, - key_value_callback_t default_callback, ModifierEffectValidator auto effect_validator) const { +node_callback_t ModifierManager::expect_validated_modifier_value_and_default(callback_t modifier_callback, key_value_callback_t default_callback, ModifierEffectValidator auto effect_validator) const { return [this, modifier_callback, default_callback, effect_validator](ast::NodeCPtr root) -> bool { ModifierValue modifier; bool ret = expect_dictionary(_modifier_effect_callback(modifier, default_callback, effect_validator))(root); @@ -205,15 +287,12 @@ node_callback_t ModifierManager::expect_validated_modifier_value_and_default(cal return ret; }; } -node_callback_t ModifierManager::expect_validated_modifier_value(callback_t modifier_callback, - ModifierEffectValidator auto effect_validator) const { +node_callback_t ModifierManager::expect_validated_modifier_value(callback_t modifier_callback, ModifierEffectValidator auto effect_validator) const { return expect_validated_modifier_value_and_default(modifier_callback, key_value_invalid_callback, effect_validator); } node_callback_t ModifierManager::expect_modifier_value_and_default(callback_t modifier_callback, key_value_callback_t default_callback) const { - return expect_validated_modifier_value_and_default(modifier_callback, default_callback, - [](ModifierEffect const&) -> bool { return true; } - ); + return expect_validated_modifier_value_and_default(modifier_callback, default_callback, [](ModifierEffect const&) -> bool { return true; }); } node_callback_t ModifierManager::expect_modifier_value(callback_t modifier_callback) const { @@ -221,11 +300,9 @@ node_callback_t ModifierManager::expect_modifier_value(callback_t modifier_callback, std::set> const& whitelist, key_value_callback_t default_callback) const { - return expect_validated_modifier_value_and_default(modifier_callback, default_callback, - [&whitelist](ModifierEffect const& effect) -> bool { - return whitelist.contains(effect.get_identifier()); - } - ); + return expect_validated_modifier_value_and_default(modifier_callback, default_callback, [&whitelist](ModifierEffect const& effect) -> bool { + return whitelist.contains(effect.get_identifier()); + }); } node_callback_t ModifierManager::expect_whitelisted_modifier_value(callback_t modifier_callback, std::set> const& whitelist) const { @@ -246,7 +323,7 @@ node_callback_t ModifierManager::expect_modifier_value_and_key_map(callback_t