From f83e869def6608f64606aead24ad1cfbb6f5c72a Mon Sep 17 00:00:00 2001 From: hop311 Date: Tue, 16 Jul 2024 23:57:50 +0100 Subject: Add IndexedMap and use in low key count, high value density cases --- src/openvic-simulation/country/CountryInstance.hpp | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 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 3022b6a..885a5fd 100644 --- a/src/openvic-simulation/country/CountryInstance.hpp +++ b/src/openvic-simulation/country/CountryInstance.hpp @@ -6,9 +6,11 @@ #include "openvic-simulation/military/Leader.hpp" #include "openvic-simulation/military/UnitInstanceGroup.hpp" +#include "openvic-simulation/research/Invention.hpp" +#include "openvic-simulation/research/Technology.hpp" #include "openvic-simulation/types/Date.hpp" -#include "openvic-simulation/types/fixed_point/FixedPointMap.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" +#include "openvic-simulation/types/IndexedMap.hpp" #include "openvic-simulation/utility/Getters.hpp" namespace OpenVic { @@ -34,7 +36,7 @@ namespace OpenVic { Religion const* PROPERTY_RW(religion); CountryParty const* PROPERTY_RW(ruling_party); Date PROPERTY_RW(last_election); - fixed_point_map_t PROPERTY(upper_house); + IndexedMap PROPERTY(upper_house); // TODO - should this be ProvinceInstance and/or non-const pointer? // Currently ProvinceDefinition as that's what CountryHistoryEntry has (loaded prior to ProvinceInstance generation) ProvinceDefinition const* PROPERTY_RW(capital); @@ -44,21 +46,27 @@ namespace OpenVic { bool PROPERTY_RW(civilised); fixed_point_t PROPERTY_RW(prestige); std::vector PROPERTY(reforms); // TODO: should be map of reform groups to active reforms: must set defaults & validate applied history + + IndexedMap PROPERTY(technologies); + IndexedMap PROPERTY(inventions); + // TODO: Military units + OOBs; will probably need an extensible deployment class plf::colony PROPERTY(generals); plf::colony PROPERTY(admirals); - CountryInstance(CountryDefinition const* new_country_definition); + CountryInstance( + CountryDefinition const* new_country_definition, decltype(technologies)::keys_t const& technology_keys, + decltype(inventions)::keys_t const& invention_keys, decltype(upper_house)::keys_t const& ideology_keys + ); public: std::string_view get_identifier() const; bool add_accepted_culture(Culture const* new_accepted_culture); bool remove_accepted_culture(Culture const* culture_to_remove); - /* Add or modify a party in the upper house. */ - void add_to_upper_house(Ideology const* party, fixed_point_t popularity); - bool remove_from_upper_house(Ideology const* party); + /* Set a party's popularity in the upper house. */ + bool set_upper_house(Ideology const* ideology, fixed_point_t popularity); bool add_reform(Reform const* new_reform); bool remove_reform(Reform const* reform_to_remove); @@ -83,7 +91,12 @@ namespace OpenVic { IdentifierRegistry IDENTIFIER_REGISTRY(country_instance); public: - bool generate_country_instances(CountryDefinitionManager const& country_definition_manager); + bool generate_country_instances( + CountryDefinitionManager const& country_definition_manager, + decltype(CountryInstance::technologies)::keys_t const& technology_keys, + decltype(CountryInstance::inventions)::keys_t const& invention_keys, + decltype(CountryInstance::upper_house)::keys_t const& ideology_keys + ); bool apply_history_to_countries( CountryHistoryManager const& history_manager, Date date, UnitInstanceManager& unit_instance_manager, -- cgit v1.2.3-56-ga3b1