diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/openvic-simulation/GameManager.hpp | 3 | ||||
-rw-r--r-- | src/openvic-simulation/Modifier.cpp | 152 | ||||
-rw-r--r-- | src/openvic-simulation/Modifier.hpp | 18 | ||||
-rw-r--r-- | src/openvic-simulation/country/Country.cpp | 204 | ||||
-rw-r--r-- | src/openvic-simulation/country/Country.hpp | 113 | ||||
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.cpp | 84 | ||||
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.hpp | 3 | ||||
-rw-r--r-- | src/openvic-simulation/politics/NationalValue.cpp | 38 | ||||
-rw-r--r-- | src/openvic-simulation/politics/NationalValue.hpp | 35 | ||||
-rw-r--r-- | src/openvic-simulation/politics/PoliticsManager.hpp | 4 | ||||
-rw-r--r-- | src/openvic-simulation/pop/Pop.cpp | 49 | ||||
-rw-r--r-- | src/openvic-simulation/pop/Pop.hpp | 22 |
12 files changed, 643 insertions, 82 deletions
diff --git a/src/openvic-simulation/GameManager.hpp b/src/openvic-simulation/GameManager.hpp index 09771c6..b2d42d3 100644 --- a/src/openvic-simulation/GameManager.hpp +++ b/src/openvic-simulation/GameManager.hpp @@ -2,6 +2,7 @@ #include "openvic-simulation/GameAdvancementHook.hpp" #include "openvic-simulation/Modifier.hpp" +#include "openvic-simulation/country/Country.hpp" #include "openvic-simulation/economy/EconomyManager.hpp" #include "openvic-simulation/history/HistoryManager.hpp" #include "openvic-simulation/map/Map.hpp" @@ -20,6 +21,7 @@ namespace OpenVic { PoliticsManager politics_manager; HistoryManager history_manager; PopManager pop_manager; + CountryManager country_manager; GameAdvancementHook clock; time_t session_start; /* SS-54, as well as allowing time-tracking */ @@ -41,6 +43,7 @@ namespace OpenVic { REF_GETTERS(politics_manager) REF_GETTERS(history_manager) REF_GETTERS(pop_manager) + REF_GETTERS(country_manager) REF_GETTERS(clock) bool setup(); diff --git a/src/openvic-simulation/Modifier.cpp b/src/openvic-simulation/Modifier.cpp index 97ddd8f..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,31 +123,116 @@ bool ModifierManager::setup_modifier_effects() { using enum ModifierEffect::format_t; - /* LEADER TRAIT MODIFIERS */ + /* Country Modifier Effects */ + ret &= add_modifier_effect("administrative_efficiency_modifier", true); + ret &= add_modifier_effect("badboy", false, RAW_DECIMAL); + 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("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("reliability", true, RAW_DECIMAL); + ret &= add_modifier_effect("experience", true); ret &= add_modifier_effect("morale", true); ret &= add_modifier_effect("organisation", true); - ret &= add_modifier_effect("speed", true); ret &= add_modifier_effect("reconnaissance", true); - ret &= add_modifier_effect("experience", true); - ret &= add_modifier_effect("attrition", false, RAW_DECIMAL); - /* MISCELLANEOUS MODIFIERS */ - ret &= add_modifier_effect("movement_cost", false); - ret &= add_modifier_effect("farm_rgo_size", true); - ret &= add_modifier_effect("farm_rgo_eff", true); - ret &= add_modifier_effect("mine_rgo_size", true); - ret &= add_modifier_effect("mine_rgo_eff", true); - ret &= add_modifier_effect("supply_limit", true, RAW_DECIMAL); - ret &= add_modifier_effect("combat_width", false); - ret &= add_modifier_effect("local_ship_build", false); - ret &= add_modifier_effect("research_points_modifier", true); - ret &= add_modifier_effect("local_rgo_output", true); - ret &= add_modifier_effect("immigrant_push", false); - ret &= add_modifier_effect("population_growth", true); - ret &= add_modifier_effect("local_RGO_throughput", true); - ret &= add_modifier_effect("assimilation_rate", true); + ret &= add_modifier_effect("reliability", true, RAW_DECIMAL); + ret &= add_modifier_effect("speed", true); /* These should be added automatically for each Building loaded (or at least * non-factories), however currently we need modifier effects locked before we @@ -170,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); @@ -193,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); @@ -202,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 { @@ -218,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 { @@ -243,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)); } diff --git a/src/openvic-simulation/country/Country.cpp b/src/openvic-simulation/country/Country.cpp new file mode 100644 index 0000000..eadd036 --- /dev/null +++ b/src/openvic-simulation/country/Country.cpp @@ -0,0 +1,204 @@ +#include "Country.hpp" + +#include <filesystem> +#include <string_view> +#include <system_error> +#include <unordered_map> +#include <vector> + +#include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp> + +#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/dataloader/Dataloader.hpp" +#include "openvic-simulation/dataloader/NodeTools.hpp" +#include "openvic-simulation/politics/Government.hpp" +#include "openvic-simulation/politics/Ideology.hpp" +#include "openvic-simulation/politics/Issue.hpp" +#include "openvic-simulation/pop/Culture.hpp" +#include "openvic-simulation/types/Colour.hpp" +#include "openvic-simulation/types/IdentifierRegistry.hpp" + +using namespace OpenVic; +using namespace OpenVic::NodeTools; + +std::string_view CountryParty::get_name() const { + return name; +} + +const Date& CountryParty::get_start_date() const { + return start_date; +} + +const Date& CountryParty::get_end_date() const { + return end_date; +} + +const Ideology& CountryParty::get_ideology() const { + return ideology; +} + +const std::vector<const Issue*>& CountryParty::get_policies() const { + return policies; +} + +CountryParty::CountryParty( + std::string_view new_name, + Date new_start_date, + Date new_end_date, + const Ideology& new_ideology, + std::vector<const Issue*>&& new_policies +) : name { new_name }, + start_date { new_start_date }, + end_date { new_end_date }, + ideology { new_ideology }, + policies { std::move(new_policies) } { +} + +std::string_view UnitNames::get_identifier() const { + return identifier; +} + +const std::vector<std::string>& UnitNames::get_names() const { + return names; +} + +UnitNames::UnitNames( + std::string_view new_identifier, + std::vector<std::string>&& new_names +) : identifier { new_identifier }, + names { std::move(new_names) } { +} + +const GraphicalCultureType& Country::get_graphical_culture() const { + return graphical_culture; +} + +const std::vector<CountryParty>& Country::get_parties() const { + return parties; +} + +const std::vector<UnitNames>& Country::get_unit_names() const { + return unit_names; +} + +bool Country::is_dynamic_tag() const { + return dynamic_tag; +} + +Country::Country( + std::string_view new_identifier, + colour_t new_color, + const GraphicalCultureType& new_graphical_culture, + std::vector<CountryParty>&& new_parties, + std::vector<UnitNames>&& new_unit_names, + bool new_dynamic_tag, + std::map<const GovernmentType*, colour_t>&& new_alternative_colours +) : HasIdentifierAndColour(new_identifier, new_color, false, false), + graphical_culture { new_graphical_culture }, + parties { std::move(new_parties) }, + unit_names { std::move(new_unit_names) }, + dynamic_tag { new_dynamic_tag }, + alternative_colours { std::move(new_alternative_colours) } { +} + +CountryManager::CountryManager() + : countries { "countries" } { +} + +bool CountryManager::add_country( + std::string_view identifier, + colour_t color, + const GraphicalCultureType& graphical_culture, + std::vector<CountryParty>&& parties, + std::vector<UnitNames>&& unit_names, + bool dynamic_tag, + std::map<const GovernmentType*, colour_t>&& alternative_colours +) { + if (identifier.empty()) { + return false; + } + + return countries.add_item({ identifier, color, graphical_culture, std::move(parties), std::move(unit_names), dynamic_tag, std::move(alternative_colours) }); +} + +bool CountryManager::load_country_data_file(GameManager& game_manager, std::string_view name, bool is_dynamic, ast::NodeCPtr root) { + colour_t color; + const GraphicalCultureType* graphical_culture; + std::vector<CountryParty> country_parties; + std::vector<UnitNames> unit_names; + std::map<const GovernmentType*, colour_t> alternative_colours; + + bool ret = expect_dictionary_keys_and_default( + [&game_manager, &alternative_colours, &name](std::string_view key, ast::NodeCPtr value) -> bool { + const GovernmentType* colour_gov_type; + bool ret = game_manager.get_politics_manager().get_government_type_manager().expect_government_type_identifier(assign_variable_callback_pointer(colour_gov_type))(key); + + if (!ret) return false; + + colour_t alternative_colour; + ret &= expect_colour(assign_variable_callback(alternative_colour))(value); + + if (!ret) return false; + + return alternative_colours.emplace(std::move(colour_gov_type), std::move(alternative_colour)).second; + }, + "color", ONE_EXACTLY, expect_colour(assign_variable_callback(color)), + "graphical_culture", ONE_EXACTLY, expect_identifier_or_string([&game_manager, &graphical_culture, &name](std::string_view value) -> bool { + graphical_culture = game_manager.get_pop_manager().get_culture_manager().get_graphical_culture_type_by_identifier(value); + if (graphical_culture == nullptr) { + Logger::error("When loading country ", name, ", specified graphical culture ", value, " is invalid!\nCheck that CultureManager has loaded before CountryManager."); + } + + return graphical_culture != nullptr; + }), + "party", ZERO_OR_MORE, [&game_manager, &country_parties, &name](ast::NodeCPtr value) -> bool { + std::string_view party_name; + Date start_date, end_date; + const Ideology* ideology; + std::vector<const Issue*> policies; + + bool ret = expect_dictionary_keys_and_default( + [&game_manager, &policies](std::string_view key, ast::NodeCPtr value) -> bool { + const Issue* policy; + bool ret = expect_identifier_or_string( + game_manager.get_politics_manager().get_issue_manager().expect_issue_identifier( + assign_variable_callback_pointer(policy) + ) + )(value); + + if (ret && policy->get_group().get_identifier() == key) { + policies.push_back(policy); + return true; + } + + return false; + }, + "name", ONE_EXACTLY, expect_identifier_or_string(assign_variable_callback(party_name)), + "start_date", ONE_EXACTLY, expect_date(assign_variable_callback(start_date)), + "end_date", ONE_EXACTLY, expect_date(assign_variable_callback(end_date)), + "ideology", ONE_EXACTLY, expect_identifier_or_string(game_manager.get_politics_manager().get_ideology_manager().expect_ideology_identifier(assign_variable_callback_pointer(ideology))) + )(value); + + country_parties.push_back({ party_name, start_date, end_date, *ideology, std::move(policies) }); + + return ret; // + }, + "unit_names", ZERO_OR_ONE, expect_dictionary([&unit_names](std::string_view key, ast::NodeCPtr value) -> bool { + std::vector<std::string> names; + + bool ret = expect_list(expect_identifier_or_string( + [&names](std::string_view value) -> bool { + names.push_back(std::string(value)); + return true; + } + ))(value); + + unit_names.push_back({ key, std::move(names) }); + + return ret; + }) + )(root); + + ret &= add_country(name, color, *graphical_culture, std::move(country_parties), std::move(unit_names), is_dynamic, std::move(alternative_colours)); + return ret; +}
\ No newline at end of file diff --git a/src/openvic-simulation/country/Country.hpp b/src/openvic-simulation/country/Country.hpp new file mode 100644 index 0000000..ce7638f --- /dev/null +++ b/src/openvic-simulation/country/Country.hpp @@ -0,0 +1,113 @@ +#pragma once + +#include <filesystem> +#include <memory> +#include <string> +#include <string_view> +#include <type_traits> +#include <unordered_map> +#include <vector> + +#include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp> + +#include "openvic-simulation/politics/Government.hpp" +#include "openvic-simulation/politics/Ideology.hpp" +#include "openvic-simulation/politics/Issue.hpp" +#include "openvic-simulation/pop/Culture.hpp" +#include "openvic-simulation/types/Colour.hpp" +#include "openvic-simulation/types/Date.hpp" +#include "openvic-simulation/types/IdentifierRegistry.hpp" + +namespace OpenVic { + struct GameManager; + struct CountryManager; + + struct CountryParty { + friend struct CountryManager; + + private: + const std::string name; + const Date start_date; + const Date end_date; + const Ideology& ideology; + const std::vector<const Issue*> policies; + + CountryParty( + std::string_view new_name, + Date new_start_date, + Date new_end_date, + const Ideology& new_ideology, + std::vector<const Issue*>&& new_policies + ); + + public: + std::string_view get_name() const; + const Date& get_start_date() const; + const Date& get_end_date() const; + const Ideology& get_ideology() const; + const std::vector<const Issue*>& get_policies() const; + }; + + struct UnitNames { + friend struct CountryManager; + + private: + const std::string identifier; + const std::vector<std::string> names; + + UnitNames(std::string_view new_identifier, std::vector<std::string>&& new_names); + + public: + std::string_view get_identifier() const; + const std::vector<std::string>& get_names() const; + }; + + struct Country : HasIdentifierAndColour { + friend struct CountryManager; + + private: + const GraphicalCultureType& graphical_culture; + const std::vector<CountryParty> parties; + const std::vector<UnitNames> unit_names; + bool dynamic_tag; + const std::map<const GovernmentType*, colour_t> alternative_colours; + + Country( + std::string_view new_identifier, + colour_t new_color, + const GraphicalCultureType& new_graphical_culture, + std::vector<CountryParty>&& new_parties, + std::vector<UnitNames>&& new_unit_names, + bool new_dynamic_tag, + std::map<const GovernmentType*, colour_t>&& new_alternative_colours + ); + + public: + const GraphicalCultureType& get_graphical_culture() const; + const std::vector<CountryParty>& get_parties() const; + const std::vector<UnitNames>& get_unit_names() const; + bool is_dynamic_tag() const; + const std::map<const GovernmentType*, colour_t>& get_alternative_colours() const; + }; + + struct CountryManager { + private: + IdentifierRegistry<Country> countries; + + public: + CountryManager(); + + bool add_country( + std::string_view identifier, + colour_t color, + const GraphicalCultureType& graphical_culture, + std::vector<CountryParty>&& parties, + std::vector<UnitNames>&& unit_names, + bool dynamic_tag, + std::map<const GovernmentType*, colour_t>&& new_alternative_colours + ); + IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_PLURAL(country, countries); + + bool load_country_data_file(GameManager& game_manager, std::string_view name, bool is_dynamic, ast::NodeCPtr root); + }; +}
\ No newline at end of file diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp index f2e94d7..475cdd1 100644 --- a/src/openvic-simulation/dataloader/Dataloader.cpp +++ b/src/openvic-simulation/dataloader/Dataloader.cpp @@ -45,17 +45,22 @@ static constexpr bool path_equals(std::string_view lhs, std::string_view rhs) { #endif } -template<typename LT, typename RT> -static bool filename_equals(const LT& lhs, const RT& rhs) { - std::string left, right; - if constexpr (std::same_as<LT, std::filesystem::path>) - left = lhs.filename().string(); - else left = lhs; - - if constexpr (std::same_as<RT, std::filesystem::path>) - right = rhs.filename().string(); - else right = rhs; - +template<typename T> +concept is_filename = std::same_as<T, std::filesystem::path> || std::convertible_to<T, std::string_view>; + +bool filename_equals(const is_filename auto& lhs, const is_filename auto& rhs) { + auto left = [&lhs] { + if constexpr (std::same_as<std::decay_t<decltype(lhs)>, std::filesystem::path>) + return lhs.filename().string(); + else + return lhs; + }(); + auto right = [&rhs] { + if constexpr (std::same_as<std::decay_t<decltype(rhs)>, std::filesystem::path>) + return rhs.filename().string(); + else + return rhs; + }(); return path_equals(left, right); } @@ -452,10 +457,10 @@ csv::Windows1252Parser Dataloader::parse_csv(fs::path const& path) { return _run_ovdl_parser<csv::Windows1252Parser, &_csv_parse>(path); } -bool Dataloader::_load_pop_types(PopManager& pop_manager, fs::path const& pop_type_directory) const { +bool Dataloader::_load_pop_types(PopManager& pop_manager, UnitManager const& unit_manager, GoodManager const& good_manager, fs::path const& pop_type_directory) const { const bool ret = apply_to_files_in_dir(pop_type_directory, ".txt", - [&pop_manager](fs::path const& file) -> bool { - return pop_manager.load_pop_type_file(file.stem().string(), parse_defines(file).get_file_node()); + [&pop_manager, &unit_manager, &good_manager](fs::path const& file) -> bool { + return pop_manager.load_pop_type_file(file.stem().string(), unit_manager, good_manager, parse_defines(file).get_file_node()); } ); pop_manager.lock_pop_types(); @@ -472,6 +477,28 @@ bool Dataloader::_load_units(UnitManager& unit_manager, GoodManager const& good_ return ret; } +bool Dataloader::_load_countries(GameManager& game_manager, fs::path const& countries_file, ast::NodeCPtr root) const { + bool is_dynamic = false; + + bool ret = expect_dictionary( + [this, &game_manager, &is_dynamic, &countries_file](std::string_view key, ast::NodeCPtr value) -> bool { + if (key == "dynamic_tags") { + return expect_bool(assign_variable_callback(is_dynamic))(value); + } + + std::string_view data_path; + + if (!expect_string(assign_variable_callback(data_path))(value)) { + return false; + } + + return game_manager.get_country_manager().load_country_data_file(game_manager, key, is_dynamic, Dataloader::parse_defines(lookup_file(countries_file.parent_path() / data_path)).get_file_node()); + } + )(root); + game_manager.get_country_manager().lock_countries(); + return ret; +} + bool Dataloader::_load_map_dir(GameManager& game_manager, fs::path const& map_directory) const { Map& map = game_manager.get_map(); @@ -594,9 +621,11 @@ bool Dataloader::load_defines(GameManager& game_manager) const { static const fs::path graphical_culture_type_file = "common/graphicalculturetype.txt"; static const fs::path ideology_file = "common/ideologies.txt"; static const fs::path issues_file = "common/issues.txt"; + static const fs::path national_values_file = "common/nationalvalues.txt"; static const fs::path production_types_file = "common/production_types.txt"; static const fs::path religion_file = "common/religion.txt"; static const fs::path leader_traits_file = "common/traits.txt"; + static const fs::path countries_file = "common/countries.txt"; bool ret = true; @@ -609,7 +638,15 @@ bool Dataloader::load_defines(GameManager& game_manager) const { Logger::error("Failed to load goods!"); ret = false; } - if (!_load_pop_types(game_manager.get_pop_manager(), pop_type_directory)) { + if (!_load_units(game_manager.get_military_manager().get_unit_manager(), + game_manager.get_economy_manager().get_good_manager(), units_directory)) { + Logger::error("Failed to load units!"); + ret = false; + } + if (!_load_pop_types(game_manager.get_pop_manager(), + game_manager.get_military_manager().get_unit_manager(), + game_manager.get_economy_manager().get_good_manager(), + pop_type_directory)) { Logger::error("Failed to load pop types!"); ret = false; } @@ -643,6 +680,15 @@ bool Dataloader::load_defines(GameManager& game_manager) const { Logger::error("Failed to load issues!"); ret = false; } + if (!game_manager.get_politics_manager().get_national_value_manager().load_national_values_file( + game_manager.get_modifier_manager(), parse_defines(lookup_file(national_values_file)).get_file_node())) { + Logger::error("Failed to load national values!"); + ret = false; + } + if (!_load_countries(game_manager, countries_file, parse_defines(lookup_file(countries_file)).get_file_node())) { + Logger::error("Failed to load countries!"); + ret = false; + } if (!game_manager.get_economy_manager().load_production_types_file( game_manager.get_pop_manager(), parse_defines(lookup_file(production_types_file)).get_file_node())) { @@ -659,12 +705,8 @@ bool Dataloader::load_defines(GameManager& game_manager) const { Logger::error("Failed to load map!"); ret = false; } - if (!_load_units(game_manager.get_military_manager().get_unit_manager(), - game_manager.get_economy_manager().get_good_manager(), units_directory)) { - Logger::error("Failed to load units!"); - ret = false; - } - if (!game_manager.get_military_manager().get_leader_trait_manager().load_leader_traits_file(game_manager.get_modifier_manager(), parse_defines(lookup_file(leader_traits_file)).get_file_node())) { + if (!game_manager.get_military_manager().get_leader_trait_manager().load_leader_traits_file( + game_manager.get_modifier_manager(), parse_defines(lookup_file(leader_traits_file)).get_file_node())) { Logger::error("Failed to load leader traits!"); ret = false; } diff --git a/src/openvic-simulation/dataloader/Dataloader.hpp b/src/openvic-simulation/dataloader/Dataloader.hpp index c268a94..7be86ad 100644 --- a/src/openvic-simulation/dataloader/Dataloader.hpp +++ b/src/openvic-simulation/dataloader/Dataloader.hpp @@ -23,9 +23,10 @@ namespace OpenVic { private: path_vector_t roots; - bool _load_pop_types(PopManager& pop_manager, fs::path const& pop_type_directory) const; + bool _load_pop_types(PopManager& pop_manager, UnitManager const& unit_manager, GoodManager const& good_manager, fs::path const& pop_type_directory) const; bool _load_units(UnitManager& unit_manager, GoodManager const& good_manager, fs::path const& units_directory) const; bool _load_map_dir(GameManager& game_manager, fs::path const& map_directory) const; + bool _load_countries(GameManager& game_manager, fs::path const& countries_file, ast::NodeCPtr root) const; public: static ovdl::v2script::Parser parse_defines(fs::path const& path); diff --git a/src/openvic-simulation/politics/NationalValue.cpp b/src/openvic-simulation/politics/NationalValue.cpp new file mode 100644 index 0000000..f1d8a3b --- /dev/null +++ b/src/openvic-simulation/politics/NationalValue.cpp @@ -0,0 +1,38 @@ +#include "NationalValue.hpp" + +using namespace OpenVic; +using namespace OpenVic::NodeTools; + +NationalValue::NationalValue(std::string_view new_identifier, ModifierValue&& new_modifiers) + : HasIdentifier { new_identifier }, modifiers { std::move(new_modifiers) } {} + +ModifierValue const& NationalValue::get_modifiers() const { + return modifiers; +} + +NationalValueManager::NationalValueManager() : national_values { "national values" } {} + +bool NationalValueManager::add_national_value(std::string_view identifier, ModifierValue&& modifiers) { + if (identifier.empty()) { + Logger::error("Invalid national value identifier - empty!"); + return false; + } + + return national_values.add_item({ identifier, std::move(modifiers) }); +} + +bool NationalValueManager::load_national_values_file(ModifierManager const& modifier_manager, ast::NodeCPtr root) { + bool ret = expect_dictionary( + [this, &modifier_manager](std::string_view national_value_identifier, ast::NodeCPtr value) -> bool { + ModifierValue modifiers; + + bool ret = modifier_manager.expect_modifier_value(move_variable_callback(modifiers))(value); + + ret &= add_national_value(national_value_identifier, std::move(modifiers)); + return ret; + } + )(root); + lock_national_values(); + + return ret; +} diff --git a/src/openvic-simulation/politics/NationalValue.hpp b/src/openvic-simulation/politics/NationalValue.hpp new file mode 100644 index 0000000..09ef85e --- /dev/null +++ b/src/openvic-simulation/politics/NationalValue.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include "openvic-simulation/Modifier.hpp" +#include "openvic-simulation/types/IdentifierRegistry.hpp" + +namespace OpenVic { + struct NationalValueManager; + + struct NationalValue : HasIdentifier { + friend struct NationalValueManager; + + private: + const ModifierValue modifiers; + + NationalValue(std::string_view new_identifier, ModifierValue&& new_modifiers); + + public: + NationalValue(NationalValue&&) = default; + + ModifierValue const& get_modifiers() const; + }; + + struct NationalValueManager { + private: + IdentifierRegistry<NationalValue> national_values; + + public: + NationalValueManager(); + + bool add_national_value(std::string_view identifier, ModifierValue&& modifiers); + IDENTIFIER_REGISTRY_ACCESSORS(national_value) + + bool load_national_values_file(ModifierManager const& modifier_manager, ast::NodeCPtr root); + }; +} // namespace OpenVic diff --git a/src/openvic-simulation/politics/PoliticsManager.hpp b/src/openvic-simulation/politics/PoliticsManager.hpp index 9072d72..1423cf7 100644 --- a/src/openvic-simulation/politics/PoliticsManager.hpp +++ b/src/openvic-simulation/politics/PoliticsManager.hpp @@ -3,6 +3,7 @@ #include "openvic-simulation/politics/Government.hpp" #include "openvic-simulation/politics/Ideology.hpp" #include "openvic-simulation/politics/Issue.hpp" +#include "openvic-simulation/politics/NationalValue.hpp" namespace OpenVic { struct PoliticsManager { @@ -10,10 +11,13 @@ namespace OpenVic { GovernmentTypeManager government_type_manager; IdeologyManager ideology_manager; IssueManager issue_manager; + NationalValueManager national_value_manager; + public: REF_GETTERS(government_type_manager) REF_GETTERS(ideology_manager) REF_GETTERS(issue_manager) + REF_GETTERS(national_value_manager) inline bool load_government_types_file(ast::NodeCPtr root) { return government_type_manager.load_government_types_file(ideology_manager, root); diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp index 14c2a41..dc53201 100644 --- a/src/openvic-simulation/pop/Pop.cpp +++ b/src/openvic-simulation/pop/Pop.cpp @@ -51,11 +51,17 @@ Pop::pop_size_t Pop::get_pop_daily_change() const { PopType::PopType(std::string_view new_identifier, colour_t new_colour, strata_t new_strata, sprite_t new_sprite, + Good::good_map_t&& new_life_needs, Good::good_map_t&& new_everyday_needs, + Good::good_map_t&& new_luxury_needs, rebel_units_t&& new_rebel_units, Pop::pop_size_t new_max_size, Pop::pop_size_t new_merge_max_size, bool new_state_capital_only, bool new_demote_migrant, bool new_is_artisan, bool new_is_slave) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, strata { new_strata }, sprite { new_sprite }, + life_needs { std::move(new_life_needs) }, + everyday_needs { std::move(new_everyday_needs) }, + luxury_needs { std::move(new_luxury_needs) }, + rebel_units { std::move(new_rebel_units) }, max_size { new_max_size }, merge_max_size { new_merge_max_size }, state_capital_only { new_state_capital_only }, @@ -71,6 +77,22 @@ PopType::sprite_t PopType::get_sprite() const { return sprite; } +Good::good_map_t const& PopType::get_life_needs() const { + return life_needs; +} + +Good::good_map_t const& PopType::get_everyday_needs() const { + return everyday_needs; +} + +Good::good_map_t const& PopType::get_luxury_needs() const { + return luxury_needs; +} + +PopType::rebel_units_t const& PopType::get_rebel_units() const { + return rebel_units; +} + PopType::strata_t PopType::get_strata() const { return strata; } @@ -117,8 +139,10 @@ ReligionManager const& PopManager::get_religion_manager() const { return religion_manager; } -bool PopManager::add_pop_type(std::string_view identifier, colour_t colour, PopType::strata_t strata, PopType::sprite_t sprite, - Pop::pop_size_t max_size, Pop::pop_size_t merge_max_size, bool state_capital_only, bool demote_migrant, bool is_artisan, bool is_slave) { +bool PopManager::add_pop_type(std::string_view identifier, colour_t colour, PopType::strata_t strata, + PopType::sprite_t sprite, Good::good_map_t&& life_needs, Good::good_map_t&& everyday_needs, + Good::good_map_t&& luxury_needs, PopType::rebel_units_t&& rebel_units, Pop::pop_size_t max_size, + Pop::pop_size_t merge_max_size, bool state_capital_only, bool demote_migrant, bool is_artisan, bool is_slave) { if (identifier.empty()) { Logger::error("Invalid pop type identifier - empty!"); return false; @@ -139,13 +163,15 @@ bool PopManager::add_pop_type(std::string_view identifier, colour_t colour, PopT Logger::error("Invalid pop type merge max size for ", identifier, ": ", merge_max_size); return false; } - return pop_types.add_item({ identifier, colour, strata, sprite, max_size, merge_max_size, state_capital_only, demote_migrant, is_artisan, is_slave }); + return pop_types.add_item({ identifier, colour, strata, sprite, std::move(life_needs), std::move(everyday_needs), + std::move(luxury_needs), std::move(rebel_units), max_size, merge_max_size, state_capital_only, demote_migrant, + is_artisan, is_slave }); } /* REQUIREMENTS: * POP-3, POP-4, POP-5, POP-6, POP-7, POP-8, POP-9, POP-10, POP-11, POP-12, POP-13, POP-14 */ -bool PopManager::load_pop_type_file(std::string_view filestem, ast::NodeCPtr root) { +bool PopManager::load_pop_type_file(std::string_view filestem, UnitManager const& unit_manager, GoodManager const& good_manager, ast::NodeCPtr root) { static const string_map_t<PopType::strata_t> strata_map = { { "poor", PopType::strata_t::POOR }, { "middle", PopType::strata_t::MIDDLE }, @@ -155,6 +181,8 @@ bool PopManager::load_pop_type_file(std::string_view filestem, ast::NodeCPtr roo colour_t colour = NULL_COLOUR; PopType::strata_t strata = PopType::strata_t::POOR; PopType::sprite_t sprite = 0; + Good::good_map_t life_needs, everyday_needs, luxury_needs; + PopType::rebel_units_t rebel_units; bool state_capital_only = false, is_artisan = false, is_slave = false, demote_migrant = false; Pop::pop_size_t max_size = 0, merge_max_size = 0; bool ret = expect_dictionary_keys( @@ -167,7 +195,7 @@ bool PopManager::load_pop_type_file(std::string_view filestem, ast::NodeCPtr roo "state_capital_only", ZERO_OR_ONE, expect_bool(assign_variable_callback(state_capital_only)), "research_points", ZERO_OR_ONE, success_callback, "research_optimum", ZERO_OR_ONE, success_callback, - "rebel", ZERO_OR_ONE, success_callback, + "rebel", ZERO_OR_ONE, unit_manager.expect_unit_decimal_map(move_variable_callback(rebel_units)), "equivalent", ZERO_OR_ONE, success_callback, "leadership", ZERO_OR_ONE, success_callback, "allowed_to_vote", ZERO_OR_ONE, success_callback, @@ -177,9 +205,9 @@ bool PopManager::load_pop_type_file(std::string_view filestem, ast::NodeCPtr roo "life_needs_income", ZERO_OR_ONE, success_callback, "everyday_needs_income", ZERO_OR_ONE, success_callback, "luxury_needs_income", ZERO_OR_ONE, success_callback, - "luxury_needs", ZERO_OR_ONE, success_callback, - "everyday_needs", ZERO_OR_ONE, success_callback, - "life_needs", ZERO_OR_ONE, success_callback, + "luxury_needs", ZERO_OR_ONE, good_manager.expect_good_decimal_map(move_variable_callback(luxury_needs)), + "everyday_needs", ZERO_OR_ONE, good_manager.expect_good_decimal_map(move_variable_callback(everyday_needs)), + "life_needs", ZERO_OR_ONE, good_manager.expect_good_decimal_map(move_variable_callback(life_needs)), "country_migration_target", ZERO_OR_ONE, success_callback, "migration_target", ZERO_OR_ONE, success_callback, "promote_to", ZERO_OR_ONE, success_callback, @@ -196,7 +224,10 @@ bool PopManager::load_pop_type_file(std::string_view filestem, ast::NodeCPtr roo "can_work_factory", ZERO_OR_ONE, success_callback, "unemployment", ZERO_OR_ONE, success_callback )(root); - ret &= add_pop_type(filestem, colour, strata, sprite, max_size, merge_max_size, state_capital_only, demote_migrant, is_artisan, is_slave); + + ret &= add_pop_type(filestem, colour, strata, sprite, std::move(life_needs), std::move(everyday_needs), + std::move(luxury_needs), std::move(rebel_units), max_size, merge_max_size, state_capital_only, demote_migrant, + is_artisan, is_slave); return ret; } diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp index e299468..26f89db 100644 --- a/src/openvic-simulation/pop/Pop.hpp +++ b/src/openvic-simulation/pop/Pop.hpp @@ -1,5 +1,7 @@ #pragma once +#include "openvic-simulation/economy/Good.hpp" +#include "openvic-simulation/military/Unit.hpp" #include "openvic-simulation/pop/Culture.hpp" #include "openvic-simulation/pop/Religion.hpp" @@ -47,6 +49,7 @@ namespace OpenVic { friend struct PopManager; using sprite_t = uint8_t; + using rebel_units_t = decimal_map_t<Unit const*>; private: const enum class strata_t { @@ -55,12 +58,16 @@ namespace OpenVic { RICH } strata; const sprite_t sprite; + const Good::good_map_t life_needs, everyday_needs, luxury_needs; + const rebel_units_t rebel_units; const Pop::pop_size_t max_size, merge_max_size; const bool state_capital_only, demote_migrant, is_artisan, is_slave; - // TODO - rebel composition, life/everyday/luxury needs, country and province migration targets, promote_to targets, ideologies and issues + // TODO - country and province migration targets, promote_to targets, ideologies and issues - PopType(std::string_view new_identifier, colour_t new_colour, strata_t new_strata, sprite_t new_sprite, Pop::pop_size_t new_max_size, Pop::pop_size_t new_merge_max_size, + PopType(std::string_view new_identifier, colour_t new_colour, strata_t new_strata, sprite_t new_sprite, + Good::good_map_t&& new_life_needs, Good::good_map_t&& new_everyday_needs, Good::good_map_t&& new_luxury_needs, + rebel_units_t&& new_rebel_units, Pop::pop_size_t new_max_size, Pop::pop_size_t new_merge_max_size, bool new_state_capital_only, bool new_demote_migrant, bool new_is_artisan, bool new_is_slave); public: @@ -68,6 +75,10 @@ namespace OpenVic { strata_t get_strata() const; sprite_t get_sprite() const; + Good::good_map_t const& get_life_needs() const; + Good::good_map_t const& get_everyday_needs() const; + Good::good_map_t const& get_luxury_needs() const; + rebel_units_t const& get_rebel_units() const; Pop::pop_size_t get_max_size() const; Pop::pop_size_t get_merge_max_size() const; bool get_state_capital_only() const; @@ -94,11 +105,12 @@ namespace OpenVic { ReligionManager const& get_religion_manager() const; bool add_pop_type(std::string_view identifier, colour_t new_colour, PopType::strata_t strata, PopType::sprite_t sprite, - Pop::pop_size_t max_size, Pop::pop_size_t merge_max_size, bool state_capital_only, bool demote_migrant, - bool is_artisan, bool is_slave); + Good::good_map_t&& life_needs, Good::good_map_t&& everyday_needs, Good::good_map_t&& luxury_needs, + PopType::rebel_units_t&& rebel_units, Pop::pop_size_t max_size, Pop::pop_size_t merge_max_size, + bool state_capital_only, bool demote_migrant, bool is_artisan, bool is_slave); IDENTIFIER_REGISTRY_ACCESSORS(pop_type) - bool load_pop_type_file(std::string_view filestem, ast::NodeCPtr root); + bool load_pop_type_file(std::string_view filestem, UnitManager const& unit_manager, GoodManager const& good_manager, ast::NodeCPtr root); bool load_pop_into_province(Province& province, std::string_view pop_type_identifier, ast::NodeCPtr pop_node) const; }; } |