diff options
author | BrickPi <49528459+BrickPi@users.noreply.github.com> | 2023-10-17 05:42:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-17 05:42:13 +0200 |
commit | f85a0880e19c0ca75eea80f8f38c1e061269dd08 (patch) | |
tree | 8626fd196a411a8d14205d5232ce88e64f91b336 /src | |
parent | e65646f260360f634cc7d4ff28e7676c766ebcd8 (diff) | |
parent | 3f59ead985c5598eee74423139a4789ebca57e13 (diff) |
Merge pull request #57 from OpenVicProject/modifier-effects
Diffstat (limited to 'src')
-rw-r--r-- | src/openvic-simulation/Modifier.cpp | 141 | ||||
-rw-r--r-- | src/openvic-simulation/Modifier.hpp | 18 |
2 files changed, 117 insertions, 42 deletions
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<ModifierValue&&> 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<ModifierValue&&> 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<ModifierValue&&> modifier_callback, - ModifierEffectValidator auto effect_validator) const { +node_callback_t ModifierManager::expect_validated_modifier_value(callback_t<ModifierValue&&> 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<ModifierValue&&> 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<ModifierValue&&> modifier_callback) const { @@ -221,11 +300,9 @@ node_callback_t ModifierManager::expect_modifier_value(callback_t<ModifierValue& } node_callback_t ModifierManager::expect_whitelisted_modifier_value_and_default(callback_t<ModifierValue&&> modifier_callback, std::set<std::string, std::less<void>> 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<ModifierValue&&> modifier_callback, std::set<std::string, std::less<void>> const& whitelist) const { @@ -246,7 +323,7 @@ node_callback_t ModifierManager::expect_modifier_value_and_key_map(callback_t<Mo return expect_modifier_value_and_key_map_and_default(modifier_callback, key_value_invalid_callback, std::move(key_map)); } -namespace OpenVic { //so the compiler shuts up +namespace OpenVic { // so the compiler shuts up std::ostream& operator<<(std::ostream& stream, ModifierValue const& value) { for (ModifierValue::effect_map_t::value_type const& effect : value.values) { stream << effect.first << ": " << effect.second << "\n"; diff --git a/src/openvic-simulation/Modifier.hpp b/src/openvic-simulation/Modifier.hpp index 0801aa5..c6b15a6 100644 --- a/src/openvic-simulation/Modifier.hpp +++ b/src/openvic-simulation/Modifier.hpp @@ -11,7 +11,9 @@ namespace OpenVic { friend struct ModifierManager; enum class format_t { - RAW_DECIMAL, PERCENTAGE_DECIMAL, INT + RAW_DECIMAL, + PERCENTAGE_DECIMAL, + INT }; private: @@ -36,6 +38,7 @@ namespace OpenVic { friend struct ModifierManager; using effect_map_t = decimal_map_t<ModifierEffect const*>; + private: effect_map_t values; @@ -104,9 +107,7 @@ namespace OpenVic { IdentifierRegistry<Modifier> modifiers; /* effect_validator takes in ModifierEffect const& */ - NodeTools::key_value_callback_t _modifier_effect_callback(ModifierValue& modifier, - NodeTools::key_value_callback_t default_callback, - ModifierEffectValidator auto effect_validator) const; + NodeTools::key_value_callback_t _modifier_effect_callback(ModifierValue& modifier, NodeTools::key_value_callback_t default_callback, ModifierEffectValidator auto effect_validator) const; public: ModifierManager(); @@ -119,10 +120,8 @@ namespace OpenVic { bool setup_modifier_effects(); - NodeTools::node_callback_t expect_validated_modifier_value_and_default(NodeTools::callback_t<ModifierValue&&> modifier_callback, - NodeTools::key_value_callback_t default_callback, ModifierEffectValidator auto effect_validator) const; - NodeTools::node_callback_t expect_validated_modifier_value(NodeTools::callback_t<ModifierValue&&> modifier_callback, - ModifierEffectValidator auto effect_validator) const; + NodeTools::node_callback_t expect_validated_modifier_value_and_default(NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_value_callback_t default_callback, ModifierEffectValidator auto effect_validator) const; + NodeTools::node_callback_t expect_validated_modifier_value(NodeTools::callback_t<ModifierValue&&> modifier_callback, ModifierEffectValidator auto effect_validator) const; NodeTools::node_callback_t expect_modifier_value_and_default(NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_value_callback_t default_callback) const; NodeTools::node_callback_t expect_modifier_value(NodeTools::callback_t<ModifierValue&&> modifier_callback) const; @@ -134,8 +133,7 @@ namespace OpenVic { NodeTools::node_callback_t expect_modifier_value_and_key_map(NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_map_t&& key_map) const; template<typename... Args> - NodeTools::node_callback_t expect_modifier_value_and_key_map_and_default(NodeTools::callback_t<ModifierValue&&> modifier_callback, - NodeTools::key_value_callback_t default_callback, NodeTools::key_map_t&& key_map, Args... args) const { + NodeTools::node_callback_t expect_modifier_value_and_key_map_and_default(NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_value_callback_t default_callback, NodeTools::key_map_t&& key_map, Args... args) const { NodeTools::add_key_map_entries(key_map, args...); return expect_modifier_value_and_key_map_and_default(modifier_callback, default_callback, std::move(key_map)); } |