From eb77495ba874d474bbbbc950a65e8f496b13f285 Mon Sep 17 00:00:00 2001 From: hop311 Date: Sun, 29 Sep 2024 21:37:11 +0100 Subject: Calculate country and province resultant modifier sums --- src/openvic-simulation/country/CountryInstance.hpp | 54 +++++++++++++--------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'src/openvic-simulation/country/CountryInstance.hpp') diff --git a/src/openvic-simulation/country/CountryInstance.hpp b/src/openvic-simulation/country/CountryInstance.hpp index a7128aa..c9b61e3 100644 --- a/src/openvic-simulation/country/CountryInstance.hpp +++ b/src/openvic-simulation/country/CountryInstance.hpp @@ -6,6 +6,7 @@ #include "openvic-simulation/military/Leader.hpp" #include "openvic-simulation/military/UnitInstanceGroup.hpp" +#include "openvic-simulation/modifier/ModifierSum.hpp" #include "openvic-simulation/politics/Rule.hpp" #include "openvic-simulation/pop/Pop.hpp" #include "openvic-simulation/types/Date.hpp" @@ -80,13 +81,17 @@ namespace OpenVic { ordered_set PROPERTY(core_provinces); ordered_set PROPERTY(states); + // The total/resultant modifier affecting this country, including owned province contributions. + ModifierSum PROPERTY(modifier_sum); + std::vector PROPERTY(event_modifiers); + /* Production */ fixed_point_t PROPERTY(industrial_power); std::vector> PROPERTY(industrial_power_from_states); std::vector> PROPERTY(industrial_power_from_investments); size_t PROPERTY(industrial_rank); fixed_point_map_t PROPERTY(foreign_investments); - IndexedMap PROPERTY(unlocked_building_types); + IndexedMap PROPERTY(building_type_unlock_levels); // TODO - total amount of each good produced /* Budget */ @@ -94,8 +99,8 @@ namespace OpenVic { // TODO - cash stockpile change over last 30 days /* Technology */ - IndexedMap PROPERTY(unlocked_technologies); - IndexedMap PROPERTY(unlocked_inventions); + IndexedMap PROPERTY(technology_unlock_levels); + IndexedMap PROPERTY(invention_unlock_levels); Technology const* PROPERTY(current_research); fixed_point_t PROPERTY(invested_research_points); Date PROPERTY(expected_completion_date); @@ -118,10 +123,10 @@ namespace OpenVic { IndexedMap PROPERTY(government_flag_overrides); GovernmentType const* PROPERTY(flag_government_type); fixed_point_t PROPERTY(suppression_points); - fixed_point_t PROPERTY(infamy); - fixed_point_t PROPERTY(plurality); + fixed_point_t PROPERTY(infamy); // in 0-25+ range + fixed_point_t PROPERTY(plurality); // in 0-100 range fixed_point_t PROPERTY(revanchism); - IndexedMap PROPERTY(unlocked_crimes); + IndexedMap PROPERTY(crime_unlock_levels); // TODO - rebel movements /* Population */ @@ -165,32 +170,32 @@ namespace OpenVic { fixed_point_t PROPERTY(total_consumed_ship_supply); fixed_point_t PROPERTY(max_ship_supply); fixed_point_t PROPERTY(leadership_points); - fixed_point_t PROPERTY(war_exhaustion); + fixed_point_t PROPERTY(war_exhaustion); // in 0-100 range bool PROPERTY_CUSTOM_PREFIX(mobilised, is); bool PROPERTY_CUSTOM_PREFIX(disarmed, is); - IndexedMap PROPERTY(unlocked_regiment_types); + IndexedMap PROPERTY(regiment_type_unlock_levels); RegimentType::allowed_cultures_t PROPERTY(allowed_regiment_cultures); - IndexedMap PROPERTY(unlocked_ship_types); + IndexedMap PROPERTY(ship_type_unlock_levels); unlock_level_t PROPERTY(gas_attack_unlock_level); unlock_level_t PROPERTY(gas_defence_unlock_level); std::vector PROPERTY(unit_variant_unlock_levels); UNIT_BRANCHED_GETTER(get_unit_instance_groups, armies, navies); UNIT_BRANCHED_GETTER(get_leaders, generals, admirals); - UNIT_BRANCHED_GETTER(get_unlocked_unit_types, unlocked_regiment_types, unlocked_ship_types); + UNIT_BRANCHED_GETTER(get_unit_type_unlock_levels, regiment_type_unlock_levels, ship_type_unlock_levels); CountryInstance( CountryDefinition const* new_country_definition, - decltype(unlocked_building_types)::keys_t const& building_type_keys, - decltype(unlocked_technologies)::keys_t const& technology_keys, - decltype(unlocked_inventions)::keys_t const& invention_keys, + decltype(building_type_unlock_levels)::keys_t const& building_type_keys, + decltype(technology_unlock_levels)::keys_t const& technology_keys, + decltype(invention_unlock_levels)::keys_t const& invention_keys, decltype(upper_house)::keys_t const& ideology_keys, decltype(reforms)::keys_t const& reform_keys, decltype(government_flag_overrides)::keys_t const& government_type_keys, - decltype(unlocked_crimes)::keys_t const& crime_keys, + decltype(crime_unlock_levels)::keys_t const& crime_keys, decltype(pop_type_distribution)::keys_t const& pop_type_keys, - decltype(unlocked_regiment_types)::keys_t const& unlocked_regiment_types_keys, - decltype(unlocked_ship_types)::keys_t const& unlocked_ship_types_keys + decltype(regiment_type_unlock_levels)::keys_t const& regiment_type_unlock_levels_keys, + decltype(ship_type_unlock_levels)::keys_t const& ship_type_unlock_levels_keys ); public: @@ -296,6 +301,10 @@ namespace OpenVic { public: + void update_modifier_sum(Date today, StaticModifierCache const& static_modifier_cache); + fixed_point_t get_modifier_effect_value(ModifierEffect const& effect) const; + fixed_point_t get_modifier_effect_value_nullcheck(ModifierEffect const* effect) const; + void update_gamestate(DefineManager const& define_manager, UnitTypeManager const& unit_type_manager); void tick(); }; @@ -324,16 +333,16 @@ namespace OpenVic { bool generate_country_instances( CountryDefinitionManager const& country_definition_manager, - decltype(CountryInstance::unlocked_building_types)::keys_t const& building_type_keys, - decltype(CountryInstance::unlocked_technologies)::keys_t const& technology_keys, - decltype(CountryInstance::unlocked_inventions)::keys_t const& invention_keys, + decltype(CountryInstance::building_type_unlock_levels)::keys_t const& building_type_keys, + decltype(CountryInstance::technology_unlock_levels)::keys_t const& technology_keys, + decltype(CountryInstance::invention_unlock_levels)::keys_t const& invention_keys, decltype(CountryInstance::upper_house)::keys_t const& ideology_keys, decltype(CountryInstance::reforms)::keys_t const& reform_keys, decltype(CountryInstance::government_flag_overrides)::keys_t const& government_type_keys, - decltype(CountryInstance::unlocked_crimes)::keys_t const& crime_keys, + decltype(CountryInstance::crime_unlock_levels)::keys_t const& crime_keys, decltype(CountryInstance::pop_type_distribution)::keys_t const& pop_type_keys, - decltype(CountryInstance::unlocked_regiment_types)::keys_t const& unlocked_regiment_types_keys, - decltype(CountryInstance::unlocked_ship_types)::keys_t const& unlocked_ship_types_keys + decltype(CountryInstance::regiment_type_unlock_levels)::keys_t const& regiment_type_unlock_levels_keys, + decltype(CountryInstance::ship_type_unlock_levels)::keys_t const& ship_type_unlock_levels_keys ); bool apply_history_to_countries( @@ -341,6 +350,7 @@ namespace OpenVic { MapInstance& map_instance ); + void update_modifier_sums(Date today, StaticModifierCache const& static_modifier_cache); void update_gamestate(Date today, DefineManager const& define_manager, UnitTypeManager const& unit_type_manager); void tick(); }; -- cgit v1.2.3-56-ga3b1