diff --git a/EU5ToVic3/Data_Files/configurables/unused/accepted_culture_thresholds.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/accepted_culture_thresholds.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/accepted_culture_thresholds.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/accepted_culture_thresholds.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/advisor_mapping.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/advisor_mapping.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/advisor_mapping.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/advisor_mapping.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/censorship_mask.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/censorship_mask.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/censorship_mask.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/censorship_mask.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/chinese_renamings.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/chinese_renamings.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/chinese_renamings.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/chinese_renamings.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/colonial_flags.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/colonial_flags.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/colonial_flags.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/colonial_flags.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/custom_flag_patterns.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/custom_flag_patterns.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/custom_flag_patterns.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/custom_flag_patterns.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/defense_war_goal_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/defense_war_goal_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/defense_war_goal_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/defense_war_goal_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/nationals.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/nationals.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/nationals.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/nationals.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/party_blobs.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/party_blobs.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/party_blobs.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/party_blobs.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/party_names.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/party_names.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/party_names.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/party_names.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/state_namesakes.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/state_namesakes.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/state_namesakes.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/state_namesakes.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/union_tags.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/union_tags.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/union_tags.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/union_tags.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/unions.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/unions.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/unions.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/unions.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/unreleasable_tags.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/unreleasable_tags.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/unreleasable_tags.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/unreleasable_tags.txt diff --git a/EU5ToVic3/Data_Files/configurables/unused/war_goal_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/war_goal_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/unused/war_goal_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic2-unused/war_goal_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/ai_secret_goal_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/ai_secret_goal_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/ai_secret_goal_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/ai_secret_goal_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/ai_strategy_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/ai_strategy_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/ai_strategy_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/ai_strategy_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/character_traits.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/character_traits.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/character_traits.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/character_traits.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/colonial_cultures.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/colonial_cultures.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/colonial_cultures.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/colonial_cultures.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/colonial_regions.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/colonial_regions.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/colonial_regions.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/colonial_regions.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/colonial_tags.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/colonial_tags.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/colonial_tags.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/colonial_tags.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/country_mappings.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/country_mappings.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/country_mappings.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/country_mappings.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/country_tiers.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/country_tiers.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/country_tiers.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/country_tiers.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/culture_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/culture_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/culture_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/culture_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/culture_trait_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/culture_trait_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/culture_trait_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/culture_trait_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/diplomatic_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/diplomatic_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/diplomatic_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/diplomatic_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/eu4_culture_new_mappings.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/eu4_culture_new_mappings.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/eu4_culture_new_mappings.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/eu4_culture_new_mappings.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/excluded_trade_companies.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/excluded_trade_companies.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/excluded_trade_companies.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/excluded_trade_companies.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/idea_effects.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/idea_effects.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/idea_effects.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/idea_effects.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/ig_ideologies.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/ig_ideologies.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/ig_ideologies.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/ig_ideologies.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/law_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/law_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/law_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/law_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/merge_nations.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/merge_nations.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/merge_nations.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/merge_nations.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/minority_pops.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/minority_pops.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/minority_pops.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/minority_pops.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/name_list_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/name_list_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/name_list_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/name_list_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/name_list_royal.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/name_list_royal.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/name_list_royal.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/name_list_royal.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/name_lists.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/name_lists.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/name_lists.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/name_lists.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/population_setup.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/population_setup.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/population_setup.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/population_setup.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/province_adjacencies.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/province_adjacencies.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/province_adjacencies.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/province_adjacencies.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/province_mappings.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/province_mappings.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/province_mappings.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/province_mappings.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/religion_group_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/religion_group_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/religion_group_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/religion_group_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/religion_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/religion_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/religion_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/religion_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/slave_culture_map.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/slave_culture_map.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/slave_culture_map.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/slave_culture_map.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/tech_setup.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/tech_setup.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/tech_setup.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/tech_setup.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/vn_colonial.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/vn_colonial.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/vn_colonial.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/vn_colonial.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/vn_province_mappings.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/vn_province_mappings.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/vn_province_mappings.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/vn_province_mappings.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/westernization.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/westernization.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/westernization.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/westernization.txt diff --git a/EU5ToVic3/Data_Files/configurables/newunused/world_supergroups.txt b/EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/world_supergroups.txt similarity index 100% rename from EU5ToVic3/Data_Files/configurables/newunused/world_supergroups.txt rename to EU5ToVic3/Data_Files/configurables/eu4tovic3-unused/world_supergroups.txt diff --git a/EU5ToVic3/Source/Configuration/Configuration.cpp b/EU5ToVic3/Source/Configuration/Configuration.cpp index e91c097..e863952 100644 --- a/EU5ToVic3/Source/Configuration/Configuration.cpp +++ b/EU5ToVic3/Source/Configuration/Configuration.cpp @@ -14,8 +14,8 @@ Configuration::Configuration(const commonItems::ConverterVersion& converterVersi parseFile("configuration.txt"); clearRegisteredKeywords(); setOutputName(); - verifyEU4Path(); - verifyEU4Version(converterVersion); + verifyEU5Path(); + verifyEU5Version(converterVersion); verifyVic3Path(); verifyVic3Version(converterVersion); Log(LogLevel::Progress) << "3 %"; @@ -27,8 +27,8 @@ Configuration::Configuration(std::istream& theStream, const commonItems::Convert parseStream(theStream); clearRegisteredKeywords(); setOutputName(); - verifyEU4Path(); - verifyEU4Version(converterVersion); + verifyEU5Path(); + verifyEU5Version(converterVersion); verifyVic3Path(); verifyVic3Version(converterVersion); } @@ -38,16 +38,16 @@ void Configuration::registerKeys() // ------ config stuff registerKeyword("SaveGame", [this](std::istream& theStream) { - EU4SaveGamePath = commonItems::getString(theStream); - Log(LogLevel::Info) << "EU4 savegame path: " << EU4SaveGamePath; + EU5SaveGamePath = commonItems::getString(theStream); + Log(LogLevel::Info) << "EU5 savegame path: " << EU5SaveGamePath; }); - registerKeyword("EU4directory", [this](std::istream& theStream) { - EU4Path = commonItems::getString(theStream); - Log(LogLevel::Info) << "EU4 path: " << EU4Path; + registerKeyword("EU5directory", [this](std::istream& theStream) { + EU5Path = commonItems::getString(theStream); + Log(LogLevel::Info) << "EU5 path: " << EU5Path; }); - registerKeyword("EU4DocumentsDirectory", [this](std::istream& theStream) { - EU4DocumentsPath = commonItems::getString(theStream); - Log(LogLevel::Info) << "EU4 documents path: " << EU4DocumentsPath; + registerKeyword("EU5DocumentsDirectory", [this](std::istream& theStream) { + EU5DocumentsPath = commonItems::getString(theStream); + Log(LogLevel::Info) << "EU5 documents path: " << EU5DocumentsPath; }); registerKeyword("Vic3directory", [this](std::istream& theStream) { Vic3Path = commonItems::getString(theStream); @@ -61,51 +61,6 @@ void Configuration::registerKeys() configBlock.startDate = static_cast(std::stoi(startDateString)); Log(LogLevel::Info) << "Start Date: " << startDateString; }); - registerKeyword("remove_type", [this](std::istream& theStream) { - const auto removeTypeString = commonItems::getString(theStream); - configBlock.removeType = static_cast(std::stoi(removeTypeString)); - Log(LogLevel::Info) << "Releasables Removal: " << removeTypeString; - }); - registerKeyword("pop_shaping", [this](std::istream& theStream) { - const auto popShapingString = commonItems::getString(theStream); - configBlock.popShaping = static_cast(std::stoi(popShapingString)); - Log(LogLevel::Info) << "Pop Shaping: " << popShapingString; - }); - registerKeyword("shaping_factor", [this](std::istream& theStream) { - const auto shapingFactorString = commonItems::getString(theStream); - configBlock.shapingFactor = std::stoi(shapingFactorString); - if (configBlock.shapingFactor < 0) - configBlock.shapingFactor = 0; - if (configBlock.shapingFactor > 100.0) - configBlock.shapingFactor = 100.0; - configBlock.shapingFactor /= 100.0; - Log(LogLevel::Info) << "Pop Shaping Factor: " << shapingFactorString; - }); - registerKeyword("euro_centrism", [this](std::istream& theStream) { - const auto euroCentrismString = commonItems::getString(theStream); - configBlock.euroCentric = static_cast(std::stoi(euroCentrismString)); - Log(LogLevel::Info) << "Eurocentrism: " << euroCentrismString; - }); - registerKeyword("convert_all", [this](std::istream& theStream) { - const auto convertAllString = commonItems::getString(theStream); - configBlock.convertAll = convertAllString == "yes"; - Log(LogLevel::Info) << "Convert All: " << convertAllString; - }); - registerKeyword("economy", [this](std::istream& theStream) { - const auto economyString = commonItems::getString(theStream); - configBlock.economy = static_cast(std::stoi(economyString)); - Log(LogLevel::Info) << "Economy: " << economyString; - }); - registerKeyword("downtiers", [this](std::istream& theStream) { - const auto downTiersString = commonItems::getString(theStream); - configBlock.downTiers = downTiersString == "yes"; - Log(LogLevel::Info) << "Downgrade Tiers: " << downTiersString; - }); - registerKeyword("splittcs", [this](std::istream& theStream) { - const auto splitTCsString = commonItems::getString(theStream); - configBlock.splitTCs = static_cast(std::stoi(splitTCsString)); - Log(LogLevel::Info) << "Split TCs: " << splitTCsString; - }); registerKeyword("output_name", [this](std::istream& theStream) { outputName = commonItems::getString(theStream); Log(LogLevel::Info) << "Output Name: " << outputName; @@ -113,24 +68,22 @@ void Configuration::registerKeys() registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); } -void Configuration::verifyEU4Path() const +void Configuration::verifyEU5Path() const { - if (!commonItems::DoesFolderExist(EU4Path)) - throw std::runtime_error("EU4 path " + EU4Path + " does not exist!"); - if (!commonItems::DoesFileExist(EU4Path + "/eu4.exe") && !commonItems::DoesFileExist(EU4Path + "/eu4") && - !commonItems::DoesFolderExist(EU4Path + "/eu4.app")) - throw std::runtime_error(EU4Path + " does not contain Europa Universalis 4!"); - if (!commonItems::DoesFileExist(EU4Path + "/map/positions.txt")) - throw std::runtime_error(EU4Path + " does not appear to be a valid EU4 install!"); - Log(LogLevel::Info) << "\tEU4 install path is " << EU4Path; + if (!commonItems::DoesFolderExist(EU5Path)) + throw std::runtime_error("EU5 path " + EU5Path + " does not exist!"); + if (!commonItems::DoesFileExist(EU5Path + "/eu5.exe") && !commonItems::DoesFileExist(EU5Path + "/eu5") && + !commonItems::DoesFolderExist(EU5Path + "/eu5.app")) + throw std::runtime_error(EU5Path + " does not contain Europa Universalis 5!"); + if (!commonItems::DoesFileExist(EU5Path + "/map/positions.txt")) + throw std::runtime_error(EU5Path + " does not appear to be a valid EU5 install!"); + Log(LogLevel::Info) << "\tEU5 install path is " << EU5Path; } void Configuration::verifyVic3Path() { if (!commonItems::DoesFolderExist(Vic3Path)) throw std::runtime_error("Vic3 path " + Vic3Path + " does not exist!"); - // TODO: OSX and Linux paths are speculative - // TODO: As a matter of fact... if (!commonItems::DoesFileExist(Vic3Path + "/binaries/victoria3.exe") && !commonItems::DoesFileExist(Vic3Path + "/Vic3game") && !commonItems::DoesFileExist(Vic3Path + "/binaries/victoria3")) throw std::runtime_error(Vic3Path + " does not contain Victoria 3!"); @@ -144,7 +97,7 @@ void Configuration::setOutputName() { if (outputName.empty()) { - outputName = trimPath(EU4SaveGamePath); + outputName = trimPath(EU5SaveGamePath); } outputName = trimExtension(outputName); @@ -155,28 +108,28 @@ void Configuration::setOutputName() Log(LogLevel::Info) << "Using output name " << outputName; } -void Configuration::verifyEU4Version(const commonItems::ConverterVersion& converterVersion) const +void Configuration::verifyEU5Version(const commonItems::ConverterVersion& converterVersion) const { - const auto EU4Version = GameVersion::extractVersionFromLauncher(EU4Path + "/launcher-settings.json"); - if (!EU4Version) + const auto EU5Version = GameVersion::extractVersionFromLauncher(EU5Path + "/launcher-settings.json"); + if (!EU5Version) { - Log(LogLevel::Error) << "EU4 version could not be determined, proceeding blind!"; + Log(LogLevel::Error) << "EU5 version could not be determined, proceeding blind!"; return; } - Log(LogLevel::Info) << "EU4 version: " << EU4Version->toShortString(); + Log(LogLevel::Info) << "EU5 version: " << EU5Version->toShortString(); - if (converterVersion.getMinSource() > *EU4Version) + if (converterVersion.getMinSource() > *EU5Version) { - Log(LogLevel::Error) << "EU4 version is v" << EU4Version->toShortString() << ", converter requires minimum v" + Log(LogLevel::Error) << "EU5 version is v" << EU5Version->toShortString() << ", converter requires minimum v" << converterVersion.getMinSource().toShortString() << "!"; - throw std::runtime_error("Converter vs EU4 installation mismatch!"); + throw std::runtime_error("Converter vs EU5 installation mismatch!"); } - if (!converterVersion.getMaxSource().isLargerishThan(*EU4Version)) + if (!converterVersion.getMaxSource().isLargerishThan(*EU5Version)) { - Log(LogLevel::Error) << "EU4 version is v" << EU4Version->toShortString() << ", converter requires maximum v" + Log(LogLevel::Error) << "EU5 version is v" << EU5Version->toShortString() << ", converter requires maximum v" << converterVersion.getMaxSource().toShortString() << "!"; - throw std::runtime_error("Converter vs EU4 installation mismatch!"); + throw std::runtime_error("Converter vs EU5 installation mismatch!"); } } diff --git a/EU5ToVic3/Source/Configuration/Configuration.h b/EU5ToVic3/Source/Configuration/Configuration.h index 20d08e5..1af9502 100644 --- a/EU5ToVic3/Source/Configuration/Configuration.h +++ b/EU5ToVic3/Source/Configuration/Configuration.h @@ -16,75 +16,33 @@ class Configuration: commonItems::parser Vanilla = 1, Dynamic = 2 }; - enum class DEADCORES - { - LeaveAll = 1, - DeadCores = 2, - AllCores = 3 - }; - enum class POPSHAPES - { - Vanilla = 1, - PopShaping = 2, - Extreme = 3 - }; - enum class EUROCENTRISM - { - EuroCentric = 1, - VanillaImport = 2 - }; - enum class ECONOMY - { - CivLevel = 1, - DevPopVanilla = 2, - DevPopActual = 3, - Test = 9 - }; - enum class SPLITTCS - { - TradeRegions = 1, - SuperRegions = 2, - Disabled = 3 - }; struct ConfigBlock { STARTDATE startDate = STARTDATE::Vanilla; - POPSHAPES popShaping = POPSHAPES::Vanilla; - DEADCORES removeType = DEADCORES::DeadCores; - EUROCENTRISM euroCentric = EUROCENTRISM::VanillaImport; - ECONOMY economy = ECONOMY::CivLevel; - SPLITTCS splitTCs = SPLITTCS::SuperRegions; - bool convertAll = false; - bool downTiers = true; - double shapingFactor = 1.0; - // runtime options. - bool vn = false; // Voltaire's Nightmare } configBlock; void setOutputName(const std::string& name) { outputName = name; } - void setVN() { configBlock.vn = true; } - void setEurocentric() { configBlock.euroCentric = EUROCENTRISM::EuroCentric; } void setVanillaStartDate() { configBlock.startDate = STARTDATE::Vanilla; } - [[nodiscard]] const auto& getEU4SaveGamePath() const { return EU4SaveGamePath; } - [[nodiscard]] const auto& getEU4Path() const { return EU4Path; } - [[nodiscard]] const auto& getEU4DocumentsPath() const { return EU4DocumentsPath; } + [[nodiscard]] const auto& getEU5SaveGamePath() const { return EU5SaveGamePath; } + [[nodiscard]] const auto& getEU5Path() const { return EU5Path; } + [[nodiscard]] const auto& getEU5DocumentsPath() const { return EU5DocumentsPath; } [[nodiscard]] const auto& getVic3Path() const { return Vic3Path; } [[nodiscard]] const auto& getOutputName() const { return outputName; } private: void registerKeys(); - void verifyEU4Path() const; + void verifyEU5Path() const; void verifyVic3Path(); void setOutputName(); void verifyVic3Version(const commonItems::ConverterVersion& converterVersion) const; - void verifyEU4Version(const commonItems::ConverterVersion& converterVersion) const; + void verifyEU5Version(const commonItems::ConverterVersion& converterVersion) const; // options from configuration.txt - std::string EU4SaveGamePath; - std::string EU4Path; - std::string EU4DocumentsPath; + std::string EU5SaveGamePath; + std::string EU5Path; + std::string EU5DocumentsPath; std::string Vic3Path; std::string outputName; }; diff --git a/EU5ToVic3/Source/EU5ToVic3Converter.cpp b/EU5ToVic3/Source/EU5ToVic3Converter.cpp index 93e717a..1320160 100644 --- a/EU5ToVic3/Source/EU5ToVic3Converter.cpp +++ b/EU5ToVic3/Source/EU5ToVic3Converter.cpp @@ -12,7 +12,7 @@ void convertEU4ToVic3(commonItems::ConverterVersion&& converterVersion) Log(LogLevel::Info) << "<> Configuration imported."; Log(LogLevel::Progress) << "4 %"; - const EU4::World sourceWorld(configuration, converterVersion); + const EU5::World sourceWorld(configuration, converterVersion); const V3::World destWorld(*configuration, sourceWorld); OUT::exportWorld(*configuration, destWorld, converterVersion); diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Army.cpp b/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Army.cpp deleted file mode 100644 index 19e85bc..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Army.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "EU4Army.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "UnitTypeLoader/UnitTypeLoader.h" - -EU4::EU4Army::EU4Army(std::istream& theStream, const std::string& potentialNavy) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); - - if (potentialNavy == "navy") - armyFloats = true; -} - -void EU4::EU4Army::registerKeys() -{ - registerSetter("name", name); - registerSetter("location", location); - registerRegex("regiment|ship", [this](const std::string& unused, std::istream& theStream) { - const EU4Regiment regimentBlock(theStream); - regimentList.push_back(regimentBlock); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -int EU4::EU4Army::getTotalTypeStrength(const std::string& type) const -{ - auto totalStrength = 0; - for (const auto& regiment: regimentList) - if (regiment.getType() == type) - totalStrength += regiment.getStrength(); - - return totalStrength; -} - -void EU4::EU4Army::updateRegimentTypes(const UnitTypeLoader& unitTypeLoader) -{ - for (auto& regiment: regimentList) - { - const auto& unitType = unitTypeLoader.getUnitTypeForRegimentTypeName(regiment.getType()); - if (unitType) - { - regiment.updateUnitType(*unitType); // this replaces "western_medieval_knights" with "infantry" of strength "5". - } - else - { - Log(LogLevel::Warning) << "Illegal unit type: " + regiment.getType() + ", your EU4 installation doesn't have this unit!"; - - // Well then. Let's play silly. - UnitType sillyUnitType; - sillyUnitType.strength = 1; - if (!armyFloats) - sillyUnitType.unitType = "infantry"; - else - sillyUnitType.unitType = "transport"; - regiment.updateUnitType(sillyUnitType); - } - } -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Army.h b/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Army.h deleted file mode 100644 index 03188cd..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Army.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef EU4_ARMY_H -#define EU4_ARMY_H -#include "EU4Regiment.h" -#include - -namespace EU4 -{ -class UnitTypeLoader; -class EU4Army: public commonItems::convenientParser -{ - public: - EU4Army() = default; - EU4Army(std::istream& theStream, const std::string& potentialNavy); // Also applies to ships - - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] auto getLocation() const { return location; } - [[nodiscard]] auto getArmyFloats() const { return armyFloats; } - [[nodiscard]] const auto& getRegiments() const { return regimentList; } - - [[nodiscard]] int getTotalTypeStrength(const std::string& type) const; - - void updateRegimentTypes(const UnitTypeLoader& unitTypeLoader); - - private: - void registerKeys(); - - std::string name; - int location = 0; // provinceID of current army's location. - bool armyFloats = false; - std::vector regimentList; -}; -} // namespace EU4 -#endif // EU4_ARMY_H diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Regiment.cpp b/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Regiment.cpp deleted file mode 100644 index 2ece518..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Regiment.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "EU4Regiment.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::EU4Regiment::EU4Regiment(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::EU4Regiment::registerKeys() -{ - registerSetter("name", name); - registerSetter("type", unitType.unitType); - registerSetter("home", home); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Regiment.h b/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Regiment.h deleted file mode 100644 index 5f0ac11..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Regiment.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef EU4_REGIMENT -#define EU4_REGIMENT -#include "ConvenientParser.h" -#include "UnitTypeLoader/UnitType.h" - -namespace EU4 -{ -class EU4Regiment: public commonItems::convenientParser -{ - public: - EU4Regiment() = default; - explicit EU4Regiment(std::istream& theStream); // Also applies to ships - - [[nodiscard]] auto getHome() const { return home; } - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getType() const { return unitType.unitType; } - [[nodiscard]] auto getStrength() const { return unitType.strength; } - - void updateUnitType(const UnitType& theType) { unitType = theType; } - - private: - void registerKeys(); - - int home = 0; // provinceID of regiment conscription, ie. home. - std::string name; - UnitType unitType; // We load it as "western_medieval_knights" but later update to "infantry", with set strength. -}; -} // namespace EU4 - -#endif // EU4_REGIMENT \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4GovernmentSection.cpp b/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4GovernmentSection.cpp deleted file mode 100644 index 29df989..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4GovernmentSection.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "EU4GovernmentSection.h" -#include "CommonRegexes.h" -#include "EU4ReformStackSection.h" -#include "ParserHelpers.h" - -EU4::GovernmentSection::GovernmentSection(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::GovernmentSection::registerKeys() -{ - registerSetter("government", government); - registerKeyword("reform_stack", [this](std::istream& theStream) { - const ReformStackSection refStack(theStream); - reforms = refStack.getReforms(); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4GovernmentSection.h b/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4GovernmentSection.h deleted file mode 100644 index 52ba33d..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4GovernmentSection.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef EU4_GOVERNMENT_SECTION -#define EU4_GOVERNMENT_SECTION -#include "ConvenientParser.h" -#include - -namespace EU4 -{ -class GovernmentSection: commonItems::convenientParser -{ - public: - explicit GovernmentSection(std::istream& theStream); - - [[nodiscard]] const auto& getGovernment() const { return government; } - [[nodiscard]] const auto& getGovernmentReforms() const { return reforms; } - - private: - void registerKeys(); - - std::string government; - std::set reforms; -}; -} // namespace EU4 - -#endif // EU4_GOVERNMENT_SECTION diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4ReformStackSection.cpp b/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4ReformStackSection.cpp deleted file mode 100644 index d64733b..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4ReformStackSection.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "EU4ReformStackSection.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::ReformStackSection::ReformStackSection(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::ReformStackSection::registerKeys() -{ - registerKeyword("reforms", [this](std::istream& theStream) { - const auto& reformList = commonItems::stringList(theStream).getStrings(); - reforms.insert(reformList.begin(), reformList.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4ReformStackSection.h b/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4ReformStackSection.h deleted file mode 100644 index adf7b10..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryGovernment/EU4ReformStackSection.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef EU4_REFORM_STACK_SECTION -#define EU4_REFORM_STACK_SECTION -#include "Parser.h" -#include - -namespace EU4 -{ -class ReformStackSection: commonItems::parser -{ - public: - explicit ReformStackSection(std::istream& theStream); - - [[nodiscard]] const auto& getReforms() const { return reforms; } - - private: - void registerKeys(); - - std::set reforms; -}; -} // namespace EU4 - -#endif // EU4_REFORM_STACK_SECTION diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistory.cpp b/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistory.cpp deleted file mode 100644 index 951b41e..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistory.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "CountryHistory.h" -#include "CommonRegexes.h" -#include "CountryHistoryDate.h" -#include "ParserHelpers.h" - -EU4::CountryHistory::CountryHistory(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::CountryHistory::registerKeys() -{ - registerSetter("primary_culture", primaryCulture); - registerSetter("religion", religion); - registerRegex(R"(\d+\.\d+\.\d+)", [this](const std::string& unused, std::istream& theStream) { - const CountryHistoryDate theDate(theStream); - auto incCharacters = theDate.getCharacters(); - characters.insert(characters.end(), incCharacters.begin(), incCharacters.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistory.h b/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistory.h deleted file mode 100644 index 52ba339..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistory.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef EU4_COUNTRY_HISTORY_H -#define EU4_COUNTRY_HISTORY_H -#include "ConvenientParser.h" -#include "CountryManager/CountryLeader/EU4Leader.h" - -namespace EU4 -{ -class CountryHistory: commonItems::convenientParser -{ - public: - explicit CountryHistory(std::istream& theStream); - - [[nodiscard]] const auto& getCharacters() const { return characters; } - [[nodiscard]] const auto& getPrimaryCulture() const { return primaryCulture; } - [[nodiscard]] const auto& getReligion() const { return religion; } - - private: - void registerKeys(); - - std::vector characters; - std::string religion; - std::string primaryCulture; -}; -} // namespace EU4 - -#endif // EU4_COUNTRY_HISTORY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistoryDate.cpp b/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistoryDate.cpp deleted file mode 100644 index cba5213..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistoryDate.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "CountryHistoryDate.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::CountryHistoryDate::CountryHistoryDate(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::CountryHistoryDate::registerKeys() -{ - registerKeyword("leader", [this](std::istream& theStream) { - Leader leader; - leader.parseLeader(theStream); - characters.push_back(leader.getCharacter()); - }); - registerRegex("monarch|monarch_heir|heir|queen", [this](const std::string& rulerType, std::istream& theStream) { - Leader leader; - leader.parseRuler(theStream); - auto character = leader.getCharacter(); - if (rulerType == "monarch" || rulerType == "monarch_heir") - character.ruler = true; - else if (rulerType == "heir") - character.heir = true; - else - character.consort = true; - characters.push_back(character); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistoryDate.h b/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistoryDate.h deleted file mode 100644 index 317754c..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryHistory/CountryHistoryDate.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef EU4_COUNTRY_HISTORY_DATE -#define EU4_COUNTRY_HISTORY_DATE -#include "CountryManager/CountryLeader/EU4Leader.h" -#include "Parser.h" - -namespace EU4 -{ -class CountryHistoryDate: commonItems::parser -{ - public: - explicit CountryHistoryDate(std::istream& theStream); - - [[nodiscard]] const auto& getCharacters() const { return characters; } - - private: - void registerKeys(); - - std::vector characters; -}; -} // namespace EU4 - -#endif // EU4_COUNTRY_HISTORY_DATE \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4Character.h b/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4Character.h deleted file mode 100644 index c8af984..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4Character.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef EU4_CHARACTER -#define EU4_CHARACTER -#include "Date.h" -#include - -namespace EU4 -{ -struct Character -{ - int leaderID = 0; - int monarchID = 0; - std::string name; - std::string leaderName; - std::string futureMonarchName; - std::string leaderType; - double heirClaim = 0; - bool female = false; - bool heir = false; - bool ruler = false; - bool consort = false; - bool land = false; - bool naval = false; - date activationDate; - date birthDate; - int fire = 0; - int shock = 0; - int maneuver = 0; - int siege = 0; - std::string country; - std::string countryOfOrigin; - std::string culture; - std::string religion; - std::string dynasty; - std::set traits; - std::string leaderTrait; - int adm = 0; - int dip = 0; - int mil = 0; -}; -} // namespace EU4 - -#endif // EU4_CHARACTER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4Leader.cpp b/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4Leader.cpp deleted file mode 100644 index 7cb4972..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4Leader.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "EU4Leader.h" -#include "CommonRegexes.h" -#include "EU4LeaderID.h" -#include "ParserHelpers.h" - -void EU4::Leader::parseLeader(std::istream& theStream) -{ - registerKeys(); - leaderParser.parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::Leader::parseRuler(std::istream& theStream) -{ - registerKeys(); - rulerParser.parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::Leader::registerKeys() -{ - leaderParser.registerSetter("name", character.leaderName); - leaderParser.registerSetter("type", character.leaderType); - leaderParser.registerKeyword("female", [this](std::istream& theStream) { - commonItems::ignoreItem("unused", theStream); - character.female = true; - }); - leaderParser.registerSetter("manuever", character.maneuver); - leaderParser.registerSetter("fire", character.fire); - leaderParser.registerSetter("shock", character.shock); - leaderParser.registerSetter("siege", character.siege); - leaderParser.registerKeyword("activation", [this](std::istream& theStream) { - character.activationDate = date(commonItems::getString(theStream)); - }); - leaderParser.registerKeyword("birth_date", [this](std::istream& theStream) { - character.birthDate = date(commonItems::getString(theStream)); - }); - leaderParser.registerKeyword("id", [this](std::istream& theStream) { - const LeaderID theID(theStream); - character.leaderID = theID.getIDNum(); - }); - leaderParser.registerKeyword("monarch_id", [this](std::istream& theStream) { - const LeaderID theID(theStream); - character.monarchID = theID.getIDNum(); - }); - leaderParser.registerSetter("personality", character.leaderTrait); - leaderParser.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - rulerParser.registerSetter("name", character.name); - rulerParser.registerSetter("country", character.country); - rulerParser.registerSetter("ADM", character.adm); - rulerParser.registerSetter("DIP", character.dip); - rulerParser.registerSetter("MIL", character.mil); - rulerParser.registerSetter("culture", character.culture); - rulerParser.registerSetter("religion", character.religion); - rulerParser.registerKeyword("personalities", [this](std::istream& theStream) { - const auto keys = commonItems::stringsOfItemNames(theStream).getStrings(); - character.traits.insert(keys.begin(), keys.end()); - }); - rulerParser.registerKeyword("leader_id", [this](std::istream& theStream) { - const LeaderID theID(theStream); - character.leaderID = theID.getIDNum(); - }); - rulerParser.registerKeyword("id", [this](std::istream& theStream) { - const LeaderID theID(theStream); - character.monarchID = theID.getIDNum(); - }); - rulerParser.registerSetter("dynasty", character.dynasty); - rulerParser.registerKeyword("birth_date", [this](std::istream& theStream) { - character.birthDate = date(commonItems::getString(theStream)); - }); - rulerParser.registerKeyword("female", [this](std::istream& theStream) { - commonItems::ignoreItem("unused", theStream); - character.female = true; - }); - rulerParser.registerSetter("monarch_name", character.futureMonarchName); - rulerParser.registerSetter("claim", character.heirClaim); - rulerParser.registerSetter("country_of_origin", character.countryOfOrigin); - rulerParser.registerSetter("culture", character.culture); - rulerParser.registerSetter("religion", character.religion); - rulerParser.registerKeyword("leader", [this](std::istream& theStream) { - leaderParser.parseStream(theStream); - }); - rulerParser.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4Leader.h b/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4Leader.h deleted file mode 100644 index d0e6c52..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4Leader.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef EU4_LEADER -#define EU4_LEADER -#include "ConvenientParser.h" -#include "EU4Character.h" - -namespace EU4 -{ -class Leader: commonItems::convenientParser -{ - public: - Leader() = default; - void parseLeader(std::istream& theStream); - void parseRuler(std::istream& theStream); - - [[nodiscard]] const auto& getCharacter() const { return character; } - - private: - void registerKeys(); - - convenientParser leaderParser; - convenientParser rulerParser; - - Character character; -}; -} // namespace EU4 - -#endif // EU4_LEADER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4LeaderID.cpp b/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4LeaderID.cpp deleted file mode 100644 index 6803804..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4LeaderID.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "EU4LeaderID.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -EU4::LeaderID::LeaderID(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::LeaderID::registerKeys() -{ - registerSetter("id", IDNum); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4LeaderID.h b/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4LeaderID.h deleted file mode 100644 index 69908c9..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryLeader/EU4LeaderID.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef EU4_LEADER_ID -#define EU4_LEADER_ID -#include "ConvenientParser.h" - -namespace EU4 -{ -class LeaderID: commonItems::convenientParser -{ - public: - LeaderID() = default; - explicit LeaderID(std::istream& theStream); - - [[nodiscard]] const auto& getIDNum() const { return IDNum; } - - private: - void registerKeys(); - - int IDNum = 0; -}; -} // namespace EU4 - -#endif // EU4_LEADER_ID \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4RelationDetails.cpp b/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4RelationDetails.cpp deleted file mode 100644 index b9849f0..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4RelationDetails.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "EU4RelationDetails.h" -#include "CommonRegexes.h" -#include "Date.h" -#include "ParserHelpers.h" -#include - -EU4::EU4RelationDetails::EU4RelationDetails(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::EU4RelationDetails::registerKeys() -{ - registerSetter("attitude", attitude); - registerSetter("cached_sum", value); - registerSetter("last_warscore", lastWarScore); - registerKeyword("military_access", [this](std::istream& theStream) { - commonItems::ignoreItem("unused", theStream); - military_access = true; - }); - registerKeyword("truce", [this](std::istream& theStream) { - commonItems::ignoreItem("unused", theStream); - truce = true; - }); - registerKeyword("last_war", [this](std::istream& theStream) { - lastWar = date(commonItems::getString(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional EU4::EU4RelationDetails::getTruceExpiry() const -{ - if (!truce) - return std::nullopt; - date expiryDate = lastWar; - const int expiresIn = 60 + static_cast(std::round(120.0 * static_cast(lastWarScore) / 100.0)); - expiryDate.ChangeByMonths(expiresIn); - return expiryDate; -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4RelationDetails.h b/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4RelationDetails.h deleted file mode 100644 index 4fbe115..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4RelationDetails.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef EU4RELATION_DETAILS_H -#define EU4RELATION_DETAILS_H -#include "ConvenientParser.h" -#include "Date.h" - -namespace EU4 -{ -class EU4RelationDetails: commonItems::convenientParser -{ - public: - EU4RelationDetails() = default; - explicit EU4RelationDetails(std::istream& theStream); - - [[nodiscard]] auto getRelations() const { return value; } - void setValue(int theValue) { value = theValue; } - [[nodiscard]] auto hasMilitaryAccess() const { return military_access; } - [[nodiscard]] const auto& getAttitude() const { return attitude; } - [[nodiscard]] std::optional getTruceExpiry() const; - - private: - void registerKeys(); - - int value = 0; - bool military_access = false; - std::string attitude = "attitude_neutral"; - date lastWar; - int lastWarScore = 0; - bool truce = false; -}; -} // namespace EU4 - -#endif // EU4RELATION_DETAILS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4Relations.cpp b/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4Relations.cpp deleted file mode 100644 index e0da293..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4Relations.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "EU4Relations.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::EU4Relations::EU4Relations(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::EU4Relations::registerKeys() -{ - registerRegex("[A-Z0-9]{3}", [this](const std::string& tag, std::istream& theStream) { - const EU4RelationDetails details(theStream); - relations.emplace(tag, details); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4Relations.h b/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4Relations.h deleted file mode 100644 index f45a9ce..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/CountryRelations/EU4Relations.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef EU4RELATIONS_H -#define EU4RELATIONS_H -#include "EU4RelationDetails.h" -#include "Parser.h" -#include - -namespace EU4 -{ -class EU4Relations: commonItems::parser -{ - public: - explicit EU4Relations(std::istream& theStream); - - [[nodiscard]] const auto& getRelations() const { return relations; } - - private: - void registerKeys(); - - std::map relations; -}; -} // namespace EU4 - -#endif // EU4RELATIONS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4ActiveIdeas.cpp b/EU5ToVic3/Source/EU5World/CountryManager/EU4ActiveIdeas.cpp deleted file mode 100644 index 2526044..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4ActiveIdeas.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "EU4ActiveIdeas.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::EU4ActiveIdeas::EU4ActiveIdeas(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::EU4ActiveIdeas::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& ideaName, std::istream& theStream) { - // Don't bother with incomplete ideas. - if (commonItems::getInt(theStream) >= 7) - activeIdeas.insert(ideaName); - }); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4ActiveIdeas.h b/EU5ToVic3/Source/EU5World/CountryManager/EU4ActiveIdeas.h deleted file mode 100644 index 26d008a..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4ActiveIdeas.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef EU4ACTIVE_IDEAS -#define EU4ACTIVE_IDEAS -#include "Parser.h" -#include - -namespace EU4 -{ -class EU4ActiveIdeas: commonItems::parser -{ - public: - explicit EU4ActiveIdeas(std::istream& theStream); - - [[nodiscard]] const auto& getActiveIdeas() const { return activeIdeas; } - - private: - void registerKeys(); - - std::set activeIdeas; -}; -} // namespace EU4 - -#endif // EU4ACTIVE_IDEAS \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4ActivePolicy.cpp b/EU5ToVic3/Source/EU5World/CountryManager/EU4ActivePolicy.cpp deleted file mode 100644 index 03f6c88..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4ActivePolicy.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "EU4ActivePolicy.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::EU4ActivePolicy::EU4ActivePolicy(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::EU4ActivePolicy::registerKeys() -{ - registerSetter("policy", policy); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4ActivePolicy.h b/EU5ToVic3/Source/EU5World/CountryManager/EU4ActivePolicy.h deleted file mode 100644 index e3dd746..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4ActivePolicy.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef EU4ACTIVE_POLICY_H -#define EU4ACTIVE_POLICY_H -#include "ConvenientParser.h" - -namespace EU4 -{ -class EU4ActivePolicy: commonItems::convenientParser -{ - public: - explicit EU4ActivePolicy(std::istream& theStream); - - [[nodiscard]] const auto& getPolicy() const { return policy; } - - private: - void registerKeys(); - - std::string policy; -}; -} // namespace EU4 - -#endif // EU4ACTIVE_POLICY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4Country.cpp b/EU5ToVic3/Source/EU5World/CountryManager/EU4Country.cpp deleted file mode 100644 index 59eb86a..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4Country.cpp +++ /dev/null @@ -1,470 +0,0 @@ -#include "EU4Country.h" -#include "CommonRegexes.h" -#include "CountryGovernment/EU4GovernmentSection.h" -#include "CountryHistory/CountryHistory.h" -#include "CountryLeader/EU4LeaderID.h" -#include "CountryRelations/EU4Relations.h" -#include "EU4ActiveIdeas.h" -#include "EU4ActivePolicy.h" -#include "EU4CountryFlags.h" -#include "EU4CountryModifier.h" -#include "EU4CountryRival.h" -#include "EU4Technology.h" -#include "Log.h" -#include "OSCompatibilityLayer.h" -#include "ParserHelpers.h" -#include -#include -#include - -EU4::Country::Country(std::string countryTag, std::istream& theStream): tag(std::move(countryTag)) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); - - // for countries lacking explicit culture/religion we grab the one in first history entry. - if (primaryCulture.empty() && !historicalPrimaryCulture.empty()) - primaryCulture = historicalPrimaryCulture; - if (religion.empty() && !historicalReligion.empty()) - religion = historicalReligion; - - determineJapaneseRelations(); - filterActiveCharacters(); -} - -void EU4::Country::registerKeys() -{ - registerKeyword("name", [this](std::istream& theStream) { - name = commonItems::getString(theStream); - // this is win1252 name, so, immediately convert to UTF8. - name = commonItems::convertWin1252ToUTF8(name); - }); - registerKeyword("adjective", [this](std::istream& theStream) { - adjective = commonItems::singleString(theStream).getString(); - // this is win1252 adjective, so, immediately convert to UTF8. - adjective = commonItems::convertWin1252ToUTF8(adjective); - }); - registerKeyword("colors", [this](std::istream& theStream) { - nationalColors = NationalSymbol(theStream); - }); - registerKeyword("capital", [this](std::istream& theStream) { - capital = commonItems::getInt(theStream); - }); - registerKeyword("technology_group", [this](std::istream& theStream) { - techGroup = commonItems::getString(theStream); - }); - registerKeyword("liberty_desire", [this](std::istream& theStream) { - libertyDesire = commonItems::getDouble(theStream); - }); - registerKeyword("institutions", [this](std::istream& theStream) { - for (const auto institution: commonItems::getInts(theStream)) - if (institution == 1) - embracedInstitutions.push_back(true); - else - embracedInstitutions.push_back(false); - }); - registerKeyword("isolationism", [this](std::istream& theStream) { - isolationism = commonItems::getInt(theStream); - }); - registerKeyword("primary_culture", [this](std::istream& theStream) { - primaryCulture = commonItems::getString(theStream); - }); - registerKeyword("religion", [this](std::istream& theStream) { - religion = commonItems::getString(theStream); - }); - registerKeyword("age_score", [this](std::istream& theStream) { - for (const auto& agScore: commonItems::getDoubles(theStream)) - score += agScore; - }); - registerKeyword("stability", [this](std::istream& theStream) { - stability = commonItems::singleDouble(theStream).getDouble(); - }); - registerKeyword("technology", [this](std::istream& theStream) { - const EU4Technology techBlock(theStream); - admTech = techBlock.getAdm(); - dipTech = techBlock.getDip(); - milTech = techBlock.getMil(); - }); - registerRegex("flags|hidden_flags|variables", [this](const std::string& unused, std::istream& theStream) { - auto flagsList = EU4CountryFlags(theStream).getFlags(); - flags.insert(flagsList.begin(), flagsList.end()); - }); - registerKeyword("modifier", [this](std::istream& theStream) { - const EU4CountryModifier newModifier(theStream); - if (!newModifier.getModifier().empty()) - modifiers.insert(newModifier.getModifier()); - }); - registerKeyword("government", [this](std::istream& theStream) { - const GovernmentSection theSection(theStream); - government = theSection.getGovernment(); - governmentReforms = theSection.getGovernmentReforms(); - }); - registerKeyword("government_rank", [this](std::istream& theStream) { - governmentRank = commonItems::getInt(theStream); - }); - registerKeyword("active_relations", [this](std::istream& theStream) { - const EU4Relations activeRelations(theStream); - relations = activeRelations.getRelations(); - }); - registerKeyword("rival", [this](std::istream& theStream) { - const EU4CountryRival rival(theStream); - rivals.emplace(rival.getCountry()); - }); - registerRegex("army|navy", [this](const std::string& armyFloats, std::istream& theStream) { - const EU4Army theArmy(theStream, armyFloats); - armies.push_back(theArmy); - }); - registerKeyword("active_idea_groups", [this](std::istream& theStream) { - const EU4ActiveIdeas activeIdeas(theStream); - nationalIdeas = activeIdeas.getActiveIdeas(); - }); - registerRegex("legitimacy|horde_unity|devotion|meritocracy|republican_tradition", [this](const std::string& unused, std::istream& theStream) { - legitimacyEquivalent = commonItems::getDouble(theStream); - }); - registerKeyword("average_autonomy", [this](std::istream& theStream) { - averageAutonomy = commonItems::singleDouble(theStream).getDouble(); - }); - registerKeyword("colonial_parent", [this](std::istream& theStream) { - commonItems::ignoreItem("unused", theStream); - colony = true; - }); - registerKeyword("overlord", [this](std::istream& theStream) { - overlord = commonItems::getString(theStream); - }); - registerKeyword("history", [this](std::istream& theStream) { - const CountryHistory theCountryHistory(theStream); - historicalCharacters = theCountryHistory.getCharacters(); - historicalPrimaryCulture = theCountryHistory.getPrimaryCulture(); - historicalReligion = theCountryHistory.getReligion(); - }); - registerKeyword("leader", [this](std::istream& theStream) { - const LeaderID idBlock(theStream); - activeLeaderIDs.insert(idBlock.getIDNum()); - }); - registerKeyword("active_policy", [this](std::istream& theStream) { - const EU4ActivePolicy policyBlock(theStream); - policies.insert(policyBlock.getPolicy()); - }); - registerKeyword("absolutism", [this](std::istream& theStream) { - absolutism = commonItems::getDouble(theStream); - }); - registerKeyword("army_tradition", [this](std::istream& theStream) { - armyTradition = commonItems::getDouble(theStream); - }); - registerKeyword("navy_tradition", [this](std::istream& theStream) { - navyTradition = commonItems::getDouble(theStream); - }); - registerKeyword("army_professionalism", [this](std::istream& theStream) { - armyProfessionalism = commonItems::getDouble(theStream); - }); - registerKeyword("monarch", [this](std::istream& theStream) { - monarchID = LeaderID(theStream).getIDNum(); - }); - registerKeyword("heir", [this](std::istream& theStream) { - heirID = LeaderID(theStream).getIDNum(); - }); - registerKeyword("queen", [this](std::istream& theStream) { - consortID = LeaderID(theStream).getIDNum(); - }); - registerKeyword("human", [this](std::istream& theStream) { - isHuman = commonItems::getString(theStream) == "yes"; - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -void EU4::Country::filterActiveCharacters() -{ - // Ruling characters *repeat*. Because they aren't actually characters, they are records of character states at a given time. - // Filter out duplicates. - std::set seenMonarchIDs; - std::set seenLeaderIDs; - - for (auto it = historicalCharacters.rbegin(); it != historicalCharacters.rend(); ++it) - { - const auto& character = *it; - if (character.ruler && monarchID == character.monarchID && !seenMonarchIDs.contains(monarchID)) - { - filteredCharacters.push_back(character); - seenMonarchIDs.emplace(monarchID); - if (character.leaderID > 0) - seenLeaderIDs.emplace(character.leaderID); - } - else if (character.consort && character.monarchID == consortID && !seenMonarchIDs.contains(consortID)) - { - filteredCharacters.push_back(character); - seenMonarchIDs.emplace(character.monarchID); - if (character.leaderID > 0) - seenLeaderIDs.emplace(character.leaderID); - } - else if (character.heir && character.monarchID == heirID && !seenMonarchIDs.contains(heirID)) - { - filteredCharacters.push_back(character); - seenMonarchIDs.emplace(character.monarchID); - if (character.leaderID > 0) - seenLeaderIDs.emplace(character.leaderID); - } - else if (character.leaderID > 0 && activeLeaderIDs.contains(character.leaderID) && !seenLeaderIDs.contains(character.leaderID)) - { - // rulers and heirs that are also leaders have already been added so they won't replicate here. - filteredCharacters.push_back(character); - seenLeaderIDs.emplace(character.leaderID); - } - } -} - -void EU4::Country::determineJapaneseRelations() -{ - if (governmentReforms.contains("shogunate")) - possibleShogun = true; - if (governmentReforms.contains("indep_daimyo")) - possibleDaimyo = true; - if (governmentReforms.contains("daimyo")) - possibleDaimyo = true; -} - -void EU4::Country::setLocalizationName(const std::string& language, const std::string& incName) -{ - namesByLanguage[language] = incName; - if (name.empty() && language == "english") - name = incName; -} - -void EU4::Country::setLocalizationAdjective(const std::string& language, const std::string& incAdjective) -{ - adjectivesByLanguage[language] = incAdjective; - if (adjective.empty() && language == "english") - adjective = incAdjective; -} - -void EU4::Country::addProvince(const std::shared_ptr& province) -{ - provinces.emplace(province->getID(), province); -} - -void EU4::Country::addCore(const std::shared_ptr& core) -{ - cores.emplace(core->getID(), core); -} - -bool EU4::Country::hasModifier(const std::string& modifier) const -{ - return modifiers.contains(modifier); -} - -bool EU4::Country::hasNationalIdea(const std::string& ni) const -{ - return nationalIdeas.contains(ni); -} - -bool EU4::Country::hasFlag(const std::string& flag) const -{ - return flags.contains(flag); -} - -bool EU4::Country::hasReform(const std::string& reform) const -{ - return governmentReforms.contains(reform); -} - -void EU4::Country::updateRegimentTypes(const UnitTypeLoader& unitTypeLoader) -{ - for (auto& theArmy: armies) - theArmy.updateRegimentTypes(unitTypeLoader); -} - -void EU4::Country::buildManufactoryCount(const std::map>& theCountries) -{ - for (const auto& province: provinces | std::views::values) - { - if (province->hasBuilding("weapons")) - ++mfgCount; - if (province->hasBuilding("wharf")) - ++mfgCount; - if (province->hasBuilding("textile")) - ++mfgCount; - if (province->hasBuilding("plantations")) - ++mfgCount; - if (province->hasBuilding("tradecompany")) - ++mfgCount; - if (province->hasBuilding("farm_estate")) - ++mfgCount; - if (province->hasBuilding("mills")) - ++mfgCount; - if (province->hasBuilding("furnace")) - mfgCount += 3; - } - if (!overlord.empty()) - { - const auto transferCount = mfgCount - lround(mfgCount / 2); - mfgTransfer -= transferCount; - const auto& overlordCountry = theCountries.find(overlord); - if (overlordCountry != theCountries.end()) - overlordCountry->second->increaseMfgTransfer(transferCount); - } -} - -double EU4::Country::getManufactoryDensity() const -{ - if (provinces.empty()) - return 0; - else - return static_cast(mfgCount) / static_cast(provinces.size()); -} - -void EU4::Country::eatCountry(const std::shared_ptr& target) -{ - // auto-cannibalism is forbidden - if (target->getTag() == tag) - return; - - Log(LogLevel::Info) << " - " << tag << " is assimilating " << target->getTag(); - - // for calculation of weighted averages - auto totalProvinces = static_cast(target->provinces.size() + provinces.size()); - if (totalProvinces == 0.0) - totalProvinces = 1; - - const auto myWeight = static_cast(provinces.size()) / totalProvinces; - const auto targetWeight = static_cast(target->provinces.size()) / totalProvinces; - - // acquire target's cores (always) - for (const auto& core: target->getCores() | std::views::values) - { - addCore(core); - core->addCore(tag); - core->removeCore(target->tag); - } - - // everything else, do only if this country actually currently exists - if (!target->provinces.empty()) - { - // acquire target's provinces - for (const auto& province: target->provinces | std::views::values) - { - province->setOwnerTag(tag); - province->setControllerTag(tag); - addProvince(province); - } - - // acquire target's armies, navies, admirals, and generals - takeArmies(target); - - // re-balance prestige and techs from weighted average - score = myWeight * score + targetWeight * target->score; - admTech = myWeight * admTech + targetWeight * target->admTech; - dipTech = myWeight * dipTech + targetWeight * target->dipTech; - milTech = myWeight * milTech + targetWeight * target->milTech; - } - - // coreless, landless countries will be cleaned up automatically - target->clearProvinces(); - target->clearCores(); -} - -void EU4::Country::takeArmies(const std::shared_ptr& target) -{ - // acquire target's armies, navies, admirals, and generals - armies.insert(armies.end(), target->armies.begin(), target->armies.end()); - for (const auto& character: target->getCharacters()) - if (!character.leaderType.empty()) - filteredCharacters.push_back(character); - target->clearArmies(); -} - -void EU4::Country::clearArmies() -{ - armies.clear(); - filteredCharacters.clear(); -} - -bool EU4::Country::cultureSurvivesInCores(const std::map>& theCountries) const -{ - // If this were a LANDLESS country, is there some other country that contains our people? - // If so, we shouldn't delete this country as it may reappear. - - for (const auto& core: cores | std::views::values) - { - if (core->getOwnerTag().empty()) // this core province belongs to noone. - continue; - if (core->getCulturePercent(primaryCulture) < 0.5) // this core province doesn't have our people. - continue; - - auto owner = theCountries.find(core->getOwnerTag()); // ownerstring will be someone else, not us. - if (owner != theCountries.end() && owner->second->getPrimaryCulture() != primaryCulture) // and they are not us, ethnically. - return true; - } - return false; -} - -std::string EU4::Country::getName(const std::string& language) const -{ - if (namesByLanguage.contains(language)) - return namesByLanguage.at(language); - - // if we're lacking a specific language, try with english. - if (namesByLanguage.contains("english")) - return namesByLanguage.at("english"); - - // otherwise, eh. - return name; -} - -std::string EU4::Country::getAdjective(const std::string& language) const -{ - if (adjectivesByLanguage.contains(language)) - return adjectivesByLanguage.at(language); - - if (adjectivesByLanguage.contains("english")) - return adjectivesByLanguage.at("english"); - - return adjective; -} - -int EU4::Country::getNumEmbracedInstitutions() const -{ - auto total = 0; - for (const auto institution: embracedInstitutions) - if (institution) - total++; - return total; -} - -void EU4::Country::clearProvinces() -{ - provinces.clear(); -} - -void EU4::Country::clearCores() -{ - cores.clear(); -} - -double EU4::Country::getCountryWeight() const -{ - auto totalDev = 0.0; - for (const auto& province: provinces | std::views::values) - totalDev += province->getProvinceWeight(); - return totalDev; -} - -double EU4::Country::getAverageDevelopment() const -{ - if (provinces.empty()) - return 0; - const double totalDev = std::accumulate(provinces.begin(), provinces.end(), 0.0, [](double sum, const auto& province) { - return sum + province.second->getBaseTax() + province.second->getBaseProduction() + province.second->getBaseManpower(); - }); - return totalDev / static_cast(provinces.size()); -} - -void EU4::Country::removeProvince(int provinceID) -{ - if (provinces.contains(provinceID)) - { - const auto& province = provinces.at(provinceID); - province->removeCore(tag); - } - provinces.erase(provinceID); - cores.erase(provinceID); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4Country.h b/EU5ToVic3/Source/EU5World/CountryManager/EU4Country.h deleted file mode 100644 index ab9d962..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4Country.h +++ /dev/null @@ -1,231 +0,0 @@ -#ifndef EU4_COUNTRY_H -#define EU4_COUNTRY_H -#include "../ProvinceManager/EU4Province.h" -#include "CountryArmy/EU4Army.h" -#include "CountryLeader/EU4Leader.h" -#include "CountryRelations/EU4RelationDetails.h" -#include "NationalSymbol/EU4NationalSymbol.h" -#include "Parser.h" -#include -#include - -namespace EU4 -{ -class Country: commonItems::parser -{ - public: - Country() = default; - Country(std::string countryTag, std::istream& theStream); - - // Tag and links - [[nodiscard]] const auto& getTag() const { return tag; } - void setTag(const auto& theTag) { tag = theTag; } - [[nodiscard]] const auto& getProvinces() const { return provinces; } - [[nodiscard]] const auto& getCores() const { return cores; } - void addProvince(const std::shared_ptr& province); - void removeProvince(int provinceID); - void addCore(const std::shared_ptr& core); - - // statuses - [[nodiscard]] auto isInHRE() const { return inHRE; } - [[nodiscard]] auto isHREmperor() const { return holyRomanEmperor; } - [[nodiscard]] auto isCelestialEmperor() const { return celestialEmperor; } - [[nodiscard]] auto isRevolutionary() const { return revolutionary; } - [[nodiscard]] auto isGP() const { return GP; } - void setInHRE(const bool _inHRE) { inHRE = _inHRE; } - void setCelestialEmperor(const bool _celestialEmperor) { celestialEmperor = _celestialEmperor; } - void setEmperor(const bool _emperor) { holyRomanEmperor = _emperor; } - void setRevolutionary(const bool _rev) { revolutionary = _rev; } - void setGP() { GP = true; } - - // in-game capital, score and tech - [[nodiscard]] auto getCapital() const { return capital; } - [[nodiscard]] auto getScore() const { return score; } - [[nodiscard]] auto getAdmTech() const { return admTech; } - void setAdmTech(double tech) { admTech = tech; } - [[nodiscard]] auto getDipTech() const { return dipTech; } - void setDipTech(double tech) { dipTech = tech; } - [[nodiscard]] auto getMilTech() const { return milTech; } - void setMilTech(double tech) { milTech = tech; } - [[nodiscard]] const auto& getTechGroup() const { return techGroup; } - void setTechGroup(const std::string& group) { techGroup = group; } - [[nodiscard]] double getAverageDevelopment() const; - - // culture religion - [[nodiscard]] const auto& getPrimaryCulture() const { return primaryCulture; } - void setPrimaryCulture(const std::string& culture) { primaryCulture = culture; } - [[nodiscard]] const auto& getReligion() const { return religion; } - void setReligion(const std::string& rel) { religion = rel; } - - // japan - [[nodiscard]] auto getIsolationism() const { return isolationism; } - [[nodiscard]] auto isPossibleDaimyo() const { return possibleDaimyo; } - [[nodiscard]] auto isPossibleShogun() const { return possibleShogun; } - - // flags and variables - [[nodiscard]] auto getFlags() const { return flags; } - void addFlag(const std::string& theFlag) { flags.emplace(theFlag); } - void setFlags(const std::set& fla) { flags = fla; } - [[nodiscard]] bool hasFlag(const std::string&) const; - [[nodiscard]] auto getModifiers() const { return modifiers; } - void setModifiers(const std::set& mods) { modifiers = mods; } - [[nodiscard]] bool hasModifier(const std::string&) const; - [[nodiscard]] bool humanPlayed() const { return isHuman; } - - // characters and armies - [[nodiscard]] const auto& getCharacters() const { return filteredCharacters; } - [[nodiscard]] const auto& getArmies() const { return armies; } - - // relations - [[nodiscard]] const auto& getRelations() const { return relations; } - void addRelation(const std::string& targetTag, const EU4RelationDetails& relation) { relations.emplace(targetTag, relation); } - [[nodiscard]] const auto& getRivals() const { return rivals; } - - // country stats - [[nodiscard]] auto getLegitimacy() const { return legitimacyEquivalent; } - [[nodiscard]] auto getStability() const { return stability; } - [[nodiscard]] auto getAverageAutonomy() const { return averageAutonomy; } - [[nodiscard]] auto getAbsolutism() const { return absolutism; } - [[nodiscard]] auto getArmyTradition() const { return armyTradition; } - [[nodiscard]] auto getNavyTradition() const { return navyTradition; } - [[nodiscard]] auto getArmyProfessionalism() const { return armyProfessionalism; } - - // dependent stuff - [[nodiscard]] auto isColony() const { return colony; } - [[nodiscard]] auto isTradeCompany() const { return tradeCompany; } - void setTradeCompany() { tradeCompany = true; } - [[nodiscard]] const auto& getOverLord() const { return overlord; } - void setOverLord(const std::string& overLordTag) { overlord = overLordTag; } - [[nodiscard]] auto getLibertyDesire() const { return libertyDesire; } - - // government, reforms, ideas, institutions - [[nodiscard]] const auto& getGovernment() const { return government; } - [[nodiscard]] auto getGovernmentRank() const { return governmentRank; } - void setGovernmentRank(int rank) { governmentRank = rank; } - [[nodiscard]] const auto& getReforms() const { return governmentReforms; } - [[nodiscard]] bool hasReform(const std::string&) const; - void addReform(const std::string& theReform) { governmentReforms.emplace(theReform); } - void setReforms(const std::set& forms) { governmentReforms = forms; } - [[nodiscard]] const auto& getPolicies() const { return policies; } - [[nodiscard]] const auto& getEmbracedInstitutions() const { return embracedInstitutions; } - void setEmbracedInstitutions(const std::vector& institutions) { embracedInstitutions = institutions; } - [[nodiscard]] int getNumEmbracedInstitutions() const; - [[nodiscard]] bool hasNationalIdea(const std::string&) const; - [[nodiscard]] const auto& getNationalIdeas() const { return nationalIdeas; } - void setNationalIdeas(const std::set& ideas) { nationalIdeas = ideas; } - - // manufactories - [[nodiscard]] auto getManufactoryCount() const { return mfgCount + mfgTransfer; } - void buildManufactoryCount(const std::map>& theCountries); - [[nodiscard]] double getManufactoryDensity() const; - - // localizations - [[nodiscard]] std::string getName(const std::string& language) const; - [[nodiscard]] std::string getName() const { return name; } - [[nodiscard]] std::string getAdjective(const std::string& language) const; - [[nodiscard]] std::string getAdjective() const { return adjective; } - [[nodiscard]] const auto& getAllNameLocalizations() const { return namesByLanguage; } - [[nodiscard]] const auto& getAllAdjectiveLocalizations() const { return adjectivesByLanguage; } - void setLocalizationName(const std::string& language, const std::string& incName); - void setLocalizationAdjective(const std::string& language, const std::string& incAdjective); - - // colors - [[nodiscard]] const auto& getNationalColors() const { return nationalColors; } - void setNationalColors(const NationalSymbol& symbol) { nationalColors = symbol; } - void setMapColor(const commonItems::Color& color) { nationalColors.setMapColor(color); } - - // processing - [[nodiscard]] bool cultureSurvivesInCores(const std::map>& theCountries) const; - [[nodiscard]] double getCountryWeight() const; - void updateRegimentTypes(const UnitTypeLoader& unitTypeLoader); - void eatCountry(const std::shared_ptr& target); - void filterActiveCharacters(); - - private: - void registerKeys(); - - // various processing functions - void determineJapaneseRelations(); - void clearProvinces(); - void clearCores(); - void increaseMfgTransfer(const int increase) { mfgTransfer += increase; } - void takeArmies(const std::shared_ptr& target); - void clearArmies(); - - std::string tag; - std::map> provinces; - std::map> cores; - - bool inHRE = false; - bool holyRomanEmperor = false; - bool celestialEmperor = false; - bool revolutionary = false; - bool GP = false; - - int capital = 0; // provinceID - double score = 0.0; - double admTech = 0.0; - double dipTech = 0.0; - double milTech = 0.0; - std::string techGroup; - - std::string primaryCulture; - std::string religion; - std::string historicalPrimaryCulture; // we use these 2 when we're lacking a proper entry. - std::string historicalReligion; // we use these 2 when we're lacking a proper entry. - - int isolationism = 1; // the isolationism of the country (for Shinto nations with Mandate of Heaven) - bool possibleDaimyo = false; - bool possibleShogun = false; - - std::set flags; - std::set modifiers; - - int monarchID = 0; - int heirID = 0; - int consortID = 0; - std::set activeLeaderIDs; - std::vector historicalCharacters; // Historical character information - std::vector filteredCharacters; // filtered active characters - - std::vector armies; // and navies - - std::map relations; - std::set rivals; - - double legitimacyEquivalent = 100; // country at 100 doesn't store the value at all for any of the legitimacy-type values - double stability = 0; - double averageAutonomy = 0; - double absolutism = 0; - double armyTradition = 0; - double navyTradition = 0; - double armyProfessionalism = 0; - - bool colony = false; - bool tradeCompany = false; - bool isHuman = false; - std::string overlord; - double libertyDesire = 0.0; - - std::string government = "monarchy"; - int governmentRank = 0; - std::set governmentReforms; - std::set policies; - std::vector embracedInstitutions; - std::set nationalIdeas; - - int mfgCount = 0; - int mfgTransfer = 0; - - // Localization attributes - unsure what we're using yet. - std::string name; - std::string adjective; - std::map namesByLanguage; // language, name - std::map adjectivesByLanguage; // language, adj - - // Colors - NationalSymbol nationalColors; -}; -} // namespace EU4 - -#endif // EU4_COUNTRY_H diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryFlags.cpp b/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryFlags.cpp deleted file mode 100644 index 0f41247..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryFlags.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "EU4CountryFlags.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::EU4CountryFlags::EU4CountryFlags(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::EU4CountryFlags::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& flag, std::istream& theStream) { - commonItems::ignoreItem(flag, theStream); - flags.insert(flag); - }); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryFlags.h b/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryFlags.h deleted file mode 100644 index fa0b781..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryFlags.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef EU4_COUNTRY_FLAGS -#define EU4_COUNTRY_FLAGS -#include "Parser.h" -#include - -namespace EU4 -{ -class EU4CountryFlags: commonItems::parser -{ - public: - EU4CountryFlags() = default; - explicit EU4CountryFlags(std::istream& theStream); - - [[nodiscard]] const auto& getFlags() const { return flags; } - - private: - void registerKeys(); - - std::set flags; -}; -} // namespace EU4 - -#endif // EU4_COUNTRY_FLAGS \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryManager.cpp b/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryManager.cpp deleted file mode 100644 index 24d2ba4..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryManager.cpp +++ /dev/null @@ -1,678 +0,0 @@ -#include "EU4CountryManager.h" -#include "CommonRegexes.h" -#include "DiplomacyParser/DiplomacyParser.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "RegionManager/RegionManager.h" -#include -#include - -namespace -{ -std::vector sortMap(const std::map& theMap) -{ - std::vector sorted; - - std::vector> pairs; - for (const auto& theElement: theMap) - pairs.emplace_back(theElement); - - std::sort(pairs.begin(), pairs.end(), [=](const std::pair& a, const std::pair& b) { - return a.second < b.second; - }); - - for (const auto& tag: pairs | std::views::keys) - sorted.emplace_back(tag); - - return sorted; -} -} // namespace - -void EU4::CountryManager::loadCountries(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::CountryManager::registerKeys() -{ - registerKeyword("---", commonItems::ignoreItem); - registerKeyword("REB", commonItems::ignoreItem); - registerKeyword("PIR", commonItems::ignoreItem); - registerKeyword("NAT", commonItems::ignoreItem); - registerRegex("[A-Z0-9]{3}", [this](const std::string& tag, std::istream& theStream) { - auto country = std::make_shared(tag, theStream); - countries.emplace(tag, country); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::shared_ptr EU4::CountryManager::getCountry(const std::string& tag) const -{ - const auto& country = countries.find(tag); - if (country != countries.end()) - return country->second; - else - return nullptr; -} - -void EU4::CountryManager::loadUnitTypes(const commonItems::ModFilesystem& modFS) -{ - unitTypeLoader.loadUnitTypes(modFS); -} - -void EU4::CountryManager::loadCommonCountries(const commonItems::ModFilesystem& modFS) -{ - commonCountryLoader.loadCommonCountries(modFS); -} - -void EU4::CountryManager::loadLocalizations(const commonItems::ModFilesystem& modFS) -{ - localizationLoader.loadLocalizations(modFS); -} - -void EU4::CountryManager::updateUnitTypes() -{ - for (const auto& country: countries | std::views::values) - country->updateRegimentTypes(unitTypeLoader); -} - -void EU4::CountryManager::linkProvincesToCountries(const ProvinceManager& provinceManager) -{ - const auto& provinces = provinceManager.getAllProvinces(); - - for (const auto& province: provinces | std::views::values) - { - // add provinces to all coreowners. - for (const auto& core: province->getCores()) - if (const auto& coreOwner = countries.find(core); coreOwner != countries.end()) - coreOwner->second->addCore(province); - - // add to actual owner - if (province->getOwnerTag().empty()) - continue; - if (const auto& owner = countries.find(province->getOwnerTag()); owner != countries.end()) - owner->second->addProvince(province); - } - - // also record capital information. - for (const auto& [tag, country]: countries) - { - if (country->getCapital() != 0 && provinces.contains(country->getCapital())) - { - provinces.at(country->getCapital())->addCapital(tag); - } - } -} - -void EU4::CountryManager::setHREAndEmperors(const std::string& HREmperor, const std::string& celestialEmperor, const ProvinceManager& provinceManager) -{ - for (const auto& country: countries | std::views::values) - { - // set HRE stuff - if (country->getCapital() != 0) - { - const auto& capital = provinceManager.getProvince(country->getCapital()); - if (capital && capital->inHre()) - country->setInHRE(true); - } - if (country->getTag() == HREmperor) - country->setEmperor(true); - - // not-HRE stuff - if (country->getTag() == celestialEmperor) - country->setCelestialEmperor(true); - } -} - -void EU4::CountryManager::setRevolutionTarget(const std::string& revolutionTarget) -{ - if (!revolutionTarget.empty()) - { - const auto& country = countries.find(revolutionTarget); - if (country != countries.end()) - { - country->second->setRevolutionary(true); - Log(LogLevel::Info) << "\t^^^ Revolution Lives!"; - return; - } - } - Log(LogLevel::Info) << "\tvvv ... revolution failed. :/"; -} - -void EU4::CountryManager::buildManufactoryCounts() const -{ - for (const auto& country: countries | std::views::values) - country->buildManufactoryCount(countries); -} - -void EU4::CountryManager::injectColorsIntoCountries() -{ - auto counter = 0; - for (const auto& [tag, country]: countries) - { - const auto& color = commonCountryLoader.getCommonColor(tag); - if (color && !country->getNationalColors().getMapColor()) - { - country->setMapColor(*color); - ++counter; - } - } - Log(LogLevel::Info) << "<> " << counter << " countries needed updating."; -} - -void EU4::CountryManager::mergeNations() -{ - if (nationMergeMapper.getMergeDaimyos()) - uniteJapan(); - - for (const auto& mergeBlock: nationMergeMapper.getMergeBlocks()) - if (mergeBlock.shouldMerge() && !mergeBlock.getMaster().empty()) - { - Log(LogLevel::Info) << "- Merging nations for: " << mergeBlock.getMaster(); - const auto& master = getCountry(mergeBlock.getMaster()); - if (!master) - { - Log(LogLevel::Debug) << "Country " << mergeBlock.getMaster() << " in configurables/merge_nations.txt does not exist in the save! Skipping."; - continue; - } - for (const auto& slaveTag: mergeBlock.getSlaves()) - { - const auto& slave = getCountry(slaveTag); - if (!slave) - { - Log(LogLevel::Debug) << "Country " << slaveTag << " in configurables/merge_nations.txt does not exist in the save! Skipping."; - continue; - } - master->eatCountry(slave); - } - } -} - -void EU4::CountryManager::uniteJapan() -{ - Log(LogLevel::Info) << "-> Uniting Japan"; - - // japan, right? - auto japan = getCountry("JAP"); - if (!japan) - { - // no japan. look for japan. - for (const auto& country: countries | std::views::values) - { - if (country->isPossibleShogun()) - { - const auto& tag = country->getTag(); - Log(LogLevel::Info) << "- " << tag << " is the shogun."; - japan = getCountry(tag); - break; - } - } - } - - for (const auto& country: countries | std::views::values) - if (country->isPossibleDaimyo()) - japan->eatCountry(country); -} - -void EU4::CountryManager::injectLocalizations() -{ - auto counter = 0; - auto counterAdj = 0; - for (const auto& theCountry: countries | std::views::values) - { - const auto& nameLocalizations = localizationLoader.getTextInEachLanguage(theCountry->getTag()); - if (nameLocalizations) - for (const auto& [language, name]: *nameLocalizations) - { - theCountry->setLocalizationName(language, name); - ++counter; - } - - const auto& adjectiveLocalizations = localizationLoader.getTextInEachLanguage(theCountry->getTag() + "_ADJ"); - if (adjectiveLocalizations) - for (const auto& [language, adjective]: *adjectiveLocalizations) - { - theCountry->setLocalizationAdjective(language, adjective); - ++counterAdj; - } - } - Log(LogLevel::Info) << "<> " << counter << " country names and " << counterAdj << " country adjectives loaded."; -} - -void EU4::CountryManager::filterDeadNations(Configuration::DEADCORES toggle) -{ - removeEmptyNations(); - - if (toggle == Configuration::DEADCORES::DeadCores) - { - removeDeadLandlessNations(); - } - else if (toggle == Configuration::DEADCORES::AllCores) - { - removeLandlessNations(); - } -} - -void EU4::CountryManager::removeEmptyNations() -{ - // Remove nations without provinces or cores. These are dead by definition as they can't be resurrected. - - auto counter = countries.size(); - std::map> survivingCountries; - - for (const auto& country: countries) - { - const auto& countryProvinces = country.second->getProvinces(); - const auto& countryCores = country.second->getCores(); - if (!countryProvinces.empty() || !countryCores.empty()) - survivingCountries.insert(country); - } - - countries.swap(survivingCountries); - counter -= countries.size(); - - Log(LogLevel::Info) << "<> " << counter << " empty nations disposed, " << countries.size() << " remain."; -} - -void EU4::CountryManager::removeDeadLandlessNations() -{ - // This one removes nations that can't be resurrected from their cores because those provinces don't contain a majority of their - // primary culture. - auto counter = countries.size(); - - std::map> landlessCountries; - for (const auto& country: countries) - if (country.second->getProvinces().empty()) - landlessCountries.insert(country); - - for (const auto& country: landlessCountries) - if (!country.second->cultureSurvivesInCores(countries)) - countries.erase(country.first); - - counter -= countries.size(); - Log(LogLevel::Info) << "<> " << counter << " dead landless nations disposed, " << countries.size() << " remain."; -} - -void EU4::CountryManager::removeLandlessNations() -{ - // The most direct one - no land, no survival. - - auto counter = countries.size(); - std::map> survivingCountries; - - for (const auto& country: countries) - if (const auto& theProvinces = country.second->getProvinces(); !theProvinces.empty()) - survivingCountries.insert(country); - - countries.swap(survivingCountries); - counter -= countries.size(); - Log(LogLevel::Info) << "<> " << counter << " landless nations disposed, " << countries.size() << " remain."; -} - -void EU4::CountryManager::assignGPStatuses() -{ - Log(LogLevel::Info) << "-> Assigning GP statuses."; - std::map prestigeScores; - for (const auto& [tag, country]: countries) - { - if (country->getProvinces().empty()) - continue; - prestigeScores.emplace(tag, country->getScore()); - } - auto prestigeOrder = sortMap(prestigeScores); - if (prestigeOrder.size() >= 8) // take the top 8 EU4 GPs. - prestigeOrder = {prestigeOrder.begin() + prestigeOrder.size() - 8, prestigeOrder.end()}; - const std::set prestigeTags = {prestigeOrder.begin(), prestigeOrder.end()}; - for (const auto& tag: prestigeTags) - countries.at(tag)->setGP(); - - Log(LogLevel::Info) << "<> GPs assigned to " << prestigeTags.size() << " countries."; -} - -void EU4::CountryManager::splitTradeCompanies(const ProvinceManager& provinceManager, - const RegionManager& regionManager, - DiplomacyParser& diplomacyParser, - const Configuration::SPLITTCS splitTCs) -{ - if (splitTCs == Configuration::SPLITTCS::Disabled) - { - Log(LogLevel::Info) << "<> Trade Company splitoff disabled by configuration."; - } - else if (splitTCs == Configuration::SPLITTCS::TradeRegions) - { - splitTradeCompaniesByTradeRegions(provinceManager, regionManager, diplomacyParser); - } - else - { - splitTradeCompaniesBySuperRegions(provinceManager, regionManager, diplomacyParser); - } -} - -void EU4::CountryManager::splitTradeCompaniesBySuperRegions(const ProvinceManager& provinceManager, - const RegionManager& regionManager, - DiplomacyParser& diplomacyParser) -{ - auto counter = 0; - - // filter by regions and tags - const auto& tcLoader = regionManager.getTradeCompanyLoader(); - std::map>> tagRegionProvinces; // tag-> region->provinces - - for (const auto& [provinceID, province]: provinceManager.getAllProvinces()) - { - if (!province->isTradeCompany()) - continue; - // not yet. If this is one of blocked trade regions, then bail. - const auto& tc = tcLoader.getTCForProvince(provinceID); - if (!tc) - continue; - // ok, where are we? - const auto& superRegionName = regionManager.getParentSuperRegionName(provinceID); - if (!superRegionName) - continue; - - if (!tagRegionProvinces.contains(province->getOwnerTag())) - tagRegionProvinces.emplace(province->getOwnerTag(), std::map>{}); - if (!tagRegionProvinces.at(province->getOwnerTag()).contains(*superRegionName)) - tagRegionProvinces.at(province->getOwnerTag()).emplace(*superRegionName, std::set{}); - tagRegionProvinces.at(province->getOwnerTag()).at(*superRegionName).emplace(provinceID); - } - - // Now.. Now now now. Single province, or 3, in a region should remain as is - as a trading port. - // More than one should get cut. So let's cut. - for (const auto& [tag, regionProvinces]: tagRegionProvinces) - { - for (const auto& [region, provinceIDs]: regionProvinces) - { - if (provinceIDs.size() <= 3) - continue; - - std::map> provinces; - for (const auto& provinceID: provinceIDs) - provinces.emplace(provinceID, provinceManager.getProvince(provinceID)); - generateSuperRegionTradeCompany(provinces, tag, region, diplomacyParser); - ++counter; - } - } - Log(LogLevel::Info) << "<> Split " << counter << " trade companies from parents."; -} - -void EU4::CountryManager::splitTradeCompaniesByTradeRegions(const ProvinceManager& provinceManager, - const RegionManager& regionManager, - DiplomacyParser& diplomacyParser) -{ - auto counter = 0; - - // filter by regions and tags - const auto& tcLoader = regionManager.getTradeCompanyLoader(); - std::map>> tagRegionProvinces; // tag-> region->provinces - - for (const auto& [provinceID, province]: provinceManager.getAllProvinces()) - { - if (!province->isTradeCompany()) - continue; - // not yet. - const auto& tc = tcLoader.getTCForProvince(provinceID); - if (!tc) - continue; - // ok, where are we? - if (!tagRegionProvinces.contains(province->getOwnerTag())) - tagRegionProvinces.emplace(province->getOwnerTag(), std::map>{}); - if (!tagRegionProvinces.at(province->getOwnerTag()).contains(tc->name)) - tagRegionProvinces.at(province->getOwnerTag()).emplace(tc->name, std::set{}); - tagRegionProvinces.at(province->getOwnerTag()).at(tc->name).emplace(provinceID); - } - - // Now.. Now now now. Single province, or 4, in a region should remain as is - as a trading port. - // More than one should get cut. So let's cut. - for (const auto& [tag, regionProvinces]: tagRegionProvinces) - { - for (const auto& [region, provinceIDs]: regionProvinces) - { - if (provinceIDs.size() <= 4) - continue; - - const auto& tc = tcLoader.getTradeCompany(region); - std::map> provinces; - for (const auto& provinceID: provinceIDs) - provinces.emplace(provinceID, provinceManager.getProvince(provinceID)); - generateTradeCompanyTradeCompany(provinces, tag, tc, diplomacyParser); - ++counter; - } - } - Log(LogLevel::Info) << "<> Split " << counter << " trade companies from parents."; -} - -void EU4::CountryManager::transferOwnerDataToTC(const std::shared_ptr& tradingCountry, - const std::string& ownerTag, - const std::map>& provinces, - DiplomacyParser& diplomacyParser) -{ - const auto& tag = tradingCountry->getTag(); - const auto& owner = countries.at(ownerTag); - for (const auto& [provinceID, province]: provinces) - { - // clear provinces - owner->removeProvince(provinceID); - // reassign provinces - province->setOwnerTag(tag); - province->setControllerTag(tag); - province->addCore(tag); - tradingCountry->addProvince(province); - tradingCountry->addCore(province); - } - - // lets transfer only what we actually need. - tradingCountry->setAdmTech(owner->getAdmTech()); - tradingCountry->setDipTech(owner->getDipTech()); - tradingCountry->setMilTech(owner->getMilTech()); - tradingCountry->setTechGroup(owner->getTechGroup()); - tradingCountry->setPrimaryCulture(owner->getPrimaryCulture()); - tradingCountry->setReligion(owner->getReligion()); - tradingCountry->setFlags(owner->getFlags()); - tradingCountry->setModifiers(owner->getModifiers()); - tradingCountry->setGovernmentRank(1); // force to 1. - tradingCountry->setReforms(owner->getReforms()); - tradingCountry->setNationalIdeas(owner->getNationalIdeas()); - tradingCountry->setEmbracedInstitutions(owner->getEmbracedInstitutions()); - tradingCountry->setNationalColors(owner->getNationalColors()); // same color. yah. - - // relations - tradingCountry->setOverLord(ownerTag); - auto relation = EU4RelationDetails(); - relation.setValue(75); - tradingCountry->addRelation(ownerTag, relation); - owner->addRelation(tag, relation); - - // subject status - EU4Agreement agreement; - agreement.setOriginTag(ownerTag); - agreement.setTargetTag(tag); - agreement.setAgreementType("private_enterprise"); - diplomacyParser.addAgreement(agreement); -} - -void EU4::CountryManager::generateSuperRegionTradeCompany(const std::map>& provinces, - const std::string& ownerTag, - const std::string& superRegionName, - DiplomacyParser& diplomacyParser) -{ - // Did we "accidentally" delete the owner? - if (!countries.contains(ownerTag)) - return; // best not to dwell on this. - - const auto tag = generateNewTag(); - const auto tradingCountry = std::make_shared(); - tradingCountry->setTag(tag); - - transferOwnerDataToTC(tradingCountry, ownerTag, provinces, diplomacyParser); - - // For superregions, names are a simple affair. - std::map regionalNames; - if (const auto& regionalLocBlock = localizationLoader.getTextInEachLanguage(superRegionName); regionalLocBlock) - regionalNames = *regionalLocBlock; - - if (regionalNames.empty()) // should never happen! - Log(LogLevel::Error) << "We cannot find localization for " << superRegionName << "! What happened to the locs?!"; - - std::map ownerNames; - if (const auto& ownerLocBlock = localizationLoader.getTextInEachLanguage(ownerTag + "_ADJ"); ownerLocBlock) - ownerNames = *ownerLocBlock; - - if (ownerNames.empty()) // should also never happen! - Log(LogLevel::Error) << "We cannot find localization for " << ownerTag + "_ADJ! What happened to the locs?!"; - - std::map tradeCompanyNames; - if (const auto& tcLocBlock = localizationLoader.getTextInEachLanguage("TRADE_COMPANY"); tcLocBlock) - tradeCompanyNames = *tcLocBlock; - - if (tradeCompanyNames.empty()) // If this happened, someone overwrote entire game locs. - Log(LogLevel::Error) << "We cannot find localization for " << TRADE_COMPANY + "! Your installation is broken."; - - for (const auto& [language, tradeName]: tradeCompanyNames) - { - if (ownerNames.contains(language) && regionalNames.contains(language)) - { - std::string longName; // I am no linguist so I cannot do this properly. - if (language == "french") // de, des, du.. I really can't. - { - longName = tradeName + " " + ownerNames.at(language) + " de " + regionalNames.at(language); - } - else if (language == "german") // not a clue if this is correct. - { - longName = ownerNames.at(language) + " " + regionalNames.at(language) + "-" + tradeName; - } - else if (language == "spanish") // ??? Maybe. - { - longName = tradeName + " " + ownerNames.at(language) + " de " + regionalNames.at(language); - } - else - { - longName = ownerNames.at(language) + " " + regionalNames.at(language) + " " + tradeName; - } - tradingCountry->setLocalizationName(language, longName); - tradingCountry->setLocalizationAdjective(language, longName); - } - } - countries.emplace(tag, tradingCountry); -} - -void EU4::CountryManager::generateTradeCompanyTradeCompany(const std::map>& provinces, - const std::string& ownerTag, - const TradeCompany& tc, - DiplomacyParser& diplomacyParser) -{ - // Did we "accidentally" delete the owner? - if (!countries.contains(ownerTag)) - return; // best not to dwell on this. - - const auto tag = generateNewTag(); - const auto tradingCountry = std::make_shared(); - tradingCountry->setTag(tag); - - transferOwnerDataToTC(tradingCountry, ownerTag, provinces, diplomacyParser); - if (tc.color) - tradingCountry->setMapColor(*tc.color); // Let's try this for now. - - // Localizations are funny. First one is usually the one we want, the TRADE_COMPANY_SOUTH_AFRICA_Root_Culture_GetName - // That expands in locmapper to: [Root.Culture.GetName] South Africa Company, which we have to manually insert. - // Failing that, there's the second one: TRADE_COMPANY_SOUTH_AFRICA_Africa_Trade_Company - // That's a straight: South Africa Trade Company, no brains required. First one is better, if present. - // Failing everything, we generate. - bool haveName = false; - for (const auto& name: tc.locNameKeys) - { - if (const auto& locBlock = localizationLoader.getTextInEachLanguage(name); locBlock) - { - auto newBlock = *locBlock; - if (locBlock->contains("english") && locBlock->at("english").find("[Root.") != std::string::npos) - { - // we need to alter. - for (const auto& [language, longName]: *locBlock) - { - std::string insertText; - if (const auto adj = localizationLoader.getTextForKey(ownerTag + "_ADJ", language); adj) - insertText = *adj; // "DUTCH East India Company" because NET_ADJ="Dutch" - else if (const auto& culName = localizationLoader.getTextForKey(countries.at(ownerTag)->getPrimaryCulture(), language); culName) - insertText = *culName; - - if (!insertText.empty()) - { - auto pos1 = longName.find("["); - if (pos1 == std::string::npos) - { - newBlock.erase(language); - continue; - } - auto pos2 = longName.find("]"); - if (pos2 == std::string::npos) - { - newBlock.erase(language); - continue; - } - - newBlock[language] = longName.substr(0, pos1) + insertText + longName.substr(pos2 + 1, longName.size()); - } - else - { - newBlock.erase(language); - } - } - } - else - { - // we're in the second one. Can't do anything about that. - } - if (!newBlock.empty()) - { - haveName = true; - for (const auto& [language, longName]: newBlock) - { - tradingCountry->setLocalizationName(language, longName); - tradingCountry->setLocalizationAdjective(language, longName); - } - break; - } - } - } - if (!haveName) - { - // Well shit. What are we even doing? - if (const auto& countryAdj = localizationLoader.getTextForKey(ownerTag + "_ADJ", "english"); countryAdj) - { - tradingCountry->setLocalizationName("english", *countryAdj + " Trading Company"); - tradingCountry->setLocalizationAdjective("english", *countryAdj + " Trading Company"); - } - else - { - // WTF time. We don't have any locs? NOT AN ISSUE! THIS WILL HAVE LOCS! THERE! THIS COUNTRY OF ALL COUNTRIES WILL HAVE LOCS! - tradingCountry->setLocalizationName("english", "Trading Company"); - tradingCountry->setLocalizationAdjective("english", "Trading Company"); - // THERE! HAPPY?! - } - } - - // and FILE! - countries.emplace(tag, tradingCountry); -} - -std::string EU4::CountryManager::generateNewTag() -{ - std::string eu4Tag; - do - { - std::ostringstream generatedV3TagStream; - generatedV3TagStream << generatedEU4TagPrefix << std::setfill('0') << std::setw(2) << generatedEU4TagSuffix; - eu4Tag = generatedV3TagStream.str(); - - ++generatedEU4TagSuffix; - if (generatedEU4TagSuffix > 99) - { - generatedEU4TagSuffix = 0; - --generatedEU4TagPrefix; - } - } while (countries.contains(eu4Tag)); - return eu4Tag; -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryManager.h b/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryManager.h deleted file mode 100644 index f85f059..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryManager.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef EU4_COUNTRY_MANAGER -#define EU4_COUNTRY_MANAGER -#include "CommonCountryLoader/CommonCountryLoader.h" -#include "Configuration.h" -#include "EU4Country.h" -#include "LocalizationLoader/EU4LocalizationLoader.h" -#include "NationMergeMapper/NationMergeMapper.h" -#include "Parser.h" -#include "ProvinceManager/ProvinceManager.h" -#include "UnitTypeLoader/UnitTypeLoader.h" -#include -#include - -namespace EU4 -{ -class RegionManager; -class DiplomacyParser; -class CountryManager: public commonItems::parser -{ - public: - CountryManager() = default; - - void loadCountries(std::istream& theStream); - - [[nodiscard]] const auto& getCountries() const { return countries; } - [[nodiscard]] std::shared_ptr getCountry(const std::string& tag) const; - [[nodiscard]] const auto& getLocalizationLoader() const { return localizationLoader; } - - // the prep - void loadUnitTypes(const commonItems::ModFilesystem& modFS); - void loadCommonCountries(const commonItems::ModFilesystem& modFS); - void loadLocalizations(const commonItems::ModFilesystem& modFS); - void loadLocalizations(const EU4LocalizationLoader& loader) { localizationLoader = loader; } - void bootNationMergeMapper() { nationMergeMapper.loadNationMerge(); } - void loadNationMergeMapper(const mappers::NationMergeMapper& mapper) { nationMergeMapper = mapper; } - - // the weave - void updateUnitTypes(); - void linkProvincesToCountries(const ProvinceManager& provinceManager); - void setHREAndEmperors(const std::string& HREmperor, const std::string& celestialEmperor, const ProvinceManager& provinceManager); - void setRevolutionTarget(const std::string& revolutionTarget); - void buildManufactoryCounts() const; - void injectColorsIntoCountries(); - void injectLocalizations(); - void mergeNations(); - void filterDeadNations(Configuration::DEADCORES toggle); - void assignGPStatuses(); - void splitTradeCompanies(const ProvinceManager& provinceManager, - const RegionManager& regionManager, - DiplomacyParser& diplomacyParser, - Configuration::SPLITTCS splitTCs); - - private: - void registerKeys(); - void uniteJapan(); - void removeEmptyNations(); - void removeDeadLandlessNations(); - void removeLandlessNations(); - void generateTradeCompanyTradeCompany(const std::map>& provinces, - const std::string& ownerTag, - const TradeCompany& tc, - DiplomacyParser& diplomacyParser); - void generateSuperRegionTradeCompany(const std::map>& provinces, - const std::string& ownerTag, - const std::string& superRegionName, - DiplomacyParser& diplomacyParser); - void splitTradeCompaniesByTradeRegions(const ProvinceManager& provinceManager, const RegionManager& regionManager, DiplomacyParser& diplomacyParser); - void splitTradeCompaniesBySuperRegions(const ProvinceManager& provinceManager, const RegionManager& regionManager, DiplomacyParser& diplomacyParser); - void transferOwnerDataToTC(const std::shared_ptr& tradingCountry, - const std::string& ownerTag, - const std::map>& provinces, - DiplomacyParser& diplomacyParser); - - [[nodiscard]] std::string generateNewTag(); - - std::map> countries; - - UnitTypeLoader unitTypeLoader; - CommonCountryLoader commonCountryLoader; - mappers::NationMergeMapper nationMergeMapper; - EU4LocalizationLoader localizationLoader; - - char generatedEU4TagPrefix = 'X'; - int generatedEU4TagSuffix = 0; -}; -} // namespace EU4 - -#endif // EU4_COUNTRY_MANAGER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryModifier.cpp b/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryModifier.cpp deleted file mode 100644 index e31f307..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryModifier.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "EU4CountryModifier.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::EU4CountryModifier::EU4CountryModifier(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::EU4CountryModifier::registerKeys() -{ - registerSetter("modifier", modifier); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryModifier.h b/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryModifier.h deleted file mode 100644 index 30f48fd..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryModifier.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef EU4_COUNTRY_MODIFIER_H -#define EU4_COUNTRY_MODIFIER_H -#include "ConvenientParser.h" - -namespace EU4 -{ -class EU4CountryModifier: commonItems::convenientParser -{ - public: - EU4CountryModifier() = default; - explicit EU4CountryModifier(std::istream& theStream); - - [[nodiscard]] const auto& getModifier() const { return modifier; } - - private: - void registerKeys(); - - std::string modifier; -}; -} // namespace EU4 - -#endif // EU4_COUNTRY_MODIFIER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryRival.cpp b/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryRival.cpp deleted file mode 100644 index 3e0d0d0..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryRival.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "EU4CountryRival.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::EU4CountryRival::EU4CountryRival(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::EU4CountryRival::registerKeys() -{ - registerSetter("country", country); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryRival.h b/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryRival.h deleted file mode 100644 index 4380208..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4CountryRival.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef EU4_COUNTRY_RIVAL_H -#define EU4_COUNTRY_RIVAL_H -#include "ConvenientParser.h" - -namespace EU4 -{ -class EU4CountryRival: commonItems::convenientParser -{ - public: - EU4CountryRival() = default; - explicit EU4CountryRival(std::istream& theStream); - - [[nodiscard]] const auto& getCountry() const { return country; } - - private: - void registerKeys(); - - std::string country; -}; -} // namespace EU4 - -#endif // EU4_COUNTRY_RIVAL_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4Technology.cpp b/EU5ToVic3/Source/EU5World/CountryManager/EU4Technology.cpp deleted file mode 100644 index 25389b2..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4Technology.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "EU4Technology.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::EU4Technology::EU4Technology(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::EU4Technology::registerKeys() -{ - registerSetter("adm_tech", adm); - registerSetter("dip_tech", dip); - registerSetter("mil_tech", mil); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/EU4Technology.h b/EU5ToVic3/Source/EU5World/CountryManager/EU4Technology.h deleted file mode 100644 index c953342..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/EU4Technology.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef EU4_TECHNOLOGY_H -#define EU4_TECHNOLOGY_H -#include "ConvenientParser.h" - -namespace EU4 -{ -class EU4Technology: commonItems::convenientParser -{ - public: - EU4Technology() = default; - explicit EU4Technology(std::istream& theStream); - - [[nodiscard]] auto getAdm() const { return adm; } - [[nodiscard]] auto getDip() const { return dip; } - [[nodiscard]] auto getMil() const { return mil; } - - private: - void registerKeys(); - - int adm = 0; - int dip = 0; - int mil = 0; -}; -} // namespace EU4 - -#endif // EU4_TECHNOLOGY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4CustomColors.cpp b/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4CustomColors.cpp deleted file mode 100644 index 4a6a522..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4CustomColors.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "EU4CustomColors.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::CustomColors::CustomColors(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::CustomColors::registerKeys() -{ - registerKeyword("flag", [this](std::istream& theStream) { - const commonItems::singleInt flagInt(theStream); - // Why, paradox, why? - if (flagInt.getInt() < 0) - customColors.flagIndex = 1; - else - customColors.flagIndex = flagInt.getInt() + 1; - }); - registerKeyword("color", [this](std::istream& theStream) { - customColors.colorIndex = commonItems::getInt(theStream) + 1; - }); - registerKeyword("symbol_index", [this](std::istream& theStream) { - customColors.symbolIndex = commonItems::getInt(theStream) + 1; - }); - registerKeyword("flag_colors", [this](std::istream& theStream) { - customColors.flagColors = commonItems::Color::Factory{}.getColor(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4CustomColors.h b/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4CustomColors.h deleted file mode 100644 index 9e76db5..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4CustomColors.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef EU4_CUSTOM_COLORS_H -#define EU4_CUSTOM_COLORS_H -#include "Color.h" -#include "EU4CustomColorsBlock.h" - -namespace EU4 -{ -class CustomColors: public commonItems::parser -{ - public: - CustomColors() = default; - explicit CustomColors(std::istream& theStream); - - [[nodiscard]] const auto& getCustomColorsBlock() const { return customColors; } - - private: - void registerKeys(); - - CustomColorsBlock customColors; // It walks like a color, it quacks like a color, but it's in fact a color INDEX from 00_custom_colors.txt -}; -} // namespace EU4 - -#endif // EU4_CUSTOM_COLORS_H diff --git a/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4CustomColorsBlock.h b/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4CustomColorsBlock.h deleted file mode 100644 index c69877c..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4CustomColorsBlock.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef EU4_CUSTOM_COLORS_BLOCK -#define EU4_CUSTOM_COLORS_BLOCK -#include "Color.h" - -namespace EU4 -{ -struct CustomColorsBlock -{ - int flagIndex = 0; - int colorIndex = 0; - int symbolIndex = 0; - std::optional flagColors; -}; -} // namespace EU4 - -#endif // EU4_CUSTOM_COLORS_BLOCK diff --git a/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4NationalSymbol.cpp b/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4NationalSymbol.cpp deleted file mode 100644 index 5cb9e44..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4NationalSymbol.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "EU4NationalSymbol.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::NationalSymbol::NationalSymbol(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::NationalSymbol::registerKeys() -{ - registerKeyword("map_color", [this](std::istream& theStream) { - mapColor = commonItems::Color::Factory{}.getColor(theStream); - }); - registerKeyword("revolutionary_colors", [this](std::istream& theStream) { - revolutionaryColor = commonItems::Color::Factory{}.getColor(theStream); - }); - registerKeyword("custom_colors", [this](std::istream& theStream) { - customColors = CustomColors(theStream).getCustomColorsBlock(); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4NationalSymbol.h b/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4NationalSymbol.h deleted file mode 100644 index 0cfa569..0000000 --- a/EU5ToVic3/Source/EU5World/CountryManager/NationalSymbol/EU4NationalSymbol.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef EU4_NATIONAL_SYMBOL_H -#define EU4_NATIONAL_SYMBOL_H -#include "EU4CustomColors.h" - -namespace EU4 -{ -class NationalSymbol: public commonItems::parser -{ - public: - NationalSymbol() = default; - explicit NationalSymbol(std::istream& theStream); - - [[nodiscard]] const auto& getMapColor() const { return mapColor; } - [[nodiscard]] const auto& getRevolutionaryColor() const { return revolutionaryColor; } - [[nodiscard]] const auto& getCustomColors() const { return customColors; } - - void setMapColor(const commonItems::Color& color) { mapColor = color; } - void setRevolutionaryColor(const commonItems::Color& color) { revolutionaryColor = color; } - void setCustomColors(const CustomColorsBlock& colors) { customColors = colors; } - - private: - void registerKeys(); - - std::optional customColors; - std::optional mapColor; - std::optional revolutionaryColor; -}; -} // namespace EU4 - -#endif // EU4_NATIONAL_SYMBOL_H diff --git a/EU5ToVic3/Source/EU5World/DiplomacyParser/DiplomacyParser.cpp b/EU5ToVic3/Source/EU5World/DiplomacyParser/DiplomacyParser.cpp deleted file mode 100644 index 327623d..0000000 --- a/EU5ToVic3/Source/EU5World/DiplomacyParser/DiplomacyParser.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "DiplomacyParser.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -void EU4::DiplomacyParser::loadDiplomacy(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::DiplomacyParser::registerKeys() -{ - registerRegex("royal_marriage|guarantee|alliance|steer_trade|transfer_trade_power", [this](const std::string& agreementClass, std::istream& theStream) { - EU4Agreement newAgreement(theStream); - newAgreement.setAgreementType(agreementClass); - agreements.push_back(newAgreement); - }); - registerKeyword("dependency", [this](std::istream& theStream) { - const EU4Agreement newAgreement(theStream); - agreements.push_back(newAgreement); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/DiplomacyParser/DiplomacyParser.h b/EU5ToVic3/Source/EU5World/DiplomacyParser/DiplomacyParser.h deleted file mode 100644 index 5c6d84c..0000000 --- a/EU5ToVic3/Source/EU5World/DiplomacyParser/DiplomacyParser.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef DIPLOMACY_PARSER -#define DIPLOMACY_PARSER -#include "EU4Agreement.h" -#include "Parser.h" - -namespace EU4 -{ -class DiplomacyParser: commonItems::parser -{ - public: - DiplomacyParser() = default; - - void loadDiplomacy(std::istream& theStream); - - [[nodiscard]] const auto& getAgreements() const { return agreements; } - void addAgreement(const EU4Agreement& agreement) { agreements.emplace_back(agreement); } - - private: - void registerKeys(); - - std::vector agreements; -}; -} // namespace EU4 - -#endif // DIPLOMACY_PARSER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/DiplomacyParser/EU4Agreement.cpp b/EU5ToVic3/Source/EU5World/DiplomacyParser/EU4Agreement.cpp deleted file mode 100644 index 25bb398..0000000 --- a/EU5ToVic3/Source/EU5World/DiplomacyParser/EU4Agreement.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "EU4Agreement.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::EU4Agreement::EU4Agreement(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::EU4Agreement::registerKeys() -{ - registerRegex("subject_type|type", [this](const std::string& unused, std::istream& theStream) { - agreementType = commonItems::getString(theStream); - }); - registerKeyword("start_date", [this](std::istream& theStream) { - startDate = date(commonItems::getString(theStream)); - }); - registerKeyword("end_date", [this](std::istream& theStream) { - endDate = date(commonItems::getString(theStream)); - }); - registerKeyword("first", [this](std::istream& theStream) { - originTag = commonItems::getString(theStream); - }); - registerKeyword("second", [this](std::istream& theStream) { - targetTag = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/DiplomacyParser/EU4Agreement.h b/EU5ToVic3/Source/EU5World/DiplomacyParser/EU4Agreement.h deleted file mode 100644 index 92559e2..0000000 --- a/EU5ToVic3/Source/EU5World/DiplomacyParser/EU4Agreement.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef EU4_AGREEMENT_H -#define EU4_AGREEMENT_H -#include "Date.h" -#include "Parser.h" - -namespace EU4 -{ -class EU4Agreement: commonItems::parser -{ - public: - EU4Agreement() = default; - explicit EU4Agreement(std::istream& theStream); - - void setAgreementType(const std::string& _type) { agreementType = _type; } - void setOriginTag(const std::string& tag) { originTag = tag; } - void setTargetTag(const std::string& tag) { targetTag = tag; } - - [[nodiscard]] const auto& getAgreementType() const { return agreementType; } - [[nodiscard]] const auto& getOriginTag() const { return originTag; } - [[nodiscard]] const auto& getTargetTag() const { return targetTag; } - [[nodiscard]] const auto& getStartDate() const { return startDate; } - [[nodiscard]] const auto& getEndDate() const { return endDate; } - - private: - void registerKeys(); - - std::string agreementType; - std::string originTag; - std::string targetTag; - date startDate; - date endDate; -}; -} // namespace EU4 - -#endif // EU4_AGREEMENT_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/EmpireParser/EmpireParser.cpp b/EU5ToVic3/Source/EU5World/EmpireParser/EmpireParser.cpp deleted file mode 100644 index 2b86b93..0000000 --- a/EU5ToVic3/Source/EU5World/EmpireParser/EmpireParser.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "EmpireParser.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::EmpireParser::EmpireParser(std::istream& theStream) -{ - registerKeywords(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::EmpireParser::registerKeywords() -{ - registerKeyword("emperor", [this](std::istream& theStream) { - emperor = commonItems::getString(theStream); - }); - registerKeyword("passed_reform", [this](std::istream& theStream) { - reforms.insert(commonItems::getString(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/EmpireParser/EmpireParser.h b/EU5ToVic3/Source/EU5World/EmpireParser/EmpireParser.h deleted file mode 100644 index aa79477..0000000 --- a/EU5ToVic3/Source/EU5World/EmpireParser/EmpireParser.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef EMPIRE_PARSER -#define EMPIRE_PARSER -#include "Parser.h" -#include - -namespace EU4 -{ -class EmpireParser: commonItems::parser -{ - public: - explicit EmpireParser(std::istream& theStream); - - [[nodiscard]] const auto& getEmperor() const { return emperor; } - [[nodiscard]] const auto& getHREReforms() const { return reforms; } - - private: - void registerKeywords(); - - std::string emperor; - std::set reforms; -}; -} // namespace EU4 - -#endif // EMPIRE_PARSER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/EmpireParser/RevolutionParser.cpp b/EU5ToVic3/Source/EU5World/EmpireParser/RevolutionParser.cpp deleted file mode 100644 index abfe5c2..0000000 --- a/EU5ToVic3/Source/EU5World/EmpireParser/RevolutionParser.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "RevolutionParser.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::RevolutionParser::RevolutionParser(std::istream& theStream) -{ - registerKeywords(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::RevolutionParser::registerKeywords() -{ - registerKeyword("revolution_target", [this](std::istream& theStream) { - revolutionTarget = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/EmpireParser/RevolutionParser.h b/EU5ToVic3/Source/EU5World/EmpireParser/RevolutionParser.h deleted file mode 100644 index 43134e6..0000000 --- a/EU5ToVic3/Source/EU5World/EmpireParser/RevolutionParser.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef REVOLUTION_PARSER -#define REVOLUTION_PARSER -#include "Parser.h" -#include - -namespace EU4 -{ -class RevolutionParser: commonItems::parser -{ - public: - explicit RevolutionParser(std::istream& theStream); - - [[nodiscard]] const auto& getRevolutionTarget() const { return revolutionTarget; } - - private: - void registerKeywords(); - - std::string revolutionTarget; -}; -} // namespace EU4 - -#endif // REVOLUTION_PARSER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCost.cpp b/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCost.cpp deleted file mode 100644 index 837c260..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCost.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "BuildingCost.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::BuildingCost::BuildingCost(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::BuildingCost::registerKeys() -{ - registerSetter("cost", cost); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCost.h b/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCost.h deleted file mode 100644 index e3bbf99..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCost.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef BUILDING_COST -#define BUILDING_COST -#include "ConvenientParser.h" - -namespace EU4 -{ -class BuildingCost: commonItems::convenientParser -{ - public: - explicit BuildingCost(std::istream& theStream); - - [[nodiscard]] auto getCost() const { return cost; } - - private: - void registerKeys(); - - double cost = 0; -}; -} // namespace EU4 - -#endif // EU4 \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCostLoader.cpp b/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCostLoader.cpp deleted file mode 100644 index 872d9c3..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCostLoader.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "BuildingCostLoader.h" -#include "BuildingCost.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "OSCompatibilityLayer.h" -#include - -void EU4::BuildingCostLoader::loadBuildingCosts(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - - for (const auto& file: modFS.GetAllFilesInFolder("/common/buildings/")) - { - if (getExtension(file) != "txt") - continue; - parseFile(file); - } - - clearRegisteredKeywords(); -} - -void EU4::BuildingCostLoader::loadBuildingCosts(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::BuildingCostLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& buildingName, std::istream& theStream) { - const BuildingCost building(theStream); - buildingCosts.emplace(buildingName, building.getCost()); - }); -} - -std::optional EU4::BuildingCostLoader::getBuildingCost(const std::string& buildingName) const -{ - const auto& building = buildingCosts.find(buildingName); - if (building != buildingCosts.end()) - return building->second; - else - return std::nullopt; -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCostLoader.h b/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCostLoader.h deleted file mode 100644 index 131dbb8..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/BuildingCostLoader/BuildingCostLoader.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef BUILDING_COST_LOADER -#define BUILDING_COST_LOADER -#include "BuildingCostLoader.h" -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include -#include - -namespace EU4 -{ -class BuildingCostLoader: commonItems::parser -{ - public: - BuildingCostLoader() = default; - - void loadBuildingCosts(const commonItems::ModFilesystem& modFS); - void loadBuildingCosts(std::istream& theStream); - - [[nodiscard]] std::optional getBuildingCost(const std::string& buildingName) const; - - private: - void registerKeys(); - - std::map buildingCosts; -}; -} // namespace EU4 - -#endif // BUILDING_COST_LOADER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegion.cpp b/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegion.cpp deleted file mode 100644 index ec6f21c..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegion.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "ColonialRegion.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::ColonialRegion::ColonialRegion(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::ColonialRegion::registerKeys() -{ - registerKeyword("provinces", [this](std::istream& theStream) { - provinces = commonItems::getInts(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegion.h b/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegion.h deleted file mode 100644 index 642d3db..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegion.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef EU4_COLONIAL_REGION_H -#define EU4_COLONIAL_REGION_H -#include "Parser.h" - -namespace EU4 -{ -class ColonialRegion: commonItems::parser -{ - public: - explicit ColonialRegion(std::istream& theStream); - - [[nodiscard]] const auto& getProvinces() const { return provinces; } - - private: - void registerKeys(); - - std::vector provinces; -}; -} // namespace EU4 - -#endif // EU4_COLONIAL_REGION_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegionLoader.cpp b/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegionLoader.cpp deleted file mode 100644 index 88d56b5..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegionLoader.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "ColonialRegionLoader.h" -#include "ColonialRegion.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "OSCompatibilityLayer.h" -#include "ParserHelpers.h" -#include - -void EU4::ColonialRegionLoader::loadColonialRegions(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - - for (const auto& file: modFS.GetAllFilesInFolder("/common/colonial_regions/")) - { - if (getExtension(file) != "txt") - continue; - parseFile(file); - } - - clearRegisteredKeywords(); - - Log(LogLevel::Info) << "<> " << provinceToColonialRegions.size() << " provinces linked to colonial regions."; -} - -void EU4::ColonialRegionLoader::loadColonialRegions(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::ColonialRegionLoader::registerKeys() -{ - registerRegex(R"(colonial_\w+)", [this](const std::string& regionName, std::istream& theStream) { - const ColonialRegion newRegion(theStream); - for (const auto& provinceID: newRegion.getProvinces()) - provinceToColonialRegions.emplace(provinceID, regionName); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional EU4::ColonialRegionLoader::getColonialRegionForProvince(int province) const -{ - if (const auto& mapping = provinceToColonialRegions.find(province); mapping != provinceToColonialRegions.end()) - return mapping->second; - else - return std::nullopt; -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegionLoader.h b/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegionLoader.h deleted file mode 100644 index 751417e..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/ColonialRegionLoader/ColonialRegionLoader.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef COLONIAL_REGION_LOADER -#define COLONIAL_REGION_LOADER -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include - -namespace EU4 -{ -class ColonialRegionLoader: commonItems::parser -{ - public: - ColonialRegionLoader() = default; - - void loadColonialRegions(std::istream& theStream); - void loadColonialRegions(const commonItems::ModFilesystem& modFS); - - [[nodiscard]] std::optional getColonialRegionForProvince(int province) const; - - private: - void registerKeys(); - - std::map provinceToColonialRegions; -}; -} // namespace EU4 - -#endif // COLONIAL_REGION_LOADER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/CommonCountryLoader/CommonCountryLoader.cpp b/EU5ToVic3/Source/EU5World/Loaders/CommonCountryLoader/CommonCountryLoader.cpp deleted file mode 100644 index c11043d..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/CommonCountryLoader/CommonCountryLoader.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "CommonCountryLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "OSCompatibilityLayer.h" -#include "ParserHelpers.h" -#include -#include -#include -namespace fs = std::filesystem; - -void EU4::CommonCountryLoader::loadCommonCountries(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - - // scoop up all country definitions - for (const auto& file: modFS.GetAllFilesInFolder("/common/country_tags/")) - { - if (getExtension(file) != "txt") - continue; - tagParser.parseFile(file); - } - - // look in each file for color. - for (const auto& [tag, filePath]: tagPaths) - { - auto path = modFS.GetActualFileLocation("/common/" + filePath); - if (!path) - { - Log(LogLevel::Error) << "Where is this file: /common/" + filePath << "?"; - continue; - } - color.reset(); - parseFile(*path); - if (color) - countryColors.emplace(tag, *color); - } - - Log(LogLevel::Info) << "<> " << countryColors.size() << " common countries processed."; - clearRegisteredKeywords(); -} - -void EU4::CommonCountryLoader::registerKeys() -{ - tagParser.registerRegex(commonItems::catchallRegex, [this](const std::string& tag, std::istream& theStream) { - tagPaths.emplace(tag, commonItems::getString(theStream)); - }); - - registerKeyword("color", [this](std::istream& theStream) { - color = commonItems::Color::Factory{}.getColor(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional EU4::CommonCountryLoader::getCommonColor(const std::string& tag) const -{ - const auto& colorItr = countryColors.find(tag); - if (colorItr != countryColors.end()) - return colorItr->second; - else - return std::nullopt; -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/CommonCountryLoader/CommonCountryLoader.h b/EU5ToVic3/Source/EU5World/Loaders/CommonCountryLoader/CommonCountryLoader.h deleted file mode 100644 index c531ae6..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/CommonCountryLoader/CommonCountryLoader.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef COMMON_COUNTRY_LOADER -#define COMMON_COUNTRY_LOADER -#include "Color.h" -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace EU4 -{ -class CommonCountryLoader: commonItems::parser -{ - public: - CommonCountryLoader() = default; - - void loadCommonCountries(const commonItems::ModFilesystem& modFS); - - [[nodiscard]] std::optional getCommonColor(const std::string& tag) const; - - private: - void registerKeys(); - - parser tagParser; - - std::map countryColors; - std::map tagPaths; - std::optional color; -}; -} // namespace EU4 - -#endif // COMMON_COUNTRY_LOADER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureGroupParser.cpp b/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureGroupParser.cpp deleted file mode 100644 index d19a01f..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureGroupParser.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "CultureGroupParser.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include - -EU4::CultureGroupParser::CultureGroupParser(std::string theName, std::istream& theStream, std::set theKnownCultures): - cultureGroupName(std::move(theName)), knownCultures(std::move(theKnownCultures)) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); - - if (!maleNames.empty()) - for (auto& culture: cultures | std::views::values) - culture.addMaleNames(maleNames); - - if (!femaleNames.empty()) - for (auto& culture: cultures | std::views::values) - culture.addFemaleNames(femaleNames); - - if (!dynastyNames.empty()) - for (auto& culture: cultures | std::views::values) - culture.addDynastyNames(dynastyNames); -} - -void EU4::CultureGroupParser::registerKeys() -{ - registerKeyword("country", commonItems::ignoreItem); - registerKeyword("province", commonItems::ignoreItem); - registerRegex("second_graphical_culture|graphical_culture", [this](const std::string& unused, std::istream& theStream) { - commonItems::ignoreItem(unused, theStream); - }); - registerKeyword("male_names", [this](std::istream& theStream) { - maleNames = commonItems::getStrings(theStream); - }); - registerKeyword("female_names", [this](std::istream& theStream) { - femaleNames = commonItems::getStrings(theStream); - }); - registerKeyword("dynasty_names", [this](std::istream& theStream) { - dynastyNames = commonItems::getStrings(theStream); - }); - registerRegex(commonItems::stringRegex, [this](const std::string& cultureName, std::istream& theStream) { - auto newCulture = CultureParser(theStream); - if (!knownCultures.contains(cultureName)) - cultures.emplace(cultureName, newCulture); - }); -} - -void EU4::CultureGroupParser::mergeCulture(const std::string& cultureName, const CultureParser& cultureParser) -{ - const auto& cultureItr = cultures.find(cultureName); - if (cultureItr != cultures.end()) - { - cultureItr->second.addMaleNames(cultureParser.getMaleNames()); - cultureItr->second.addFemaleNames(cultureParser.getFemaleNames()); - cultureItr->second.addDynastyNames(cultureParser.getDynastyNames()); - if (!cultureParser.getPrimaryTag().empty()) - cultureItr->second.setPrimaryTag(cultureParser.getPrimaryTag()); // overwriting with modded. - } - else - { - cultures.emplace(cultureName, cultureParser); - } -} - -std::set EU4::CultureGroupParser::getCultureNames() const -{ - std::set toReturn; - for (const auto& cultureName: cultures | std::views::keys) - toReturn.emplace(cultureName); - return toReturn; -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureGroupParser.h b/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureGroupParser.h deleted file mode 100644 index 1b40164..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureGroupParser.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef CULTURE_GROUP_PARSER -#define CULTURE_GROUP_PARSER -#include "CultureParser.h" -#include "Parser.h" -#include - -namespace EU4 -{ -class CultureGroupParser: commonItems::parser -{ - public: - CultureGroupParser() = default; - CultureGroupParser(std::string theName, std::istream& theStream, std::set theKnownCultures); - - [[nodiscard]] const auto& getName() const { return cultureGroupName; } - [[nodiscard]] const auto& getCultures() const { return cultures; } - - void mergeCulture(const std::string& cultureName, const CultureParser& cultureParser); - [[nodiscard]] std::set getCultureNames() const; - - private: - void registerKeys(); - - std::string cultureGroupName; - std::map cultures; - - std::set knownCultures; // used to discard excess definitions when parsing modded sources. - std::vector maleNames; - std::vector femaleNames; - std::vector dynastyNames; -}; -} // namespace EU4 - -#endif // CULTURE_GROUP_PARSER diff --git a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureLoader.cpp b/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureLoader.cpp deleted file mode 100644 index 2099572..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureLoader.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "CultureLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include -#include - -void EU4::CultureLoader::loadCultures(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - - for (const auto& file: modFS.GetAllFilesInFolder("/common/cultures/")) - { - if (getExtension(file) != "txt") - continue; - parseFile(file); - } - - clearRegisteredKeywords(); - - Log(LogLevel::Info) << "<> Loaded " << cultureGroupsMap.size() << " culture groups."; -} - -void EU4::CultureLoader::loadCultures(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::CultureLoader::registerKeys() -{ - registerRegex(commonItems::stringRegex, [this](const std::string& cultureGroupName, std::istream& theStream) { - auto newGroup = CultureGroupParser(cultureGroupName, theStream, knownCultures); - - if (cultureGroupsMap.contains(cultureGroupName)) - { - // We would normally override base definitions with incoming modded ones, but CK2 definitions - // for example are crap and don't actually list all required cultures, so we have to merge. - for (const auto& [cultureName, culture]: newGroup.getCultures()) - cultureGroupsMap[cultureGroupName].mergeCulture(cultureName, culture); - } - else - { - cultureGroupsMap.emplace(cultureGroupName, newGroup); - } - const auto names = newGroup.getCultureNames(); - knownCultures.insert(names.begin(), names.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional EU4::CultureLoader::getGroupNameForCulture(const std::string& culture) const -{ - for (const auto& [groupName, group]: cultureGroupsMap) - if (group.getCultures().contains(culture)) - return groupName; - return std::nullopt; -} - -std::optional EU4::CultureLoader::getGroupForCulture(const std::string& culture) const -{ - for (const auto& group: cultureGroupsMap | std::views::values) - if (group.getCultures().contains(culture)) - return group; - return std::nullopt; -} - -bool EU4::CultureLoader::containsCulture(const std::string& culture) const -{ - return std::ranges::any_of(cultureGroupsMap.begin(), cultureGroupsMap.end(), [culture](const auto& cultureGroup) { - return cultureGroup.second.getCultures().contains(culture); - }); -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureLoader.h b/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureLoader.h deleted file mode 100644 index 304e140..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureLoader.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef CULTURE_LOADER -#define CULTURE_LOADER -#include "CultureGroupParser.h" -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace EU4 -{ -class CultureLoader: commonItems::parser -{ - public: - CultureLoader() = default; - - void loadCultures(const commonItems::ModFilesystem& modFS); - void loadCultures(std::istream& theStream); - - [[nodiscard]] const auto& getCultureGroupsMap() const { return cultureGroupsMap; } - [[nodiscard]] std::optional getGroupNameForCulture(const std::string& culture) const; - [[nodiscard]] std::optional getGroupForCulture(const std::string& culture) const; - [[nodiscard]] bool containsCulture(const std::string& culture) const; - - private: - void registerKeys(); - - std::set knownCultures; // used to discard excess definitions when parsing modded sources. - std::map cultureGroupsMap; -}; -} // namespace EU4 - -#endif // CULTURE_LOADER diff --git a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureParser.cpp b/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureParser.cpp deleted file mode 100644 index c373387..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureParser.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "CultureParser.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::CultureParser::CultureParser(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::CultureParser::registerKeys() -{ - registerKeyword("primary", [this](std::istream& theStream) { - primaryTag = commonItems::getString(theStream); - }); - registerKeyword("male_names", [this](std::istream& theStream) { - maleNames = commonItems::getStrings(theStream); - }); - registerKeyword("female_names", [this](std::istream& theStream) { - femaleNames = commonItems::getStrings(theStream); - }); - registerKeyword("dynasty_names", [this](std::istream& theStream) { - dynastyNames = commonItems::getStrings(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureParser.h b/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureParser.h deleted file mode 100644 index 3351c50..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/CultureLoader/CultureParser.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef CULTURE_PARSER -#define CULTURE_PARSER -#include "Parser.h" - -namespace EU4 -{ -class CultureParser: commonItems::parser -{ - public: - CultureParser() = default; - explicit CultureParser(std::istream& theStream); - - [[nodiscard]] const auto& getPrimaryTag() const { return primaryTag; } - [[nodiscard]] const auto& getMaleNames() const { return maleNames; } - [[nodiscard]] const auto& getFemaleNames() const { return femaleNames; } - [[nodiscard]] const auto& getDynastyNames() const { return dynastyNames; } - - void setPrimaryTag(const std::string& theTag) { primaryTag = theTag; } - void addMaleNames(const std::vector& theNames) { maleNames.insert(maleNames.end(), theNames.begin(), theNames.end()); } - void addFemaleNames(const std::vector& theNames) { femaleNames.insert(femaleNames.end(), theNames.begin(), theNames.end()); } - void addDynastyNames(const std::vector& theNames) { dynastyNames.insert(dynastyNames.end(), theNames.begin(), theNames.end()); } - - private: - void registerKeys(); - - std::string primaryTag; - std::vector maleNames; - std::vector femaleNames; - std::vector dynastyNames; -}; -} // namespace EU4 - -#endif // CULTURE_PARSER diff --git a/EU5ToVic3/Source/EU5World/Loaders/DefaultMapParser/DefaultMapParser.cpp b/EU5ToVic3/Source/EU5World/Loaders/DefaultMapParser/DefaultMapParser.cpp deleted file mode 100644 index b31bc35..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/DefaultMapParser/DefaultMapParser.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "DefaultMapParser.h" -#include "CommonRegexes.h" -#include "OSCompatibilityLayer.h" -#include "ParserHelpers.h" -#include - -void EU4::DefaultMapParser::loadDefaultMap(const commonItems::ModFilesystem& modFS) -{ - // This is a case where mods take priority over definitions. If a mod has defs than we use those and ignore EU4 installation. - registerKeys(); - - const auto& file = modFS.GetActualFileLocation("/map/default.map"); - if (!file) - throw std::runtime_error("/map/default.map cannot be found!"); - - parseFile(*file); - Log(LogLevel::Info) << "<> " << seas.size() << " seas and " << lakes.size() << " lakes registered."; - - clearRegisteredKeywords(); -} - -void EU4::DefaultMapParser::loadDefaultMap(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::DefaultMapParser::registerKeys() -{ - registerKeyword("sea_starts", [this](std::istream& theStream) { - auto seaList = commonItems::getInts(theStream); - seas.insert(seaList.begin(), seaList.end()); - }); - registerKeyword("only_used_for_random", [this](std::istream& theStream) { - auto rnwList = commonItems::getInts(theStream); - randoms.insert(rnwList.begin(), rnwList.end()); - }); - registerKeyword("lakes", [this](std::istream& theStream) { - auto lakeList = commonItems::getInts(theStream); - lakes.insert(lakeList.begin(), lakeList.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/DefaultMapParser/DefaultMapParser.h b/EU5ToVic3/Source/EU5World/Loaders/DefaultMapParser/DefaultMapParser.h deleted file mode 100644 index 09a2579..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/DefaultMapParser/DefaultMapParser.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef DEFAULTMAP_PARSER -#define DEFAULTMAP_PARSER -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include - -namespace EU4 -{ -class DefaultMapParser: commonItems::parser -{ - public: - DefaultMapParser() = default; - void loadDefaultMap(const commonItems::ModFilesystem& modFS); - void loadDefaultMap(std::istream& theStream); - - [[nodiscard]] const auto& getSeaIDs() const { return seas; } - [[nodiscard]] const auto& getRandomsIDs() const { return randoms; } - [[nodiscard]] const auto& getLakeIDs() const { return lakes; } - - [[nodiscard]] auto isSea(auto provinceID) const { return seas.contains(provinceID); } - [[nodiscard]] auto isLake(auto provinceID) const { return lakes.contains(provinceID); } - [[nodiscard]] auto isRNW(auto provinceID) const { return randoms.contains(provinceID); } - - private: - void registerKeys(); - - std::set seas; - std::set randoms; - std::set lakes; -}; -} // namespace EU4 - -#endif // DEFAULTMAP_PARSER diff --git a/EU5ToVic3/Source/EU5World/Loaders/DefinitionScraper/DefinitionScraper.cpp b/EU5ToVic3/Source/EU5World/Loaders/DefinitionScraper/DefinitionScraper.cpp deleted file mode 100644 index 4c27549..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/DefinitionScraper/DefinitionScraper.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "DefinitionScraper.h" -#include "OSCompatibilityLayer.h" -#include - -void EU4::DefinitionScraper::loadDefinitions(const commonItems::ModFilesystem& modFS) -{ - const auto& file = modFS.GetActualFileLocation("/map/definition.csv"); - if (!file) - throw std::runtime_error("/map/definition.csv cannot be found!"); - - std::ifstream definitionsFile(*file); - parseStream(definitionsFile); - definitionsFile.close(); - - Log(LogLevel::Info) << "<> " << provinceIDs.size() << " province definitions registered."; -} - -void EU4::DefinitionScraper::loadDefinitions(std::istream& theStream) -{ - parseStream(theStream); -} - -void EU4::DefinitionScraper::parseStream(std::istream& theStream) -{ - std::string line; - getline(theStream, line); // discard first line. - - while (!theStream.eof()) - { - getline(theStream, line); - if (!isdigit(line[0]) || line.length() < 4) - continue; - - try - { - const auto& parsedLineID = parseLine(line); - if (parsedLineID) - provinceIDs.insert(*parsedLineID); - // silently ignore crap we managed to avoid ourselves. - } - catch (std::exception& e) - { - throw std::runtime_error("Error in definitions.csv line: [" + line + "]! Breaking. (" + e.what() + ")"); - } - } -} - -std::optional EU4::DefinitionScraper::parseLine(const std::string& line) -{ - // We're parsing entire province line in order to make sure it's legit and valid. - // Mods can come in with broken lines that don't actually load in the game. - - auto sepLoc = line.find(';'); - if (sepLoc == std::string::npos) - return std::nullopt; - auto sepLocSave = sepLoc; - auto ID = std::stoi(line.substr(0, sepLoc)); - sepLoc = line.find(';', sepLocSave + 1); - if (sepLoc == std::string::npos) - return std::nullopt; - - // simulate r - try - { - auto r = static_cast(std::stoi(line.substr(sepLocSave + 1, sepLoc - sepLocSave - 1))); - } - catch (std::exception&) - { - return std::nullopt; - } - sepLocSave = sepLoc; - sepLoc = line.find(';', sepLocSave + 1); - if (sepLoc == std::string::npos) - return std::nullopt; - - // simulate g - try - { - auto g = static_cast(std::stoi(line.substr(sepLocSave + 1, sepLoc - sepLocSave - 1))); - } - catch (std::exception&) - { - return std::nullopt; - } - sepLocSave = sepLoc; - sepLoc = line.find(';', sepLocSave + 1); - if (sepLoc == std::string::npos) - return std::nullopt; - - // simulate b - try - { - auto b = static_cast(std::stoi(line.substr(sepLocSave + 1, sepLoc - sepLocSave - 1))); - } - catch (std::exception&) - { - return std::nullopt; - } - - return ID; -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/DefinitionScraper/DefinitionScraper.h b/EU5ToVic3/Source/EU5World/Loaders/DefinitionScraper/DefinitionScraper.h deleted file mode 100644 index 13bf6f7..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/DefinitionScraper/DefinitionScraper.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef DEFINITION_SCRAPER -#define DEFINITION_SCRAPER -#include "ModLoader/ModFilesystem.h" -#include -#include -#include - -namespace EU4 -{ -class DefinitionScraper -{ - public: - void loadDefinitions(const commonItems::ModFilesystem& modFS); - void loadDefinitions(std::istream& theStream); - - [[nodiscard]] const auto& getProvinceIDs() const { return provinceIDs; } - [[nodiscard]] auto isValidID(auto provinceID) const { return provinceIDs.contains(provinceID); } - - private: - void parseStream(std::istream& theStream); - - [[nodiscard]] std::optional parseLine(const std::string& line); - - std::set provinceIDs; -}; - -} // namespace EU4 -#endif // DEFINITION_SCRAPER diff --git a/EU5ToVic3/Source/EU5World/Loaders/LocalizationLoader/EU4LocalizationLoader.cpp b/EU5ToVic3/Source/EU5World/Loaders/LocalizationLoader/EU4LocalizationLoader.cpp deleted file mode 100644 index b46bd57..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/LocalizationLoader/EU4LocalizationLoader.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include "EU4LocalizationLoader.h" -#include "CommonFunctions.h" -#include -#include -#include -namespace fs = std::filesystem; - -void EU4::EU4LocalizationLoader::loadLocalizations(const commonItems::ModFilesystem& modFS) -{ - for (const auto& file: modFS.GetAllFilesInFolderRecursive("/localisation/")) - { - if (getExtension(file) != "yml") - continue; - readFromFile(file); - } -} - -void EU4::EU4LocalizationLoader::loadLocalizations(std::istream& theStream) -{ - readFromStream(theStream); -} - -void EU4::EU4LocalizationLoader::readFromFile(const std::string& fileName) -{ - std::ifstream locFile(fs::u8path(fileName)); - readFromStream(locFile); - locFile.close(); -} - -void EU4::EU4LocalizationLoader::readFromStream(std::istream& theStream) -{ - std::string line; - std::getline(theStream, line); // First line is the language is like "l_english:" - - const auto& language = determineLanguageForFile(removeUTF8BOM(line)); - if (!language) - return; - - while (!theStream.eof()) - { - std::getline(theStream, line); // Subsequent lines are ' KEY: "Text"' - const auto [key, value] = determineKeyLocalisationPair(line); - if (!key.empty() && !value.empty()) - { - // We read the files in reverse, starting from mods. We don't want vanilla to override our locs. - if (localizations.contains(key) && localizations.at(key).contains(*language)) - continue; - localizations[key][*language] = value; - } - } -} - -std::optional> EU4::EU4LocalizationLoader::getTextInEachLanguage(const std::string& key) const -{ - const auto& keyFindIter = localizations.find(key); - if (keyFindIter == localizations.end()) - return std::nullopt; - else - return keyFindIter->second; -} - -std::optional EU4::EU4LocalizationLoader::getTextForKey(const std::string& key, const std::string& language) const -{ - const auto& keyFindIter = localizations.find(key); - if (keyFindIter == localizations.end()) - return std::nullopt; - - const auto& locMap = keyFindIter->second; - if (locMap.contains(language)) - return locMap.at(language); - if (locMap.contains("english")) - return locMap.at("english"); - - // If we don't have anything but korean, we might as well not respond. - return std::nullopt; -} - -std::optional EU4::EU4LocalizationLoader::determineLanguageForFile(const std::string& text) -{ - if (text.size() < 2 || text[0] != 'l' || text[1] != '_') - return std::nullopt; - - const size_t beginPos = 2; - const auto endPos = text.find(':', beginPos); - if (endPos == std::string::npos) - return std::nullopt; - - return text.substr(beginPos, endPos - beginPos); -} - -std::pair EU4::EU4LocalizationLoader::determineKeyLocalisationPair(const std::string& text) -{ - std::pair blankReturn; - - if (text.size() > 2 && (text[0] == '#' || text[1] == '#')) - return blankReturn; - - const auto keyBeginPos = text.find_first_not_of(' '); - if (keyBeginPos == std::string::npos) - return blankReturn; - - const auto keyEndPos = text.find_first_of(':', keyBeginPos + 1); - const auto quotePos = text.find_first_of('"', keyEndPos); - if (quotePos == std::string::npos) - return blankReturn; - - const auto localizationBeginPos = quotePos + 1; - const auto localizationEndPos = text.find_last_of('"', text.size()); - return std::make_pair(text.substr(keyBeginPos, keyEndPos - keyBeginPos), text.substr(localizationBeginPos, localizationEndPos - localizationBeginPos)); -} - -std::string EU4::EU4LocalizationLoader::removeUTF8BOM(const std::string& text) -{ - if (text.size() >= 3 && text[0] == '\xEF' && text[1] == '\xBB' && text[2] == '\xBF') - return text.substr(3); - else - return text; -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/LocalizationLoader/EU4LocalizationLoader.h b/EU5ToVic3/Source/EU5World/Loaders/LocalizationLoader/EU4LocalizationLoader.h deleted file mode 100644 index 07085e2..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/LocalizationLoader/EU4LocalizationLoader.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef EU4_LOCALIZATION_LOADER -#define EU4_LOCALIZATION_LOADER -#include "ModLoader/ModFilesystem.h" -#include -#include -#include -#include - -namespace EU4 -{ -class EU4LocalizationLoader -{ - public: - EU4LocalizationLoader() = default; - - void loadLocalizations(const commonItems::ModFilesystem& modFS); - void loadLocalizations(std::istream& theStream); - - [[nodiscard]] std::optional> getTextInEachLanguage(const std::string& key) const; - [[nodiscard]] std::optional getTextForKey(const std::string& key, const std::string& language) const; - - private: - void readFromFile(const std::string& fileName); - void readFromStream(std::istream& theStream); - - [[nodiscard]] static std::optional determineLanguageForFile(const std::string& text); - [[nodiscard]] static std::pair determineKeyLocalisationPair(const std::string& text); - [[nodiscard]] static std::string removeUTF8BOM(const std::string& text); - - std::map> localizations; // key, map -}; -} // namespace EU4 - -#endif // EU4_LOCALIZATION_LOADER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/ModLoader/ModNames.cpp b/EU5ToVic3/Source/EU5World/Loaders/ModLoader/ModNames.cpp index 9af0d0e..6b28f8a 100644 --- a/EU5ToVic3/Source/EU5World/Loaders/ModLoader/ModNames.cpp +++ b/EU5ToVic3/Source/EU5World/Loaders/ModLoader/ModNames.cpp @@ -2,14 +2,14 @@ #include "CommonRegexes.h" #include "ParserHelpers.h" -EU4::ModNames::ModNames(std::istream& theStream) +EU5::ModNames::ModNames(std::istream& theStream) { registerKeys(); parseStream(theStream); clearRegisteredKeywords(); } -void EU4::ModNames::registerKeys() +void EU5::ModNames::registerKeys() { registerSetter("filename", path); registerSetter("name", name); diff --git a/EU5ToVic3/Source/EU5World/Loaders/ModLoader/ModNames.h b/EU5ToVic3/Source/EU5World/Loaders/ModLoader/ModNames.h index 92d0d3f..fac0abf 100644 --- a/EU5ToVic3/Source/EU5World/Loaders/ModLoader/ModNames.h +++ b/EU5ToVic3/Source/EU5World/Loaders/ModLoader/ModNames.h @@ -1,8 +1,8 @@ -#ifndef EU4_MODNAMES_H -#define EU4_MODNAMES_H +#ifndef EU5_MODNAMES_H +#define EU5_MODNAMES_H #include "ConvenientParser.h" -namespace EU4 +namespace EU5 { class ModNames: commonItems::convenientParser { @@ -18,6 +18,6 @@ class ModNames: commonItems::convenientParser std::string name; std::string path; }; -} // namespace EU4 +} // namespace EU5 -#endif // EU4_MODNAMES_H \ No newline at end of file +#endif // EU5_MODNAMES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/Religion.h b/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/Religion.h deleted file mode 100644 index 27c9ba2..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/Religion.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef RELIGION_H -#define RELIGION_H -#include "Color.h" -#include - -namespace EU4 -{ -struct Religion -{ - Religion() = default; - Religion(std::string name, std::string group = {}, std::string trappings = {}): - name(std::move(name)), group(std::move(group)), trappings(std::move(trappings)) - { - } - bool operator==(const Religion& rhs) const { return name == rhs.name && group == rhs.group && trappings == rhs.trappings; } - - std::string name; - std::string group; - std::string trappings; // a converted_dynamic_faith_107 can have "orthodox" trappings if split from orthodox in ck3 regardless of actual group. - std::optional color; -}; -} // namespace EU4 - -#endif // RELIGION_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionEntry.cpp b/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionEntry.cpp deleted file mode 100644 index 8e71afd..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionEntry.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "ReligionEntry.h" -#include "Color.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::ReligionEntry::ReligionEntry(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::ReligionEntry::registerKeys() -{ - registerKeyword("color", [this](std::istream& theStream) { - color = commonItems::Color::Factory().getColor(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionEntry.h b/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionEntry.h deleted file mode 100644 index 78d674e..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionEntry.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef RELIGION_ENTRY -#define RELIGION_ENTRY -#include "Color.h" -#include "Parser.h" - -namespace EU4 -{ -class ReligionEntry: commonItems::parser -{ - public: - ReligionEntry(std::istream& theStream); - [[nodiscard]] const auto& getColor() const { return color; } - - private: - void registerKeys(); - - std::optional color; -}; -} // namespace EU4 - -#endif // RELIGION_ENTRY \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionLoader.cpp b/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionLoader.cpp deleted file mode 100644 index 92c8a72..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionLoader.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "ReligionLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ModLoader/ModFilesystem.h" -#include "OSCompatibilityLayer.h" -#include "ParserHelpers.h" -#include "ReligionParser.h" -#include - -void EU4::ReligionLoader::loadReligions(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/religions/")) - { - if (getExtension(fileName) != "txt") - continue; - auto theFileName = trimPath(fileName); - // Watch out for our own special religions. - if (theFileName.starts_with("99_converted_")) - { - // This is one of ours. - const auto pos = theFileName.find("-from-"); // 99_converted_dynamic_faith_107-from-shamanism.txt - if (pos == std::string::npos || pos <= 13) - { - // Someone changed it. Skip metadata. - Log(LogLevel::Warning) << "! Religion Mapper: Filename for custom religion is broken: " << theFileName; - } - else - { - auto source = theFileName.substr(pos + 6, theFileName.size() - 10 - pos); // shaving off ".txt" extension, grabbing "shamanism" - if (source.empty()) // they may be corrupted. "99_converted_dynamic_faith_101-from-.txt" is known CK3 error. - Log(LogLevel::Warning) << "! Religion Mapper: Cannot parse filename for metadata: " << theFileName; - else - activeTrappings = source; - } - } - parseFile(fileName); - activeTrappings.reset(); - } - - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Loaded " << religions.size() << " religions."; -} - -void EU4::ReligionLoader::loadReligions(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::ReligionLoader::registerKeys() -{ - registerRegex(commonItems::stringRegex, [this](const std::string& religionGroup, std::istream& theStream) { - const ReligionParser newGroup(theStream); - auto fetchedReligions = newGroup.getReligions(); - // in case we're parsing our own ck3 religion source file, there should be only one religion in the file, and the trappings will be active. - if (activeTrappings && fetchedReligions.size() == 1) - { - auto customReligion = *fetchedReligions.begin(); - customReligion.group = religionGroup; - customReligion.trappings = *activeTrappings; - religions.emplace(customReligion.name, customReligion); - } - else - { - // all the normal cases - for (auto& religion: fetchedReligions) - { - religion.group = religionGroup; - // We'll set trappings on the other side. - if (religions.contains(religion.name)) - religions.at(religion.name) = religion; - else - religions.emplace(religion.name, religion); - } - } - }); -} - -std::optional EU4::ReligionLoader::getGroupForReligion(const std::string& religion) const -{ - const auto religionItr = religions.find(religion); - if (religionItr == religions.end() || religionItr->second.group.empty()) - return std::nullopt; - - return religionItr->second.group; -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionLoader.h b/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionLoader.h deleted file mode 100644 index 9ec1814..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionLoader.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef RELIGION_LOADER -#define RELIGION_LOADER -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include "Religion.h" - -namespace EU4 -{ -class ReligionLoader: commonItems::parser -{ - public: - ReligionLoader() = default; - - void loadReligions(const commonItems::ModFilesystem& modFS); - void loadReligions(std::istream& theStream); - - [[nodiscard]] const auto& getAllReligions() const { return religions; } - [[nodiscard]] std::optional getGroupForReligion(const std::string& religion) const; - - private: - void registerKeys(); - - std::optional activeTrappings; // used to pass along filename metadata - std::map religions; -}; -} // namespace EU4 - -#endif // RELIGION_LOADER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionParser.cpp b/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionParser.cpp deleted file mode 100644 index 0575292..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionParser.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "ReligionParser.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "ReligionEntry.h" - -EU4::ReligionParser::ReligionParser(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::ReligionParser::registerKeys() -{ - registerKeyword("defender_of_faith", commonItems::ignoreItem); - registerKeyword("can_form_personal_unions", commonItems::ignoreItem); - registerKeyword("center_of_religion", commonItems::ignoreItem); - registerKeyword("flags_with_emblem_percentage", commonItems::ignoreItem); - registerKeyword("flag_emblem_index_range", commonItems::ignoreItem); - registerKeyword("ai_will_propagate_through_trade", commonItems::ignoreItem); - registerKeyword("religious_schools", commonItems::ignoreItem); - registerKeyword("harmonized_modifier", commonItems::ignoreItem); - registerKeyword("crusade_name", commonItems::ignoreItem); - - registerRegex(commonItems::stringRegex, [this](const std::string& religionName, std::istream& theStream) { - const auto religionEntry = ReligionEntry(theStream); - Religion religion; - religion.name = religionName; - if (religionEntry.getColor()) - religion.color = *religionEntry.getColor(); - religions.emplace_back(religion); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionParser.h b/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionParser.h deleted file mode 100644 index c2efcdb..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/ReligionLoader/ReligionParser.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef RELIGIONPARSER -#define RELIGIONPARSER -#include "Parser.h" -#include "Religion.h" - -namespace EU4 -{ -class ReligionParser: commonItems::parser -{ - public: - ReligionParser(std::istream& theStream); - [[nodiscard]] const auto& getReligions() const { return religions; } - - private: - void registerKeys(); - - std::vector religions; -}; -} // namespace EU4 - -#endif // RELIGIONPARSER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompany.h b/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompany.h deleted file mode 100644 index 9f0af32..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompany.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef TRADE_COMPANY -#define TRADE_COMPANY -#include "Color.h" -#include -#include -#include - -namespace EU4 -{ -struct TradeCompany -{ - std::string name; - std::optional color; - std::set provinces; - std::vector locNameKeys; // composite locnameKeys that need to be processed! Fist one is specific, second is generic. -}; -} // namespace EU4 - -#endif // TRADE_COMPANY diff --git a/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyEntry.cpp b/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyEntry.cpp deleted file mode 100644 index aba7488..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyEntry.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "TradeCompanyEntry.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "StringUtils.h" -#include "sstream" - -EU4::TradeCompanyEntry::TradeCompanyEntry(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::TradeCompanyEntry::registerKeys() -{ - registerKeyword("color", [this](std::istream& theStream) { - tradeCompany.color = commonItems::Color::Factory().getColor(theStream); - }); - registerKeyword("provinces", [this](std::istream& theStream) { - auto provinces = commonItems::getInts(theStream); - tradeCompany.provinces.insert(provinces.begin(), provinces.end()); - }); - registerKeyword("names", [this](std::istream& theStream) { - const auto entry = commonItems::stringOfItem(theStream).getString(); - if (entry.find("trigger") != std::string::npos) // let's not go there - triggers need actual comprehension. - return; - std::stringstream theEntry(entry); - auto names = commonItems::assignments(theEntry).getAssignments(); - if (names.contains("name")) - tradeCompany.locNameKeys.emplace_back(commonItems::remQuotes(names.at("name"))); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyEntry.h b/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyEntry.h deleted file mode 100644 index 6a6c5a5..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyEntry.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef TRADE_COMPANY_ENTRY -#define TRADE_COMPANY_ENTRY -#include "Parser.h" -#include "TradeCompany.h" - -namespace EU4 -{ -class TradeCompanyEntry: commonItems::parser -{ - public: - TradeCompanyEntry() = default; - explicit TradeCompanyEntry(std::istream& theStream); - - [[nodiscard]] const auto& getTradeCompany() const { return tradeCompany; } - - private: - void registerKeys(); - - TradeCompany tradeCompany; -}; -} // namespace EU4 - -#endif // TRADE_COMPANY_ENTRY diff --git a/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyLoader.cpp b/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyLoader.cpp deleted file mode 100644 index eb06f2b..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyLoader.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "TradeCompanyLoader.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "TradeCompanyEntry.h" -#include -#include - -void EU4::TradeCompanyLoader::loadTradeCompanies(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading Trade Company Regions."; - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("common/trade_companies")) - parseFile(fileName); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Loaded " << tradingCompanies.size() << " Trade Companies."; -} - -void EU4::TradeCompanyLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& tcName, std::istream& theStream) { - auto tc = TradeCompanyEntry(theStream).getTradeCompany(); - tc.name = tcName; - tradingCompanies.emplace(tcName, tc); - }); -} - -bool EU4::TradeCompanyLoader::isProvinceInTradeRegion(int province) const -{ - return std::ranges::any_of(tradingCompanies, [&](const auto& tradeCompany) { - return tradeCompany.second.provinces.contains(province) && !excludedTCMapper.getExcludedTCs().contains(tradeCompany.second.name); - }); -} - -std::optional EU4::TradeCompanyLoader::getTCForProvince(int province) const -{ - for (const auto& tc: tradingCompanies | std::views::values) - if (tc.provinces.contains(province) && !excludedTCMapper.getExcludedTCs().contains(tc.name)) - return tc; - return std::nullopt; -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyLoader.h b/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyLoader.h deleted file mode 100644 index 9c126db..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/TradeCompanyLoader/TradeCompanyLoader.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef TRADE_COMPANY_LOADER -#define TRADE_COMPANY_LOADER -#include "ExcludedTradeCompaniesMapper/ExcludedTradeCompaniesMapper.h" -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include "TradeCompany.h" - -namespace EU4 -{ -class TradeCompanyLoader: commonItems::parser -{ - public: - TradeCompanyLoader() = default; - void loadTradeCompanies(const commonItems::ModFilesystem& modFS); - void loadExcludedTradeCompanies(const std::string& filePath) { excludedTCMapper.loadMappingRules(filePath); } - - [[nodiscard]] bool isProvinceInTradeRegion(int province) const; - [[nodiscard]] std::optional getTCForProvince(int province) const; - [[nodiscard]] const auto& getTradeCompany(const std::string& name) const { return tradingCompanies.at(name); } - - private: - void registerKeys(); - - std::map tradingCompanies; - mappers::ExcludedTradeCompaniesMapper excludedTCMapper; -}; -} // namespace EU4 - -#endif // TRADE_COMPANY_LOADER diff --git a/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitType.h b/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitType.h deleted file mode 100644 index f854c20..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitType.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef UNIT_TYPE -#define UNIT_TYPE -#include - -namespace EU4 -{ -struct UnitType -{ - std::string unitType; - int strength = 0; -}; -} // namespace EU4 - -#endif // UNIT_TYPE diff --git a/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeLoader.cpp b/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeLoader.cpp deleted file mode 100644 index b340056..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeLoader.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "UnitTypeLoader.h" -#include "CommonFunctions.h" -#include "OSCompatibilityLayer.h" -#include "UnitTypeParser.h" -#include - -void EU4::UnitTypeLoader::loadUnitTypes(const commonItems::ModFilesystem& modFS) -{ - for (const auto& file: modFS.GetAllFilesInFolder("/common/units/")) - { - if (getExtension(file) != "txt") - continue; - addUnitFileToRegimentTypeMap(getPath(file), trimPath(file)); - } - - Log(LogLevel::Info) << "<> Loaded " << unitTypeMap.size() << " unit definitions."; -} - -void EU4::UnitTypeLoader::loadUnitType(const std::string& unitName, std::istream& theStream) -{ - const UnitTypeParser unitType(theStream); - unitTypeMap.emplace(unitName, unitType.getUnitType()); -} - -void EU4::UnitTypeLoader::addUnitFileToRegimentTypeMap(const std::string& directory, const std::string& filename) -{ - auto name = trimExtension(filename); - - const UnitTypeParser unitType(directory + "/" + filename); - if (unitType.getUnitType().unitType.empty()) - { - Log(LogLevel::Warning) << "Unit file for " << name << " at: " << directory << "/" << filename << " has no type!"; - return; - } - - unitTypeMap.emplace(name, unitType.getUnitType()); -} - -std::optional EU4::UnitTypeLoader::getUnitTypeForRegimentTypeName(const std::string& regimentTypeName) const -{ - if (const auto& typeItr = unitTypeMap.find(regimentTypeName); typeItr != unitTypeMap.end()) - return typeItr->second; - else - return std::nullopt; -} diff --git a/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeLoader.h b/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeLoader.h deleted file mode 100644 index ce6042f..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeLoader.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef UNIT_TYPE_LOADER -#define UNIT_TYPE_LOADER -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include "UnitType.h" - -namespace EU4 -{ -class UnitTypeLoader -{ - public: - void loadUnitTypes(const commonItems::ModFilesystem& modFS); - void loadUnitType(const std::string& unitName, std::istream& theStream); - - [[nodiscard]] std::optional getUnitTypeForRegimentTypeName(const std::string& regimentTypeName) const; - - private: - void addUnitFileToRegimentTypeMap(const std::string& directory, const std::string& filename); - - std::map unitTypeMap; -}; -}; // namespace EU4 - -#endif // UNIT_TYPE_LOADER diff --git a/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeParser.cpp b/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeParser.cpp deleted file mode 100644 index ae78caf..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeParser.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "UnitTypeParser.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::UnitTypeParser::UnitTypeParser(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -EU4::UnitTypeParser::UnitTypeParser(const std::string& filePath) -{ - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); -} - -void EU4::UnitTypeParser::registerKeys() -{ - registerKeyword("type", [this](std::istream& theStream) { - unitType.unitType = commonItems::getString(theStream); - }); - registerRegex("maneuver|offensive_morale|defensive_morale|offensive_fire|defensive_fire|offensive_shock|defensive_shock|hull_size", - [this](const std::string& unused, std::istream& theStream) { - unitType.strength += commonItems::singleInt(theStream).getInt(); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeParser.h b/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeParser.h deleted file mode 100644 index 4beb274..0000000 --- a/EU5ToVic3/Source/EU5World/Loaders/UnitTypeLoader/UnitTypeParser.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef UNIT_TYPE_PARSER -#define UNIT_TYPE_PARSER -#include "Parser.h" -#include "UnitType.h" - -namespace EU4 -{ -class UnitTypeParser: commonItems::parser -{ - public: - UnitTypeParser() = default; - explicit UnitTypeParser(std::istream& theStream); - explicit UnitTypeParser(const std::string& filePath); - - [[nodiscard]] const auto& getUnitType() const { return unitType; } - - private: - void registerKeys(); - - UnitType unitType; -}; -}; // namespace EU4 - -#endif // UNIT_TYPE_PARSER diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/DateChange.h b/EU5ToVic3/Source/EU5World/ProvinceManager/DateChange.h deleted file mode 100644 index 0575319..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/DateChange.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef DATE_CHANGE -#define DATE_CHANGE -#include "Parser.h" - -namespace EU4 -{ -struct DateChange -{ - DateChange(const std::string& theChangeType, const std::string& theChangeValue) - { - changeType = theChangeType; - changeValue = theChangeValue; - } - bool operator==(const DateChange& rhs) const { return changeType == rhs.changeType && changeValue == rhs.changeValue; } - - std::string changeType; - std::string changeValue; -}; - -} // namespace EU4 - -#endif // DATE_CHANGE \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/DateItems.cpp b/EU5ToVic3/Source/EU5World/ProvinceManager/DateItems.cpp deleted file mode 100644 index 8a67e3e..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/DateItems.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "DateItems.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::DateItems::DateItems(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::DateItems::registerKeys() -{ - registerRegex("owner|culture|religion", [this](const std::string& changeType, std::istream& theStream) { - dateChanges.emplace_back(DateChange(changeType, commonItems::getString(theStream))); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/DateItems.h b/EU5ToVic3/Source/EU5World/ProvinceManager/DateItems.h deleted file mode 100644 index 24ff54a..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/DateItems.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef DATE_ITEMS -#define DATE_ITEMS -#include "DateChange.h" -#include "Parser.h" -#include - -namespace EU4 -{ -class DateItems: commonItems::parser -{ - public: - explicit DateItems(std::istream& theStream); - - [[nodiscard]] const auto& getDateChanges() const { return dateChanges; } - - private: - void registerKeys(); - - std::vector dateChanges; -}; -} // namespace EU4 - -#endif // DATE_ITEMS \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/EU4Province.cpp b/EU5ToVic3/Source/EU5World/ProvinceManager/EU4Province.cpp deleted file mode 100644 index 25ac9b5..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/EU4Province.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "EU4Province.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -EU4::Province::Province(const std::string& numString, std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); - - provID = 0 - stoi(numString); - - // Provinces without starting culture (nativeless provinces) won't have all entries - if (!provinceHistory.hasInitializedHistory() && !culture.empty() && !religion.empty()) - { - provinceHistory.setStartingCulture(culture); - provinceHistory.setStartingReligion(religion); - } -} - -void EU4::Province::registerKeys() -{ - registerSetter("name", name); - registerSetter("culture", culture); - registerSetter("religion", religion); - registerSetter("base_tax", baseTax); - registerSetter("base_production", baseProduction); - registerSetter("base_manpower", baseManpower); - registerSetter("owner", ownerTag); - registerSetter("controller", controllerTag); - registerKeyword("cores", [this](std::istream& theStream) { - const auto& coreList = commonItems::getStrings(theStream); - cores.insert(coreList.begin(), coreList.end()); - }); - registerKeyword("territorial_core", [this](std::istream& theStream) { - commonItems::ignoreItem("unused", theStream); - territorialCore = true; - }); - registerKeyword("active_trade_company", [this](std::istream& theStream) { - tradeCompany = commonItems::getString(theStream) == "yes"; - }); - registerKeyword("hre", [this](std::istream& theStream) { - inHRE = commonItems::getString(theStream) == "yes"; - }); - registerKeyword("history", [this](std::istream& theStream) { - const ProvinceHistory theHistory(theStream); - provinceHistory = theHistory; - }); - registerKeyword("buildings", [this](std::istream& theStream) { - const ProvinceBuildings theBuildings(theStream); - buildings = theBuildings.getBuildings(); - }); - registerKeyword("great_projects", [this](std::istream& theStream) { - const auto& projectList = commonItems::getStrings(theStream); - greatProjects.insert(projectList.begin(), projectList.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -void EU4::Province::determineProvinceWeight(const BuildingCostLoader& buildingTypes) -{ - // Uncolonized/unowned province is worth exactly zero. - if (ownerTag.empty()) - return; - - auto buildingWeight = 0.0; - for (const auto& buildingName: buildings) - { - const auto& buildingCost = buildingTypes.getBuildingCost(buildingName); - if (buildingCost) - buildingWeight += *buildingCost; - } - // This is the cost of all built buildings, scaled to 1% (every 100 gold in buildings = 1 dev). - buildingWeight /= 100; - - // This is how much dev there is and how much was invested in the province. - const auto currentDevelopment = baseTax + baseProduction + baseManpower; - const auto developmentDelta = currentDevelopment - provinceHistory.getOriginalDevelopment(); - - // Province weight is absolute dev + buildings. It is used in extreme popShaping. - // Also used in dev-based distributions of Vic3 Construction Points - provinceWeight = currentDevelopment + buildingWeight; - - // Investment weight is invested dev + buildings. Its FACTOR is used in devPush popShaping. - investedWeight = developmentDelta + buildingWeight; -} - -double EU4::Province::getCulturePercent(const std::string& theCulture) const -{ - auto culturePercent = 0.0; - for (const auto& pop: provinceHistory.getPopRatios()) - if (pop.getCulture() == theCulture) - culturePercent += pop.getLowerRatio(); - - return culturePercent; -} diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/EU4Province.h b/EU5ToVic3/Source/EU5World/ProvinceManager/EU4Province.h deleted file mode 100644 index 9143ea9..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/EU4Province.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef EU4_PROVINCE_H -#define EU4_PROVINCE_H -#include "BuildingCostLoader/BuildingCostLoader.h" -#include "ConvenientParser.h" -#include "ProvinceBuildings.h" -#include "ProvinceHistory.h" - -namespace EU4 -{ -class Province: commonItems::convenientParser -{ - public: - Province() = default; - Province(const std::string& numString, std::istream& theStream); - - [[nodiscard]] auto getID() const { return provID; } - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getOwnerTag() const { return ownerTag; } - void setOwnerTag(const std::string& theTag) { ownerTag = theTag; } - [[nodiscard]] const auto& getControllerTag() const { return controllerTag; } - void setControllerTag(const std::string& theTag) { controllerTag = theTag; } - [[nodiscard]] const auto& getCulture() const { return culture; } - [[nodiscard]] const auto& getReligion() const { return religion; } - void addCapital(const std::string& theTag) { capitals.emplace(theTag); } - [[nodiscard]] const auto& getCapitals() const { return capitals; } - - [[nodiscard]] auto inHre() const { return inHRE; } - [[nodiscard]] auto isTradeCompany() const { return tradeCompany; } - [[nodiscard]] auto isTerritorialCore() const { return territorialCore; } - - [[nodiscard]] auto getBaseTax() const { return baseTax; } - [[nodiscard]] auto getBaseProduction() const { return baseProduction; } - [[nodiscard]] auto getBaseManpower() const { return baseManpower; } - - [[nodiscard]] const auto& getCores() const { return cores; } - void addCore(const std::string& tag) { cores.insert(tag); } - void removeCore(const std::string& tag) { cores.erase(tag); } - - [[nodiscard]] const auto& getBuildings() const { return buildings; } - [[nodiscard]] const auto& getProvinceHistory() const { return provinceHistory; } - void setProvinceHistory(const ProvinceHistory& history) { provinceHistory = history; } - - [[nodiscard]] auto hasBuilding(const std::string& building) const { return buildings.contains(building); } - [[nodiscard]] auto hasGreatProject(const std::string& greatProject) const { return greatProjects.contains(greatProject); } - - [[nodiscard]] auto isSea() const { return sea; } - void setSea() { sea = true; } - - void setAssimilationFactor(double factor) { assimilationFactor = factor; } - void buildPopRatios(const DatingData& datingData) { provinceHistory.buildPopRatios(assimilationFactor, datingData); } - void markNeoCulture(const std::string& theCulture) { provinceHistory.markNeoCulture(theCulture); } - void purgeHistories() { provinceHistory.purgeHistories(); } - - [[nodiscard]] double getCulturePercent(const std::string& theCulture) const; - [[nodiscard]] const auto& getStartingCulture() const { return provinceHistory.getStartingCulture(); } - - // These relate to province weight, to be used in pop shaping. - void determineProvinceWeight(const BuildingCostLoader& buildingTypes); - [[nodiscard]] auto getProvinceWeight() const { return provinceWeight; } - [[nodiscard]] auto getInvestedWeight() const { return investedWeight; } - void setInvestmentFactor(double factor) { investmentFactor = factor; } - [[nodiscard]] auto getInvestmentFactor() const { return investmentFactor; } - - private: - void registerKeys(); - - int provID = 0; - std::string name; - std::string ownerTag; - std::string controllerTag; - std::string culture; - std::string religion; - std::set capitals; // eu4 tags for whichever countries this is capital. - - bool inHRE = false; - bool territorialCore = false; - bool tradeCompany = false; - bool sea = false; - - // province attributes for weights - double baseTax = 0; - double baseProduction = 0; - double baseManpower = 0; - double provinceWeight = 0; // absolute dev + buildings - double investedWeight = 0; // devpushed dev + buildings - double investmentFactor = 0; // a log function to normalise the investedWeight. - - ProvinceHistory provinceHistory; - std::set cores; - std::set buildings; - std::set greatProjects; - - double assimilationFactor = 0; -}; -} // namespace EU4 - -#endif // EU4_PROVINCE_H diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/PopRatio.cpp b/EU5ToVic3/Source/EU5World/ProvinceManager/PopRatio.cpp deleted file mode 100644 index 9d5fbcb..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/PopRatio.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "PopRatio.h" -#include -#include - -EU4::PopRatio::PopRatio(std::string _culture, std::string _religion): culture(std::move(_culture)), religion(std::move(_religion)) -{ -} - -bool EU4::PopRatio::operator==(const PopRatio& rhs) const -{ - if (culture == rhs.culture && religion == rhs.religion) - return true; - return false; -} - -void EU4::PopRatio::decay(const float diffInYears, const double assimilationFactor) -{ - // for standard factor 0.0025 ratio will decrease by 0.25% every year. It will never hit 0% - // for any assimilation factor but will progressively decrease at an ever-slower rate. - - upperRatio -= upperRatio * (1 - pow(1 - assimilationFactor, diffInYears)); - middleRatio -= middleRatio * (1 - pow(1 - assimilationFactor, diffInYears)); - lowerRatio -= lowerRatio * (1 - pow(1 - assimilationFactor, diffInYears)); -} - -void EU4::PopRatio::increase(const float diffInYears, const double assimilationFactor) -{ - // for standard factor 0.0025 ratio will increase by 0.25% of the remainder every year. It will never hit 100% - // for any assimilation factor but will progressively increase at an ever-slower rate. - - upperRatio += (1 - upperRatio) * (1 - pow(1 - assimilationFactor, diffInYears)); - middleRatio += (1 - middleRatio) * (1 - pow(1 - assimilationFactor, diffInYears)); - lowerRatio += (1 - lowerRatio) * (1 - pow(1 - assimilationFactor, diffInYears)); -} - -void EU4::PopRatio::convertFrom() -{ - upperRatio /= 2; - middleRatio /= 2; -} - -void EU4::PopRatio::convertToCulture(const std::string& _culture) -{ - upperRatio = 0.5; - middleRatio = 0.5; - lowerRatio = 0; - culture = _culture; -} - -void EU4::PopRatio::convertToReligion(const std::string& _religion) -{ - upperRatio = 0.5; - middleRatio = 0.5; - lowerRatio = 0; - religion = _religion; -} - -void EU4::PopRatio::convertTo(const std::string& _culture, const std::string& _religion) -{ - upperRatio = 0.5; - middleRatio = 0.5; - lowerRatio = 0; - culture = _culture; - religion = _religion; -} - -void EU4::PopRatio::mergeRatio(const PopRatio& ratio) -{ - upperRatio += ratio.getUpperRatio(); - middleRatio += ratio.getMiddleRatio(); - lowerRatio += ratio.getLowerRatio(); -} - -void EU4::PopRatio::multiplyRatios(double factor) -{ - upperRatio *= factor; - middleRatio *= factor; - lowerRatio *= factor; -} diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/PopRatio.h b/EU5ToVic3/Source/EU5World/ProvinceManager/PopRatio.h deleted file mode 100644 index 82c5a22..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/PopRatio.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef POP_RATIO_H -#define POP_RATIO_H -#include - -namespace EU4 -{ -class PopRatio -{ - public: - PopRatio(std::string _culture, std::string _religion); - bool operator==(const PopRatio& rhs) const; - - void decay(float diffInYears, double assimilationFactor); - void increase(float diffInYears, double assimilationFactor); - void convertFrom(); - void convertToCulture(const std::string& culture); - void convertToReligion(const std::string& religion); - void convertTo(const std::string& culture, const std::string& religion); - void multiplyRatios(double factor); - - [[nodiscard]] const auto& getCulture() const { return culture; } - [[nodiscard]] const auto& getReligion() const { return religion; } - [[nodiscard]] auto getUpperRatio() const { return upperRatio; } - [[nodiscard]] auto getMiddleRatio() const { return middleRatio; } - [[nodiscard]] auto getLowerRatio() const { return lowerRatio; } - - void markSpent() { spent = true; } - [[nodiscard]] auto isSpent() const { return spent; } - void markNeoCulture() { neoCulture = true; } - [[nodiscard]] auto isNeoCulture() const { return neoCulture; } - - void mergeRatio(const PopRatio& ratio); - - private: - std::string culture; - std::string religion; - double upperRatio = 1; - double middleRatio = 1; - double lowerRatio = 1; - bool spent = false; // Mark as disposable. - bool neoCulture = false; // if true, V3World should map this to an appropriate neoculture. -}; -} // namespace EU4 - -#endif // POP_RATIO_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceBuildings.cpp b/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceBuildings.cpp deleted file mode 100644 index d28ed64..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceBuildings.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "ProvinceBuildings.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::ProvinceBuildings::ProvinceBuildings(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::ProvinceBuildings::registerKeys() -{ - registerRegex(commonItems::stringRegex, [this](const std::string& building, std::istream& theStream) { - commonItems::ignoreItem(building, theStream); - buildings.insert(building); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceBuildings.h b/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceBuildings.h deleted file mode 100644 index 3d441d9..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceBuildings.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef PROVINCE_BUILDINGS_H -#define PROVINCE_BUILDINGS_H -#include "Parser.h" -#include - -namespace EU4 -{ -class ProvinceBuildings: commonItems::parser -{ - public: - ProvinceBuildings() = default; - explicit ProvinceBuildings(std::istream& theStream); - - [[nodiscard]] const auto& getBuildings() const { return buildings; } - - private: - void registerKeys(); - - std::set buildings; -}; -} // namespace EU4 - -#endif // PROVINCE_BUILDINGS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceHistory.cpp b/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceHistory.cpp deleted file mode 100644 index 36a2fd0..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceHistory.cpp +++ /dev/null @@ -1,254 +0,0 @@ -#include "ProvinceHistory.h" -#include "CommonRegexes.h" -#include "Configuration.h" -#include "DateItems.h" -#include "Log.h" -#include "ParserHelpers.h" - -EU4::ProvinceHistory::ProvinceHistory(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::ProvinceHistory::registerKeys() -{ - registerKeyword("owner", [this](std::istream& theStream) { - ownershipHistory.emplace_back(std::make_pair(date("1.1.1"), commonItems::getString(theStream))); - }); - registerKeyword("culture", [this](std::istream& theStream) { - const auto culture = commonItems::getString(theStream); - setStartingCulture(culture); - }); - registerKeyword("religion", [this](std::istream& theStream) { - const auto religion = commonItems::getString(theStream); - setStartingReligion(religion); - }); - registerSetter("base_tax", originalTax); - registerSetter("base_production", originalProduction); - registerSetter("base_manpower", originalManpower); - registerRegex(R"(\d+\.\d+\.\d+)", [this](const std::string& dateString, std::istream& theStream) { - auto theDate = date(dateString); - const DateItems theItems(theStream); - for (const auto& dateChange: theItems.getDateChanges()) - if (dateChange.changeType == "owner") - ownershipHistory.emplace_back(std::make_pair(theDate, dateChange.changeValue)); - else if (dateChange.changeType == "culture") - cultureHistory.emplace_back(std::make_pair(theDate, dateChange.changeValue)); - else if (dateChange.changeType == "religion") - religionHistory.emplace_back(std::make_pair(theDate, dateChange.changeValue)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -void EU4::ProvinceHistory::setStartingCulture(const std::string& culture) -{ - startingCulture = culture; - if (cultureHistory.empty()) - cultureHistory.emplace_back(std::make_pair(date("1.1.1"), culture)); -} - -void EU4::ProvinceHistory::setStartingReligion(const std::string& religion) -{ - startingReligion = religion; - if (religionHistory.empty()) - religionHistory.emplace_back(std::make_pair(date("1.1.1"), religion)); -} - -void EU4::ProvinceHistory::purgeHistories() -{ - if (!cultureHistory.empty()) - { - auto lastCulture = cultureHistory.back(); - lastCulture.first = date("1.1.1"); - cultureHistory.clear(); - cultureHistory.emplace_back(lastCulture); - } - if (!religionHistory.empty()) - { - auto lastReligion = religionHistory.back(); - lastReligion.first = date("1.1.1"); - religionHistory.clear(); - religionHistory.emplace_back(lastReligion); - } -} - -void EU4::ProvinceHistory::buildPopRatios(const double assimilationFactor, const DatingData& datingData) -{ - // Don't build pop ratios for empty provinces. - if (cultureHistory.empty() || religionHistory.empty()) - return; - - auto endDate = datingData.lastEU4Date; - if (endDate > datingData.hardEndingDate || !endDate.isSet()) - endDate = datingData.hardEndingDate; - - // position iterators at beginning of each queue + 1 - std::string startCulture; - auto cultureEvent = cultureHistory.begin(); - if (cultureEvent != cultureHistory.end()) - { - startCulture = cultureEvent->second; - ++cultureEvent; - } - - std::string startReligion; - auto religionEvent = religionHistory.begin(); - if (religionEvent != religionHistory.end()) - { - startReligion = religionEvent->second; - ++religionEvent; - } - - // This is the popRatio we're working on. It'll get modified for every entry and copied into popRatios. - // Idea is that for every new conversion we "make room" by cutting down and decaying *other* popRatios, - // while growing current one by the number of years that pass between events. - - PopRatio currentRatio(startCulture, startReligion); - date cultureEventDate; - date religionEventDate; - - // Sometimes the game queues many repeated events that do the same thing ("set religion to catholic" etc). - // We have to monitor if we've seen these changes before. - std::string lastCulture; - std::string lastReligion; - - // We start not by first date but by EU4 game start. We don't care what happened before. - auto lastLoopDate = datingData.startEU4Date; - const auto futureDate = date("9999.1.1"); // this is a future date we set to queues that we don't want to touch any more. - - while (cultureEvent != cultureHistory.end() || religionEvent != religionHistory.end()) - { - if (cultureEvent == cultureHistory.end()) - cultureEventDate = futureDate; - else - cultureEventDate = cultureEvent->first; - - if (religionEvent == religionHistory.end()) - religionEventDate = futureDate; - else - religionEventDate = religionEvent->first; - - if (cultureEventDate < religionEventDate) - { - if (lastCulture == cultureEvent->second) - { - // skip this event entirely, pretend it never happened. - ++cultureEvent; - continue; - } - - // Make room for the new pie chart slice and grow the current one - decayPopRatios(lastLoopDate, cultureEventDate, currentRatio, assimilationFactor); - // shove in the new slice - popRatios.push_back(currentRatio); - // and halve the populations of middle and upper class in every one of them - // (see tests for explanation) - for (auto& itr: popRatios) - itr.convertFrom(); - - currentRatio.convertToCulture(cultureEvent->second); - lastCulture = cultureEvent->second; - lastLoopDate = cultureEventDate; - ++cultureEvent; - } - else if (cultureEventDate == religionEventDate) - { - if (lastCulture == cultureEvent->second && lastReligion == religionEvent->second) - { - // skip this event entirely, pretend it never happened. One of these *may* be at .end() so we're careful. - if (cultureEvent != cultureHistory.end()) - ++cultureEvent; - if (religionEvent != religionHistory.end()) - ++religionEvent; - continue; - } - - // culture and religion change on the same day; - decayPopRatios(lastLoopDate, cultureEventDate, currentRatio, assimilationFactor); - popRatios.push_back(currentRatio); - for (auto& itr: popRatios) - itr.convertFrom(); - - currentRatio.convertTo(cultureEvent->second, religionEvent->second); - lastCulture = cultureEvent->second; - lastReligion = religionEvent->second; - lastLoopDate = cultureEventDate; - ++cultureEvent; - ++religionEvent; - } - else if (religionEventDate < cultureEventDate) - { - if (lastReligion == religionEvent->second) - { - // skip this event entirely, pretend it never happened. - ++religionEvent; - continue; - } - - decayPopRatios(lastLoopDate, religionEventDate, currentRatio, assimilationFactor); - popRatios.push_back(currentRatio); - for (auto& itr: popRatios) - itr.convertFrom(); - - currentRatio.convertToReligion(religionEvent->second); - lastReligion = religionEvent->second; - lastLoopDate = religionEventDate; - ++religionEvent; - } - } - // Finally, fast forward the ratios to the last event date, wrapping up the loop. - decayPopRatios(lastLoopDate, endDate, currentRatio, assimilationFactor); - - // And shove in the current state of the endgame popRatio. - if (!currentRatio.getCulture().empty() || !currentRatio.getReligion().empty()) - popRatios.push_back(currentRatio); - - // Now, for provinces that have been victims of tribal migrations they will have many identical ratios. We need to merge them. - std::vector mergedRatios; - - auto ratioItr = popRatios.begin(); - while (ratioItr != popRatios.end()) - { - if (ratioItr->isSpent()) - { - ++ratioItr; - continue; - } - - auto otherRatioItr = ratioItr + 1; - while (otherRatioItr != popRatios.end()) - { - if (!otherRatioItr->isSpent() && *otherRatioItr == *ratioItr) - { - ratioItr->mergeRatio(*otherRatioItr); - otherRatioItr->markSpent(); - } - ++otherRatioItr; - } - mergedRatios.emplace_back(*ratioItr); - ++ratioItr; - } - - popRatios.swap(mergedRatios); -} - -void EU4::ProvinceHistory::decayPopRatios(const date& oldDate, const date& newDate, PopRatio& currentPop, const double assimilationFactor) -{ - if (oldDate == newDate) - return; - - const auto diffInYears = newDate.diffInYears(oldDate); - for (auto& popRatio: popRatios) - popRatio.decay(diffInYears, assimilationFactor); - - currentPop.increase(diffInYears, assimilationFactor); -} - -void EU4::ProvinceHistory::markNeoCulture(const std::string& culture) -{ - for (auto& popRatio: popRatios) - if (popRatio.getCulture() == culture) - popRatio.markNeoCulture(); -} diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceHistory.h b/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceHistory.h deleted file mode 100644 index c5df4d9..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceHistory.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef PROVINCE_HISTORY_H -#define PROVINCE_HISTORY_H -#include "ConvenientParser.h" -#include "Date.h" -#include "DatingData.h" -#include "PopRatio.h" -#include - -namespace EU4 -{ -class ProvinceHistory: commonItems::convenientParser -{ - public: - ProvinceHistory() = default; - explicit ProvinceHistory(std::istream& theStream); - - void setStartingCulture(const std::string& culture); - void setStartingReligion(const std::string& religion); - - [[nodiscard]] const auto& getStartingCulture() const { return startingCulture; } - [[nodiscard]] const auto& getStartingReligion() const { return startingReligion; } - - [[nodiscard]] bool hasInitializedHistory() const { return !religionHistory.empty() && !cultureHistory.empty(); } - [[nodiscard]] auto getOriginalDevelopment() const { return originalTax + originalProduction + originalManpower; } - - [[nodiscard]] const auto& getOwnershipHistory() const { return ownershipHistory; } - [[nodiscard]] const auto& getReligionHistory() const { return religionHistory; } - [[nodiscard]] const auto& getCultureHistory() const { return cultureHistory; } - - void buildPopRatios(double assimilationFactor, const DatingData& datingData); - void addPopRatio(const PopRatio& pop) { popRatios.emplace_back(pop); } - void markNeoCulture(const std::string& culture); - void purgeHistories(); - [[nodiscard]] const auto& getPopRatios() const { return popRatios; } - - private: - void registerKeys(); - void decayPopRatios(const date& oldDate, const date& newDate, PopRatio& currentPop, double assimilationFactor); - - std::string startingCulture; - std::string startingReligion; - - double originalTax = 0; - double originalProduction = 0; - double originalManpower = 0; - - std::vector> ownershipHistory; - std::vector> religionHistory; - std::vector> cultureHistory; - - std::vector popRatios; -}; -} // namespace EU4 - -#endif // PROVINCE_HISTORY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceManager.cpp b/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceManager.cpp deleted file mode 100644 index 27f4b5e..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceManager.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include "ProvinceManager.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include -#include - -void EU4::ProvinceManager::loadProvinces(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::ProvinceManager::registerKeys() -{ - registerRegex(commonItems::integerRegex, [this](const std::string& numberString, std::istream& theStream) { - auto newProvince = std::make_shared(numberString, theStream); - provinces.emplace(newProvince->getID(), std::move(newProvince)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::shared_ptr EU4::ProvinceManager::getProvince(const int provinceID) const -{ - if (const auto& province = provinces.find(provinceID); province != provinces.end()) - return province->second; - - Log(LogLevel::Warning) << "Accessing EU4 province " << provinceID << " that does not exist (Save/EU4 version mismatch?)"; - return nullptr; -} - -void EU4::ProvinceManager::loadParsers(const commonItems::ModFilesystem& modFS) -{ - defaultMapParser.loadDefaultMap(modFS); - definitionScraper.loadDefinitions(modFS); - buildingCostLoader.loadBuildingCosts(modFS); -} - -void EU4::ProvinceManager::classifyProvinces(const RegionManager& regionManager) -{ - // We are poking at mapdata to classify provinces as land, sea, lake, rnw or wasteland. - // Then we'll be discarding lakes, rnws and wastelands. - // We'll also be assigning assimilation factors for popbuilding later. - - std::map> viableProvinces; - - for (const auto& [provinceID, province]: provinces) - { - if (!definitionScraper.isValidID(provinceID)) - { - // This means save contains province(s) not present in definitions. We're running against old or broken EU4 installation. - // Continuing is not advised. - Log(LogLevel::Error) << "Province " << provinceID << " was not found in map/definition.csv."; - Log(LogLevel::Error) << "You are converting a newer save against an old EU4 installation, or you have mods that alter the map in a broken fashion."; - Log(LogLevel::Error) << "Upgrade installation or fix the mod map definition errors to continue."; - throw std::runtime_error("Unable to continue. Province inconsistency detected."); - } - - if (defaultMapParser.isLake(provinceID)) // discard lake - { - discardedProvinces.emplace(provinceID, province); - continue; - } - if (defaultMapParser.isRNW(provinceID)) // discard RNW - { - discardedProvinces.emplace(provinceID, province); - continue; - } - if (!regionManager.provinceIsValid(provinceID)) // regionManager considers wastelands invalid, as they aren't registered. - { - // this is a special case. Wastelands DO map to something concrete - they generate their own chunks, albeit with no incoming demographics or ownership. - // Yet they don't participate in geopolitical structure (regions) and need to be tiptoed around. - - // Mark as wasteland but don't discard. - wastelands.emplace(provinceID, province); - viableProvinces.emplace(provinceID, province); - continue; - } - if (defaultMapParser.isSea(provinceID)) - { - province->setSea(); - } - else - { - // Whatever remains is a legit land province - const auto& assimilationFactor = regionManager.getAssimilationFactor(provinceID); - if (assimilationFactor) - province->setAssimilationFactor(*assimilationFactor); - } - viableProvinces.emplace(provinceID, province); - } - provinces.swap(viableProvinces); - Log(LogLevel::Info) << "<> Provinces filtered, " << provinces.size() << " remain."; -} - -void EU4::ProvinceManager::buildPopRatios(const DatingData& datingData, bool convertAll) -{ - for (const auto& province: provinces | std::views::values) - if (!province->isSea()) - { - if (convertAll) - province->purgeHistories(); - province->buildPopRatios(datingData); - } -} - -void EU4::ProvinceManager::buildProvinceWeights(const RegionManager& regionManager) -{ - std::map superRegionInvestmentWeight; - std::map superRegionStartingWeight; - std::map superRegionProvinces; - - for (const auto& [provinceID, province]: provinces) - { - if (!regionManager.provinceIsValid(provinceID)) - continue; - if (province->isSea()) - continue; - province->determineProvinceWeight(buildingCostLoader); - const auto& superRegion = regionManager.getParentSuperRegionName(provinceID); - if (!superRegion) - continue; - superRegionInvestmentWeight[*superRegion] += province->getInvestedWeight(); - superRegionStartingWeight[*superRegion] += province->getProvinceHistory().getOriginalDevelopment(); - superRegionProvinces[*superRegion]++; - } - - double europe = 0; - for (const auto& [provinceID, province]: provinces) - { - if (!regionManager.provinceIsValid(provinceID)) - continue; - if (province->isSea()) - continue; - const auto& superRegion = regionManager.getParentSuperRegionName(provinceID); - if (!superRegion) - continue; - const auto srWeightIncrease = superRegionInvestmentWeight[*superRegion]; - if (srWeightIncrease <= 0) - continue; - const auto srAverageWeightIncrease = srWeightIncrease / superRegionProvinces[*superRegion]; - const auto provinceIncreaseFactor = province->getInvestedWeight() / srAverageWeightIncrease; - - // This formula gives +0.5 for 5x over average increase of dev, and -0.25 max penalty for no invested dev. - const auto investmentFactor = 1 / (1 + 3.32 * exp(-1.2 * provinceIncreaseFactor)) - 0.5; - province->setInvestmentFactor(investmentFactor); - } -} diff --git a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceManager.h b/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceManager.h deleted file mode 100644 index b2b6e4b..0000000 --- a/EU5ToVic3/Source/EU5World/ProvinceManager/ProvinceManager.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef PROVINCE_MANAGER -#define PROVINCE_MANAGER -#include "BuildingCostLoader/BuildingCostLoader.h" -#include "DatingData.h" -#include "DefaultMapParser/DefaultMapParser.h" -#include "DefinitionScraper/DefinitionScraper.h" -#include "EU4Province.h" -#include "Parser.h" -#include "RegionManager/RegionManager.h" -#include - -namespace EU4 -{ -class ProvinceManager: commonItems::parser -{ - public: - ProvinceManager() = default; - void loadProvinces(std::istream& theStream); - - void loadParsers(const commonItems::ModFilesystem& modFS); - - // individual external loads for testing - void loadDefaultMapParser(const DefaultMapParser& defaultParser) { defaultMapParser = defaultParser; } - void loadDefinitionScraper(const DefinitionScraper& defScraper) { definitionScraper = defScraper; } - void loadBuildingCostLoader(const BuildingCostLoader& buildCostLoader) { buildingCostLoader = buildCostLoader; } - - [[nodiscard]] const auto& getAllProvinces() const { return provinces; } - [[nodiscard]] std::shared_ptr getProvince(int provinceID) const; - [[nodiscard]] bool isProvinceWasteland(int provinceID) const { return wastelands.contains(provinceID); } - [[nodiscard]] bool isProvinceDiscarded(int provinceID) const { return discardedProvinces.contains(provinceID); } - - void classifyProvinces(const RegionManager& regionManager); - void buildPopRatios(const DatingData& datingData, bool convertAll); - void buildProvinceWeights(const RegionManager& regionManager); - - private: - void registerKeys(); - - std::map> provinces; - std::map> wastelands; // Wastelands we DO care for but can't use as we'd use regular provinces. - std::map> discardedProvinces; // RNW, lakes etc. Stuff we know about but don't care for. - - DefaultMapParser defaultMapParser; - DefinitionScraper definitionScraper; - BuildingCostLoader buildingCostLoader; -}; -} // namespace EU4 - -#endif // PROVINCE_MANAGER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/RegionManager/Area.cpp b/EU5ToVic3/Source/EU5World/RegionManager/Area.cpp deleted file mode 100644 index a467aeb..0000000 --- a/EU5ToVic3/Source/EU5World/RegionManager/Area.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "Area.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -EU4::Area::Area(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::Area::registerKeys() -{ - registerKeyword("color", commonItems::ignoreItem); - registerRegex(commonItems::integerRegex, [this](const std::string& number, std::istream& theStream) { - // This is a peculiar file format where we pull free-floating numbers from thin air. - // The regex itself will consume the stream. - try - { - provinces.emplace(std::stoi(number)); - } - catch (std::exception& e) - { - Log(LogLevel::Error) << "Broken province inside area.txt?! " << e.what(); - throw std::runtime_error(e.what()); - } - }); -} - -bool EU4::Area::areaContainsProvince(const int province) const -{ - return provinces.contains(province); -} diff --git a/EU5ToVic3/Source/EU5World/RegionManager/Area.h b/EU5ToVic3/Source/EU5World/RegionManager/Area.h deleted file mode 100644 index 9a1e45f..0000000 --- a/EU5ToVic3/Source/EU5World/RegionManager/Area.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef EU4_AREA_H -#define EU4_AREA_H -#include "Parser.h" -#include - -namespace EU4 -{ -class Area: commonItems::parser -{ - public: - Area() = default; - explicit Area(std::istream& theStream); - - [[nodiscard]] const auto& getProvinces() const { return provinces; } - [[nodiscard]] bool areaContainsProvince(int province) const; - - private: - void registerKeys(); - - std::set provinces; -}; -} // namespace EU4 - -#endif // EU4_AREA_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/RegionManager/Region.cpp b/EU5ToVic3/Source/EU5World/RegionManager/Region.cpp deleted file mode 100644 index 8eb527e..0000000 --- a/EU5ToVic3/Source/EU5World/RegionManager/Region.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "Region.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include - -EU4::Region::Region(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::Region::registerKeys() -{ - registerKeyword("areas", [this](std::istream& theStream) { - for (const auto& name: commonItems::getStrings(theStream)) - areas.emplace(name, nullptr); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -bool EU4::Region::regionContainsProvince(int provinceID) const -{ - for (const auto& area: areas | std::views::values) - if (area->areaContainsProvince(provinceID)) - return true; - return false; -} diff --git a/EU5ToVic3/Source/EU5World/RegionManager/Region.h b/EU5ToVic3/Source/EU5World/RegionManager/Region.h deleted file mode 100644 index 274ca61..0000000 --- a/EU5ToVic3/Source/EU5World/RegionManager/Region.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef EU4_REGION_H -#define EU4_REGION_H -#include "Area.h" -#include "Parser.h" - -namespace EU4 -{ -class Region: commonItems::parser -{ - public: - Region() = default; - explicit Region(std::istream& theStream); - - [[nodiscard]] const auto& getAreas() const { return areas; } - [[nodiscard]] bool regionContainsProvince(int provinceID) const; - - void linkArea(const std::pair>& theArea) { areas.at(theArea.first) = theArea.second; } - - private: - void registerKeys(); - - std::map> areas; -}; -} // namespace EU4 - -#endif // EU4_REGION_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/RegionManager/RegionManager.cpp b/EU5ToVic3/Source/EU5World/RegionManager/RegionManager.cpp deleted file mode 100644 index fd81986..0000000 --- a/EU5ToVic3/Source/EU5World/RegionManager/RegionManager.cpp +++ /dev/null @@ -1,314 +0,0 @@ -#include "RegionManager.h" -#include "Log.h" -#include "OSCompatibilityLayer.h" -#include "ParserHelpers.h" -#include "ProvinceManager/ProvinceManager.h" -#include -#include -#include -namespace fs = std::filesystem; - -void EU4::RegionManager::loadRegions(const commonItems::ModFilesystem& modsFS) -{ - const auto& areaFile = modsFS.GetActualFileLocation("map/area.txt"); - if (!areaFile) - throw std::runtime_error("There is no map/area.txt!"); - std::ifstream areaStream(fs::u8path(*areaFile)); - if (!areaStream.is_open()) - throw std::runtime_error("Could not open " + *areaFile + "!"); - registerAreaKeys(); - parseStream(areaStream); - clearRegisteredKeywords(); - areaStream.close(); - - const auto& sRegionFile = modsFS.GetActualFileLocation("map/superregion.txt"); - if (!sRegionFile) - throw std::runtime_error("There is no map/superregion.txt!"); - std::ifstream superRegionStream(fs::u8path(*sRegionFile)); - if (!superRegionStream.is_open()) - throw std::runtime_error("Could not open " + *sRegionFile + "!"); - registerSuperRegionKeys(); - parseStream(superRegionStream); - clearRegisteredKeywords(); - superRegionStream.close(); - - const auto& regionFile = modsFS.GetActualFileLocation("map/region.txt"); - if (!regionFile) - throw std::runtime_error("There is no map/region.txt!"); - std::ifstream regionStream(fs::u8path(*regionFile)); - if (!regionStream.is_open()) - throw std::runtime_error("Could not open " + *regionFile + "!"); - registerRegionKeys(); - parseStream(regionStream); - clearRegisteredKeywords(); - regionStream.close(); - - linkSuperRegions(); - linkRegions(); - superGroupMapper.loadSuperGroups(); - applySuperGroups(); -} - -void EU4::RegionManager::loadRegions(std::istream& areaStream, std::istream& regionStream, std::istream& superRegionStream) -{ - registerAreaKeys(); - parseStream(areaStream); - clearRegisteredKeywords(); - - registerSuperRegionKeys(); - parseStream(superRegionStream); - clearRegisteredKeywords(); - - registerRegionKeys(); - parseStream(regionStream); - clearRegisteredKeywords(); - - linkSuperRegions(); - linkRegions(); - // load supergroups manually with loadSuperGroups() and then applySuperGroups() when testing. -} - -void EU4::RegionManager::registerAreaKeys() -{ - registerRegex(R"([\w_]+)", [this](const std::string& areaName, std::istream& theStream) { - areas.emplace(areaName, std::make_shared(theStream)); - }); -} - -void EU4::RegionManager::registerSuperRegionKeys() -{ - registerRegex(R"([\w_]+)", [this](const std::string& superRegionName, std::istream& theStream) { - const commonItems::stringList theList(theStream); - std::vector tempRegions; - for (const auto& region: theList.getStrings()) - { - if (region == "restrict_charter") - continue; - tempRegions.emplace_back(region); - } - superRegions.emplace(superRegionName, std::make_shared(tempRegions)); - }); -} - -void EU4::RegionManager::registerRegionKeys() -{ - registerRegex(R"([\w_]+)", [this](const std::string& regionName, std::istream& theStream) { - regions.emplace(regionName, std::make_shared(theStream)); - }); -} - - -bool EU4::RegionManager::provinceIsInRegion(int provinceID, const std::string& regionName) const -{ - if (const auto& regionItr = regions.find(regionName); regionItr != regions.end()) - return regionItr->second->regionContainsProvince(provinceID); - - // "Regions" are such a fluid term. - if (const auto& superRegionItr = superRegions.find(regionName); superRegionItr != superRegions.end()) - return superRegionItr->second->superRegionContainsProvince(provinceID); - - // And sometimes they don't mean what people think they mean at all. - if (const auto& areaItr = areas.find(regionName); areaItr != areas.end()) - return areaItr->second->areaContainsProvince(provinceID); - - return false; -} - -std::optional EU4::RegionManager::getParentAreaName(const int provinceID) const -{ - for (const auto& [areaName, area]: areas) - if (area->areaContainsProvince(provinceID)) - return areaName; - - Log(LogLevel::Warning) << "Province ID " << provinceID << " has no parent area name!"; - return std::nullopt; -} - -std::optional EU4::RegionManager::getParentRegionName(const int provinceID) const -{ - for (const auto& [regionName, region]: regions) - if (region->regionContainsProvince(provinceID)) - return regionName; - - Log(LogLevel::Warning) << "Province ID " << provinceID << " has no parent region name!"; - return std::nullopt; -} - -std::optional EU4::RegionManager::getParentSuperRegionName(const int provinceID) const -{ - for (const auto& [superRegionName, superRegion]: superRegions) - if (superRegion->superRegionContainsProvince(provinceID)) - return superRegionName; - - Log(LogLevel::Warning) << "Province ID " << provinceID << " has no parent superregion name!"; - return std::nullopt; -} - -std::optional EU4::RegionManager::getParentSuperGroupName(const int provinceID) const -{ - for (const auto& superRegion: superRegions | std::views::values) - if (superRegion->superRegionContainsProvince(provinceID)) - return superRegion->getSuperGroup(); - - Log(LogLevel::Warning) << "Province ID " << provinceID << " has no parent supergroup name!"; - return std::nullopt; -} - -bool EU4::RegionManager::regionNameIsValid(const std::string& regionName) const -{ - const auto& regionItr = regions.find(regionName); - if (regionItr != regions.end()) - return true; - - // Who knows what the mapper needs. All kinds of stuff. - const auto& superRegionItr = superRegions.find(regionName); - if (superRegionItr != superRegions.end()) - return true; - - // And more stuff, what's the worst that could happen? - const auto& areaItr = areas.find(regionName); - if (areaItr != areas.end()) - return true; - - return false; -} - -void EU4::RegionManager::linkSuperRegions() -{ - for (const auto& [superRegionName, superRegion]: superRegions) - { - const auto& requiredRegions = superRegion->getRegions(); - for (const auto& requiredRegionName: requiredRegions | std::views::keys) - { - const auto& regionItr = regions.find(requiredRegionName); - if (regionItr != regions.end()) - { - superRegion->linkRegion(std::pair(regionItr->first, regionItr->second)); - } - else - { - throw std::runtime_error("Superregion's " + superRegionName + " region " + requiredRegionName + " does not exist!"); - } - } - } -} - -void EU4::RegionManager::linkRegions() -{ - for (const auto& [regionName, region]: regions) - { - const auto& requiredAreas = region->getAreas(); - for (const auto& requiredAreaName: requiredAreas | std::views::keys) - { - const auto& areaItr = areas.find(requiredAreaName); - if (areaItr != areas.end()) - { - region->linkArea(std::pair(areaItr->first, areaItr->second)); - } - else - { - throw std::runtime_error("Region's " + regionName + " area " + requiredAreaName + " does not exist!"); - } - } - } -} - -bool EU4::RegionManager::provinceIsValid(int provinceID) const -{ - for (const auto& area: areas | std::views::values) - if (area->areaContainsProvince(provinceID)) - return true; - return false; -} - -void EU4::RegionManager::applySuperGroups() -{ - for (const auto& [superRegionName, superRegion]: superRegions) - { - superRegion->setAssimilationFactor(superGroupMapper.getAssimilationFactor(superRegionName)); - if (const auto& superGroup = superGroupMapper.getGroupForSuperRegion(superRegionName); superGroup) - { - superRegion->setSuperGroup(*superGroup); - } - else - { - if (superRegionName.find("sea") == std::string::npos) - Log(LogLevel::Warning) << "Superregion " << superRegionName << " doesn't have a supergroup in world_supergroups.txt!"; - superRegion->setSuperGroup("old_world"); // defaulting to the safe choice. - } - } -} - -std::optional EU4::RegionManager::getAssimilationFactor(int provinceID) const -{ - for (const auto& superRegion: superRegions | std::views::values) - if (superRegion->superRegionContainsProvince(provinceID)) - return superRegion->getAssimilationFactor(); - - Log(LogLevel::Warning) << "Province ID " << provinceID << " has no assimilation factor!"; - return std::nullopt; -} - -std::optional EU4::RegionManager::getColonialRegionForProvince(int province) const -{ - return colonialRegionLoader.getColonialRegionForProvince(province); -} - -void EU4::RegionManager::catalogueNativeCultures(const ProvinceManager& provinceManager) const -{ - for (const auto& [provinceID, province]: provinceManager.getAllProvinces()) - { - if (province->getStartingCulture().empty()) - continue; - if (const auto& superRegionName = getParentSuperRegionName(provinceID); superRegionName) - superRegions.at(*superRegionName)->registerNativeCulture(province->getStartingCulture()); - } -} - -void EU4::RegionManager::flagNeoCultures(const ProvinceManager& provinceManager) const -{ - for (const auto& [provinceID, province]: provinceManager.getAllProvinces()) - { - // Are its cultures native or require flagging? - for (const auto& popRatio: province->getProvinceHistory().getPopRatios()) - { - const auto& culture = popRatio.getCulture(); - if (doesProvinceRequireNeoCulture(provinceID, culture)) - province->markNeoCulture(culture); - } - } -} - -bool EU4::RegionManager::doesProvinceRequireNeoCulture(int provinceID, const std::string& culture) const -{ - // This one is funny. A province requires a neoculture if all of these: - // 1. it belongs to a colonial region - // 2. the culture given (presumably from that very province) is not native to the province's superRegion. - // 3. superRegion of province is in different group than native superregion - // result of this function fuels generation of a new neoculture in cultureManager. - - if (!getColonialRegionForProvince(provinceID)) - return false; // not in colonial region. - - const auto& superRegionName = getParentSuperRegionName(provinceID); - if (!superRegionName) - return false; - const auto& superRegion = superRegions.at(*superRegionName); - if (superRegion->superRegionContainsNativeCulture(culture)) - return false; - // this here does the same thing as superregion check but is slower so we put it last. Most cultures won't trip it. - const auto& superGroupName = superRegion->getSuperGroup(); - if (superGroupContainsNativeCulture(culture, superGroupName)) - return false; - return true; -} - -bool EU4::RegionManager::superGroupContainsNativeCulture(const std::string& culture, const std::string& superGroupName) const -{ - for (const auto& superRegion: superRegions | std::views::values) - if (superRegion->getSuperGroup() == superGroupName) - if (superRegion->superRegionContainsNativeCulture(culture)) - return true; - - return false; -} diff --git a/EU5ToVic3/Source/EU5World/RegionManager/RegionManager.h b/EU5ToVic3/Source/EU5World/RegionManager/RegionManager.h deleted file mode 100644 index 8237477..0000000 --- a/EU5ToVic3/Source/EU5World/RegionManager/RegionManager.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef EU4_REGIONMANAGER_H -#define EU4_REGIONMANAGER_H -#include "Area.h" -#include "ColonialRegionLoader/ColonialRegionLoader.h" -#include "Mappers/SuperGroupMapper/SuperGroupMapper.h" -#include "Parser.h" -#include "Region.h" -#include "SuperRegion.h" -#include "TradeCompanyLoader/TradeCompanyLoader.h" - -namespace EU4 -{ -class ProvinceManager; -class RegionManager: commonItems::parser -{ - public: - void loadRegions(const commonItems::ModFilesystem& modsFS); - void loadRegions(std::istream& areaStream, std::istream& regionStream, std::istream& superRegionStream); // for testing - void loadSuperGroups(const mappers::SuperGroupMapper& sgMapper) { superGroupMapper = sgMapper; } // for testing - - void loadColonialRegions(const commonItems::ModFilesystem& modFS) { colonialRegionLoader.loadColonialRegions(modFS); } - void loadColonialRegions(const ColonialRegionLoader& loader) { colonialRegionLoader = loader; } // testing - - void loadTradeCompanies(const commonItems::ModFilesystem& modFS) { tradeCompanyLoader.loadTradeCompanies(modFS); } - void loadExcludedTradeCompanies(const std::string& filePath) { tradeCompanyLoader.loadExcludedTradeCompanies(filePath); } - [[nodiscard]] const auto& getTradeCompanyLoader() const { return tradeCompanyLoader; } - - [[nodiscard]] bool provinceIsInRegion(int provinceID, const std::string& regionName) const; - [[nodiscard]] bool regionNameIsValid(const std::string& regionName) const; - [[nodiscard]] bool provinceIsValid(int provinceID) const; - [[nodiscard]] std::optional getColonialRegionForProvince(int province) const; - - [[nodiscard]] std::optional getParentAreaName(int provinceID) const; - [[nodiscard]] std::optional getParentRegionName(int provinceID) const; - [[nodiscard]] std::optional getParentSuperRegionName(int provinceID) const; - [[nodiscard]] std::optional getParentSuperGroupName(int provinceID) const; - [[nodiscard]] std::optional getAssimilationFactor(int provinceID) const; - - [[nodiscard]] bool doesProvinceRequireNeoCulture(int provinceID, const std::string& culture) const; - - void applySuperGroups(); - void catalogueNativeCultures(const ProvinceManager& provinceManager) const; - void flagNeoCultures(const ProvinceManager& provinceManager) const; - - private: - [[nodiscard]] bool superGroupContainsNativeCulture(const std::string& culture, const std::string& superGroupName) const; - - void registerAreaKeys(); - void registerSuperRegionKeys(); - void registerRegionKeys(); - void linkSuperRegions(); - void linkRegions(); - - std::map> areas; - std::map> regions; - std::map> superRegions; - - mappers::SuperGroupMapper superGroupMapper; - ColonialRegionLoader colonialRegionLoader; - TradeCompanyLoader tradeCompanyLoader; -}; -} // namespace EU4 - -#endif // EU4_REGIONMANAGER_H diff --git a/EU5ToVic3/Source/EU5World/RegionManager/SuperRegion.cpp b/EU5ToVic3/Source/EU5World/RegionManager/SuperRegion.cpp deleted file mode 100644 index e17b3b0..0000000 --- a/EU5ToVic3/Source/EU5World/RegionManager/SuperRegion.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "SuperRegion.h" -#include - -EU4::SuperRegion::SuperRegion(const std::vector& theRegions) -{ - for (const auto& region: theRegions) - regions.emplace(region, nullptr); -} - -bool EU4::SuperRegion::superRegionContainsProvince(const int province) const -{ - for (const auto& region: regions | std::views::values) - if (region->regionContainsProvince(province)) - return true; - return false; -} - -bool EU4::SuperRegion::superRegionContainsNativeCulture(const std::string& culture) const -{ - return nativeCultures.contains(culture); -} diff --git a/EU5ToVic3/Source/EU5World/RegionManager/SuperRegion.h b/EU5ToVic3/Source/EU5World/RegionManager/SuperRegion.h deleted file mode 100644 index 7eee82a..0000000 --- a/EU5ToVic3/Source/EU5World/RegionManager/SuperRegion.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef EU4_SUPERREGION_H -#define EU4_SUPERREGION_H -#include "Region.h" - -namespace EU4 -{ -class SuperRegion -{ - public: - SuperRegion() = default; - explicit SuperRegion(const std::vector& theRegions); - - [[nodiscard]] const auto& getRegions() const { return regions; } - [[nodiscard]] auto getAssimilationFactor() const { return assimilation; } - [[nodiscard]] const auto& getSuperGroup() const { return superGroup; } - - [[nodiscard]] bool superRegionContainsProvince(int provinceID) const; - [[nodiscard]] bool superRegionContainsNativeCulture(const std::string& culture) const; - - void setAssimilationFactor(double factor) { assimilation = factor; } - void setSuperGroup(const auto& sGroup) { superGroup = sGroup; } - void linkRegion(const std::pair>& theRegion) { regions.at(theRegion.first) = theRegion.second; } - void registerNativeCulture(const std::string& culture) { nativeCultures.insert(culture); } - - private: - std::map> regions; - std::set nativeCultures; - - double assimilation = 0; - std::string superGroup; -}; -} // namespace EU4 - -#endif // EU4_SUPERREGION_H \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/WarParser/WarDetails.cpp b/EU5ToVic3/Source/EU5World/WarParser/WarDetails.cpp deleted file mode 100644 index a2fb62d..0000000 --- a/EU5ToVic3/Source/EU5World/WarParser/WarDetails.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "WarDetails.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -void EU4::WarDetails::addDetails(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::WarDetails::registerKeys() -{ - registerSetter("type", warGoalType); - registerSetter("province", targetProvinceID); - registerSetter("tag", targetTag); - registerRegex(R"(\d+\.\d+\.\d+)", [this](const std::string& dateString, std::istream& theStream) { - if (!startDate.isSet()) - startDate = date(dateString); - commonItems::ignoreItem(dateString, theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/WarParser/WarDetails.h b/EU5ToVic3/Source/EU5World/WarParser/WarDetails.h deleted file mode 100644 index 609ece1..0000000 --- a/EU5ToVic3/Source/EU5World/WarParser/WarDetails.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef WAR_DETAILS -#define WAR_DETAILS -#include "ConvenientParser.h" -#include "Date.h" - -namespace EU4 -{ -class WarDetails: commonItems::convenientParser -{ - public: - WarDetails() = default; - void addDetails(std::istream& theStream); - - // This is a storage container shared between EU4 and V3. Because war never changes. - int targetProvinceID = 0; - std::string warGoalType; - std::string targetTag; - std::string warGoalClass; - date startDate; - - private: - void registerKeys(); -}; -} // namespace EU4 - -#endif // WAR_DETAILS \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/WarParser/WarParser.cpp b/EU5ToVic3/Source/EU5World/WarParser/WarParser.cpp deleted file mode 100644 index 12b82de..0000000 --- a/EU5ToVic3/Source/EU5World/WarParser/WarParser.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "WarParser.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -EU4::WarParser::WarParser(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void EU4::WarParser::registerKeys() -{ - registerKeyword("name", [this](std::istream& theStream) { - name = commonItems::getString(theStream); - }); - registerKeyword("history", [this](std::istream& theStream) { - details.addDetails(theStream); - }); - registerKeyword("attackers", [this](std::istream& theStream) { - attackers = commonItems::getStrings(theStream); - }); - registerKeyword("defenders", [this](std::istream& theStream) { - defenders = commonItems::getStrings(theStream); - }); - registerRegex(R"(take_\w+|defend_\w+|\w*superiority|blockade_\w+)", [this](const std::string& warGoalClass, std::istream& theStream) { - details.addDetails(theStream); - details.warGoalClass = warGoalClass; - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/EU5World/WarParser/WarParser.h b/EU5ToVic3/Source/EU5World/WarParser/WarParser.h deleted file mode 100644 index 3c78782..0000000 --- a/EU5ToVic3/Source/EU5World/WarParser/WarParser.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef WAR_PARSER -#define WAR_PARSER -#include "Parser.h" -#include "WarDetails.h" - -namespace EU4 -{ -class WarParser: commonItems::parser -{ - public: - explicit WarParser(std::istream& theStream); - - [[nodiscard]] const auto& getDetails() const { return details; } - [[nodiscard]] const auto& getAttackers() const { return attackers; } - [[nodiscard]] const auto& getDefenders() const { return defenders; } - [[nodiscard]] const auto& getName() const { return name; } - - private: - void registerKeys(); - - WarDetails details; - std::string name; - std::vector attackers; // order matters! first is primary attacker. - std::vector defenders; // order matters! first is primary defender. -}; -} // namespace EU4 - -#endif // WAR_PARSER \ No newline at end of file diff --git a/EU5ToVic3/Source/EU5World/World.cpp b/EU5ToVic3/Source/EU5World/World.cpp index 21cc309..1d53f5d 100644 --- a/EU5ToVic3/Source/EU5World/World.cpp +++ b/EU5ToVic3/Source/EU5World/World.cpp @@ -1,28 +1,25 @@ #include "World.h" #include "CommonRegexes.h" #include "Configuration.h" -#include "EmpireParser/EmpireParser.h" -#include "EmpireParser/RevolutionParser.h" #include "GameVersion.h" #include "Log.h" #include "ModLoader/ModNames.h" #include "ParserHelpers.h" #include "rakaly.h" #include "zip.h" -#include #include #include #include namespace fs = std::filesystem; -EU4::World::World(const std::shared_ptr& theConfiguration, const commonItems::ConverterVersion& converterVersion) +EU5::World::World(const std::shared_ptr& theConfiguration, const commonItems::ConverterVersion& converterVersion) { - Log(LogLevel::Info) << "*** Hello EU4, loading World. ***"; - EU4Path = theConfiguration->getEU4Path(); - saveGame.path = theConfiguration->getEU4SaveGamePath(); + Log(LogLevel::Info) << "*** Hello EU5, loading World. ***"; + EU5Path = theConfiguration->getEU5Path(); + saveGame.path = theConfiguration->getEU5SaveGamePath(); Log(LogLevel::Progress) << "6 %"; - Log(LogLevel::Info) << "-> Verifying EU4 save."; + Log(LogLevel::Info) << "-> Verifying EU5 save."; verifySave(); Log(LogLevel::Progress) << "7 %"; @@ -39,98 +36,71 @@ EU4::World::World(const std::shared_ptr& theConfiguration, const Log(LogLevel::Progress) << "15 %"; // With mods loaded we can init stuff that requires them. - modFS = commonItems::ModFilesystem(EU4Path, mods); + modFS = commonItems::ModFilesystem(EU5Path, mods); Log(LogLevel::Info) << "-> Booting Loaders:"; Log(LogLevel::Info) << "\t\tRegions"; - regionManager.loadRegions(modFS); Log(LogLevel::Info) << "\t\tColonial Regions"; - regionManager.loadColonialRegions(modFS); Log(LogLevel::Info) << "\t\tTrade Companies"; - regionManager.loadTradeCompanies(modFS); - regionManager.loadExcludedTradeCompanies("configurables/excluded_trade_companies.txt"); Log(LogLevel::Info) << "\t\tReligions"; - religionLoader.loadReligions(modFS); Log(LogLevel::Info) << "\t\tCultures"; - cultureLoader.loadCultures(modFS); Log(LogLevel::Info) << "\t\tUnit Types"; - countryManager.loadUnitTypes(modFS); Log(LogLevel::Info) << "\t\tCommon Countries"; - countryManager.loadCommonCountries(modFS); Log(LogLevel::Info) << "\t\tLocalizations"; - countryManager.loadLocalizations(modFS); Log(LogLevel::Progress) << "16 %"; Log(LogLevel::Info) << "*** Building world ***"; Log(LogLevel::Info) << "-> Classifying Provinces According to Aesthetic Principles"; - provinceManager.loadParsers(modFS); - provinceManager.classifyProvinces(regionManager); Log(LogLevel::Progress) << "17 %"; Log(LogLevel::Info) << "-> Calculating Province Weights"; - provinceManager.buildProvinceWeights(regionManager); Log(LogLevel::Progress) << "18 %"; Log(LogLevel::Info) << "-> Determining Demographics"; - provinceManager.buildPopRatios(datingData, theConfiguration->configBlock.convertAll); Log(LogLevel::Progress) << "19 %"; Log(LogLevel::Info) << "-> Linking Provinces to Countries"; - countryManager.linkProvincesToCountries(provinceManager); Log(LogLevel::Progress) << "20 %"; Log(LogLevel::Info) << "-> Updating Unit Types in Regiments"; - countryManager.updateUnitTypes(); Log(LogLevel::Progress) << "21 %"; Log(LogLevel::Info) << "-> Injecting Imperialism into Countries"; - countryManager.setHREAndEmperors(HREmperor, celestialEmperor, provinceManager); Log(LogLevel::Progress) << "22 %"; Log(LogLevel::Info) << "-> Injecting Art Deco into Countries"; - countryManager.injectColorsIntoCountries(); Log(LogLevel::Progress) << "23 %"; Log(LogLevel::Info) << "-> Injecting Smokestacks into Provinces"; - countryManager.buildManufactoryCounts(); - countryManager.assignGPStatuses(); Log(LogLevel::Progress) << "24 %"; Log(LogLevel::Info) << "-> Injecting Localizations into Countries"; - countryManager.injectLocalizations(); Log(LogLevel::Progress) << "25 %"; Log(LogLevel::Info) << "-> Viva la revolution?"; - countryManager.setRevolutionTarget(revolutionTarget); Log(LogLevel::Progress) << "26 %"; Log(LogLevel::Info) << "-> Merging Nations"; - countryManager.bootNationMergeMapper(); - countryManager.mergeNations(); Log(LogLevel::Progress) << "27 %"; Log(LogLevel::Info) << "-> Cataloguing Native Fauna"; - regionManager.catalogueNativeCultures(provinceManager); Log(LogLevel::Info) << "-> Clasifying Invasive Fauna"; - regionManager.flagNeoCultures(provinceManager); Log(LogLevel::Progress) << "28 %"; Log(LogLevel::Info) << "-> Dropping Dead, Empty and/or Coreless Nations"; - countryManager.filterDeadNations(theConfiguration->configBlock.removeType); Log(LogLevel::Progress) << "29 %"; Log(LogLevel::Info) << "-> Splitting Trade Companies into nations"; - countryManager.splitTradeCompanies(provinceManager, regionManager, diplomacyParser, theConfiguration->configBlock.splitTCs); Log(LogLevel::Progress) << "39 %"; Log(LogLevel::Info) << "*** Good-bye EU4, you served us well. ***"; Log(LogLevel::Progress) << "40 %"; } -void EU4::World::registerKeys(const std::shared_ptr& theConfiguration, const commonItems::ConverterVersion& converterVersion) +void EU5::World::registerKeys(const std::shared_ptr& theConfiguration, const commonItems::ConverterVersion& converterVersion) { - registerKeyword("EU4txt", [](std::istream& theStream) { + registerKeyword("EU5txt", [](std::istream& theStream) { }); registerKeyword("date", [this](std::istream& theStream) { if (saveGame.parsedMeta) @@ -141,20 +111,6 @@ void EU4::World::registerKeys(const std::shared_ptr& theConfigura registerKeyword("start_date", [this](std::istream& theStream) { datingData.startEU4Date = date(commonItems::getString(theStream)); }); - registerRegex("(multiplayer_)?random_seed", [this](const std::string& unused, std::istream& theStream) { - auto theSeed = commonItems::getString(theStream); - if (theSeed.size() > 5) - theSeed = theSeed.substr(theSeed.size() - 5); - try - { - eu4Seed = std::stoi(theSeed); - } - catch (std::exception& e) - { - Log(LogLevel::Error) << "Failed reading random_seed, setting 0: " << e.what(); - eu4Seed = 0; - } - }); registerKeyword("savegame_version", [this, converterVersion](std::istream& theStream) { if (saveGame.parsedMeta) { @@ -197,68 +153,13 @@ void EU4::World::registerKeys(const std::shared_ptr& theConfigura // Let's locate, verify and potentially update those mods immediately. commonItems::ModLoader modLoader; - modLoader.loadMods(theConfiguration->getEU4DocumentsPath(), incomingMods); + modLoader.loadMods(theConfiguration->getEU5DocumentsPath(), incomingMods); mods = modLoader.getMods(); - - // check for overrides. - for (const auto& mod: mods) - { - if (mod.name == "Voltaire's Nightmare") - { - Log(LogLevel::Notice) << "Voltaire's Nightmare detected. Enabling VN support."; - theConfiguration->setVN(); - if (theConfiguration->configBlock.euroCentric != Configuration::EUROCENTRISM::EuroCentric) - { - Log(LogLevel::Notice) << "VN is auto-enabling Eurocentric conversion."; - theConfiguration->setEurocentric(); - } - if (theConfiguration->configBlock.startDate != Configuration::STARTDATE::Vanilla) - { - Log(LogLevel::Notice) << "VN is auto-enabling 1836 startdate."; - theConfiguration->setVanillaStartDate(); - } - } - } - }); - registerKeyword("provinces", [this](std::istream& theStream) { - Log(LogLevel::Info) << "-> Importing Provinces"; - provinceManager.loadProvinces(theStream); - Log(LogLevel::Info) << "<> Imported " << provinceManager.getAllProvinces().size() << " provinces."; - }); - registerKeyword("countries", [this](std::istream& theStream) { - Log(LogLevel::Info) << "-> Importing Countries"; - countryManager.loadCountries(theStream); - Log(LogLevel::Info) << "<> Imported " << countryManager.getCountries().size() << " countries."; - }); - registerKeyword("empire", [this](std::istream& theStream) { - const EmpireParser empireBlock(theStream); - HREmperor = empireBlock.getEmperor(); - hreReforms = empireBlock.getHREReforms(); - Log(LogLevel::Info) << "-> HREmperor is: " << HREmperor; - }); - registerKeyword("celestial_empire", [this](std::istream& theStream) { - const EmpireParser empireBlock(theStream); - celestialEmperor = empireBlock.getEmperor(); - Log(LogLevel::Info) << "-> Celestial emperor is: " << celestialEmperor; - }); - registerKeyword("revolution", [this](std::istream& theStream) { - const RevolutionParser revolutionBlock(theStream); - revolutionTarget = revolutionBlock.getRevolutionTarget(); - Log(LogLevel::Info) << "-> The revolution's leader is: " << revolutionTarget; - }); - registerKeyword("diplomacy", [this](std::istream& theStream) { - Log(LogLevel::Info) << "-> Loading Diplomacy"; - diplomacyParser.loadDiplomacy(theStream); - Log(LogLevel::Info) << "-> Loaded " << diplomacyParser.getAgreements().size() << " agreements"; - }); - registerKeyword("active_war", [this](std::istream& theStream) { - const WarParser newWar(theStream); - wars.push_back(newWar); }); registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); } -void EU4::World::verifySave() +void EU5::World::verifySave() { const std::ifstream saveFile(std::filesystem::u8path(saveGame.path), std::ios::in | std::ios::binary); std::stringstream inStream; diff --git a/EU5ToVic3/Source/EU5World/World.h b/EU5ToVic3/Source/EU5World/World.h index f8be0c0..909695d 100644 --- a/EU5ToVic3/Source/EU5World/World.h +++ b/EU5ToVic3/Source/EU5World/World.h @@ -1,20 +1,13 @@ -#ifndef EU4_WORLD_H -#define EU4_WORLD_H +#ifndef EU5_WORLD_H +#define EU5_WORLD_H #include "Configuration.h" #include "ConverterVersion.h" -#include "CountryManager/EU4CountryManager.h" -#include "CultureLoader/CultureLoader.h" #include "DatingData.h" -#include "DiplomacyParser/DiplomacyParser.h" #include "GameVersion.h" #include "ModLoader/ModLoader.h" #include "Parser.h" -#include "ProvinceManager/ProvinceManager.h" -#include "RegionManager/RegionManager.h" -#include "ReligionLoader/ReligionLoader.h" -#include "WarParser/WarParser.h" -namespace EU4 +namespace EU5 { class World: commonItems::parser { @@ -22,20 +15,9 @@ class World: commonItems::parser World(const std::shared_ptr& theConfiguration, const commonItems::ConverterVersion& converterVersion); // V3World inputs - [[nodiscard]] bool isHREDecentralized() const { return hreReforms.contains("emperor_reichskrieg"); } - [[nodiscard]] auto getEU4RandomSeed() const { return eu4Seed; } // for use in province shuffler - [[nodiscard]] const auto& getWars() const { return wars; } - - [[nodiscard]] const auto& getCountryManager() const { return countryManager; } - [[nodiscard]] const auto& getProvinceManager() const { return provinceManager; } - [[nodiscard]] const auto& getRegionManager() const { return regionManager; } - [[nodiscard]] const auto& getCultureLoader() const { return cultureLoader; } - [[nodiscard]] const auto& getReligionLoader() const { return religionLoader; } - [[nodiscard]] const auto& getDiplomacy() const { return diplomacyParser; } - [[nodiscard]] const auto& getEU4Localizations() const { return countryManager.getLocalizationLoader(); } [[nodiscard]] const auto& getDatingData() const { return datingData; } - [[nodiscard]] const auto& getEU4ModFS() const { return modFS; } + [[nodiscard]] const auto& getEU5ModFS() const { return modFS; } private: void registerKeys(const std::shared_ptr& theConfiguration, const commonItems::ConverterVersion& converterVersion); @@ -49,27 +31,15 @@ class World: commonItems::parser std::string path; } saveGame; - std::string EU4Path; + std::string EU5Path; Mods mods; commonItems::ModFilesystem modFS; DatingData datingData; GameVersion version; - int eu4Seed = 0; - std::string HREmperor; - std::string celestialEmperor; - std::set hreReforms; - std::string revolutionTarget; - std::vector wars; - RegionManager regionManager; - ReligionLoader religionLoader; - CultureLoader cultureLoader; - ProvinceManager provinceManager; - CountryManager countryManager; - DiplomacyParser diplomacyParser; }; -} // namespace EU4 +} // namespace EU5 -#endif // EU4_WORLD_H +#endif // EU5_WORLD_H diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/eu4 b/EU5ToVic3/Source/Mappers/.dummy similarity index 100% rename from EU5ToVic3Tests/TestFiles/eu4installation/eu4 rename to EU5ToVic3/Source/Mappers/.dummy diff --git a/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapper.cpp b/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapper.cpp deleted file mode 100644 index 23d3c33..0000000 --- a/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapper.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "AISecretGoalMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include - -namespace -{ -std::vector sortMap(const std::map& theMap) -{ - std::vector sorted; - - std::vector> pairs; - for (const auto& theElement: theMap) - pairs.emplace_back(theElement); - - std::sort(pairs.begin(), pairs.end(), [=](const std::pair& a, const std::pair& b) { - return a.second > b.second; - }); - - for (const auto& tag: pairs | std::views::keys) - sorted.emplace_back(tag); - - return sorted; -} -} // namespace - - -void mappers::AISecretGoalMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading AI Secret Goal mapping rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << goalRules.size() << " goals loaded."; -} - -void mappers::AISecretGoalMapper::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& goalName, std::istream& theStream) { - activeGoal = goalName; - goalParser.parseStream(theStream); - }); - - goalParser.registerRegex(commonItems::integerRegex, [this](const std::string& value, std::istream& theStream) { - if (!goalRules.contains(activeGoal)) - goalRules.emplace(activeGoal, std::vector>{}); - goalRules.at(activeGoal).emplace_back(std::make_pair(std::stoi(value), AISecretGoalMapping(theStream))); - }); - goalParser.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::AISecretGoalMapper::matchSecretGoal(const V3::Country& country, - const V3::Country& target, - const V3::ClayManager& clayManager) const -{ - std::map goalValues; - - for (const auto& [goal, rules]: goalRules) - { - for (const auto& [value, rule]: rules) - if (rule.matchGoal(country, target, clayManager)) - goalValues[goal] += value; - } - - if (goalValues.empty()) - return std::nullopt; - - auto sorted = sortMap(goalValues); - return *sorted.begin(); -} diff --git a/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapper.h b/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapper.h deleted file mode 100644 index 6ec17c0..0000000 --- a/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapper.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef AI_SECRET_GOAL_MAPPER -#define AI_SECRET_GOAL_MAPPER -#include "AISecretGoalMapping.h" -#include "Parser.h" - -namespace mappers -{ -class AISecretGoalMapper: commonItems::parser -{ - public: - AISecretGoalMapper() = default; - void loadMappingRules(const std::string& filePath); - - [[nodiscard]] std::optional matchSecretGoal(const V3::Country& country, const V3::Country& target, const V3::ClayManager& clayManager) const; - - private: - void registerKeys(); - - parser goalParser; - - std::string activeGoal; - std::map>> goalRules; -}; -} // namespace mappers - -#endif // AI_SECRET_GOAL_MAPPER \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapping.cpp b/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapping.cpp deleted file mode 100644 index 29ec3fa..0000000 --- a/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapping.cpp +++ /dev/null @@ -1,224 +0,0 @@ -#include "AISecretGoalMapping.h" -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/SubState.h" -#include "CommonRegexes.h" -#include "CountryManager/EU4Country.h" -#include "Loaders/SuperRegionLoader/V3SuperRegion.h" -#include "ParserHelpers.h" -#include "PoliticalManager/Country/Country.h" - -mappers::AISecretGoalMapping::AISecretGoalMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::AISecretGoalMapping::registerKeys() -{ - registerKeyword("capital", [this](std::istream& theStream) { - capital = commonItems::getString(theStream); - }); - registerKeyword("target_capital", [this](std::istream& theStream) { - targetCapital = commonItems::getString(theStream); - }); - registerKeyword("target_capital_diff_region", [this](std::istream& theStream) { - targetCapitalDiffRegion = commonItems::getString(theStream) == "yes"; - }); - registerKeyword("target_rank_leq", [this](std::istream& theStream) { - targetRankLEQ = commonItems::getInt(theStream); - }); - registerKeyword("target_rank_geq", [this](std::istream& theStream) { - targetRankGEQ = commonItems::getInt(theStream); - }); - registerKeyword("target_subject", [this](std::istream& theStream) { - targetSubject = commonItems::getString(theStream) == "yes"; - }); - registerKeyword("target_overlord", [this](std::istream& theStream) { - targetOverlord = commonItems::getString(theStream) == "yes"; - }); - registerKeyword("target_is_rival", [this](std::istream& theStream) { - targetRival = commonItems::getString(theStream) == "yes"; - }); - registerKeyword("target_gp", [this](std::istream& theStream) { - targetGP = commonItems::getString(theStream) == "yes"; - }); - registerKeyword("gp", [this](std::istream& theStream) { - gp = commonItems::getString(theStream) == "yes"; - }); - registerKeyword("target_is_claimed", [this](std::istream& theStream) { - targetIsClaimed = commonItems::getString(theStream) == "yes"; - }); - registerKeyword("target_is_claimed_by_rival", [this](std::istream& theStream) { - targetIsClaimedByRival = commonItems::getString(theStream) == "yes"; - }); - registerKeyword("gov_form_diff", [this](std::istream& theStream) { - govFormDiff = commonItems::getString(theStream) == "yes"; - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -bool mappers::AISecretGoalMapping::matchGoal(const V3::Country& country, const V3::Country& target, const V3::ClayManager& clayManager) const -{ - const std::map tierRanks = - {{"city_state", 1}, {"principality", 2}, {"grand_principality", 3}, {"kingdom", 4}, {"empire", 5}, {"hegemony", 6}}; - const std::map govForms = {{"law_chiefdom", "tribe"}, - {"law_monarchy", "monarchy"}, - {"law_theocracy", "theocracy"}, - {"law_presidential_republic", "republic"}, - {"law_parliamentary_republic", "republic"}, - {"law_council_republic", "republic"}}; - - if (capital) - { - if (country.getProcessedData().capitalStateName.empty()) - return false; - if (!clayManager.stateIsInRegion(country.getProcessedData().capitalStateName, *capital)) - return false; - } - - if (targetCapital) - { - if (target.getProcessedData().capitalStateName.empty()) - return false; - if (!clayManager.stateIsInRegion(target.getProcessedData().capitalStateName, *targetCapital)) - return false; - } - - if (targetCapitalDiffRegion) - { - if (country.getProcessedData().capitalStateName.empty() || target.getProcessedData().capitalStateName.empty()) - return false; - if (const auto& capCountry = clayManager.getParentSuperRegion(country.getProcessedData().capitalStateName); capCountry) - { - if (const auto& capTarget = clayManager.getParentSuperRegion(target.getProcessedData().capitalStateName); capTarget) - { - if ((capCountry->getName() != capTarget->getName()) != *targetCapitalDiffRegion) - return false; - } - else - return false; - } - else - return false; - } - - if (targetRankLEQ) - { - if (tierRanks.contains(country.getProcessedData().tier) && tierRanks.contains(target.getProcessedData().tier)) - { - if (tierRanks.at(target.getProcessedData().tier) - tierRanks.at(country.getProcessedData().tier) > *targetRankLEQ) - return false; - } - else - return false; - } - - if (targetRankGEQ) - { - if (tierRanks.contains(country.getProcessedData().tier) && tierRanks.contains(target.getProcessedData().tier)) - { - if (tierRanks.at(target.getProcessedData().tier) - tierRanks.at(country.getProcessedData().tier) < *targetRankGEQ) - return false; - } - else - return false; - } - - if (targetSubject) - { - if (target.getProcessedData().overlordTag.empty()) - return false; - if ((target.getProcessedData().overlordTag == country.getTag()) != *targetSubject) - return false; - } - - if (targetOverlord) - { - if (country.getProcessedData().overlordTag.empty()) - return false; - if ((country.getProcessedData().overlordTag == target.getTag()) != *targetOverlord) - return false; - } - - if (targetRival) - { - if ((country.getProcessedData().rivals.contains(target.getTag())) != *targetRival) - return false; - } - - if (targetGP) - { - if (!target.getSourceCountry()) - return false; - if (target.getSourceCountry()->isGP() != *targetGP) - return false; - } - - if (gp) - { - if (!country.getSourceCountry()) - return false; - if (country.getSourceCountry()->isGP() != *gp) - return false; - } - - if (targetIsClaimed) - { - bool claimExists = false; - for (const auto& subState: target.getSubStates()) - if (subState->getClaims().contains(country.getTag())) - { - claimExists = true; - break; - } - if (claimExists != *targetIsClaimed) - return false; - } - - if (targetIsClaimedByRival) - { - bool claimExists = false; - const auto& rivals = country.getProcessedData().rivals; - for (const auto& subState: target.getSubStates()) - { - for (const auto& claim: subState->getClaims()) - if (rivals.contains(claim)) - { - claimExists = true; - break; - } - if (claimExists) - break; - } - if (claimExists != *targetIsClaimedByRival) - return false; - } - - if (govFormDiff) - { - std::string countryForm; - std::string targetForm; - - for (const auto& law: country.getProcessedData().laws) - if (govForms.contains(law)) - { - countryForm = govForms.at(law); - break; - } - for (const auto& law: target.getProcessedData().laws) - if (govForms.contains(law)) - { - targetForm = govForms.at(law); - break; - } - - if (countryForm.empty() || targetForm.empty()) - return false; - - if ((countryForm != targetForm) != *govFormDiff) - return false; - } - - return true; -} diff --git a/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapping.h b/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapping.h deleted file mode 100644 index 7a249aa..0000000 --- a/EU5ToVic3/Source/Mappers/AISecretGoalMapper/AISecretGoalMapping.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef AI_SECRET_GOAL_MAPPING_H -#define AI_SECRET_GOAL_MAPPING_H -#include "Parser.h" - -namespace V3 -{ -class ClayManager; -class Country; -} // namespace V3 - -namespace mappers -{ -class AISecretGoalMapping: commonItems::parser -{ - public: - AISecretGoalMapping() = default; - explicit AISecretGoalMapping(std::istream& theStream); - - [[nodiscard]] bool matchGoal(const V3::Country& country, const V3::Country& target, const V3::ClayManager& clayManager) const; - - private: - void registerKeys(); - - std::optional capital; - std::optional targetCapital; - std::optional targetCapitalDiffRegion; - std::optional targetRankLEQ; - std::optional targetRankGEQ; - std::optional targetSubject; - std::optional targetOverlord; - std::optional targetRival; - std::optional targetGP; - std::optional gp; - std::optional targetIsClaimed; - std::optional targetIsClaimedByRival; - std::optional govFormDiff; -}; -} // namespace mappers - -#endif // AI_SECRET_GOAL_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapper.cpp b/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapper.cpp deleted file mode 100644 index 00d730d..0000000 --- a/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapper.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "AIStrategyMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::AIStrategyMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading AI Strategy mapping rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << admStrategies.size() + dipStrategies.size() + polStrategies.size() << " strategies loaded."; -} - -void mappers::AIStrategyMapper::registerKeys() -{ - registerKeyword("adm", [this](std::istream& theStream) { - admParser.parseStream(theStream); - }); - registerKeyword("dip", [this](std::istream& theStream) { - dipParser.parseStream(theStream); - }); - registerKeyword("pol", [this](std::istream& theStream) { - polParser.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - admParser.registerKeyword("default", [this](std::istream& theStream) { - defaultAdmStrategy = commonItems::getString(theStream); - }); - admParser.registerRegex(commonItems::catchallRegex, [this](const std::string& strategyName, std::istream& theStream) { - admStrategies.emplace(strategyName, AIStrategyMapping(theStream)); - }); - - dipParser.registerKeyword("default", [this](std::istream& theStream) { - defaultDipStrategy = commonItems::getString(theStream); - }); - dipParser.registerRegex(commonItems::catchallRegex, [this](const std::string& strategyName, std::istream& theStream) { - dipStrategies.emplace(strategyName, AIStrategyMapping(theStream)); - }); - - polParser.registerKeyword("default", [this](std::istream& theStream) { - defaultPolStrategy = commonItems::getString(theStream); - }); - polParser.registerRegex(commonItems::catchallRegex, [this](const std::string& strategyName, std::istream& theStream) { - polStrategies.emplace(strategyName, AIStrategyMapping(theStream)); - }); -} - -std::map mappers::AIStrategyMapper::getAdmStrategies(const V3::Country& country, const V3::ClayManager& clayManager) const -{ - return filterStrategies(admStrategies, defaultAdmStrategy, country, clayManager); -} - -std::map mappers::AIStrategyMapper::getDipStrategies(const V3::Country& country, const V3::ClayManager& clayManager) const -{ - return filterStrategies(dipStrategies, defaultDipStrategy, country, clayManager); -} - -std::map mappers::AIStrategyMapper::getPolStrategies(const V3::Country& country, const V3::ClayManager& clayManager) const -{ - return filterStrategies(polStrategies, defaultPolStrategy, country, clayManager); -} - -std::map mappers::AIStrategyMapper::filterStrategies(const std::map& strategies, - std::string defaultStrategy, - const V3::Country& country, - const V3::ClayManager& clayManager) -{ - // Matching strategies is a map of various strategies that seem likely. AI will pick some of them at random according to their values (which are random - // weights) - - std::map matchingStrategies; - - for (const auto& [strategyName, strategy]: strategies) - { - auto value = strategy.matchStrategy(country, clayManager); - if (value > 0) - { - if (strategy.isOverride()) // overrides means ignore whatever else, and return this instead. - return std::map{{strategyName, 0}}; - matchingStrategies.emplace(strategyName, value); - } - } - - // if we matched nothing, send whatever we have preset as default for this category. - if (matchingStrategies.empty() && !defaultStrategy.empty()) - return std::map{{defaultStrategy, 0}}; - else - return matchingStrategies; -} diff --git a/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapper.h b/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapper.h deleted file mode 100644 index 118bd80..0000000 --- a/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapper.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef AI_STRATEGY_MAPPER -#define AI_STRATEGY_MAPPER -#include "AIStrategyMapping.h" -#include "Parser.h" - -namespace mappers -{ -class AIStrategyMapper: commonItems::parser -{ - public: - AIStrategyMapper() = default; - void loadMappingRules(const std::string& filePath); - - [[nodiscard]] std::map getAdmStrategies(const V3::Country& country, const V3::ClayManager& clayManager) const; - [[nodiscard]] std::map getDipStrategies(const V3::Country& country, const V3::ClayManager& clayManager) const; - [[nodiscard]] std::map getPolStrategies(const V3::Country& country, const V3::ClayManager& clayManager) const; - - private: - void registerKeys(); - - [[nodiscard]] static std::map filterStrategies(const std::map& strategies, - std::string defaultStrategy, - const V3::Country& country, - const V3::ClayManager& clayManager); - - parser admParser; - parser dipParser; - parser polParser; - - std::map admStrategies; - std::string defaultAdmStrategy; - std::map dipStrategies; - std::string defaultDipStrategy; - std::map polStrategies; - std::string defaultPolStrategy; -}; -} // namespace mappers - -#endif // AI_STRATEGY_MAPPER \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapping.cpp b/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapping.cpp deleted file mode 100644 index 7beeb3c..0000000 --- a/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapping.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "AIStrategyMapping.h" -#include "ClayManager/ClayManager.h" -#include "CommonRegexes.h" -#include "CountryManager/EU4Country.h" -#include "ParserHelpers.h" -#include "PoliticalManager/Country/Country.h" - -mappers::AIStrategyMapping::AIStrategyMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::AIStrategyMapping::registerKeys() -{ - registerKeyword("laws", [this](std::istream& theStream) { - lawsParser.parseStream(theStream); - }); - registerKeyword("capital", [this](std::istream& theStream) { - capitalParser.parseStream(theStream); - }); - registerKeyword("gp", [this](std::istream& theStream) { - gp = commonItems::getInt(theStream); - }); - registerKeyword("not_gp", [this](std::istream& theStream) { - notGP = commonItems::getInt(theStream); - }); - registerKeyword("hremperor", [this](std::istream& theStream) { - hremperor = commonItems::getInt(theStream); - }); - registerKeyword("cemperor", [this](std::istream& theStream) { - cemperor = commonItems::getInt(theStream); - }); - registerKeyword("override", [this](std::istream& theStream) { - override = commonItems::getString(theStream) == "yes"; - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - lawsParser.registerRegex(commonItems::catchallRegex, [this](const std::string& lawName, std::istream& theStream) { - laws.emplace(lawName, commonItems::getInt(theStream)); - }); - - capitalParser.registerRegex(commonItems::catchallRegex, [this](const std::string& regionName, std::istream& theStream) { - capitalRegions.emplace(regionName, commonItems::getInt(theStream)); - }); -} - -int mappers::AIStrategyMapping::matchStrategy(const V3::Country& country, const V3::ClayManager& clayManager) const -{ - int toReturn = 0; - for (const auto& [law, value]: laws) - if (country.getProcessedData().laws.contains(law)) - toReturn += value; - - for (const auto& [region, value]: capitalRegions) - { - if (country.getProcessedData().capitalStateName.empty()) - break; - if (clayManager.stateIsInRegion(country.getProcessedData().capitalStateName, region)) - { - toReturn += value; - break; - } - } - if (gp > 0 && country.getSourceCountry() && country.getSourceCountry()->isGP()) - toReturn += gp; - if (notGP > 0 && country.getSourceCountry() && !country.getSourceCountry()->isGP()) - toReturn += notGP; - if (hremperor > 0 && country.getSourceCountry() && country.getSourceCountry()->isHREmperor()) - toReturn += hremperor; - if (cemperor > 0 && country.getSourceCountry() && country.getSourceCountry()->isCelestialEmperor()) - toReturn += cemperor; - - return toReturn; -} diff --git a/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapping.h b/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapping.h deleted file mode 100644 index ced28c5..0000000 --- a/EU5ToVic3/Source/Mappers/AIStrategyMapper/AIStrategyMapping.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef AI_STRATEGY_MAPPING_H -#define AI_STRATEGY_MAPPING_H -#include "Parser.h" - -namespace V3 -{ -class ClayManager; -class Country; -} // namespace V3 - -namespace mappers -{ -class AIStrategyMapping: commonItems::parser -{ - public: - AIStrategyMapping() = default; - explicit AIStrategyMapping(std::istream& theStream); - - [[nodiscard]] auto isOverride() const { return override; } - [[nodiscard]] int matchStrategy(const V3::Country& country, const V3::ClayManager& clayManager) const; - - private: - void registerKeys(); - - parser lawsParser; - parser capitalParser; - - std::map laws; - std::map capitalRegions; - int gp = 0; - int notGP = 0; - int hremperor = 0; - int cemperor = 0; - bool override = false; -}; -} // namespace mappers - -#endif // AI_STRATEGY_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapper.cpp b/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapper.cpp deleted file mode 100644 index f190d27..0000000 --- a/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapper.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "BuildingMapper.h" -#include "BuildingMapping.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::BuildingMapper::loadBuildingMappings(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Parsing building mappings."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << mappings.size() << " buildings loaded."; -} - -void mappers::BuildingMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - const BuildingMapping newMapping(theStream); - mappings.emplace(newMapping.getEU4Building(), newMapping.getVic3Buildings()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::set mappers::BuildingMapper::getVic3Buildings(const std::string& eu4Building) const -{ - if (mappings.contains(eu4Building)) - { - return mappings.at(eu4Building); - } - - // Many buildings will not have mappings, this is expected. - return {}; -} \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapper.h b/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapper.h deleted file mode 100644 index d9f8f5f..0000000 --- a/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapper.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef BUILDING_MAPPER_H -#define BUILDING_MAPPER_H -#include "Parser.h" -#include - -namespace mappers -{ -class BuildingMapper: commonItems::parser -{ - public: - BuildingMapper() = default; - void loadBuildingMappings(const std::string& filePath); - - [[nodiscard]] std::set getVic3Buildings(const std::string& eu4Building) const; - - private: - void registerKeys(); - - std::map> mappings; -}; -} // namespace mappers - -#endif // BUILDING_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapping.cpp b/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapping.cpp deleted file mode 100644 index 7eb3f8c..0000000 --- a/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapping.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "BuildingMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::BuildingMapping::BuildingMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::BuildingMapping::registerKeys() -{ - registerKeyword("eu4", [this](std::istream& theStream) { - eu4Building = commonItems::getString(theStream); - }); - registerKeyword("vic3", [this](std::istream& theStream) { - auto theVic3Buildings = commonItems::getStrings(theStream); - vic3Buildings.insert(theVic3Buildings.begin(), theVic3Buildings.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapping.h b/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapping.h deleted file mode 100644 index e924513..0000000 --- a/EU5ToVic3/Source/Mappers/BuildingMapper/BuildingMapping.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef BUILDING_MAPPING_H -#define BUILDING_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class BuildingMapping: commonItems::parser -{ - public: - explicit BuildingMapping(std::istream& theStream); - - - [[nodiscard]] const auto& getEU4Building() const { return eu4Building; } - [[nodiscard]] const auto& getVic3Buildings() const { return vic3Buildings; } - - private: - void registerKeys(); - - std::string eu4Building; - std::set vic3Buildings; -}; -} // namespace mappers - -#endif // BUILDING_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/PMRule.h b/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/PMRule.h deleted file mode 100644 index 9c067ab..0000000 --- a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/PMRule.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef PM_RULE_H -#define PM_RULE_H -#include - -namespace mappers -{ -struct PMRule -{ - std::string pm; - double percent = 1.0; - - bool operator==(const PMRule&) const = default; -}; -} // namespace mappers -#endif // PM_RULE_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodEntry.cpp b/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodEntry.cpp deleted file mode 100644 index 2ca0d9b..0000000 --- a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodEntry.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "ProductionMethodEntry.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::ProductionMethodEntry::ProductionMethodEntry(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ProductionMethodEntry::registerKeys() -{ - registerKeyword("name", [this](std::istream& theStream) { - rule.pm = commonItems::getString(theStream); - }); - registerKeyword("percent", [this](std::istream& theStream) { - rule.percent = commonItems::getDouble(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodEntry.h b/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodEntry.h deleted file mode 100644 index 267ff3d..0000000 --- a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodEntry.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef LAW_ENTRY_H -#define LAW_ENTRY_H -#include "PMRule.h" -#include "Parser.h" - -namespace mappers -{ -class ProductionMethodEntry: commonItems::parser -{ - - public: - ProductionMethodEntry() = default; - explicit ProductionMethodEntry(std::istream& theStream); - - [[nodiscard]] const auto& getRule() const { return rule; } - - private: - void registerKeys(); - - PMRule rule; -}; -} // namespace mappers -#endif // LAW_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapper.cpp b/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapper.cpp deleted file mode 100644 index 094b08e..0000000 --- a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapper.cpp +++ /dev/null @@ -1,370 +0,0 @@ -#include "ProductionMethodMapper.h" -#include "ClayManager/State/SubState.h" -#include "CommonRegexes.h" -#include "EconomyManager/Building/Building.h" -#include "EconomyManager/Building/ProductionMethods/ProductionMethod.h" -#include "EconomyManager/Building/ProductionMethods/ProductionMethodGroup.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "PoliticalManager/Country/Country.h" -#include "ProductionMethodMapping.h" -#include -#include - -void mappers::ProductionMethodMapper::loadRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading PM rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Loaded PM rules for " << buildingToRules.size() << " buildings."; -} - - -void mappers::ProductionMethodMapper::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& buildingName, std::istream& theStream) { - ProductionMethodMapping PMMapping; - PMMapping.loadRules(theStream); - - // Gov Admins are special, leave them out - if (buildingName != "building_government_administration") - buildingToRules.emplace(buildingName, PMMapping.getRules()); - }); -} - -void mappers::ProductionMethodMapper::applyRules(const V3::Country& country, - const std::map& PMs, - const std::map& PMGroups) const -{ - for (const auto& buildingType: getCountryBuildingTypes(country)) - { - if (!buildingToRules.contains(buildingType)) - continue; - - auto builtBuildings = getBuiltBuildings(country, buildingType); // All instances of the current building type in the country - for (const auto& rule: buildingToRules.at(buildingType)) - { - auto selectedBuildings = pickBuildings(builtBuildings, rule.percent); - if (selectedBuildings.empty()) - continue; - - const auto& buildingPMGroups = selectedBuildings[0]->getPMGroups(); - const auto [defaultPM, selectedPM] = pickPM(country, rule.pm, buildingPMGroups, PMs, PMGroups); // select PM - - // For each building in the vector, add the PMs to it - for (const auto& builtBuilding: builtBuildings) - { - if (std::ranges::find(selectedBuildings, builtBuilding) != selectedBuildings.end()) - builtBuilding->addPM(selectedPM); - else - builtBuilding->addPM(defaultPM); - } - } - } -} - -std::set mappers::ProductionMethodMapper::getCountryBuildingTypes(const V3::Country& country) -{ - std::set countryBuildingTypes; - for (const auto& subState: country.getSubStates()) - { - for (const auto& building: subState->getBuildings()) - countryBuildingTypes.emplace(building->getName()); - } - - return countryBuildingTypes; -} - -std::vector> mappers::ProductionMethodMapper::getBuiltBuildings(const V3::Country& country, const std::string& buildingType) -{ - std::vector> builtBuildings; - - const auto& findBuilding = [buildingType](const std::shared_ptr& subStateBuilding) { - return subStateBuilding->getName() == buildingType; - }; - - for (const auto& subState: country.getSubStates()) - { - if (const auto& builtBuilding = std::ranges::find_if(subState->getBuildings(), findBuilding); builtBuilding != subState->getBuildings().end()) - builtBuildings.push_back(*builtBuilding); - } - - return builtBuildings; -} - -std::vector> mappers::ProductionMethodMapper::pickBuildings(const std::vector>& buildings, - const double percent) -{ - if (percent >= 1) - { - return buildings; - } - - auto sumBuildingLevels = [](const int sum, const std::shared_ptr& building) { - return sum + building->getLevel(); - }; - - const int target = static_cast(std::accumulate(buildings.begin(), buildings.end(), 0, sumBuildingLevels) * percent); - - // Select all buildings with level <= target - std::vector> selectedBuildings; - std::copy_if(buildings.begin(), buildings.end(), std::back_inserter(selectedBuildings), [target](const std::shared_ptr& building) { - return building->getLevel() <= target && building->getLevel() > 0; - }); - - if (std::accumulate(selectedBuildings.begin(), selectedBuildings.end(), 0, sumBuildingLevels) > target) - { - selectedBuildings = subSetSum(selectedBuildings, target); - } - - // Now return either selectedBuildings, or a single building if the sum of selectedBuildings - // is further from target than the smallest building larger than target. - - // Get smallest building larger than the target number - int smallestLargeBuildingLevel = INT_MAX; - std::shared_ptr smallestLargeBuilding = nullptr; - - for (const auto& building: buildings) - { - if (building->getLevel() > target && building->getLevel() < smallestLargeBuildingLevel) - { - smallestLargeBuildingLevel = building->getLevel(); - smallestLargeBuilding = building; - } - } - - if (!smallestLargeBuilding) - return selectedBuildings; - const int selectedSum = std::accumulate(selectedBuildings.begin(), selectedBuildings.end(), 0, sumBuildingLevels); - if (smallestLargeBuildingLevel - target < std::abs(target - selectedSum)) - { - selectedBuildings.clear(); - selectedBuildings.push_back(smallestLargeBuilding); - } - - return selectedBuildings; -} - -std::pair mappers::ProductionMethodMapper::pickPM(const V3::Country& country, - const std::string& targetName, - const std::set& buildingPMGroups, - const std::map& PMs, - const std::map& PMGroups) -{ - // NOTE(Gawquon): This works for most PMs, but is not guaranteed to work for ownership PMs. - // This is just a basic version that will support every use-case we currently care about. - for (const auto& PMGroup: PMGroups | std::views::values) - { - if (!buildingPMGroups.contains(PMGroup.getName())) - { - continue; // We're only checking PMGroups that are present in the building we're working on - } - - if (std::ranges::find(PMGroup.getPMs(), targetName) != PMGroup.getPMs().end()) - { - // Validate every PM in group - for (const auto& PM: PMGroup.getPMs()) - { - if (!PMs.contains(PM)) - { - Log(LogLevel::Error) << "Unknown PM: " << PM << "."; - return {"", ""}; - } - } - - // Walk the group - std::string pick = PMGroup.getPMs()[0]; - for (auto PM: PMGroup.getPMs()) - { - if (!country.hasAnyOfTech(PMs.at(PM).getUnlockingTechs())) - return {PMGroup.getPMs()[0], pick}; - if (PM == targetName) - return {PMGroup.getPMs()[0], PM}; - pick = PM; - } - } - } - - Log(LogLevel::Error) << "Could not find a PM group for PM: " << targetName << "."; - - return {"", ""}; -} - -////////////////////////////////////////// Subset-sum fxns -std::vector> mappers::ProductionMethodMapper::subSetSum(const std::vector>& subSet, int targetVal) -{ - /* - * An adaptation of David Pisinger's O(nr) Subset-sum algorithm. - * Paper: http://hjemmesider.diku.dk/~pisinger/95-6.ps - * StackExchange generic implementation: https://stackoverflow.com/questions/9962568/fast-solution-to-subset-sum-algorithm-by-pisinger - * - * - * s_index < breakIndex - * t_index >= breakIndex - * breakIndex is the index at which the sum of everything to the left first exceeds the target number. - * The first index of the 2D array is the index of the subSet, the second index is the currentSum. - * - * mu = currentSum, the row index - * b = the breakIndex, the col index - * - * For a subSet with a max value of 2 and a target of 15 the table looks something like this - * mu | b-1 | b | b+1 - * 13 | -1 | 0 | 0 - * 14 | 2 | 0 | 0 - * 15 | -1 | 0 | 0 - * 16 | 0 | 0 | 0 - * 17 | 0 | 0 | 0 - * 18 | 0 | 0 | 0 - */ - - const auto maxItem = *std::max_element(subSet.begin(), subSet.end(), [](const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return lhs->getLevel() < rhs->getLevel(); - }); - const auto maxVal = maxItem->getLevel(); - const auto [breakIndex, breakSum] = findBreakIndexAndSum(subSet, targetVal); - - // The 2D array of the possible balanced state-space - // The table on paper is not 0 indexed on its second index. We need to transform all sum based indices to be centered around the breakSum - // This means we'll be using negative indices to represent possible sums < the breakSum - std::vector stateSpace(subSet.size() - breakIndex + 1, std::vector(static_cast(2 * maxVal))); - - // Pisinger balsub 1-4 - initializeBreakSolution(stateSpace, maxVal, breakIndex, breakSum, targetVal); - - // Pisinger balsub 5-9 - completeBalancedOperations(stateSpace, maxVal, breakIndex, subSet); - - // First check for exact solutions, then close solutions under & over - std::vector> result; - - const auto finalState = stateSpace[subSet.size() - breakIndex].begin() + (maxVal - 1); - for (int offBy = 0; offBy <= maxVal - 1; ++offBy) - { - if (finalState[-offBy] >= 0) - { - result = traceSteps(stateSpace, -offBy, maxVal, breakIndex, subSet); - break; - } - if (finalState[offBy] >= 0) - { - result = traceSteps(stateSpace, -offBy, maxVal, breakIndex, subSet); - break; - } - } - return result; -} -std::pair mappers::ProductionMethodMapper::findBreakIndexAndSum(const std::vector>& subSet, const int targetNumber) -{ - // Find the first index that exceeds targetNumber when added to the selection - int sum = 0; - for (int i = 0; i < static_cast(subSet.size()); ++i) - { - if (sum + subSet[i]->getLevel() > targetNumber) - return {i, sum}; - sum += subSet[i]->getLevel(); - } - return {-1, -1}; -} - -void mappers::ProductionMethodMapper::initializeBreakSolution(std::vector>& stateSpace, - const int maxVal, - const int breakIndex, - const int breakSum, - const int targetVal) -{ - // Transform Pisinger's algorithm which centers on targetNumber, to be centered around 0 to play nicely with vector index math - const auto initialState = stateSpace[0].begin() + (maxVal - 1); - for (int currentSum = -maxVal + 1; currentSum <= 0; ++currentSum) - { - initialState[currentSum] = -1; - } - for (int currentSum = 1; currentSum <= maxVal; ++currentSum) - { - initialState[currentSum] = 0; - } - initialState[breakSum - targetVal] = breakIndex; -} - -void mappers::ProductionMethodMapper::completeBalancedOperations(std::vector>& stateSpace, - const int maxVal, - const int breakIndex, - const std::vector>& subSet) -{ - // Consider the t_index indices in increasing order - for (int t_index = breakIndex; t_index < static_cast(subSet.size()); ++t_index) - { - const auto prevState = stateSpace[t_index - breakIndex].begin() + (maxVal - 1); - const auto currentState = stateSpace[t_index - breakIndex + 1].begin() + (maxVal - 1); - - for (int currentSum = -maxVal + 1; currentSum <= maxVal; ++currentSum) - { - currentState[currentSum] = prevState[currentSum]; - } - for (int currentSum = -maxVal + 1; currentSum <= 0; ++currentSum) - { - const int nextSum = currentSum + subSet[t_index]->getLevel(); - currentState[nextSum] = std::max(currentState[nextSum], prevState[currentSum]); - } - for (int currentSum = subSet[t_index]->getLevel(); currentSum >= 1; --currentSum) - { - // Now consider the s_indices in decreasing order - for (int s_index = currentState[currentSum] - 1; s_index >= prevState[currentSum]; --s_index) - { - const int nextSum = currentSum - subSet[s_index]->getLevel(); - currentState[nextSum] = std::max(currentState[nextSum], s_index); - } - } - } -} - -std::vector> mappers::ProductionMethodMapper::traceSteps(const std::vector>& theStates, - const int offBy, - const int maxVal, - const int breakIndex, - const std::vector>& subSet) -{ - // Now we use the state knowledge to trace the solution from the beginning - std::vector mask(subSet.size(), false); - int sum = offBy; - - // Start with the break solution. e.g. {1,1,1,0,0,0,0} - for (int i = 0; i < breakIndex; ++i) - { - mask[i] = true; - } - - for (int t_index = static_cast(subSet.size()) - 1; t_index >= breakIndex; --t_index) - { - auto currentState = theStates[t_index - breakIndex + 1].begin() + (maxVal - 1); - auto prevState = theStates[t_index - breakIndex].begin() + (maxVal - 1); - - // Then read the state data to flip s_index indices. e.g. {1,1->0,1,0,0,0,0} - for (int s_index = currentState[sum]; s_index >= 0; s_index = currentState[sum]) - { - const int currentSum = sum + subSet[s_index]->getLevel(); - if (currentSum > maxVal || s_index >= currentState[currentSum]) - { - break; - } - sum = currentSum; - mask[s_index] = false; - } - - // Then read the state data to flip t_index indices. e.g. {1,0,1,0,0->1,0,0->1} - const int currentSum = sum - subSet[t_index]->getLevel(); - if (currentSum >= -maxVal + 1 && prevState[currentSum] >= currentState[sum]) - { - sum = currentSum; - mask[t_index] = true; - } - } - - std::vector> output; - for (int i = 0; i < static_cast(subSet.size()); i++) - { - if (mask[i]) - output.push_back(subSet[i]); - } - return output; -} diff --git a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapper.h b/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapper.h deleted file mode 100644 index 7ae82d5..0000000 --- a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapper.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef PRODUCTION_METHOD_MAPPER_H -#define PRODUCTION_METHOD_MAPPER_H -#include "Parser.h" -#include "ProductionMethodMapping.h" - -namespace V3 -{ -class Building; -class ProductionMethodGroup; -class ProductionMethod; -class Country; -} // namespace V3 -namespace mappers -{ -class ProductionMethodMapper: commonItems::parser -{ - public: - ProductionMethodMapper() = default; - void loadRules(const std::string& filePath); - void applyRules(const V3::Country& country, - const std::map& PMs, - const std::map& PMGroups) const; - - [[nodiscard]] const auto& getRules() const { return buildingToRules; } - - private: - void registerKeys(); - - - // applyRules helpers - [[nodiscard]] static std::set getCountryBuildingTypes(const V3::Country& country); - [[nodiscard]] static std::vector> getBuiltBuildings(const V3::Country& country, const std::string& buildingType); - [[nodiscard]] static std::vector> pickBuildings(const std::vector>& buildings, double percent); - [[nodiscard]] static std::pair pickPM(const V3::Country& country, - const std::string& targetName, - const std::set& buildingPMGroups, - const std::map& PMs, - const std::map& PMGroups); - - // Subset-sum - static std::vector> subSetSum(const std::vector>& subSet, int targetVal); - static std::pair findBreakIndexAndSum(const std::vector>& subSet, int targetNumber); - static void initializeBreakSolution(std::vector>& stateSpace, int maxVal, int breakIndex, int breakSum, int targetVal); - static void completeBalancedOperations(std::vector>& stateSpace, - int maxVal, - int breakIndex, - const std::vector>& subSet); - static std::vector> traceSteps(const std::vector>& theStates, - int offBy, - int maxVal, - int breakIndex, - const std::vector>& subSet); - - std::map> buildingToRules; // building_name -> PMRules -}; -} // namespace mappers - -#endif // PRODUCTION_METHOD_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapping.cpp b/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapping.cpp deleted file mode 100644 index 17c17df..0000000 --- a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapping.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "ProductionMethodMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "ProductionMethodEntry.h" - -void mappers::ProductionMethodMapping::loadRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ProductionMethodMapping::registerKeys() -{ - registerKeyword("pm", [this](std::istream& theStream) { - rules.push_back(ProductionMethodEntry(theStream).getRule()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapping.h b/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapping.h deleted file mode 100644 index 5db17af..0000000 --- a/EU5ToVic3/Source/Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodMapping.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef PRODUCTION_METHOD_MAPPING_H -#define PRODUCTION_METHOD_MAPPING_H -#include "PMRule.h" -#include "Parser.h" - -namespace mappers -{ -class ProductionMethodMapping: commonItems::parser -{ - public: - ProductionMethodMapping() = default; - void loadRules(std::istream& theStream); - - [[nodiscard]] const auto& getRules() const { return rules; } - - private: - void registerKeys(); - - std::vector rules; -}; -} // namespace mappers - -#endif // PRODUCTION_METHOD_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/AssignmentMapping.cpp b/EU5ToVic3/Source/Mappers/CharacterTraitMapper/AssignmentMapping.cpp deleted file mode 100644 index f106a09..0000000 --- a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/AssignmentMapping.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "AssignmentMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::AssignmentMapping::AssignmentMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::AssignmentMapping::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& assignment, std::istream& theStream) { - assignments.emplace(assignment, commonItems::getString(theStream)); - }); -} diff --git a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/AssignmentMapping.h b/EU5ToVic3/Source/Mappers/CharacterTraitMapper/AssignmentMapping.h deleted file mode 100644 index ad7c4cb..0000000 --- a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/AssignmentMapping.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef ASSIGNMENT_MAPPING_H -#define ASSIGNMENT_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class AssignmentMapping: commonItems::parser -{ - public: - AssignmentMapping() = default; - explicit AssignmentMapping(std::istream& theStream); - - [[nodiscard]] const auto& getAssignments() const { return assignments; } - - private: - void registerKeys(); - - std::map assignments; -}; -} // namespace mappers - -#endif // ASSIGNMENT_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/CharacterTraitMapper.cpp b/EU5ToVic3/Source/Mappers/CharacterTraitMapper/CharacterTraitMapper.cpp deleted file mode 100644 index e14ded8..0000000 --- a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/CharacterTraitMapper.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include "CharacterTraitMapper.h" -#include "AssignmentMapping.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include - -#include "CountryManager/CountryLeader/EU4Character.h" - -void mappers::CharacterTraitMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading character trait mapping rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); -} - -void mappers::CharacterTraitMapper::registerKeys() -{ - registerKeyword("personalities", [this](std::istream& theStream) { - personalities = AssignmentMapping(theStream).getAssignments(); - }); - registerKeyword("global", [this](std::istream& theStream) { - global = AssignmentMapping(theStream).getAssignments(); - }); - registerKeyword("admiral", [this](std::istream& theStream) { - admirals.emplace_back(SkillMapping(theStream)); - }); - registerKeyword("general", [this](std::istream& theStream) { - generals.emplace_back(SkillMapping(theStream)); - }); - registerKeyword("ruler", [this](std::istream& theStream) { - rulers.emplace_back(SkillMapping(theStream)); - }); - registerKeyword("incompetency", [this](std::istream& theStream) { - const auto incompetencyList = commonItems::getStrings(theStream); - incompetencies.insert(incompetencyList.begin(), incompetencyList.end()); - }); - registerKeyword("veterancy", [this](std::istream& theStream) { - const auto veterancyList = commonItems::getStrings(theStream); - veterancies.insert(veterancyList.begin(), veterancyList.end()); - }); - registerKeyword("age", [this](std::istream& theStream) { - const auto ageList = commonItems::getStrings(theStream); - ageisms.insert(ageList.begin(), ageList.end()); - }); - registerKeyword("disorders", [this](std::istream& theStream) { - const auto disorderList = commonItems::getStrings(theStream); - disorders.insert(disorderList.begin(), disorderList.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::CharacterTraitMapper::getPersonality(const std::string& eu4Personality) const -{ - if (personalities.contains(eu4Personality)) - return personalities.at(eu4Personality); - return std::nullopt; -} - -std::set mappers::CharacterTraitMapper::getSkillTraits(const EU4::Character& eu4Character) const -{ - // map general/admiral skill trait. - std::set traits; - if (!eu4Character.leaderType.empty()) - { - if (global.contains(eu4Character.leaderType)) - traits.emplace(global.at(eu4Character.leaderType)); - else if (const auto& traitMatch = matchLeaderSkill(eu4Character.leaderType, - std::vector{eu4Character.fire, eu4Character.shock, eu4Character.maneuver, eu4Character.siege}); - traitMatch) - traits.emplace(*traitMatch); - } - // map ruler trait - if (eu4Character.ruler || eu4Character.consort || eu4Character.heir) - { - if (const auto& traitMatch = matchLeaderSkill("ruler", std::vector{eu4Character.adm, eu4Character.dip, eu4Character.mil}); traitMatch) - traits.emplace(*traitMatch); - } - - return traits; -} - -std::optional mappers::CharacterTraitMapper::matchLeaderSkill(const std::string& leaderType, const std::vector& skills) const -{ - if (leaderType == "general") - for (const auto& mapping: generals) - if (const auto& match = mapping.matchTrait(skills); match) - return match; - if (leaderType == "admiral") - for (const auto& mapping: admirals) - if (const auto& match = mapping.matchTrait(skills); match) - return match; - if (leaderType == "ruler") - for (const auto& mapping: rulers) - if (const auto& match = mapping.matchTrait(skills); match) - return match; - return std::nullopt; -} - -std::string mappers::CharacterTraitMapper::getGratisIncompetency(int seed) const -{ - auto pos = seed; - if (pos < 0) - pos = 0; - if (pos >= static_cast(incompetencies.size())) - pos = pos % static_cast(incompetencies.size()); - return *std::next(incompetencies.begin(), pos); -} - -std::string mappers::CharacterTraitMapper::getGratisVeterancy(int seed) const -{ - auto pos = seed; - if (pos < 0) - pos = 0; - if (pos >= static_cast(veterancies.size())) - pos = pos % static_cast(veterancies.size()); - return *std::next(veterancies.begin(), pos); -} - -std::string mappers::CharacterTraitMapper::getGratisAgeism(int seed) const -{ - auto pos = seed; - if (pos < 0) - pos = 0; - if (pos >= static_cast(ageisms.size())) - pos = pos % static_cast(ageisms.size()); - return *std::next(ageisms.begin(), pos); -} - -std::string mappers::CharacterTraitMapper::getGratisDisorder(int seed) const -{ - auto pos = seed; - if (pos < 0) - pos = 0; - if (pos >= static_cast(disorders.size())) - pos = pos % static_cast(disorders.size()); - return *std::next(disorders.begin(), pos); -} diff --git a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/CharacterTraitMapper.h b/EU5ToVic3/Source/Mappers/CharacterTraitMapper/CharacterTraitMapper.h deleted file mode 100644 index 914d1c1..0000000 --- a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/CharacterTraitMapper.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef CHARACTER_TRAIT_MAPPER_H -#define CHARACTER_TRAIT_MAPPER_H -#include "Parser.h" -#include "SkillMapping.h" - -namespace EU4 -{ -struct Character; -} -namespace mappers -{ -class CharacterTraitMapper: commonItems::parser -{ - public: - CharacterTraitMapper() = default; - void loadMappingRules(const std::string& filePath); - - [[nodiscard]] std::optional getPersonality(const std::string& eu4Personality) const; - [[nodiscard]] std::set getSkillTraits(const EU4::Character& eu4Character) const; - [[nodiscard]] std::string getGratisIncompetency(int seed) const; - [[nodiscard]] std::string getGratisVeterancy(int seed) const; - [[nodiscard]] std::string getGratisAgeism(int seed) const; - [[nodiscard]] std::string getGratisDisorder(int seed) const; - - private: - void registerKeys(); - [[nodiscard]] std::optional matchLeaderSkill(const std::string& leaderType, const std::vector& skills) const; - - - std::map personalities; - std::map global; - std::vector admirals; - std::vector generals; - std::vector rulers; - std::set incompetencies; - std::set veterancies; - std::set ageisms; - std::set disorders; -}; -} // namespace mappers - -#endif // CHARACTER_TRAIT_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/SkillMapping.cpp b/EU5ToVic3/Source/Mappers/CharacterTraitMapper/SkillMapping.cpp deleted file mode 100644 index 441437f..0000000 --- a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/SkillMapping.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "SkillMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include - -mappers::SkillMapping::SkillMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::SkillMapping::registerKeys() -{ - registerKeyword("sum", [this](std::istream& theStream) { - sum = commonItems::getInt(theStream); - }); - registerKeyword("prim", [this](std::istream& theStream) { - primary = commonItems::getString(theStream); - }); - registerKeyword("trait", [this](std::istream& theStream) { - trait = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::SkillMapping::matchTrait(const std::vector& stats) const -{ - const auto total = std::accumulate(stats.begin(), stats.end(), 0); - if (total < sum) - return std::nullopt; - - if (!primary) - return trait; - - if ((*primary == "adm" || *primary == "dip" || *primary == "mil") && stats.size() == 3) - { - const auto adm = stats[0]; - const auto dip = stats[1]; - const auto mil = stats[2]; - - if (*primary == "adm" && adm > dip && adm > mil) - return trait; - else if (*primary == "dip" && dip > adm && dip > mil) - return trait; - else if (*primary == "mil" && mil > adm && mil > dip) - return trait; - } - else if ((*primary == "fir" || *primary == "sho" || *primary == "man" || *primary == "sie") && stats.size() == 4) - { - const auto fir = stats[0]; - const auto sho = stats[1]; - const auto man = stats[2]; - const auto sie = stats[3]; - - if (*primary == "fir" && fir > sho && fir > man && fir > sie) - return trait; - else if (*primary == "sho" && sho > fir && sho > man && sho > sie) - return trait; - else if (*primary == "man" && man > fir && man > sho && man > sie) - return trait; - else if (*primary == "sie" && sie > fir && sie > sho && sie > man) - return trait; - } - - return std::nullopt; -} diff --git a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/SkillMapping.h b/EU5ToVic3/Source/Mappers/CharacterTraitMapper/SkillMapping.h deleted file mode 100644 index a8cd9f8..0000000 --- a/EU5ToVic3/Source/Mappers/CharacterTraitMapper/SkillMapping.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef SKILL_MAPPING_H -#define SKILL_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class SkillMapping: commonItems::parser -{ - public: - SkillMapping() = default; - explicit SkillMapping(std::istream& theStream); - - [[nodiscard]] std::optional matchTrait(const std::vector& stats) const; - - private: - void registerKeys(); - - int sum = 0; - std::optional primary; - std::string trait; -}; -} // namespace mappers - -#endif // SKILL_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CoastalMapper/CoastalMapper.cpp b/EU5ToVic3/Source/Mappers/CoastalMapper/CoastalMapper.cpp deleted file mode 100644 index 6af8bd3..0000000 --- a/EU5ToVic3/Source/Mappers/CoastalMapper/CoastalMapper.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "CoastalMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::CoastalMapper::loadAdjacencies(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading Physical Province Adjacencies."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Loaded " << adjacencies.size() << " adjacencies."; -} - -void mappers::CoastalMapper::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& sourceProvince, std::istream& theStream) { - auto targets = commonItems::getStrings(theStream); - adjacencies.emplace(sourceProvince, std::set()); - adjacencies.at(sourceProvince).insert(targets.begin(), targets.end()); - }); -} - -std::set mappers::CoastalMapper::getAdjacencies(const std::string& province) const -{ - if (adjacencies.contains(province)) - return adjacencies.at(province); - return std::set{}; -} diff --git a/EU5ToVic3/Source/Mappers/CoastalMapper/CoastalMapper.h b/EU5ToVic3/Source/Mappers/CoastalMapper/CoastalMapper.h deleted file mode 100644 index 905269b..0000000 --- a/EU5ToVic3/Source/Mappers/CoastalMapper/CoastalMapper.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef COASTAL_MAPPER_H -#define COASTAL_MAPPER_H -#include "Parser.h" - -namespace mappers -{ -class CoastalMapper: commonItems::parser -{ - public: - CoastalMapper() = default; - void loadAdjacencies(const std::string& filePath); - - [[nodiscard]] std::set getAdjacencies(const std::string& province) const; - - private: - void registerKeys(); - - std::map> adjacencies; -}; -} // namespace mappers - -#endif // COASTAL_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapper.cpp b/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapper.cpp deleted file mode 100644 index 042d98f..0000000 --- a/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapper.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "ColonialRegionMapper.h" -#include "ClayManager/ClayManager.h" -#include "CommonRegexes.h" -#include "Log.h" -#include - -void mappers::ColonialRegionMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading colonial region definitions."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << colonialRegions.size() << " regions loaded."; -} - -void mappers::ColonialRegionMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ColonialRegionMapper::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& regionName, std::istream& theStream) { - colonialRegions.emplace(regionName, ColonialRegionMapping(theStream)); - }); -} - -std::optional mappers::ColonialRegionMapper::getColonyForState(const std::string& v3State, - const V3::ClayManager& clayManager) const -{ - for (const auto& colony: colonialRegions | std::views::values) - { - if (colony.getRegions().contains(v3State)) - return colony; - for (const auto& region: colony.getRegions()) - if (clayManager.stateIsInRegion(v3State, region)) - return colony; - } - return std::nullopt; -} - -std::optional mappers::ColonialRegionMapper::getColonyNameForState(const std::string& v3State, const V3::ClayManager& clayManager) const -{ - for (const auto& [colonyName, colony]: colonialRegions) - { - if (colony.getRegions().contains(v3State)) - return colonyName; - for (const auto& region: colony.getRegions()) - if (clayManager.stateIsInRegion(v3State, region)) - return colonyName; - } - return std::nullopt; -} diff --git a/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapper.h b/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapper.h deleted file mode 100644 index 02ddb5f..0000000 --- a/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapper.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef COLONIAL_REGION_MAPPER_H -#define COLONIAL_REGION_MAPPER_H -#include "ColonialRegionMapping.h" -#include "Parser.h" - -namespace V3 -{ -class ClayManager; -} -namespace mappers -{ -class ColonialRegionMapper: commonItems::parser -{ - public: - ColonialRegionMapper() = default; - void loadMappingRules(const std::string& filePath); - void loadMappingRules(std::istream& theStream); - - [[nodiscard]] const auto& getColonialRegions() const { return colonialRegions; } - [[nodiscard]] std::optional getColonyForState(const std::string& v3State, const V3::ClayManager& clayManager) const; - [[nodiscard]] std::optional getColonyNameForState(const std::string& v3State, const V3::ClayManager& clayManager) const; - - private: - void registerKeys(); - - std::map colonialRegions; -}; -} // namespace mappers - -#endif // COUNTRY_MAPPINGS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapping.cpp b/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapping.cpp deleted file mode 100644 index ea8d3b8..0000000 --- a/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapping.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "ColonialRegionMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::ColonialRegionMapping::ColonialRegionMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ColonialRegionMapping::registerKeys() -{ - registerKeyword("region", [this](std::istream& theStream) { - regions.emplace(commonItems::getString(theStream)); - }); - registerKeyword("alone_name", [this](std::istream& theStream) { - aloneName = commonItems::getString(theStream); - }); - registerKeyword("split_name", [this](std::istream& theStream) { - splitName = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapping.h b/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapping.h deleted file mode 100644 index 80e6345..0000000 --- a/EU5ToVic3/Source/Mappers/ColonialRegionMapper/ColonialRegionMapping.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef COLONIAL_REGION_MAPPING_H -#define COLONIAL_REGION_MAPPING_H -#include "Parser.h" -#include - -namespace mappers -{ -class ColonialRegionMapping: commonItems::parser -{ - public: - ColonialRegionMapping() = default; - explicit ColonialRegionMapping(std::istream& theStream); - - [[nodiscard]] const auto& getRegions() const { return regions; } - [[nodiscard]] const auto& getAloneName() const { return aloneName; } - [[nodiscard]] const auto& getSplitName() const { return splitName; } - - private: - void registerKeys(); - - std::set regions; - std::string aloneName; - std::string splitName; -}; -} // namespace mappers - -#endif // COLONIAL_REGION_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapper.cpp b/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapper.cpp deleted file mode 100644 index 28e1bb2..0000000 --- a/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapper.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "ColonialTagMapper.h" -#include "ClayManager/ClayManager.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "PoliticalManager/Country/Country.h" -#include - -void mappers::ColonialTagMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading colonial tag mapping rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << colonialTagMappings.size() << " colonial tag rules loaded."; -} - -void mappers::ColonialTagMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - const auto mapping = ColonialTagMapping(theStream); - knownColonialTags.emplace(mapping.getTag()); - colonialTagMappings.emplace_back(mapping); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::ColonialTagMapper::matchColonialTag(const V3::Country& country, - const ColonialRegionMapper& colonialRegionMapper, - const V3::ClayManager& clayManager) const -{ - // Don't replace tags which are alerady defined as colonial tags! - // We got those through name or tag matches so leave them as they are! - if (knownColonialTags.contains(country.getTag())) - return std::nullopt; - - for (const auto& mapping: colonialTagMappings) - if (const auto& match = mapping.matchColonialTag(country, colonialRegionMapper, clayManager); match) - return match; - return std::nullopt; -} diff --git a/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapper.h b/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapper.h deleted file mode 100644 index 543c8f6..0000000 --- a/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapper.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef COLONIAL_TAG_MAPPER_H -#define COLONIAL_TAG_MAPPER_H -#include "ColonialTagMapping.h" -#include "Parser.h" - -namespace V3 -{ -class ClayManager; -} -namespace mappers -{ -class ColonialTagMapper: commonItems::parser -{ - public: - ColonialTagMapper() = default; - void loadMappingRules(const std::string& filePath); - - [[nodiscard]] std::optional matchColonialTag(const V3::Country& country, - const ColonialRegionMapper& colonialRegionMapper, - const V3::ClayManager& clayManager) const; - - private: - void registerKeys(); - - std::vector colonialTagMappings; - std::set knownColonialTags; -}; -} // namespace mappers - -#endif // COLONIAL_TAG_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapping.cpp b/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapping.cpp deleted file mode 100644 index a38e925..0000000 --- a/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapping.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "ColonialTagMapping.h" -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/SubState.h" -#include "ColonialRegionMapper/ColonialRegionMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "PoliticalManager/Country/Country.h" - -mappers::ColonialTagMapping::ColonialTagMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ColonialTagMapping::registerKeys() -{ - registerKeyword("region", [this](std::istream& theStream) { - region = commonItems::getString(theStream); - }); - registerKeyword("alone", [this](std::istream& theStream) { - aloneName = commonItems::getString(theStream); - }); - registerKeyword("tag", [this](std::istream& theStream) { - tag = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::ColonialTagMapping::matchColonialTag(const V3::Country& country, - const ColonialRegionMapper& colonialRegionMapper, - const V3::ClayManager& clayManager) const -{ - const auto& subStates = country.getSubStates(); - if (subStates.empty()) - return std::nullopt; - - const auto& capitalStateName = country.getProcessedData().capitalStateName; - if (capitalStateName.empty() && !tag.empty()) - return std::nullopt; - - // first the capital matches - if (!tag.empty()) - { - if (capitalStateName == region) - return tag; - return std::nullopt; - } - - if (aloneName.empty()) - { - Log(LogLevel::Warning) << "There is an error with " << region << " mapping in colonial_tags.txt. No alone entry."; - return std::nullopt; - } - - // then the whole region match. - const auto& colonialRegions = colonialRegionMapper.getColonialRegions(); - if (!colonialRegions.contains(region)) - { - Log(LogLevel::Warning) << "Attempting to colonial region match " << region << " which isn't defined in colonial_regions.txt!"; - return std::nullopt; - } - - // what is required - const auto& requiredRegions = colonialRegions.at(region).getRegions(); - std::set requiredStates; - for (const auto& theRegion: requiredRegions) - { - auto states = clayManager.getStateNamesForRegion(theRegion); - requiredStates.insert(states.begin(), states.end()); - } - - // what is owned - std::set ownedStates; - for (const auto& state: country.getSubStates()) - ownedStates.emplace(state->getHomeStateName()); - - // do we have presence in each of the required states? No need to check for 100% ownership, presence is sufficient. - for (const auto& requiredState: requiredStates) - if (!ownedStates.contains(requiredState)) - return std::nullopt; - - return aloneName; -} diff --git a/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapping.h b/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapping.h deleted file mode 100644 index 31979c1..0000000 --- a/EU5ToVic3/Source/Mappers/ColonialTagMapper/ColonialTagMapping.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef COLONIAL_TAG_MAPPING_H -#define COLONIAL_TAG_MAPPING_H -#include "Parser.h" - -namespace V3 -{ -class Country; -class ClayManager; -} // namespace V3 -namespace mappers -{ -class ColonialRegionMapper; -class ColonialTagMapping: commonItems::parser -{ - public: - ColonialTagMapping() = default; - explicit ColonialTagMapping(std::istream& theStream); - - [[nodiscard]] std::optional matchColonialTag(const V3::Country& country, - const ColonialRegionMapper& colonialRegionMapper, - const V3::ClayManager& clayManager) const; - [[nodiscard]] const auto& getTag() const { return tag; } - - private: - void registerKeys(); - - std::string region; - std::string aloneName; - std::string tag; -}; -} // namespace mappers - -#endif // COLONIAL_TAG_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapper.cpp b/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapper.cpp deleted file mode 100644 index bc3c1ff..0000000 --- a/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapper.cpp +++ /dev/null @@ -1,221 +0,0 @@ -#include "CountryMapper.h" -#include "CommonRegexes.h" -#include "CountryManager/EU4Country.h" -#include "Log.h" -#include "ParserHelpers.h" -#include - -void mappers::CountryMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Parsing country mapping rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << countryMappingRules.size() << " rules loaded."; -} - -void mappers::CountryMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::CountryMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - const CountryMapping newMapping(theStream); - countryMappingRules.emplace_back(newMapping); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -bool mappers::CountryMapper::tagIsDynamic(const std::string& tag) const -{ - if (tag.size() < 3) // A shorter tag is certainly dynamic. Also probably illegal but that isn't our problem. - return true; - - if (dynamicallyGeneratedTags.contains(tag)) - return true; - - // Generally a strong check for colonial tags, eg. C04. Can be used for other purposes. - return isalpha(tag[0]) && isdigit(tag[1]) && isdigit(tag[2]); -} - -bool mappers::CountryMapper::tagIsNonCanon(const std::string& tag) const -{ - if (tag.size() < 3) // A shorter tag is certainly non-canon. Also probably illegal but that isn't our problem. - return true; - - if (dynamicallyGeneratedTags.contains(tag)) - return true; - - // A truism for non-canon countries, generally both dynamic C04, and converter-generated (by CK3toEU4), eg. Z0A, Y0B.. - return isalpha(tag[0]) && isdigit(tag[1]) && isalnum(tag[2]); -} - -std::string mappers::CountryMapper::generateNewTag() -{ - std::string v3Tag; - do - { - std::ostringstream generatedV3TagStream; - generatedV3TagStream << generatedV3TagPrefix << std::setfill('0') << std::setw(2) << generatedV3TagSuffix; - v3Tag = generatedV3TagStream.str(); - - ++generatedV3TagSuffix; - if (generatedV3TagSuffix > 99) - { - generatedV3TagSuffix = 0; - --generatedV3TagPrefix; - } - } while (tagIsAlreadyAssigned(v3Tag) || knownVanillaV3Tags.contains(v3Tag)); - dynamicallyGeneratedTags.emplace(v3Tag); - return v3Tag; -} - -bool mappers::CountryMapper::tagIsAlreadyAssigned(const std::string& v3Tag) const -{ - return v3TagToEU4TagMap.contains(v3Tag) || unmappedV3Tags.contains(v3Tag); -} - -std::optional mappers::CountryMapper::getV3Tag(const std::string& eu4Tag) const -{ - // This is an override for anything that looks like a rebellious title. - const std::set eu4RebelTags = {"REB", "PIR", "NAT"}; - if (eu4RebelTags.contains(eu4Tag)) - return "REB"; - - if (eu4TagToV3TagMap.contains(eu4Tag)) - return eu4TagToV3TagMap.at(eu4Tag); - - return std::nullopt; -} - -std::optional mappers::CountryMapper::getEU4Tag(const std::string& v3Tag) const -{ - if (v3TagToEU4TagMap.contains(v3Tag)) - return v3TagToEU4TagMap.at(v3Tag); - - return std::nullopt; -} - -std::optional mappers::CountryMapper::getFlagCode(const std::string& v3Tag) const -{ - if (v3FlagCodes.contains(v3Tag)) - return v3FlagCodes.at(v3Tag); - - return std::nullopt; -} - -std::string mappers::CountryMapper::assignV3TagToEU4Country(const std::shared_ptr& country) -{ - // Is this country already mapped? - const auto& eu4Tag = country->getTag(); - if (eu4TagToV3TagMap.contains(eu4Tag)) - return eu4TagToV3TagMap.at(eu4Tag); - - // prep filtering details. - const auto& eu4Name = country->getName("english"); - const auto& countryFlags = country->getFlags(); - const auto& countryReforms = country->getReforms(); - - // and start poking rules. - for (const auto& rule: countryMappingRules) - { - // Do we have blocking flags or reforms? - const bool flagLock = existsLocks(rule.getFlags(), countryFlags); - const bool reformLock = existsLocks(rule.getReforms(), countryReforms); - - // are we clear? - if (flagLock || reformLock) // either blocks, we're failing. - continue; - - // Only do name and tag if there's something to be done here. - if (rule.getName() || rule.getEU4Tag()) - { - // Do we have a blocking name or blocking tag? - const auto nameBlock = existsBlock(rule.getName(), eu4Name); - const auto tagBlock = existsBlock(rule.getEU4Tag(), eu4Tag); - - // are we clear? - if ((!nameBlock || *nameBlock) && (!tagBlock || *tagBlock)) // to continue we need either one of these BOTH existing and not blocking. - continue; - } - - // file a relation and wrap up. - return mapToTag(eu4Tag, rule.getV3Tag(), rule.getFlagCode()); - } - - // No rules match. Generate, file and wrap it up. - return mapToTag(eu4Tag, std::nullopt, std::nullopt); -} - -bool mappers::CountryMapper::existsLocks(const std::set& ruleLocks, const std::set& countryKeys) -{ - bool locker = false; - if (!ruleLocks.empty()) - { - locker = true; - for (const auto& lock: ruleLocks) - if (countryKeys.contains(lock)) - { - locker = false; - break; - } - } - return locker; -} - -std::optional mappers::CountryMapper::existsBlock(const std::optional& ruleString, const std::string& countryString) -{ - if (!ruleString) - return std::nullopt; - if (*ruleString == countryString) - return false; - return true; -} - -std::string mappers::CountryMapper::mapToTag(const std::string& eu4Tag, const std::optional& v3Tag, const std::optional& flagCode) -{ - std::string newTag; - if (v3Tag) - { - if (tagIsAlreadyAssigned(*v3Tag)) // it it taken already? - newTag = generateNewTag(); - else - newTag = *v3Tag; - } - else - { - newTag = generateNewTag(); - } - eu4TagToV3TagMap.emplace(eu4Tag, newTag); - v3TagToEU4TagMap.emplace(newTag, eu4Tag); - if (flagCode) - v3FlagCodes.emplace(newTag, *flagCode); - - return newTag; -} - -std::string mappers::CountryMapper::requestNewV3Tag() -{ - auto newTag = generateNewTag(); - unmappedV3Tags.emplace(newTag); - return newTag; -} - -void mappers::CountryMapper::relink(const std::string& eu4tag, const std::string& currentTag, const std::string& newTag) -{ - if (!eu4TagToV3TagMap.contains(eu4tag)) - Log(LogLevel::Error) << "Relinking eu4 tag " + eu4tag + " failed, it was never linked!"; - - eu4TagToV3TagMap.at(eu4tag) = newTag; - v3TagToEU4TagMap.erase(currentTag); - v3TagToEU4TagMap.emplace(newTag, eu4tag); - if (v3FlagCodes.contains(currentTag)) - { - v3FlagCodes.emplace(newTag, v3FlagCodes.at(currentTag)); - v3FlagCodes.erase(currentTag); - } -} diff --git a/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapper.h b/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapper.h deleted file mode 100644 index 9d7b749..0000000 --- a/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapper.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef COUNTRY_MAPPER_H -#define COUNTRY_MAPPER_H -#include "CountryMapping.h" -#include "Parser.h" - -namespace EU4 -{ -class Country; -} - -namespace mappers -{ -class CountryMapper: commonItems::parser -{ - public: - CountryMapper() = default; - void loadMappingRules(const std::string& filePath); - void loadMappingRules(std::istream& theStream); - - void registerKnownVanillaV3Tag(const std::string& tag) { knownVanillaV3Tags.emplace(tag); } - - [[nodiscard]] std::optional getV3Tag(const std::string& eu4Tag) const; - [[nodiscard]] std::optional getEU4Tag(const std::string& v3Tag) const; - [[nodiscard]] std::optional getFlagCode(const std::string& v3Tag) const; - [[nodiscard]] bool tagIsDynamic(const std::string& tag) const; // alpha-digit-digit, eg. C01, T15 - [[nodiscard]] bool tagIsNonCanon(const std::string& tag) const; // both dynamic and imported, eg. Z0A, X0J - - [[nodiscard]] std::string assignV3TagToEU4Country(const std::shared_ptr& country); - [[nodiscard]] std::string requestNewV3Tag(); - - [[nodiscard]] const auto& getMappingRules() const { return countryMappingRules; } - - void relink(const std::string& eu4tag, const std::string& currentTag, const std::string& newTag); - - private: - void registerKeys(); - - [[nodiscard]] bool tagIsAlreadyAssigned(const std::string& v3Tag) const; - [[nodiscard]] std::string generateNewTag(); - - [[nodiscard]] static bool existsLocks(const std::set& ruleLocks, const std::set& countryKeys); - [[nodiscard]] static std::optional existsBlock(const std::optional& ruleString, const std::string& countryString); - [[nodiscard]] std::string mapToTag(const std::string& eu4Tag, const std::optional& v3Tag, const std::optional& flagCode); - - std::vector countryMappingRules; - std::map eu4TagToV3TagMap; - std::map v3TagToEU4TagMap; - std::map v3FlagCodes; // v3 tag -> flagcode - std::set unmappedV3Tags; // stuff we generate on the fly for decentralized countries. - std::set knownVanillaV3Tags; // countries we import at game start. Includes names with potential for generated-collisions. - std::set dynamicallyGeneratedTags; // stuff we created ourselves. Safe to delete if needed. - - char generatedV3TagPrefix = 'X'; - int generatedV3TagSuffix = 0; -}; -} // namespace mappers - -#endif // COUNTRY_MAPPINGS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapping.cpp b/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapping.cpp deleted file mode 100644 index af11352..0000000 --- a/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapping.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "CountryMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::CountryMapping::CountryMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::CountryMapping::registerKeys() -{ - registerKeyword("eu4", [this](std::istream& theStream) { - eu4Tag = commonItems::getString(theStream); - }); - registerKeyword("vic3", [this](std::istream& theStream) { - v3Tag = commonItems::getString(theStream); - }); - registerKeyword("name", [this](std::istream& theStream) { - name = commonItems::getString(theStream); - }); - registerKeyword("flag_code", [this](std::istream& theStream) { - flagCode = commonItems::getString(theStream); - }); - registerKeyword("reform", [this](std::istream& theStream) { - reforms.insert(commonItems::getString(theStream)); - }); - registerKeyword("flag", [this](std::istream& theStream) { - flags.insert(commonItems::getString(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapping.h b/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapping.h deleted file mode 100644 index 81e7f6b..0000000 --- a/EU5ToVic3/Source/Mappers/CountryMapper/CountryMapping.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef COUNTRY_MAPPING_H -#define COUNTRY_MAPPING_H -#include "Parser.h" -#include - -namespace mappers -{ -class CountryMapping: commonItems::parser -{ - public: - CountryMapping() = default; - explicit CountryMapping(std::istream& theStream); - - [[nodiscard]] const auto& getEU4Tag() const { return eu4Tag; } - [[nodiscard]] const auto& getV3Tag() const { return v3Tag; } - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getFlagCode() const { return flagCode; } - [[nodiscard]] const auto& getReforms() const { return reforms; } - [[nodiscard]] const auto& getFlags() const { return flags; } - - private: - void registerKeys(); - - std::optional eu4Tag; - std::optional v3Tag; - std::optional name; - std::optional flagCode; - std::set reforms; - std::set flags; -}; -} // namespace mappers - -#endif // COUNTRY_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapper.cpp b/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapper.cpp deleted file mode 100644 index 3c15bbc..0000000 --- a/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapper.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "CountryTierMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::CountryTierMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Parsing country tier mapping rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << vanillaMappings.size() + vnMappings.size() << " rules loaded."; -} - -void mappers::CountryTierMapper::registerKeys() -{ - registerKeyword("vanilla", [this](std::istream& theStream) { - vanillaGame = true; - gameTypeParser.parseStream(theStream); - }); - registerKeyword("vn", [this](std::istream& theStream) { - vanillaGame = false; - gameTypeParser.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - gameTypeParser.registerRegex(commonItems::catchallRegex, [this](const std::string& tierName, std::istream& theStream) { - const auto mapping = CountryTierMapping(theStream, tierName); - if (vanillaGame) - vanillaMappings.emplace_back(mapping); - else - vnMappings.emplace_back(mapping); - }); -} - -std::optional mappers::CountryTierMapper::matchCountryTier(const int rank, const size_t size, const bool vn) const -{ - if (!vn) - { - for (const auto& mapping: vanillaMappings) - if (const auto& match = mapping.matchTier(rank, size); match) - return *match; - } - else - { - for (const auto& mapping: vnMappings) - if (const auto& match = mapping.matchTier(rank, size); match) - return *match; - } - return std::nullopt; -} diff --git a/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapper.h b/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapper.h deleted file mode 100644 index d437fc5..0000000 --- a/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapper.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef COUNTRY_TIER_MAPPER_H -#define COUNTRY_TIER_MAPPER_H -#include "CountryTierMapping.h" -#include "Parser.h" - -namespace mappers -{ -class CountryTierMapper: commonItems::parser -{ - public: - CountryTierMapper() = default; - void loadMappingRules(const std::string& filePath); - - [[nodiscard]] std::optional matchCountryTier(int rank, size_t size, bool vn = false) const; - - private: - void registerKeys(); - parser gameTypeParser; - bool vanillaGame = false; - - std::vector vanillaMappings; - std::vector vnMappings; -}; -} // namespace mappers - -#endif // COUNTRY_MAPPINGS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapping.cpp b/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapping.cpp deleted file mode 100644 index a2e64e8..0000000 --- a/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapping.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "CountryTierMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::CountryTierMapping::CountryTierMapping(std::istream& theStream, std::string theName): name(std::move(theName)) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::CountryTierMapping::registerKeys() -{ - registerKeyword("size", [this](std::istream& theStream) { - size = commonItems::getInt(theStream); - }); - registerKeyword("rank", [this](std::istream& theStream) { - rank = commonItems::getInt(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::CountryTierMapping::matchTier(const int incRank, const size_t incSize) const -{ - if (size && incSize > *size) - return std::nullopt; - if (incRank > rank) - return std::nullopt; - return name; -} diff --git a/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapping.h b/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapping.h deleted file mode 100644 index e51968d..0000000 --- a/EU5ToVic3/Source/Mappers/CountryTierMapper/CountryTierMapping.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef COUNTRY_TIER_MAPPING_H -#define COUNTRY_TIER_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class CountryTierMapping: commonItems::parser -{ - public: - CountryTierMapping() = default; - explicit CountryTierMapping(std::istream& theStream, std::string theName); - - [[nodiscard]] std::optional matchTier(int incRank, size_t incSize) const; - - private: - void registerKeys(); - - int rank = -1; - std::optional size; - std::string name; -}; -} // namespace mappers - -#endif // COUNTRY_TIER_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDef.h b/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDef.h deleted file mode 100644 index def8c77..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDef.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef CULTURE_DEF_H -#define CULTURE_DEF_H -#include "Color.h" - -namespace mappers -{ -struct CultureDef -{ - std::string name; - std::optional color; - std::string religion; - std::set traits; - std::set maleCommonFirstNames; - std::set femaleCommonFirstNames; - std::set commonLastNames; - std::set nobleLastNames; - std::set maleRegalFirstNames; - std::set femaleRegalFirstNames; - std::set regalLastNames; - std::set ethnicities; - std::string graphics; - bool skipProcessing = false; // We're skipping *separate* processing for defs that we import (from DW for example). - bool skipExport = false; // We're skipping *separate* export for defs that we copy over from blankmod. - - std::map locBlock; - std::map nameLocBlock; // all english since we load from disk -}; -} // namespace mappers - -#endif // CULTURE_DEF_H diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionEntry.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionEntry.cpp deleted file mode 100644 index c56a482..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionEntry.cpp +++ /dev/null @@ -1,142 +0,0 @@ -#include "CultureDefinitionEntry.h" -#include "CommonRegexes.h" -#include "OSCompatibilityLayer.h" -#include "ParserHelpers.h" -#include - -namespace -{ -std::string normalizeString(const std::string& input) -{ - auto toReturn = commonItems::normalizeUTF8Path(input); - std::replace(toReturn.begin(), toReturn.end(), ' ', '_'); - std::replace(toReturn.begin(), toReturn.end(), '\'', '_'); - return toReturn; -} -} // namespace - -mappers::CultureDefinitionEntry::CultureDefinitionEntry(std::istream& theStream, bool skipProcessing, bool skipExport) -{ - cultureDef.skipProcessing = skipProcessing; - cultureDef.skipExport = skipExport; - registerkeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::CultureDefinitionEntry::registerkeys() -{ - ethStripper.registerRegex(R"(\d+)", [this](const std::string& unused, std::istream& theStream) { - cultureDef.ethnicities.emplace(commonItems::getString(theStream)); - }); - ethStripper.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - registerKeyword("color", [this](std::istream& theStream) { - cultureDef.color = commonItems::Color::Factory().getColor(theStream); - }); - registerKeyword("religion", [this](std::istream& theStream) { - cultureDef.religion = commonItems::getString(theStream); - }); - registerKeyword("traits", [this](std::istream& theStream) { - for (const auto& trait: commonItems::getStrings(theStream)) - cultureDef.traits.emplace(trait); - }); - registerKeyword("male_common_first_names", [this](std::istream& theStream) { - for (const auto& name: commonItems::getStrings(theStream)) - { - if (cultureDef.skipProcessing) - cultureDef.maleCommonFirstNames.emplace(name); - else - { - auto dwName = "dw_" + normalizeString(name); - cultureDef.maleCommonFirstNames.emplace(dwName); - cultureDef.nameLocBlock.emplace(dwName, name); - } - } - }); - registerKeyword("female_common_first_names", [this](std::istream& theStream) { - for (const auto& name: commonItems::getStrings(theStream)) - { - if (cultureDef.skipProcessing) - cultureDef.femaleCommonFirstNames.emplace(name); - else - { - auto dwName = "dw_" + normalizeString(name); - cultureDef.femaleCommonFirstNames.emplace(dwName); - cultureDef.nameLocBlock.emplace(dwName, name); - } - } - }); - registerKeyword("noble_last_names", [this](std::istream& theStream) { - for (const auto& name: commonItems::getStrings(theStream)) - { - if (cultureDef.skipProcessing) - cultureDef.nobleLastNames.emplace(name); - else - { - auto dwName = "dw_" + normalizeString(name); - cultureDef.nobleLastNames.emplace(dwName); - cultureDef.nameLocBlock.emplace(dwName, name); - } - } - }); - registerKeyword("common_last_names", [this](std::istream& theStream) { - for (const auto& name: commonItems::getStrings(theStream)) - { - if (cultureDef.skipProcessing) - cultureDef.commonLastNames.emplace(name); - else - { - auto dwName = "dw_" + normalizeString(name); - cultureDef.commonLastNames.emplace(dwName); - cultureDef.nameLocBlock.emplace(dwName, name); - } - } - }); - registerKeyword("male_regal_first_names", [this](std::istream& theStream) { - for (const auto& name: commonItems::getStrings(theStream)) - { - if (cultureDef.skipProcessing) - cultureDef.maleRegalFirstNames.emplace(name); - else - { - auto dwName = "dw_" + normalizeString(name); - cultureDef.maleRegalFirstNames.emplace(dwName); - cultureDef.nameLocBlock.emplace(dwName, name); - } - } - }); - registerKeyword("female_regal_first_names", [this](std::istream& theStream) { - for (const auto& name: commonItems::getStrings(theStream)) - { - if (cultureDef.skipProcessing) - cultureDef.femaleRegalFirstNames.emplace(name); - else - { - auto dwName = "dw_" + normalizeString(name); - cultureDef.femaleRegalFirstNames.emplace(dwName); - cultureDef.nameLocBlock.emplace(dwName, name); - } - } - }); - registerKeyword("regal_last_names", [this](std::istream& theStream) { - for (const auto& name: commonItems::getStrings(theStream)) - { - if (cultureDef.skipProcessing) - cultureDef.regalLastNames.emplace(name); - else - { - auto dwName = "dw_" + normalizeString(name); - cultureDef.regalLastNames.emplace(dwName); - cultureDef.nameLocBlock.emplace(dwName, name); - } - } - }); - registerKeyword("ethnicities", [this](std::istream& theStream) { - ethStripper.parseStream(theStream); - }); - registerKeyword("graphics", [this](std::istream& theStream) { - cultureDef.graphics = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionEntry.h b/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionEntry.h deleted file mode 100644 index 8d57639..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionEntry.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef CULTURE_DEFINITION_ENTRY_H -#define CULTURE_DEFINITION_ENTRY_H -#include "CultureDef.h" -#include "Parser.h" - -namespace mappers -{ -class CultureDefinitionEntry: commonItems::parser -{ - public: - explicit CultureDefinitionEntry(std::istream& theStream, bool skipProcessing, bool skipExport); - - [[nodiscard]] const auto& getCultureDef() const { return cultureDef; } - - private: - void registerkeys(); - parser ethStripper; - - CultureDef cultureDef; -}; -} // namespace mappers - -#endif // CULTURE_DEFINITION_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionLoader.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionLoader.cpp deleted file mode 100644 index d3abb8e..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionLoader.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "CultureDefinitionLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "CultureDefinitionEntry.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::CultureDefinitionLoader::loadDefinitions(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading culture definitions."; - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/cultures/")) - { - if (getExtension(fileName) != "txt") - continue; - - if (fileName.find("99_") != std::string::npos) - skipProcessing = false; - else - skipProcessing = true; - - if (fileName.find("blankMod") != std::string::npos) - skipExport = true; - else - skipExport = false; - - parseFile(fileName); - } - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << cultureDefinitions.size() << " definitions loaded."; -} - -void mappers::CultureDefinitionLoader::loadDefinitions(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::CultureDefinitionLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& cultureName, std::istream& theStream) { - auto relDef = CultureDefinitionEntry(theStream, skipProcessing, skipExport).getCultureDef(); - relDef.name = cultureName; - - if (!cultureDefinitions.contains(cultureName)) - cultureDefinitions.emplace(cultureName, relDef); - else - cultureDefinitions.at(cultureName) = relDef; - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionLoader.h b/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionLoader.h deleted file mode 100644 index 6d857b1..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureDefinitionLoader/CultureDefinitionLoader.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef CULTURE_DEFINITION_LOADER_H -#define CULTURE_DEFINITION_LOADER_H -#include "CultureDef.h" -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace mappers -{ -class CultureDefinitionLoader: commonItems::parser -{ - public: - CultureDefinitionLoader() = default; - void loadDefinitions(const commonItems::ModFilesystem& modFS); - void loadDefinitions(std::istream& theStream); - - [[nodiscard]] const auto& getDefinitions() const { return cultureDefinitions; } - - private: - void registerKeys(); - - std::map cultureDefinitions; - bool skipProcessing = true; // skip processing for cultures not loaded from 99_<...>.txt! - bool skipExport = true; // skip export for cultures loaded from */blankMod/* -}; -} // namespace mappers - -#endif // CULTURE_DEFINITION_LOADER_H diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureMapper.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/CultureMapper.cpp deleted file mode 100644 index de09846..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureMapper.cpp +++ /dev/null @@ -1,613 +0,0 @@ -#include "CultureMapper.h" -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/State.h" -#include "ClayManager/State/SubState.h" -#include "CommonRegexes.h" -#include "CultureDefinitionLoader/CultureDefinitionLoader.h" -#include "CultureLoader/CultureGroupParser.h" -#include "CultureLoader/CultureLoader.h" -#include "CultureMappingRule.h" -#include "CultureTraitMapper/CultureTraitMapper.h" -#include "LocalizationLoader/EU4LocalizationLoader.h" -#include "Log.h" -#include "NameListLoader/NameListLoader.h" -#include "NameListMapper/NameListMapper.h" -#include "ParserHelpers.h" -#include "TraitDefinitionLoader/TraitDefinitionLoader.h" -#include -#include - -namespace -{ -std::string normalizeString(const std::string& input) -{ - auto toReturn = commonItems::normalizeUTF8Path(input); - std::replace(toReturn.begin(), toReturn.end(), ' ', '_'); - std::replace(toReturn.begin(), toReturn.end(), '\'', '_'); - return toReturn; -} -void copyNamePoolNames(mappers::CultureDef& cultureDef, const mappers::NameListEntry& namePool) -{ - cultureDef.commonLastNames = namePool.getDynastyNames(); - cultureDef.nobleLastNames = namePool.getDynastyNames(); - cultureDef.maleCommonFirstNames = namePool.getMaleNames(); - cultureDef.maleRegalFirstNames = namePool.getMaleNames(); - cultureDef.femaleCommonFirstNames = namePool.getFemaleNames(); - cultureDef.femaleRegalFirstNames = namePool.getFemaleNames(); -} - -void copyEU4Names(mappers::CultureDef& cultureDef, const EU4::CultureParser& sourceCulture) -{ - for (const auto& name: sourceCulture.getDynastyNames()) - { - auto normName = "eu4_" + normalizeString(name); - cultureDef.nameLocBlock.emplace(normName, name); - cultureDef.commonLastNames.emplace(normName); - cultureDef.nobleLastNames.emplace(normName); - } - for (const auto& name: sourceCulture.getMaleNames()) - { - auto normName = "eu4_" + normalizeString(name); - cultureDef.nameLocBlock.emplace(normName, name); - cultureDef.maleCommonFirstNames.emplace(normName); - cultureDef.maleRegalFirstNames.emplace(normName); - } - for (const auto& name: sourceCulture.getFemaleNames()) - { - auto normName = "eu4_" + normalizeString(name); - cultureDef.nameLocBlock.emplace(normName, name); - cultureDef.femaleCommonFirstNames.emplace(normName); - cultureDef.femaleRegalFirstNames.emplace(normName); - } -} - -std::vector breakDownCulturalName(const std::string& eu4CultureName) -{ - // dynamic-afghani-culture-num1 - // dynamic-afghani-panjabi-culture-num2 - - std::vector componentCultures; - if (!eu4CultureName.starts_with("dynamic-") || eu4CultureName.size() <= 8) - { - componentCultures.emplace_back(eu4CultureName); - return componentCultures; - } - - // easy now. eeeasy. Max 2 cultures. - auto theName = eu4CultureName.substr(8, eu4CultureName.size()); - if (const auto& pos = theName.find('-'); pos != std::string::npos && pos < theName.size() - 1) - { - componentCultures.emplace_back(theName.substr(0, pos)); - theName = theName.substr(pos + 1, theName.size()); - } - if (const auto& pos = theName.find('-'); pos != std::string::npos && pos < theName.size() - 1) - { - if (theName.substr(0, pos) != "culture") - componentCultures.emplace_back(theName.substr(0, pos)); - } - return componentCultures; -} - -void importLocalizationForNeoCulture(mappers::CultureDef& newDef, const mappers::ColonialRegionMapping& colony, int colonialCulturesCount) -{ - if (colonialCulturesCount == 1) - { - // overwriting everything with preset english. sorry. yup. - for (auto& loc: newDef.locBlock | std::views::values) - loc = colony.getAloneName(); - } - else - { - std::string eng; - if (newDef.locBlock.contains("english")) - eng = newDef.locBlock.at("english"); - else - { - // ??? Don't have english? hmm. - eng = newDef.name; - } - const auto& splitSuffix = colony.getSplitName(); - if (const auto& pos = splitSuffix.find("$PARENT$"); pos != std::string::npos) - { - eng = splitSuffix.substr(0, pos) + eng; - if (splitSuffix.size() > pos + 8) - eng += splitSuffix.substr(pos + 8, splitSuffix.size()); - } - for (auto& loc: newDef.locBlock | std::views::values) - loc = eng; - } -} - -commonItems::Color generateCultureColors(const std::string& cultureName, const std::string& saltName) -{ - const auto salt = std::accumulate(saltName.begin(), saltName.end(), 0, [](int sum, const char letter) { - return sum + static_cast(static_cast(letter)); - }); - - if (cultureName.size() < 3) - return commonItems::Color{std::array{200, 164, 213}}; // I just like these numbers. - int r = (static_cast(cultureName[0]) * 29 + salt) % 256; // should be random enough. - int g = (static_cast(cultureName[1]) * 17 + salt) % 256; - int b = (static_cast(cultureName[2]) * 23 + salt) % 256; - if (r < 50) // make them brighter. - r += 50; - if (g < 50) - g += 50; - if (b < 50) - b += 50; - return commonItems::Color{std::array{r, g, b}}; -} -} // namespace - - -void mappers::CultureMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::CultureMapper::loadMappingRules(const std::string& fileName) -{ - Log(LogLevel::Info) << "-> Parsing culture mapping rules."; - registerKeys(); - parseFile(fileName); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << cultureMapRules.size() << " rules loaded."; -} - -void mappers::CultureMapper::loadColonialRules(std::istream& theStream) -{ - colonialRegionMapper.loadMappingRules(theStream); -} - -void mappers::CultureMapper::loadColonialRules(const std::string& fileName) -{ - colonialRegionMapper.loadMappingRules(fileName); -} - -void mappers::CultureMapper::loadWesternizationRules(std::istream& theStream) -{ - westernizationMapper.loadMappingRules(theStream); -} - -void mappers::CultureMapper::loadWesternizationRules(const std::string& fileName) -{ - westernizationMapper.loadMappingRules(fileName); -} - -void mappers::CultureMapper::registerKeys() -{ - registerRegex(R"(@\w+)", [this](const std::string& macro, std::istream& theStream) { - encounteredMacros.emplace(macro, commonItems::getString(theStream)); - }); - registerKeyword("link", [this](std::istream& theStream) { - CultureMappingRule rule; - rule.loadMappingRules(theStream); - for (const auto& macro: rule.getRequestedMacros()) - if (encounteredMacros.contains(macro)) - rule.loadMappingRules(encounteredMacros.at(macro)); - if ((!rule.getCultures().empty() || !rule.getCultureGroups().empty()) && !rule.getV3Culture().empty()) - cultureMapRules.emplace_back(rule); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::CultureMapper::cultureMatch(const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& eu4culture, - const std::string& eu4religion, - const std::string& v3state, - const std::string& v3ownerTag, - bool neoCultureRequest, - bool silent) -{ - for (const auto& cultureMappingRule: cultureMapRules) - { - if (!neoCultureRequest) - { - if (const auto& possibleMatch = - cultureMappingRule.cultureMatch(clayManager, cultureLoader, religionLoader, eu4culture, eu4religion, v3state, v3ownerTag); - possibleMatch) - { - usedCultures.emplace(*possibleMatch); - return *possibleMatch; - } - } - else - { - // we want neocultures in a very specific region. General rules don't apply unless they cover our region. - if (const auto& possibleMatch = - cultureMappingRule.cultureRegionalMatch(clayManager, cultureLoader, religionLoader, eu4culture, eu4religion, v3state, v3ownerTag); - possibleMatch) - { - usedCultures.emplace(*possibleMatch); - return *possibleMatch; - } - } - } - - // if this normal culture is already recorded as unmapped, all is well. - if (!neoCultureRequest && unmappedCultures.contains(eu4culture)) - { - usedCultures.emplace(eu4culture); - return eu4culture; - } - - // Is this a normal unmapped culture? We shouldn't be here - it should have been recorded when expanding unless it's not present in vanilla eu4 defs, - // which is bad in itself. - if (!neoCultureRequest) - { - if (!silent) - Log(LogLevel::Warning) << "! CultureMapper - Attempting to match culture " << eu4culture << " in state " << v3state << " failed."; - unmappedCultures.emplace(eu4culture); - usedCultures.emplace(eu4culture); - return eu4culture; - } - - // For neoculture requests we need to consult and potentially expand our global registry. - return getNeoCultureMatch(eu4culture, v3state, clayManager); -} - -std::optional mappers::CultureMapper::suspiciousCultureMatch(const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& eu4culture, - const std::string& eu4religion, - const std::string& v3state, - const std::string& v3ownerTag) -{ - if (const auto& potentialColony = colonialRegionMapper.getColonyNameForState(v3state, clayManager); potentialColony) - { - // this is option 1. - if (colonyNeoCultureTargets.contains(*potentialColony) && colonyNeoCultureTargets.at(*potentialColony).contains(eu4culture)) - return colonyNeoCultureTargets.at(*potentialColony).at(eu4culture); - } - - // Otherwise, do a straight match at that location. - return cultureMatch(clayManager, cultureLoader, religionLoader, eu4culture, eu4religion, v3state, v3ownerTag, false, false); -} - -std::string mappers::CultureMapper::getNeoCultureMatch(const std::string& eu4culture, const std::string& v3state, const V3::ClayManager& clayManager) -{ - if (v3state.empty()) // possibly pinging a general location. - { - unmappedCultures.emplace(eu4culture); - usedCultures.emplace(eu4culture); - return eu4culture; - } - - const auto& colony = colonialRegionMapper.getColonyNameForState(v3state, clayManager); - if (!colony) - { - // not uncommon if we don't have defined colonies. - Log(LogLevel::Warning) << "We don't have a defined colony for " << v3state << "! Can't create neoculture for " << eu4culture; - unmappedCultures.emplace(eu4culture); - usedCultures.emplace(eu4culture); - return eu4culture; - } - - if (colonyNeoCultureTargets.contains(*colony) && colonyNeoCultureTargets.at(*colony).contains(eu4culture)) - return colonyNeoCultureTargets.at(*colony).at(eu4culture); - - // we have to generate a new neo culture. SIMPLE! - auto generated = "neo-" + *colony + "-" + eu4culture; - // neo-usa_north_colony-dynamic-culture1-culture7-culture-num1. Trivial. - - if (!colonyNeoCultureTargets.contains(*colony)) - colonyNeoCultureTargets.emplace(*colony, std::map{}); - colonyNeoCultureTargets.at(*colony).emplace(eu4culture, generated); - unmappedCultures.emplace(generated); - usedCultures.emplace(generated); - return generated; -} - -void mappers::CultureMapper::expandCulturalMappings(const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader) -{ - // We'll simply iterate over all known eu4 cultures, see what maps, and then record what we see for the first time. - - for (const auto& cultureGroup: cultureLoader.getCultureGroupsMap() | std::views::values) - for (const auto& cultureName: cultureGroup.getCultures() | std::views::keys) - if (!cultureMatch(clayManager, cultureLoader, religionLoader, cultureName, "", "", "", false, true)) - unmappedCultures.emplace(cultureName); - - Log(LogLevel::Info) << "<> Additional " << unmappedCultures.size() << " cultures imported."; -} - -void mappers::CultureMapper::loadCultureDefinitions(const commonItems::ModFilesystem& modFS) -{ - CultureDefinitionLoader cultureDefinitionLoader; - cultureDefinitionLoader.loadDefinitions(modFS); - v3CultureDefinitions = cultureDefinitionLoader.getDefinitions(); -} - -void mappers::CultureMapper::loadTraitDefinitions(const commonItems::ModFilesystem& modFS) -{ - TraitDefinitionLoader traitDefinitionLoader; - traitDefinitionLoader.loadDefinitions(modFS); - v3TraitDefinitions = traitDefinitionLoader.getDefinitions(); -} - -void mappers::CultureMapper::generateCultureDefinitions(const std::string& nameListsPath, - const std::string& nameListMapPath, - const std::string& cultureTraitsPath, - const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const EU4::EU4LocalizationLoader& eu4Locs) -{ - Log(LogLevel::Info) << "-> Generating culture definitions."; - - NameListLoader nameListLoader; - nameListLoader.loadNameLists(nameListsPath); - NameListMapper nameListMapper; - nameListMapper.loadMappingRules(nameListMapPath); - CultureTraitMapper cultureTraitMapper; - cultureTraitMapper.loadMappingRules(cultureTraitsPath); - - // shove existing vanilla defs into the bin. - const auto& defCount = v3CultureDefinitions.size(); - - for (const auto& eu4CultureName: usedCultures) - { - // do we have a ready definition already? - if (v3CultureDefinitions.contains(eu4CultureName)) - continue; - - // neocultures need special treatment. - if (eu4CultureName.starts_with("neo-")) - { - std::string actualEU4CultureName; - ColonialRegionMapping colony; - std::string actualColonyName; - - for (const auto& [colonyName, cultureMap]: colonyNeoCultureTargets) - for (const auto& [eu4Culture, neoCultureName]: cultureMap) - if (neoCultureName == eu4CultureName) - { - actualEU4CultureName = eu4Culture; - actualColonyName = colonyName; - colony = colonialRegionMapper.getColonialRegions().at(colonyName); - } - auto newDef = generateCultureDefinition(clayManager, - actualEU4CultureName, - cultureTraitMapper, - nameListMapper, - nameListLoader, - cultureLoader, - religionLoader, - eu4Locs, - eu4CultureName); - newDef.name = eu4CultureName; - importLocalizationForNeoCulture(newDef, colony, static_cast(colonyNeoCultureTargets.at(actualColonyName).size())); - v3CultureDefinitions.emplace(eu4CultureName, newDef); - continue; - } - - if (!cultureLoader.containsCulture(eu4CultureName)) - { - Log(LogLevel::Warning) << "EU4 cultures don't contain " << eu4CultureName << "? What are we even doing?"; - continue; - } - - // generate a definition and file. - auto newDef = - generateCultureDefinition(clayManager, eu4CultureName, cultureTraitMapper, nameListMapper, nameListLoader, cultureLoader, religionLoader, eu4Locs); - v3CultureDefinitions.emplace(eu4CultureName, newDef); - } - - Log(LogLevel::Info) << "-> Generated " << v3CultureDefinitions.size() - defCount << " culture definitions."; -} - -void mappers::CultureMapper::injectReligionsIntoCultureDefs(const V3::ClayManager& clayManager) -{ - Log(LogLevel::Info) << "-> Updating primary religions for cultures according to census."; - std::map> culturalReligionPopSizeMap; // census cache - - for (const auto& state: clayManager.getStates() | std::views::values) - for (const auto& subState: state->getSubStates()) - for (const auto& pop: subState->getSubStatePops().getPops()) - if (!pop.getCulture().empty() && !pop.getReligion().empty()) - { - const auto& culture = pop.getCulture(); - const auto& religion = pop.getReligion(); - if (!culturalReligionPopSizeMap.contains(culture)) - culturalReligionPopSizeMap.emplace(culture, std::map{}); - if (!culturalReligionPopSizeMap.at(culture).contains(religion)) - culturalReligionPopSizeMap.at(culture).emplace(religion, 0); - culturalReligionPopSizeMap.at(culture).at(religion) += pop.getSize(); - } - - // file census results - for (const auto& [culture, religionPopSizeMap]: culturalReligionPopSizeMap) - { - if (!v3CultureDefinitions.contains(culture)) // uh-huh. - continue; - if (religionPopSizeMap.empty()) - continue; - const auto dominantReligion = std::max_element(std::begin(religionPopSizeMap), std::end(religionPopSizeMap), [](const auto& p1, const auto& p2) { - return p1.second < p2.second; - }); - v3CultureDefinitions.at(culture).religion = dominantReligion->first; - } - Log(LogLevel::Info) << "<> Update complete."; -} - -int mappers::CultureMapper::getWesternizationScoreForCulture(const std::string& cultureName) const -{ - if (!v3CultureDefinitions.contains(cultureName)) - { - Log(LogLevel::Warning) << "Can't retrieve Westernization for unknown culture: " << cultureName; - return 0; - } - - return westernizationMapper.getWesternizationForTraits(v3CultureDefinitions.at(cultureName).traits); -} - -int mappers::CultureMapper::getLiteracyScoreForCulture(const std::string& cultureName) const -{ - if (!v3CultureDefinitions.contains(cultureName)) - { - Log(LogLevel::Warning) << "Can't retrieve Literacy for unknown culture: " << cultureName; - return 0; - } - - return westernizationMapper.getLiteracyForTraits(v3CultureDefinitions.at(cultureName).traits); -} - -int mappers::CultureMapper::getIndustryScoreForCulture(const std::string& cultureName) const -{ - if (!v3CultureDefinitions.contains(cultureName)) - { - Log(LogLevel::Warning) << "Can't retrieve Industry for unknown culture: " << cultureName; - return 0; - } - - return westernizationMapper.getIndustryForTraits(v3CultureDefinitions.at(cultureName).traits); -} - -mappers::CultureDef mappers::CultureMapper::generateCultureDefinition(const V3::ClayManager& clayManager, - const std::string& eu4CultureName, - const CultureTraitMapper& cultureTraitMapper, - const NameListMapper& nameListMapper, - const NameListLoader& nameListLoader, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const EU4::EU4LocalizationLoader& eu4Locs, - const std::string& seedName) -{ - CultureDef newDef; - newDef.name = eu4CultureName; - bool dynamicCulture = false; - if (eu4CultureName.starts_with("dynamic-") && eu4CultureName.size() > 8) - dynamicCulture = true; - bool primaryComponent = true; - - // NAMEPOOLS & TRAITS - // What's in a name? Could be a number of things. - for (const auto& sourceCultureName: breakDownCulturalName(eu4CultureName)) - { - const auto& sourceCultureGroup = cultureLoader.getGroupForCulture(sourceCultureName); - if (!sourceCultureGroup) - { - // heavy corruption. CK3 ALWAYS maps to existing EU4 cultures! This is bullshit. - Log(LogLevel::Error) << "Cannot find EU4 culture " << sourceCultureName << " in EU4 cultures! THIS IS BAD. Cannot stat " << eu4CultureName << "!"; - continue; - } - - // If we broke down a dynamic culture, use its first component to find a closest vanilla vic3 culture. This is relevant for formables/releasables. - if (dynamicCulture && primaryComponent) - { - if (const auto& match = cultureMatch(clayManager, cultureLoader, religionLoader, sourceCultureName, "", "", ""); match) - { - relatedCultures[*match].emplace(eu4CultureName); - // eu4 cultures have no color defined. We need to seed-generate something. - if (!seedName.empty()) - newDef.color = generateCultureColors(sourceCultureName, seedName); - else - newDef.color = generateCultureColors(sourceCultureName, eu4CultureName); - primaryComponent = false; - } - else - // primaryComponent intentionally remains true if we failed on the match so maybe second component can match something and become the primary - // component. - Log(LogLevel::Warning) << "Cannot find related/base culture of " << eu4CultureName << "!"; - } - - const auto& sourceCulture = sourceCultureGroup->getCultures().at(sourceCultureName); - const auto& groupName = sourceCultureGroup->getName(); - if (const auto& traitsblock = cultureTraitMapper.getTraitsForCulture(sourceCultureName, groupName); !traitsblock) - { - Log(LogLevel::Warning) << "EU4 culture " << sourceCultureName << " has no mapped traits! Rectify!"; - } - else - { - newDef.traits.insert(traitsblock->getTraits().begin(), traitsblock->getTraits().end()); - newDef.ethnicities.emplace(traitsblock->getEthnicity()); - newDef.graphics = traitsblock->getGraphics(); // Any will do but there must be only one. - } - if (const auto& nameListMatch = nameListMapper.getNamesForCulture(sourceCultureName, groupName); !nameListMatch) - { - // Can be common. Be silent about this. - Log(LogLevel::Debug) << "EU4 culture " << sourceCultureName << "/" << groupName << " has no mapped namelist! Falling back to EU4 names."; - copyEU4Names(newDef, sourceCulture); // ok, use eu4 names. - } - else if (const auto& nameList = nameListLoader.getNameList(nameListMatch->getNamePool()); !nameList) - { - Log(LogLevel::Warning) << "EU4 culture " << sourceCultureName << " has has a namepool " << nameListMatch->getNamePool() - << " which doesn't exist! Falling back to EU4 names."; - copyEU4Names(newDef, sourceCulture); // ok, use eu4 names. sigh. - } - else - { - copyNamePoolNames(newDef, *nameList); - } - } - - // sanities - if (newDef.ethnicities.empty()) - newDef.ethnicities.emplace("neutral"); // fallback (?) - - // graphics - if (newDef.graphics.empty()) - newDef.graphics = "generic"; - - // locs - if (const auto& locMatch = eu4Locs.getTextInEachLanguage(eu4CultureName); !locMatch) - Log(LogLevel::Warning) << "WHY doesn't " << eu4CultureName << " have a localization in EU4?"; - else - newDef.locBlock = *locMatch; - - if (!newDef.color) - { - if (!seedName.empty()) - newDef.color = generateCultureColors(eu4CultureName, seedName); - else - newDef.color = generateCultureColors(eu4CultureName, eu4CultureName); - } - - return newDef; -} - -std::optional mappers::CultureMapper::doCulturesShareHeritageTrait(const std::string& cultureA, const std::string& cultureB) const -{ - if (!v3CultureDefinitions.contains(cultureA)) - return std::nullopt; - - if (!v3CultureDefinitions.contains(cultureB)) - return std::nullopt; - - for (const auto& traitA: v3CultureDefinitions.at(cultureA).traits) - { - if (!v3TraitDefinitions.contains(traitA) || !v3TraitDefinitions.at(traitA).isHeritageTrait) - continue; - - if (v3CultureDefinitions.at(cultureB).traits.contains(traitA)) - return true; - } - - return false; -} - -std::optional mappers::CultureMapper::doCulturesShareNonHeritageTrait(const std::string& cultureA, const std::string& cultureB) const -{ - if (!v3CultureDefinitions.contains(cultureA)) - return std::nullopt; - - if (!v3CultureDefinitions.contains(cultureB)) - return std::nullopt; - - for (const auto& traitA: v3CultureDefinitions.at(cultureA).traits) - { - if (!v3TraitDefinitions.contains(traitA) || v3TraitDefinitions.at(traitA).isHeritageTrait) - continue; - - if (v3CultureDefinitions.at(cultureB).traits.contains(traitA)) - return true; - } - - return false; -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureMapper.h b/EU5ToVic3/Source/Mappers/CultureMapper/CultureMapper.h deleted file mode 100644 index e8c2699..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureMapper.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef CULTURE_MAPPER_H -#define CULTURE_MAPPER_H -#include "ColonialRegionMapper/ColonialRegionMapper.h" -#include "CultureDefinitionLoader/CultureDef.h" -#include "CultureMappingRule.h" -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include "TraitDefinitionLoader/TraitDef.h" -#include "WesternizationMapper/WesternizationMapper.h" - -namespace EU4 -{ -class CultureLoader; -class ReligionLoader; -class CultureGroupParser; -class CultureParser; -class EU4LocalizationLoader; -} // namespace EU4 - -namespace V3 -{ -class ClayManager; -} -namespace mappers -{ -class NameListLoader; -class NameListMapper; -class NameListEntry; -class CultureTraitMapper; -class CultureDefinitionLoader; -class CultureMapper: commonItems::parser -{ - public: - CultureMapper() = default; - - void loadMappingRules(std::istream& theStream); - void loadMappingRules(const std::string& fileName); - void loadColonialRules(std::istream& theStream); - void loadColonialRules(const std::string& fileName); - void loadWesternizationRules(std::istream& theStream); - void loadWesternizationRules(const std::string& fileName); - void expandCulturalMappings(const V3::ClayManager& clayManager, const EU4::CultureLoader& cultureLoader, const EU4::ReligionLoader& religionLoader); - - [[nodiscard]] const auto& getMacros() const { return encounteredMacros; } - [[nodiscard]] const auto& getUnMappedCultures() const { return unmappedCultures; } - [[nodiscard]] const auto& getUsedCultures() const { return usedCultures; } - [[nodiscard]] const auto& getV3CultureDefinitions() const { return v3CultureDefinitions; } - void setV3CultureDefinitions(const std::map& culDefs) { v3CultureDefinitions = culDefs; } - [[nodiscard]] const auto& getRelatedCultures() const { return relatedCultures; } - [[nodiscard]] const auto& getColonialRegionMapper() const { return colonialRegionMapper; } - - [[nodiscard]] std::optional cultureMatch(const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& eu4culture, - const std::string& eu4religion, - const std::string& v3state, - const std::string& v3ownerTag, - bool neoCultureRequest = false, - bool silent = false); - - // This is a check where we ping for a v3 culture without having a clue what we're asking for exactly. - // 1. If the state is colonial, and we have a record of that eu4 culture having a neoculture in that colony, - // then we return that neoculture. - // 2. If the state is colonial, and we don't have a record of eu4 culture having a neoculture in that colony, - // it's possible we're a native country, and return regular match. - // 3. If the state is not colonial, return regular match same as 2. - [[nodiscard]] std::optional suspiciousCultureMatch(const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& eu4culture, - const std::string& eu4religion, - const std::string& v3state, - const std::string& v3ownerTag); - - void generateCultureDefinitions(const std::string& nameListsPath, - const std::string& nameListMapPath, - const std::string& cultureTraitsPath, - const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const EU4::EU4LocalizationLoader& eu4Locs); - - void loadCultureDefinitions(const commonItems::ModFilesystem& modFS); - void loadTraitDefinitions(const commonItems::ModFilesystem& modFS); - - void injectReligionsIntoCultureDefs(const V3::ClayManager& clayManager); - - [[nodiscard]] int getWesternizationScoreForCulture(const std::string& cultureName) const; - [[nodiscard]] int getLiteracyScoreForCulture(const std::string& cultureName) const; - [[nodiscard]] int getIndustryScoreForCulture(const std::string& cultureName) const; - - [[nodiscard]] std::optional doCulturesShareHeritageTrait(const std::string& cultureA, const std::string& cultureB) const; - [[nodiscard]] std::optional doCulturesShareNonHeritageTrait(const std::string& cultureA, const std::string& cultureB) const; - - private: - [[nodiscard]] std::string getNeoCultureMatch(const std::string& eu4culture, const std::string& v3state, const V3::ClayManager& clayManager); - [[nodiscard]] CultureDef generateCultureDefinition(const V3::ClayManager& clayManager, - const std::string& eu4CultureName, - const CultureTraitMapper& cultureTraitMapper, - const NameListMapper& nameListMapper, - const NameListLoader& nameListLoader, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const EU4::EU4LocalizationLoader& eu4Locs, - const std::string& seedName = {}); - - void registerKeys(); - - std::vector cultureMapRules; - std::map encounteredMacros; - std::set unmappedCultures; // same name for eu4 as for vic3. - std::set usedCultures; // Only the stuff we actually use in Vic3. - std::map v3CultureDefinitions; - std::map v3TraitDefinitions; - std::map> colonyNeoCultureTargets; // colony->[eu4 culture -> v3 neoculture] - std::map> relatedCultures; // vanilla culture -> related dynamic cultures (hungarian -> {hungaro-latvian ... }) - - ColonialRegionMapper colonialRegionMapper; - WesternizationMapper westernizationMapper; -}; -} // namespace mappers - -#endif // CULTURE_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureMappingRule.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/CultureMappingRule.cpp deleted file mode 100644 index 29212ed..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureMappingRule.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#include "CultureMappingRule.h" -#include "ClayManager/ClayManager.h" -#include "CommonRegexes.h" -#include "Configuration.h" -#include "CultureLoader/CultureLoader.h" -#include "ParserHelpers.h" -#include "ReligionLoader/ReligionLoader.h" -#include - -void mappers::CultureMappingRule::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::CultureMappingRule::loadMappingRules(const std::string& theString) -{ - registerKeys(); - auto theStream = std::stringstream(theString); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::CultureMappingRule::registerKeys() -{ - registerRegex(R"(@\w+)", [this](const std::string& macro, std::istream& theStream) { - requestedMacros.insert(macro); - }); - registerKeyword("vic3", [this](std::istream& theStream) { - v3culture = commonItems::getString(theStream); - }); - registerKeyword("eu4", [this](std::istream& theStream) { - cultures.insert(commonItems::getString(theStream)); - }); - registerKeyword("eu4group", [this](std::istream& theStream) { - cultureGroups.insert(commonItems::getString(theStream)); - }); - registerKeyword("religion", [this](std::istream& theStream) { - religions.insert(commonItems::getString(theStream)); - }); - registerKeyword("religion_group", [this](std::istream& theStream) { - religionGroups.insert(commonItems::getString(theStream)); - }); - registerKeyword("region", [this](std::istream& theStream) { - regions.insert(commonItems::getString(theStream)); - }); - registerKeyword("owner", [this](std::istream& theStream) { - owners.insert(commonItems::getString(theStream)); - }); - registerKeyword("neoculture_override", [this](std::istream& theStream) { - neocultureOverride = (commonItems::getString(theStream) == "yes"); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::CultureMappingRule::cultureMatch(const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& eu4culture, - const std::string& eu4religion, - const std::string& v3state, - const std::string& v3ownerTag) const -{ - // We need at least a viable incoming EU4culture - if (eu4culture.empty()) - return std::nullopt; - - // if we fail on both cultural match and culture group match, bail - const auto& incCultureGroup = cultureLoader.getGroupNameForCulture(eu4culture); - if (!cultures.contains(eu4culture) && (!incCultureGroup || !cultureGroups.contains(*incCultureGroup))) - return std::nullopt; - - // if there's an owner requirement and we fail, bail - if (!owners.empty()) - if (v3ownerTag.empty() || !owners.contains(v3ownerTag)) - return std::nullopt; - - // if there's a religion and we fail on both religions and groups, bail - if (!religions.empty() || !religionGroups.empty()) - { - if (eu4religion.empty()) - return std::nullopt; - - // need to check both religions and groups - const auto incReligiousGroup = religionLoader.getGroupForReligion(eu4religion); - if (!incReligiousGroup) - return std::nullopt; - - if (!religions.contains(eu4religion) && !religionGroups.contains(*incReligiousGroup)) - return std::nullopt; - } - - // If there's a state given, don't fail on regions checks. - if (!regions.empty()) - { - if (v3state.empty()) - return std::nullopt; - - auto regionMatch = false; - for (const auto& region: regions) - { - if (!clayManager.regionIsValid(region)) - { - // Regions can change between versions so don't react to invalid region name. - continue; - } - if (clayManager.stateIsInRegion(v3state, region)) - regionMatch = true; - } - if (!regionMatch) - return std::nullopt; - } - return v3culture; -} - -std::optional mappers::CultureMappingRule::cultureRegionalMatch(const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& eu4culture, - const std::string& eu4religion, - const std::string& v3state, - const std::string& v3ownerTag) const -{ - // This is useful for generating neocultures in specific target regions like the new world without actually being there. - - // This is a regional match. We need a mapping within the given SPECIFIC region, so if the - // mapping rule has no regional qualifiers it needs to fail. - - // If we have a Neoculture Override, cheat and try to match anyway. This way brazilians match brazilian directly although the link lacks region. - if (regions.empty() && !neocultureOverride) - return std::nullopt; - - // Otherwise, as usual. - return cultureMatch(clayManager, cultureLoader, religionLoader, eu4culture, eu4religion, v3state, v3ownerTag); -} - -std::optional mappers::CultureMappingRule::cultureNonRegionalNonReligiousMatch(const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& eu4culture, - const std::string& eu4religion, - const std::string& v3state, - const std::string& v3ownerTag) const -{ - // This is useful when generating neocultures by asking what a given original culture maps to absent any specific qualifiers. - - // This is a non regional non religious match. We need a mapping without any region/religion, so if the - // mapping rule has any regional/religious qualifiers it needs to fail. - if (!regions.empty()) - return std::nullopt; - if (!religions.empty() || !religionGroups.empty()) - return std::nullopt; - - // Otherwise, as usual. - return cultureMatch(clayManager, cultureLoader, religionLoader, eu4culture, eu4religion, v3state, v3ownerTag); -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureMappingRule.h b/EU5ToVic3/Source/Mappers/CultureMapper/CultureMappingRule.h deleted file mode 100644 index 659cbd5..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureMappingRule.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef CULTURE_MAPPING_RULE_H -#define CULTURE_MAPPING_RULE_H -#include "Parser.h" -#include - -namespace EU4 -{ -class CultureLoader; -class ReligionLoader; -} // namespace EU4 - -namespace V3 -{ -class ClayManager; -} - -namespace mappers -{ -class CultureMappingRule: commonItems::parser -{ - public: - CultureMappingRule() = default; - - void loadMappingRules(std::istream& theStream); - void loadMappingRules(const std::string& theString); - - [[nodiscard]] auto getV3Culture() const { return v3culture; } - [[nodiscard]] auto getCultures() const { return cultures; } - [[nodiscard]] auto getCultureGroups() const { return cultureGroups; } - [[nodiscard]] auto getReligions() const { return religions; } - [[nodiscard]] auto getReligionGroups() const { return religionGroups; } - [[nodiscard]] auto getRegions() const { return regions; } - [[nodiscard]] auto getOwners() const { return owners; } - [[nodiscard]] auto getRequestedMacros() const { return requestedMacros; } - - [[nodiscard]] std::optional cultureMatch(const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& eu4culture, - const std::string& eu4religion, - const std::string& v3state, - const std::string& v3ownerTag) const; - - [[nodiscard]] std::optional cultureRegionalMatch(const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& eu4culture, - const std::string& eu4religion, - const std::string& v3state, - const std::string& v3ownerTag) const; - - [[nodiscard]] std::optional cultureNonRegionalNonReligiousMatch(const V3::ClayManager& clayManager, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& eu4culture, - const std::string& eu4religion, - const std::string& v3state, - const std::string& v3ownerTag) const; - - private: - void registerKeys(); - - std::string v3culture; // vic3 - std::set cultures; // eu4 - std::set cultureGroups; // eu4 - std::set religions; // eu4 - std::set religionGroups; // eu4 - std::set regions; // vic3 - std::set owners; // vic3 - // Links without a region will still match for suspicious matches looking for neocultures. - // In practical terms, straight brazilian->brazilian link will match regardless of *where*. - bool neocultureOverride = false; - - std::set requestedMacros; -}; -} // namespace mappers - -#endif // CULTURE_MAPPING_RULE_H diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapper.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapper.cpp deleted file mode 100644 index 7dfa146..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapper.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "CultureTraitMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::CultureTraitMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Parsing culture trait mapping rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << mappings.size() << " rules loaded."; -} - -void mappers::CultureTraitMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::CultureTraitMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - mappings.emplace_back(CultureTraitMapping(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::CultureTraitMapper::getTraitsForCulture(const std::string& eu4Culture, - const std::string& eu4CultureGroup) const -{ - for (const auto& mapping: mappings) - if (!eu4Culture.empty() && mapping.getCulture() == eu4Culture || !eu4CultureGroup.empty() && mapping.getCultureGroup() == eu4CultureGroup) - return mapping; - return std::nullopt; -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapper.h b/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapper.h deleted file mode 100644 index ab31fd4..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapper.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef CULTURE_TRAIT_MAPPER_H -#define CULTURE_TRAIT_MAPPER_H -#include "CultureTraitMapping.h" -#include "Parser.h" - -namespace mappers -{ -class CultureTraitMapper: commonItems::parser -{ - public: - CultureTraitMapper() = default; - void loadMappingRules(const std::string& filePath); - void loadMappingRules(std::istream& theStream); - - [[nodiscard]] std::optional getTraitsForCulture(const std::string& eu4Culture, const std::string& eu4CultureGroup) const; - - private: - void registerKeys(); - - std::vector mappings; -}; -} // namespace mappers - -#endif // RELIGION_GROUP_MAPPER_H diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapping.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapping.cpp deleted file mode 100644 index dea00d2..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapping.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "CultureTraitMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::CultureTraitMapping::CultureTraitMapping(std::istream& theStream) -{ - registerkeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::CultureTraitMapping::registerkeys() -{ - registerKeyword("eu4", [this](std::istream& theStream) { - culture = commonItems::getString(theStream); - }); - registerKeyword("eu4group", [this](std::istream& theStream) { - cultureGroup = commonItems::getString(theStream); - }); - registerKeyword("trait", [this](std::istream& theStream) { - traits.emplace(commonItems::getString(theStream)); - }); - registerKeyword("ethnicity", [this](std::istream& theStream) { - ethnicity = commonItems::getString(theStream); - }); - registerKeyword("graphics", [this](std::istream& theStream) { - graphics = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapping.h b/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapping.h deleted file mode 100644 index 04ff8d6..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/CultureTraitMapper/CultureTraitMapping.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef CULTURE_TRAIT_MAPPING_H -#define CULTURE_TRAIT_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class CultureTraitMapping: commonItems::parser -{ - public: - explicit CultureTraitMapping(std::istream& theStream); - - [[nodiscard]] const auto& getCulture() const { return culture; } - [[nodiscard]] const auto& getCultureGroup() const { return cultureGroup; } - [[nodiscard]] const auto& getTraits() const { return traits; } - [[nodiscard]] const auto& getEthnicity() const { return ethnicity; } - [[nodiscard]] const auto& getGraphics() const { return graphics; } - - private: - void registerkeys(); - - std::string culture; - std::string cultureGroup; - std::set traits; - std::string ethnicity; - std::string graphics; -}; -} // namespace mappers - -#endif // CULTURE_TRAIT_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListEntry.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListEntry.cpp deleted file mode 100644 index 89f2c50..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListEntry.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "NameListEntry.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::NameListEntry::NameListEntry(std::istream& theStream) -{ - registerkeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::NameListEntry::registerkeys() -{ - registerKeyword("dynasty_names", [this](std::istream& theStream) { - for (const auto& name: commonItems::getStrings(theStream)) - dynastyNames.emplace(name); - }); - registerKeyword("male_names", [this](std::istream& theStream) { - for (const auto& name: commonItems::getStrings(theStream)) - maleNames.emplace(name); - }); - registerKeyword("female_names", [this](std::istream& theStream) { - for (const auto& name: commonItems::getStrings(theStream)) - femaleNames.emplace(name); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListEntry.h b/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListEntry.h deleted file mode 100644 index 97748a9..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListEntry.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef NAME_LIST_ENTRY_H -#define NAME_LIST_ENTRY_H -#include "Parser.h" - -namespace mappers -{ -class NameListEntry: commonItems::parser -{ - public: - explicit NameListEntry(std::istream& theStream); - - [[nodiscard]] const auto& getDynastyNames() const { return dynastyNames; } - [[nodiscard]] const auto& getMaleNames() const { return maleNames; } - [[nodiscard]] const auto& getFemaleNames() const { return femaleNames; } - - private: - void registerkeys(); - - std::set dynastyNames; - std::set maleNames; - std::set femaleNames; -}; -} // namespace mappers - -#endif // NAME_LIST_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListLoader.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListLoader.cpp deleted file mode 100644 index a9957b9..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListLoader.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "NameListLoader.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::NameListLoader::loadNameLists(const std::string& nameListPath) -{ - Log(LogLevel::Info) << "-> Loading name lists."; - registerKeys(); - parseFile(nameListPath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << nameLists.size() << " name lists loaded."; -} - -void mappers::NameListLoader::loadNameLists(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::NameListLoader::registerKeys() -{ - registerKeyword("country", commonItems::ignoreItem); - registerKeyword("province", commonItems::ignoreItem); - registerRegex(commonItems::catchallRegex, [this](const std::string& nameListName, std::istream& theStream) { - nameLists.emplace(nameListName, NameListEntry(theStream)); - }); -} - -std::optional mappers::NameListLoader::getNameList(const std::string& nameListName) const -{ - if (nameLists.contains(nameListName)) - return nameLists.at(nameListName); - return std::nullopt; -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListLoader.h b/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListLoader.h deleted file mode 100644 index 279f5d4..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/NameListLoader/NameListLoader.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef NAME_LIST_LOADER_H -#define NAME_LIST_LOADER_H -#include "NameListEntry.h" -#include "Parser.h" - -namespace mappers -{ -class NameListLoader: commonItems::parser -{ - public: - NameListLoader() = default; - void loadNameLists(const std::string& nameListPath); - void loadNameLists(std::istream& theStream); - - [[nodiscard]] std::optional getNameList(const std::string& nameListName) const; - - private: - void registerKeys(); - - std::map nameLists; -}; -} // namespace mappers - -#endif // NAME_LIST_LOADER_H diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapper.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapper.cpp deleted file mode 100644 index 1029a87..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapper.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "NameListMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::NameListMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Parsing name list mapping rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << mappings.size() << " rules loaded."; -} - -void mappers::NameListMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::NameListMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - mappings.emplace_back(NameListMapping(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::NameListMapper::getNamesForCulture(const std::string& eu4Culture, const std::string& eu4CultureGroup) const -{ - for (const auto& mapping: mappings) - if (!eu4Culture.empty() && mapping.getCulture() == eu4Culture || !eu4CultureGroup.empty() && mapping.getCultureGroup() == eu4CultureGroup) - return mapping; - return std::nullopt; -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapper.h b/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapper.h deleted file mode 100644 index 60e2650..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapper.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef NAME_LIST_MAPPER_H -#define NAME_LIST_MAPPER_H -#include "NameListMapping.h" -#include "Parser.h" - -namespace mappers -{ -class NameListMapper: commonItems::parser -{ - public: - NameListMapper() = default; - void loadMappingRules(const std::string& filePath); - void loadMappingRules(std::istream& theStream); - - [[nodiscard]] std::optional getNamesForCulture(const std::string& eu4Culture, const std::string& eu4CultureGroup) const; - - private: - void registerKeys(); - - std::vector mappings; -}; -} // namespace mappers - -#endif // NAME_LIST_MAPPER_H diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapping.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapping.cpp deleted file mode 100644 index 7f4519d..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapping.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "NameListMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::NameListMapping::NameListMapping(std::istream& theStream) -{ - registerkeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::NameListMapping::registerkeys() -{ - registerKeyword("eu4", [this](std::istream& theStream) { - culture = commonItems::getString(theStream); - }); - registerKeyword("eu4group", [this](std::istream& theStream) { - cultureGroup = commonItems::getString(theStream); - }); - registerKeyword("name_pool", [this](std::istream& theStream) { - namePool = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapping.h b/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapping.h deleted file mode 100644 index b254956..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/NameListMapper/NameListMapping.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef NAME_LIST_MAPPING_H -#define NAME_LIST_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class NameListMapping: commonItems::parser -{ - public: - explicit NameListMapping(std::istream& theStream); - - [[nodiscard]] const auto& getCulture() const { return culture; } - [[nodiscard]] const auto& getCultureGroup() const { return cultureGroup; } - [[nodiscard]] const auto& getNamePool() const { return namePool; } - - private: - void registerkeys(); - - std::string culture; - std::string cultureGroup; - std::string namePool; -}; -} // namespace mappers - -#endif // NAME_LIST_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDef.h b/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDef.h deleted file mode 100644 index d45ce00..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDef.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef TRAIT_DEF_H -#define TRAIT_DEF_H - -namespace mappers -{ -struct TraitDef -{ - std::string name; - bool isHeritageTrait = false; -}; -} // namespace mappers - -#endif // TRAIT_DEF_H diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionEntry.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionEntry.cpp deleted file mode 100644 index b5051e7..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionEntry.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "TraitDefinitionEntry.h" -#include "CommonRegexes.h" - -mappers::TraitDefinitionEntry::TraitDefinitionEntry(std::istream& theStream) -{ - registerkeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::TraitDefinitionEntry::registerkeys() -{ - registerKeyword("heritage", [this](std::istream& theStream) { - traitDef.isHeritageTrait = commonItems::getString(theStream) == "yes"; - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionEntry.h b/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionEntry.h deleted file mode 100644 index 161fe5d..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionEntry.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef TRAIT_DEFINITION_ENTRY_H -#define TRAIT_DEFINITION_ENTRY_H -#include "Parser.h" -#include "TraitDef.h" - -namespace mappers -{ -class TraitDefinitionEntry: commonItems::parser -{ - public: - explicit TraitDefinitionEntry(std::istream& theStream); - - [[nodiscard]] const auto& getTraitDef() const { return traitDef; } - - private: - void registerkeys(); - - TraitDef traitDef; -}; -} // namespace mappers - -#endif // TRAIT_DEFINITION_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionLoader.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionLoader.cpp deleted file mode 100644 index d0332ba..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionLoader.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "TraitDefinitionLoader.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "TraitDefinitionEntry.h" - -void mappers::TraitDefinitionLoader::loadDefinitions(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading discrimination trait definitions."; - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/discrimination_traits/")) - { - if (getExtension(fileName) != "txt") - continue; - - parseFile(fileName); - } - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << traitDefinitions.size() << " definitions loaded."; -} - -void mappers::TraitDefinitionLoader::loadDefinitions(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::TraitDefinitionLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& traitName, std::istream& theStream) { - auto traitDef = TraitDefinitionEntry(theStream).getTraitDef(); - traitDef.name = traitName; - traitDefinitions.emplace(traitName, traitDef); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionLoader.h b/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionLoader.h deleted file mode 100644 index c29de52..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/TraitDefinitionLoader/TraitDefinitionLoader.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TRAIT_DEFINITION_LOADER_H -#define TRAIT_DEFINITION_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include "TraitDef.h" - -namespace mappers -{ -class TraitDefinitionLoader: commonItems::parser -{ - public: - TraitDefinitionLoader() = default; - void loadDefinitions(const commonItems::ModFilesystem& modFS); - void loadDefinitions(std::istream& theStream); - - [[nodiscard]] const auto& getDefinitions() const { return traitDefinitions; } - - private: - void registerKeys(); - - std::map traitDefinitions; -}; -} // namespace mappers - -#endif // TRAIT_DEFINITION_LOADER_H diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapper.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapper.cpp deleted file mode 100644 index 234c762..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapper.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "WesternizationMapper.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "WesternizationMapping.h" - -void mappers::WesternizationMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Parsing westernization groups."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Parsed " << westernizations.size() << " groups."; -} - -void mappers::WesternizationMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::WesternizationMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - const WesternizationMapping mapping(theStream); - for (const auto& trait: mapping.getTraits()) - { - westernizations.emplace(trait, mapping.getWesternization()); - literacies.emplace(trait, mapping.getLiteracy()); - industries.emplace(trait, mapping.getIndustry()); - } - }); -} - -int mappers::WesternizationMapper::getWesternizationForTraits(const std::set& traits) const -{ - auto maxLevel = 0; - for (const auto& trait: traits) - if (westernizations.contains(trait)) - { - if (westernizations.at(trait) > maxLevel) - maxLevel = westernizations.at(trait); - } - else - { - Log(LogLevel::Warning) << "Trait " << trait << " has no westernization.txt link!"; - } - return maxLevel; -} - -int mappers::WesternizationMapper::getIndustryForTraits(const std::set& traits) const -{ - auto maxLevel = 0; - for (const auto& trait: traits) - if (industries.contains(trait)) - { - if (industries.at(trait) > maxLevel) - maxLevel = industries.at(trait); - } - else - { - Log(LogLevel::Warning) << "Trait " << trait << " has no westernization.txt link!"; - } - return maxLevel; -} - -int mappers::WesternizationMapper::getLiteracyForTraits(const std::set& traits) const -{ - auto maxLevel = 0; - for (const auto& trait: traits) - if (literacies.contains(trait)) - { - if (literacies.at(trait) > maxLevel) - maxLevel = literacies.at(trait); - } - else - { - Log(LogLevel::Warning) << "Trait " << trait << " has no westernization.txt link!"; - } - return maxLevel; -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapper.h b/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapper.h deleted file mode 100644 index f404d7c..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapper.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef WESTERNIZATION_MAPPER_H -#define WESTERNIZATION_MAPPER_H - -#include "Parser.h" -#include - -namespace mappers -{ -class WesternizationMapper: commonItems::parser -{ - public: - WesternizationMapper() = default; - void loadMappingRules(const std::string& filePath); - void loadMappingRules(std::istream& theStream); - - [[nodiscard]] int getWesternizationForTraits(const std::set& traits) const; - [[nodiscard]] int getLiteracyForTraits(const std::set& traits) const; - [[nodiscard]] int getIndustryForTraits(const std::set& traits) const; - - private: - void registerKeys(); - - std::map westernizations; - std::map literacies; - std::map industries; -}; -} // namespace mappers - -#endif // WESTERNIZATION_MAPPER_H diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapping.cpp b/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapping.cpp deleted file mode 100644 index d965ed2..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapping.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "WesternizationMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::WesternizationMapping::WesternizationMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::WesternizationMapping::registerKeys() -{ - registerKeyword("westernization", [this](std::istream& theStream) { - westernization = commonItems::getInt(theStream); - }); - registerKeyword("literacy", [this](std::istream& theStream) { - literacy = commonItems::getInt(theStream); - }); - registerKeyword("industry", [this](std::istream& theStream) { - industry = commonItems::getInt(theStream); - }); - registerKeyword("traits", [this](std::istream& theStream) { - const auto& traitList = commonItems::getStrings(theStream); - traits.insert(traitList.begin(), traitList.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapping.h b/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapping.h deleted file mode 100644 index 96f9098..0000000 --- a/EU5ToVic3/Source/Mappers/CultureMapper/WesternizationMapper/WesternizationMapping.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef WESTERNIZATION_MAPPING_H -#define WESTERNIZATION_MAPPING_H -#include "Parser.h" -#include - -namespace mappers -{ -class WesternizationMapping: commonItems::parser -{ - public: - explicit WesternizationMapping(std::istream& theStream); - - [[nodiscard]] auto getWesternization() const { return westernization; } - [[nodiscard]] auto getLiteracy() const { return literacy; } - [[nodiscard]] const auto& getIndustry() const { return industry; } - [[nodiscard]] const auto& getTraits() const { return traits; } - - private: - void registerKeys(); - - // Values range 0-10. 5 is default. - int westernization = 5; - int literacy = 5; - int industry = 5; - std::set traits; -}; -} // namespace mappers - -#endif // WESTERNIZATION_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/DiplomaticMapper/DiplomaticMapper.cpp b/EU5ToVic3/Source/Mappers/DiplomaticMapper/DiplomaticMapper.cpp deleted file mode 100644 index 4c96b20..0000000 --- a/EU5ToVic3/Source/Mappers/DiplomaticMapper/DiplomaticMapper.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "DiplomaticMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::DiplomaticMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Parsing Diplomatic Mapping Rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Loaded " << agreementTypes.size() + relationshipBoosts.size() << " categories."; -} - -void mappers::DiplomaticMapper::registerKeys() -{ - registerRegex(R"([-+\d]+)", [this](const std::string& boostValue, std::istream& theStream) { - try - { - int boost = std::stoi(boostValue); - const auto theList = commonItems::getStrings(theStream); - relationshipBoosts.emplace(boost, std::set{}); - relationshipBoosts.at(boost).insert(theList.begin(), theList.end()); - } - catch (std::exception& e) - { - Log(LogLevel::Error) << "Broken boost value inside diplomatic map: " << boostValue << " - " << e.what(); - } - }); - registerRegex(commonItems::catchallRegex, [this](const std::string& agreementType, std::istream& theStream) { - const auto theList = commonItems::getStrings(theStream); - agreementTypes.emplace(agreementType, std::set{}); - agreementTypes.at(agreementType).insert(theList.begin(), theList.end()); - }); -} - -std::optional mappers::DiplomaticMapper::getAgreementType(const std::string& agreement) const -{ - for (const auto& [type, agreements]: agreementTypes) - if (agreements.contains(agreement)) - return type; - return std::nullopt; -} - -int mappers::DiplomaticMapper::getRelationshipBoost(const std::string& agreement) const -{ - for (const auto& [boost, agreements]: relationshipBoosts) - if (agreements.contains(agreement)) - return boost; - return 0; -} diff --git a/EU5ToVic3/Source/Mappers/DiplomaticMapper/DiplomaticMapper.h b/EU5ToVic3/Source/Mappers/DiplomaticMapper/DiplomaticMapper.h deleted file mode 100644 index 6b452fa..0000000 --- a/EU5ToVic3/Source/Mappers/DiplomaticMapper/DiplomaticMapper.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef DIPLOMATIC_MAPPER_H -#define DIPLOMATIC_MAPPER_H -#include "Parser.h" -#include - -namespace mappers -{ -class DiplomaticMapper: commonItems::parser -{ - public: - DiplomaticMapper() = default; - void loadMappingRules(const std::string& filePath); - - [[nodiscard]] std::optional getAgreementType(const std::string& agreement) const; - [[nodiscard]] int getRelationshipBoost(const std::string& agreement) const; - - private: - void registerKeys(); - - std::map> relationshipBoosts; - std::map> agreementTypes; -}; -} // namespace mappers - -#endif // DIPLOMATIC_MAPPER_H diff --git a/EU5ToVic3/Source/Mappers/ExcludedTradeCompaniesMapper/ExcludedTradeCompaniesMapper.cpp b/EU5ToVic3/Source/Mappers/ExcludedTradeCompaniesMapper/ExcludedTradeCompaniesMapper.cpp deleted file mode 100644 index a8c79a1..0000000 --- a/EU5ToVic3/Source/Mappers/ExcludedTradeCompaniesMapper/ExcludedTradeCompaniesMapper.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ExcludedTradeCompaniesMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::ExcludedTradeCompaniesMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading Excluded Trade Company Rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << excludedTCs.size() << " excluded TCs loaded."; -} - -void mappers::ExcludedTradeCompaniesMapper::registerKeys() -{ - registerKeyword("excluded_trade_companies", [this](std::istream& theStream) { - auto names = commonItems::getStrings(theStream); - excludedTCs.insert(names.begin(), names.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/ExcludedTradeCompaniesMapper/ExcludedTradeCompaniesMapper.h b/EU5ToVic3/Source/Mappers/ExcludedTradeCompaniesMapper/ExcludedTradeCompaniesMapper.h deleted file mode 100644 index 01eddb3..0000000 --- a/EU5ToVic3/Source/Mappers/ExcludedTradeCompaniesMapper/ExcludedTradeCompaniesMapper.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef EXCLUDED_TRADE_COMPANIES_MAPPER_H -#define EXCLUDED_TRADE_COMPANIES_MAPPER_H -#include "Parser.h" - -namespace mappers -{ -class ExcludedTradeCompaniesMapper: commonItems::parser -{ - public: - ExcludedTradeCompaniesMapper() = default; - void loadMappingRules(const std::string& filePath); - - [[nodiscard]] const auto& getExcludedTCs() const { return excludedTCs; } - - private: - void registerKeys(); - - std::set excludedTCs; -}; -} // namespace mappers - -#endif // EXCLUDED_TRADE_COMPANIES_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapper.cpp b/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapper.cpp deleted file mode 100644 index e26164e..0000000 --- a/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapper.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "IGIdeologiesMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::IGIdeologiesMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading IG Ideology Mod Rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << mappings.size() << " rules loaded."; -} - -void mappers::IGIdeologiesMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - auto mapping = IGIdeologiesMapping(theStream); - mappings.emplace_back(mapping); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::map mappers::IGIdeologiesMapper::getIGIdeologyMods(const V3::Country& country, - const CultureMapper& cultureMapper, - const ReligionMapper& religionMapper, - const V3::ClayManager& clayManager) const -{ - std::map toReturn; - for (const auto& mapping: mappings) - toReturn = mapping.alterIdeologyMods(toReturn, country, cultureMapper, religionMapper, clayManager); - return toReturn; -} diff --git a/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapper.h b/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapper.h deleted file mode 100644 index d4db6dc..0000000 --- a/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapper.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef IG_IDEOLOGIES_MAPPER_H -#define IG_IDEOLOGIES_MAPPER_H -#include "IGIdeologiesMapping.h" -#include "Parser.h" - -namespace mappers -{ -class IGIdeologiesMapper: commonItems::parser -{ - public: - IGIdeologiesMapper() = default; - void loadMappingRules(const std::string& filePath); - - [[nodiscard]] std::map getIGIdeologyMods(const V3::Country& country, - const CultureMapper& cultureMapper, - const ReligionMapper& religionMapper, - const V3::ClayManager& clayManager) const; - - private: - void registerKeys(); - - std::vector mappings; -}; -} // namespace mappers - -#endif // IG_IDEOLOGIES_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapping.cpp b/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapping.cpp deleted file mode 100644 index a34e4be..0000000 --- a/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapping.cpp +++ /dev/null @@ -1,202 +0,0 @@ -#include "IGIdeologiesMapping.h" -#include "ClayManager/ClayManager.h" -#include "CommonRegexes.h" -#include "CountryManager/EU4Country.h" -#include "CultureMapper/CultureMapper.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "PoliticalManager/Country/Country.h" -#include "ReligionMapper/ReligionMapper.h" - -mappers::IGIdeologiesMapping::IGIdeologiesMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::IGIdeologiesMapping::registerKeys() -{ - registerKeyword("culturetrait", [this](std::istream& theStream) { - cultureTraits.emplace(commonItems::getString(theStream)); - }); - registerKeyword("religiontrait", [this](std::istream& theStream) { - religionTraits.emplace(commonItems::getString(theStream)); - }); - registerKeyword("eu4religion", [this](std::istream& theStream) { - eu4Religions.emplace(commonItems::getString(theStream)); - }); - registerKeyword("eu4gov", [this](std::istream& theStream) { - eu4Govs.emplace(commonItems::getString(theStream)); - }); - registerKeyword("eu4idea", [this](std::istream& theStream) { - eu4Ideas.emplace(commonItems::getString(theStream)); - }); - registerKeyword("eu4reform", [this](std::istream& theStream) { - eu4Reforms.emplace(commonItems::getString(theStream)); - }); - registerKeyword("capital", [this](std::istream& theStream) { - capitals.emplace(commonItems::getString(theStream)); - }); - registerKeyword("law", [this](std::istream& theStream) { - laws.emplace(commonItems::getString(theStream)); - }); - registerKeyword("colony", [this](std::istream& theStream) { - colony = (commonItems::getString(theStream) == "yes"); - }); - registerKeyword("eoc", [this](std::istream& theStream) { - emperorOfChina = (commonItems::getString(theStream) == "yes"); - }); - registerKeyword("hremperor", [this](std::istream& theStream) { - HREmperor = (commonItems::getString(theStream) == "yes"); - }); - registerRegex(R"(ig_\w+)", [this](const std::string& IGName, std::istream& theStream) { - if (!IGIdeologyMods.contains(IGName)) - IGIdeologyMods.emplace(IGName, IGIdeologyMod()); - - const auto mod = commonItems::getString(theStream); - if (mod.starts_with("add:")) - IGIdeologyMods.at(IGName).addedIdeologies.emplace(mod.substr(4, mod.size())); - else if (mod.starts_with("remove:")) - IGIdeologyMods.at(IGName).removedIdeologies.emplace(mod.substr(7, mod.size())); - else - Log(LogLevel::Warning) << "Unrecognized IG Ideology mod: " << mod << " for " << IGName << "! Skipping!"; - }); - - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::map mappers::IGIdeologiesMapping::alterIdeologyMods(const std::map& incMods, - const V3::Country& country, - const CultureMapper& cultureMapper, - const ReligionMapper& religionMapper, - const V3::ClayManager& clayManager) const -{ - if (!matchCountry(country, cultureMapper, religionMapper, clayManager)) - return incMods; - - auto newMods = incMods; - for (const auto& [ig, theMod]: IGIdeologyMods) - { - if (!newMods.contains(ig)) - newMods.emplace(ig, IGIdeologyMod()); - for (const auto& ideology: theMod.addedIdeologies) - if (newMods.at(ig).removedIdeologies.contains(ideology)) - newMods.at(ig).removedIdeologies.erase(ideology); - else - newMods.at(ig).addedIdeologies.emplace(ideology); - - for (const auto& ideology: theMod.removedIdeologies) - if (newMods.at(ig).addedIdeologies.contains(ideology)) - newMods.at(ig).addedIdeologies.erase(ideology); - else - newMods.at(ig).removedIdeologies.emplace(ideology); - } - return newMods; -} - -bool mappers::IGIdeologiesMapping::matchCountry(const V3::Country& country, - const CultureMapper& cultureMapper, - const ReligionMapper& religionMapper, - const V3::ClayManager& clayManager) const -{ - if (!country.getSourceCountry()) - return false; - const auto& srcCountry = country.getSourceCountry(); - - if (!cultureTraits.empty()) - { - bool match = false; - for (const auto& trait: cultureTraits) - { - for (const auto& culture: country.getProcessedData().cultures) - if (cultureMapper.getV3CultureDefinitions().contains(culture) && cultureMapper.getV3CultureDefinitions().at(culture).traits.contains(trait)) - match = true; - } - if (!match) - return false; - } - - if (!religionTraits.empty()) - { - bool match = false; - const auto& religion = country.getProcessedData().religion; - for (const auto& trait: religionTraits) - if (religionMapper.getV3ReligionDefinitions().contains(religion) && religionMapper.getV3ReligionDefinitions().at(religion).traits.contains(trait)) - match = true; - if (!match) - return false; - } - - if (!eu4Religions.empty()) - { - if (!eu4Religions.contains(srcCountry->getReligion())) - return false; - } - - if (!eu4Govs.empty()) - { - if (!eu4Govs.contains(srcCountry->getGovernment())) - return false; - } - - if (!eu4Ideas.empty()) - { - bool match = false; - for (const auto& idea: eu4Ideas) - if (srcCountry->getNationalIdeas().contains(idea)) - match = true; - if (!match) - return false; - } - - if (!eu4Reforms.empty()) - { - bool match = false; - for (const auto& reform: eu4Reforms) - if (srcCountry->getReforms().contains(reform)) - match = true; - if (!match) - return false; - } - - if (!capitals.empty()) - { - bool match = false; - for (const auto& region: capitals) - if (clayManager.stateIsInRegion(country.getProcessedData().capitalStateName, region)) - match = true; - if (!match) - return false; - } - - if (!laws.empty()) - { - bool match = false; - for (const auto& law: laws) - if (country.getProcessedData().laws.contains(law)) - match = true; - if (!match) - return false; - } - - if (colony) - { - if (srcCountry->isColony() != *colony) - return false; - } - - if (emperorOfChina) - { - if (srcCountry->isCelestialEmperor() != *emperorOfChina) - return false; - } - - if (HREmperor) - { - if (srcCountry->isHREmperor() != *HREmperor) - return false; - } - - return true; -} diff --git a/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapping.h b/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapping.h deleted file mode 100644 index 7770d3f..0000000 --- a/EU5ToVic3/Source/Mappers/IGIdeologiesMapper/IGIdeologiesMapping.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef IG_IDEOLOGIES_MAPPING_H -#define IG_IDEOLOGIES_MAPPING_H -#include "Parser.h" - -namespace V3 -{ -class Country; -class ClayManager; -} // namespace V3 - -namespace mappers -{ -class CultureMapper; -class ReligionMapper; -struct IGIdeologyMod -{ - std::set addedIdeologies; - std::set removedIdeologies; -}; -class IGIdeologiesMapping: commonItems::parser -{ - public: - IGIdeologiesMapping() = default; - explicit IGIdeologiesMapping(std::istream& theStream); - - [[nodiscard]] std::map alterIdeologyMods(const std::map& incMods, - const V3::Country& country, - const CultureMapper& cultureMapper, - const ReligionMapper& religionMapper, - const V3::ClayManager& clayManager) const; - - private: - void registerKeys(); - - [[nodiscard]] bool matchCountry(const V3::Country& country, - const CultureMapper& cultureMapper, - const ReligionMapper& religionMapper, - const V3::ClayManager& clayManager) const; - - std::set cultureTraits; - std::set religionTraits; - std::set eu4Religions; - std::set eu4Govs; - std::set eu4Ideas; - std::set eu4Reforms; - std::set capitals; - std::set laws; - std::optional colony; - std::optional emperorOfChina; - std::optional HREmperor; - std::map IGIdeologyMods; // ig, added and removed ideologies. -}; -} // namespace mappers - -#endif // IG_IDEOLOGIES_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapper.cpp b/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapper.cpp deleted file mode 100644 index de1ecbe..0000000 --- a/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapper.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "IdeaEffectsMapper.h" -#include "CommonRegexes.h" -#include "Log.h" - -void mappers::IdeaEffectsMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading Idea Effects."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << ideaEffects.size() << " effects loaded."; -} - -void mappers::IdeaEffectsMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::IdeaEffectsMapper::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& ideaName, std::istream& theStream) { - ideaEffects.emplace(ideaName, IdeaEffectsMapping(theStream)); - }); -} - -mappers::IdeaEffect mappers::IdeaEffectsMapper::getEffectForIdeas(const std::set& ideas) const -{ - IdeaEffect effect; - std::map interestGroupCounter; - for (const auto& idea: ideas) - { - if (!ideaEffects.contains(idea)) - continue; // No need to scream for unmapped mod ideas - const auto ideaEffect = ideaEffects.at(idea); - effect.literacy += ideaEffect.getLiteracy(); - effect.adm += ideaEffect.getAdm(); - effect.dip += ideaEffect.getDip(); - effect.mil += ideaEffect.getMil(); - for (const auto& ig: ideaEffect.getBoostedInterestGroups()) - { - if (interestGroupCounter.contains(ig)) - ++interestGroupCounter.at(ig); - else - interestGroupCounter.emplace(ig, 1); - } - for (const auto& noIg: ideaEffect.getSuppressedInterestGroups()) - { - if (interestGroupCounter.contains(noIg)) - --interestGroupCounter.at(noIg); - else - interestGroupCounter.emplace(noIg, -1); - } - } - for (const auto& [ig, count]: interestGroupCounter) - if (count > 0) - { - effect.boostedInterestGroups.emplace(ig); - if (count >= 2) - effect.rulingInterestGroups.emplace(ig); - } - else if (count < 0) - { - effect.suppressedInterestGroups.emplace(ig); - } - - return effect; -} diff --git a/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapper.h b/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapper.h deleted file mode 100644 index 71645f7..0000000 --- a/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapper.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef IDEA_EFFECTS_MAPPER_H -#define IDEA_EFFECTS_MAPPER_H -#include "IdeaEffectsMapping.h" -#include "Parser.h" - -namespace mappers -{ -struct IdeaEffect -{ - [[nodiscard]] auto getTechMod() const { return adm + dip + mil; } - - int literacy = 0; - int adm = 0; - int dip = 0; - int mil = 0; - std::set rulingInterestGroups; - std::set boostedInterestGroups; - std::set suppressedInterestGroups; -}; -class IdeaEffectsMapper: commonItems::parser -{ - public: - IdeaEffectsMapper() = default; - void loadMappingRules(const std::string& filePath); - void loadMappingRules(std::istream& theStream); - - [[nodiscard]] IdeaEffect getEffectForIdeas(const std::set& ideas) const; - - private: - void registerKeys(); - - std::map ideaEffects; // idea->effect -}; -} // namespace mappers - -#endif // IDEA_EFFECTS_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapping.cpp b/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapping.cpp deleted file mode 100644 index 1b91544..0000000 --- a/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapping.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "IdeaEffectsMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::IdeaEffectsMapping::IdeaEffectsMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::IdeaEffectsMapping::registerKeys() -{ - registerKeyword("literacy", [this](std::istream& theStream) { - literacy = commonItems::getInt(theStream); - }); - registerKeyword("adm", [this](std::istream& theStream) { - adm = commonItems::getInt(theStream); - }); - registerKeyword("dip", [this](std::istream& theStream) { - dip = commonItems::getInt(theStream); - }); - registerKeyword("mil", [this](std::istream& theStream) { - mil = commonItems::getInt(theStream); - }); - registerKeyword("ig", [this](std::istream& theStream) { - boostedInterestGroups.emplace(commonItems::getString(theStream)); - }); - registerKeyword("noig", [this](std::istream& theStream) { - suppressedInterestGroups.emplace(commonItems::getString(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapping.h b/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapping.h deleted file mode 100644 index 0d9a1d8..0000000 --- a/EU5ToVic3/Source/Mappers/IdeaEffectsMapper/IdeaEffectsMapping.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef IDEA_EFFECTS_MAPPING_H -#define IDEA_EFFECTS_MAPPING_H -#include "Parser.h" -#include - -namespace mappers -{ -class IdeaEffectsMapping: commonItems::parser -{ - public: - IdeaEffectsMapping() = default; - explicit IdeaEffectsMapping(std::istream& theStream); - - [[nodiscard]] auto getLiteracy() const { return literacy; } - [[nodiscard]] auto getAdm() const { return adm; } - [[nodiscard]] auto getDip() const { return dip; } - [[nodiscard]] auto getMil() const { return mil; } - [[nodiscard]] const auto& getBoostedInterestGroups() const { return boostedInterestGroups; } - [[nodiscard]] const auto& getSuppressedInterestGroups() const { return suppressedInterestGroups; } - - private: - void registerKeys(); - - int literacy = 0; - int adm = 0; - int dip = 0; - int mil = 0; - std::set boostedInterestGroups; - std::set suppressedInterestGroups; -}; -} // namespace mappers - -#endif // IDEA_EFFECTS_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/LawMapper/LawGroup.cpp b/EU5ToVic3/Source/Mappers/LawMapper/LawGroup.cpp deleted file mode 100644 index 1809d6d..0000000 --- a/EU5ToVic3/Source/Mappers/LawMapper/LawGroup.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "LawGroup.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::LawGroup::LawGroup(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::LawGroup::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& lawName, std::istream& theStream) { - laws.emplace(lawName, LawMapping(theStream)); - }); -} diff --git a/EU5ToVic3/Source/Mappers/LawMapper/LawGroup.h b/EU5ToVic3/Source/Mappers/LawMapper/LawGroup.h deleted file mode 100644 index 8089876..0000000 --- a/EU5ToVic3/Source/Mappers/LawMapper/LawGroup.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef LAW_GROUP_H -#define LAW_GROUP_H -#include "LawMapping.h" -#include "Parser.h" - -namespace mappers -{ -class LawGroup: commonItems::parser -{ - public: - LawGroup() = default; - explicit LawGroup(std::istream& theStream); - - [[nodiscard]] const auto& getLaws() const { return laws; } - - private: - void registerKeys(); - - std::map laws; -}; -} // namespace mappers - -#endif // LAW_GROUP_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/LawMapper/LawMapper.cpp b/EU5ToVic3/Source/Mappers/LawMapper/LawMapper.cpp deleted file mode 100644 index 71eb9cb..0000000 --- a/EU5ToVic3/Source/Mappers/LawMapper/LawMapper.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "LawMapper.h" -#include "CommonRegexes.h" -#include "CountryManager/EU4Country.h" -#include "LawGroup.h" -#include "Log.h" -#include "PoliticalManager/Country/Country.h" -#include -#include - -namespace -{ -std::vector sortLaws(const std::map>& theMap) -{ - std::vector sorted; - - std::vector>> pairs; - for (const auto& theElement: theMap) - pairs.emplace_back(theElement); - - std::sort(pairs.begin(), - pairs.end(), - [=](const std::pair>& a, const std::pair>& b) { - if (a.second.first > b.second.first) - return true; - if (b.second.first > a.second.first) - return false; - return a.second.second > b.second.second; - }); - - for (const auto& key: pairs | std::views::keys) - sorted.emplace_back(key); - - return sorted; -} -} // namespace - - -void mappers::LawMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading Law Mapping Rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << lawGroups.size() << " law groups loaded."; -} - -void mappers::LawMapper::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& lawGroupName, std::istream& theStream) { - lawGroups.emplace(lawGroupName, LawGroup(theStream).getLaws()); - }); -} - -std::optional mappers::LawMapper::grantLawFromGroup(const std::string& lawGroup, const V3::Country& country) const -{ - if (!lawGroups.contains(lawGroup) || !country.getSourceCountry() || country.getSourceCountry()->getGovernment().empty()) - return std::nullopt; - - // prep all needed. - const auto& form = country.getSourceCountry()->getGovernment(); - const auto& ideas = country.getSourceCountry()->getNationalIdeas(); - const auto& reforms = country.getSourceCountry()->getReforms(); - const auto& existingLaws = country.getProcessedData().laws; - const auto& existingTechs = country.getProcessedData().techs; - - std::map> lawScores; // how strong selections are these laws. Law -> pair. - std::set nonBlockedLaws; // these laws are *not* a match but are not blocked. Used for fallbacks. - - // Roll through all laws and look for all matches - how well they fit. - for (const auto& [lawName, lawMapping]: lawGroups.at(lawGroup)) - { - // do we already have a law from this group? If so bail on everything! - if (existingLaws.contains(lawName)) - return std::nullopt; - - if (!laws.contains(lawName)) - { - Log(LogLevel::Warning) << "We're trying to map to law: " << lawName << " that has no definition! Skipping."; - continue; - } - - const auto score = lawMapping.getScore(form, ideas, reforms); - if (score > 0) // can't place laws with 0 score since they may be nominally incompatible with our country (monarchy instead of republic etc). - lawScores.emplace(lawName, std::pair{score, laws.at(lawName).progressiveness}); - else if (score == 0.0 && !isLawBlocked(lawName, existingLaws, existingTechs)) - nonBlockedLaws.emplace(lawName); // we can use these is push comes to shove. - } - - // then sort the lawScores, highest match first. - const auto sortedLaws = sortLaws(lawScores); - - // iterating through these, go to first law that doesn't block and return that. - for (const auto& lawName: sortedLaws) - { - if (isLawBlocked(lawName, existingLaws, existingTechs)) - continue; - - // we found a match. - return lawName; - } - - // failing all, well, look to "unselections" - laws that don't match at all but that aren't technically forbidden, - // and pick the most progressive one. No worries at picking late-game laws since we never map to them in law_map.txt, - // so they are never even considered. - auto sortedUnSelections = filterLawsByAllowedProgressiveness(nonBlockedLaws); - if (!sortedUnSelections.empty()) - return *sortedUnSelections.begin(); - - Log(LogLevel::Debug) << "Zero law matches for " << country.getTag() << " in group: " << lawGroup; - return std::nullopt; -} - -bool mappers::LawMapper::isLawBlocked(const std::string& lawName, const std::set& existingLaws, const std::set& existingTechs) const -{ - - const auto& law = laws.at(lawName); - - for (const auto& existingLaw: existingLaws) - if (law.blockingLaws.contains(existingLaw)) - return true; - - if (!law.requiredLaws.empty()) - { - const bool match = std::ranges::any_of(law.requiredLaws.begin(), law.requiredLaws.end(), [existingLaws](const auto& law) { - return existingLaws.contains(law); - }); - if (!match) - return true; - } - - if (!law.requiredTechs.empty()) - { - const bool match = std::ranges::any_of(law.requiredTechs.begin(), law.requiredTechs.end(), [existingTechs](const auto& tech) { - return existingTechs.contains(tech); - }); - if (!match) - return true; - } - - return false; -} - -std::vector mappers::LawMapper::filterLawsByAllowedProgressiveness(const std::set& nonBlockedLaws) const -{ - std::map> possibleLaws; - for (const auto& lawName: nonBlockedLaws) - possibleLaws.emplace(lawName, std::pair{0, laws.at(lawName).progressiveness}); - auto sortedLaws = sortLaws(possibleLaws); - return sortedLaws; -} \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/LawMapper/LawMapper.h b/EU5ToVic3/Source/Mappers/LawMapper/LawMapper.h deleted file mode 100644 index f9d3a08..0000000 --- a/EU5ToVic3/Source/Mappers/LawMapper/LawMapper.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef LAW_MAPPER_H -#define LAW_MAPPER_H -#include "LawMapping.h" -#include "Loaders/LawLoader/Law.h" -#include "Parser.h" - -namespace V3 -{ -class Country; -} -namespace mappers -{ -typedef std::map Laws; -class LawMapper: commonItems::parser -{ - public: - LawMapper() = default; - void loadMappingRules(const std::string& filePath); - void loadLawDefinitions(const std::map& theLaws) { laws = theLaws; } - - [[nodiscard]] const auto& getLawGroups() const { return lawGroups; } - [[nodiscard]] const auto& getLaws() const { return laws; } - - [[nodiscard]] std::optional grantLawFromGroup(const std::string& lawGroup, const V3::Country& country) const; - - private: - void registerKeys(); - - [[nodiscard]] bool isLawBlocked(const std::string& lawName, const std::set& existingLaws, const std::set& existingTechs) const; - [[nodiscard]] std::vector filterLawsByAllowedProgressiveness(const std::set& nonBlockedLaws) const; - - std::map lawGroups; - std::map laws; -}; -} // namespace mappers - -#endif // LAW_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/LawMapper/LawMapping.cpp b/EU5ToVic3/Source/Mappers/LawMapper/LawMapping.cpp deleted file mode 100644 index 362c7fe..0000000 --- a/EU5ToVic3/Source/Mappers/LawMapper/LawMapping.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "LawMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::LawMapping::LawMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::LawMapping::registerKeys() -{ - registerKeyword("forms", [this](std::istream& theStream) { - for (const auto& entry: commonItems::getStrings(theStream)) - forms.emplace(entry); - }); - registerKeyword("ideas", [this](std::istream& theStream) { - for (const auto& entry: commonItems::getStrings(theStream)) - ideas.emplace(entry); - }); - registerKeyword("reforms", [this](std::istream& theStream) { - for (const auto& entry: commonItems::getStrings(theStream)) - reforms.emplace(entry); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -double mappers::LawMapping::getScore(const std::string& incForm, const std::set& incIdeas, const std::set& incReforms) const -{ - double score = 0; - if (forms.contains(incForm)) - score += 0.01; // we're just tagging this choice as fallback. - for (const auto& incIdea: incIdeas) - if (ideas.contains(incIdea)) - ++score; - for (const auto& incReform: incReforms) - if (reforms.contains(incReform)) - ++score; - return score; -} diff --git a/EU5ToVic3/Source/Mappers/LawMapper/LawMapping.h b/EU5ToVic3/Source/Mappers/LawMapper/LawMapping.h deleted file mode 100644 index 66394e9..0000000 --- a/EU5ToVic3/Source/Mappers/LawMapper/LawMapping.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef LAW_MAPPING_H -#define LAW_MAPPING_H -#include "Parser.h" -#include - -namespace mappers -{ -class LawMapping: commonItems::parser -{ - public: - LawMapping() = default; - explicit LawMapping(std::istream& theStream); - - [[nodiscard]] const auto& getForms() const { return forms; } - [[nodiscard]] const auto& getIdeas() const { return ideas; } - [[nodiscard]] const auto& getReforms() const { return reforms; } - - [[nodiscard]] double getScore(const std::string& incForm, const std::set& incIdeas, const std::set& incReforms) const; - - private: - void registerKeys(); - - std::set forms; - std::set ideas; - std::set reforms; -}; -} // namespace mappers - -#endif // LAW_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPop.cpp b/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPop.cpp deleted file mode 100644 index 75991f0..0000000 --- a/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPop.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "MinorityPop.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::MinorityPop::MinorityPop(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::MinorityPop::registerKeys() -{ - registerKeyword("religion", [this](std::istream& theStream) { - religion = commonItems::getString(theStream); - }); - registerKeyword("culture", [this](std::istream& theStream) { - culture = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPop.h b/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPop.h deleted file mode 100644 index 18c33f3..0000000 --- a/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPop.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MINORITY_POP_H -#define MINORITY_POP_H -#include "Parser.h" - -namespace mappers -{ -class MinorityPop: commonItems::parser -{ - public: - explicit MinorityPop(std::istream& theStream); - - [[nodiscard]] const auto& getReligion() const { return religion; } - [[nodiscard]] const auto& getCulture() const { return culture; } - - private: - void registerKeys(); - - std::string religion; - std::string culture; -}; -}; // namespace mappers - -#endif // MINORITY_POP_H diff --git a/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPopMapper.cpp b/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPopMapper.cpp deleted file mode 100644 index c7e7472..0000000 --- a/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPopMapper.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "MinorityPopMapper.h" -#include "CommonRegexes.h" -#include "MinorityPop.h" -#include "ParserHelpers.h" - -mappers::MinorityPopMapper::MinorityPopMapper(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::MinorityPopMapper::loadMappingRules(const std::string& filePath) -{ - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); -} - -void mappers::MinorityPopMapper::registerKeys() -{ - registerKeyword("minority", [this](std::istream& theStream) { - const MinorityPop minPop(theStream); - minorityPopMap.emplace_back(std::make_pair(minPop.getCulture(), minPop.getReligion())); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -bool mappers::MinorityPopMapper::blankMajorityFromMinority(V3::Pop& pop) const -{ - // We are blanking majority part from a minority pop so that we may apply any - // religion to metis or any culture to jews. - for (const auto& [minorityCulture, minorityReligion]: minorityPopMap) - { - if (pop.getCulture() == minorityCulture && pop.getReligion() == minorityReligion) - { - pop.setMinority(); - return true; - } - - if (minorityCulture.empty() && pop.getReligion() == minorityReligion) - { - pop.blankCulture(); - pop.setMinority(); - return true; - } - - if (pop.getCulture() == minorityCulture && minorityReligion.empty()) - { - pop.blankReligion(); - pop.setMinority(); - return true; - } - } - return false; -} diff --git a/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPopMapper.h b/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPopMapper.h deleted file mode 100644 index 827f9c3..0000000 --- a/EU5ToVic3/Source/Mappers/MinorityPopMapper/MinorityPopMapper.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MINORITY_POP_MAPPER_H -#define MINORITY_POP_MAPPER_H -#include "Parser.h" -#include "PopManager/Pops/Pop.h" - -namespace mappers -{ -class MinorityPopMapper: commonItems::parser -{ - public: - MinorityPopMapper() = default; - explicit MinorityPopMapper(std::istream& theStream); - void loadMappingRules(const std::string& filePath); - - [[nodiscard]] bool blankMajorityFromMinority(V3::Pop& pop) const; - - private: - void registerKeys(); - - std::vector> minorityPopMap; -}; -}; // namespace mappers - -#endif // MINORITY_POP_MAPPER_H diff --git a/EU5ToVic3/Source/Mappers/NationMergeMapper/MergeBlock.cpp b/EU5ToVic3/Source/Mappers/NationMergeMapper/MergeBlock.cpp deleted file mode 100644 index 5f36798..0000000 --- a/EU5ToVic3/Source/Mappers/NationMergeMapper/MergeBlock.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "MergeBlock.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::MergeBlock::MergeBlock(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::MergeBlock::registerKeys() -{ - registerSetter("master", master); - registerKeyword("slave", [this](std::istream& theStream) { - slaves.insert(commonItems::getString(theStream)); - }); - registerKeyword("merge", [this](std::istream& theStream) { - merge = commonItems::getString(theStream) == "yes"; - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/NationMergeMapper/MergeBlock.h b/EU5ToVic3/Source/Mappers/NationMergeMapper/MergeBlock.h deleted file mode 100644 index 1e431b3..0000000 --- a/EU5ToVic3/Source/Mappers/NationMergeMapper/MergeBlock.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MERGE_BLOCK -#define MERGE_BLOCK -#include "ConvenientParser.h" -#include - -namespace mappers -{ -class MergeBlock: commonItems::convenientParser -{ - public: - explicit MergeBlock(std::istream& theStream); - - [[nodiscard]] const auto& getMaster() const { return master; } - [[nodiscard]] const auto& getSlaves() const { return slaves; } - [[nodiscard]] auto shouldMerge() const { return merge; } - - private: - void registerKeys(); - - std::string master; - std::set slaves; - bool merge = false; -}; -} // namespace mappers - -#endif // MERGE_BLOCK diff --git a/EU5ToVic3/Source/Mappers/NationMergeMapper/NationMergeMapper.cpp b/EU5ToVic3/Source/Mappers/NationMergeMapper/NationMergeMapper.cpp deleted file mode 100644 index 6e39d96..0000000 --- a/EU5ToVic3/Source/Mappers/NationMergeMapper/NationMergeMapper.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "NationMergeMapper.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -void mappers::NationMergeMapper::loadNationMerge() -{ - registerKeys(); - parseFile("configurables/merge_nations.txt"); - clearRegisteredKeywords(); -} - -void mappers::NationMergeMapper::loadNationMerge(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::NationMergeMapper::registerKeys() -{ - registerKeyword("merge_daimyos", [this](std::istream& theStream) { - mergeDaimyos = commonItems::getString(theStream) == "yes"; - }); - registerRegex(commonItems::catchallRegex, [this](const std::string& unused, std::istream& theStream) { - const MergeBlock newBlock(theStream); - mergeBlocks.push_back(newBlock); - }); -} diff --git a/EU5ToVic3/Source/Mappers/NationMergeMapper/NationMergeMapper.h b/EU5ToVic3/Source/Mappers/NationMergeMapper/NationMergeMapper.h deleted file mode 100644 index 041dd76..0000000 --- a/EU5ToVic3/Source/Mappers/NationMergeMapper/NationMergeMapper.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef NATION_MERGE_MAPPER -#define NATION_MERGE_MAPPER -#include "MergeBlock.h" -#include "Parser.h" - -namespace mappers -{ -class NationMergeMapper: commonItems::parser -{ - public: - NationMergeMapper() = default; - - void loadNationMerge(); - void loadNationMerge(std::istream& theStream); - - [[nodiscard]] const auto& getMergeBlocks() const { return mergeBlocks; } - [[nodiscard]] auto getMergeDaimyos() const { return mergeDaimyos; } - - private: - void registerKeys(); - - std::vector mergeBlocks; - bool mergeDaimyos = false; -}; -} // namespace mappers - -#endif // NATION_MERGE_MAPPER diff --git a/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapper.cpp b/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapper.cpp deleted file mode 100644 index b468272..0000000 --- a/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapper.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "PopulationSetupMapper.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "PopulationSetupMapping.h" - -void mappers::PopulationSetupMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Parsing population setup rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Parsed " << literacySteps.size() << " literacy rules and " << wealthSteps.size() << " wealth rules."; -} - -void mappers::PopulationSetupMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::PopulationSetupMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - const PopulationSetupMapping mapping(theStream); - if (mapping.getLiteracy()) - literacySteps.emplace(*mapping.getLiteracy(), mapping.getEffect()); - if (mapping.getAverageDev()) - wealthSteps.emplace(*mapping.getAverageDev(), mapping.getEffect()); - }); -} - -std::string mappers::PopulationSetupMapper::getLiteracyEffectForLiteracy(const double literacy) const -{ - double delta = 999; - std::string bestEffect; - for (const auto& [literacyLevel, effect]: literacySteps) - { - const auto currentDelta = literacy - literacyLevel; - if (currentDelta >= 0 && currentDelta < delta) - { - delta = currentDelta; - bestEffect = effect; - } - } - return bestEffect; -} - -std::string mappers::PopulationSetupMapper::getWealthEffectForDev(const double dev) const -{ - double delta = 999; - std::string bestEffect; - for (const auto& [devLevel, effect]: wealthSteps) - { - const auto currentDelta = dev - devLevel; - if (currentDelta >= 0 && currentDelta < delta) - { - delta = currentDelta; - bestEffect = effect; - } - } - return bestEffect; -} \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapper.h b/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapper.h deleted file mode 100644 index 2041907..0000000 --- a/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapper.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef POPULATION_SETUP_MAPPER_H -#define POPULATION_SETUP_MAPPER_H -#include "Parser.h" -#include - -namespace mappers -{ -class PopulationSetupMapper: commonItems::parser -{ - public: - PopulationSetupMapper() = default; - void loadMappingRules(const std::string& filePath); - void loadMappingRules(std::istream& theStream); - - [[nodiscard]] std::string getWealthEffectForDev(double dev) const; - [[nodiscard]] std::string getLiteracyEffectForLiteracy(double literacy) const; - - private: - void registerKeys(); - - std::map literacySteps; - std::map wealthSteps; -}; -} // namespace mappers - -#endif // POPULATION_SETUP_MAPPER_H diff --git a/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapping.cpp b/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapping.cpp deleted file mode 100644 index 4258385..0000000 --- a/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapping.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "PopulationSetupMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::PopulationSetupMapping::PopulationSetupMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::PopulationSetupMapping::registerKeys() -{ - registerKeyword("literacy", [this](std::istream& theStream) { - literacy = commonItems::getDouble(theStream); - }); - registerKeyword("averagedev", [this](std::istream& theStream) { - averageDev = commonItems::getDouble(theStream); - }); - registerKeyword("effect", [this](std::istream& theStream) { - effect = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapping.h b/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapping.h deleted file mode 100644 index 4894fdf..0000000 --- a/EU5ToVic3/Source/Mappers/PopulationSetupMapper/PopulationSetupMapping.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef POPULATION_SETUP_MAPPING_H -#define POPULATION_SETUP_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class PopulationSetupMapping: commonItems::parser -{ - public: - explicit PopulationSetupMapping(std::istream& theStream); - - [[nodiscard]] const auto& getLiteracy() const { return literacy; } - [[nodiscard]] const auto& getAverageDev() const { return averageDev; } - [[nodiscard]] const auto& getEffect() const { return effect; } - - private: - void registerKeys(); - - std::optional literacy; - std::optional averageDev; - std::string effect; -}; -} // namespace mappers - -#endif // POPULATION_SETUP_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapper.cpp b/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapper.cpp deleted file mode 100644 index 50f1a19..0000000 --- a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapper.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "ProvinceMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "ProvinceMapping.h" - -void mappers::ProvinceMapper::loadProvinceMappings(const std::string& fileName) -{ - Log(LogLevel::Info) << "-> Parsing province mapping rules."; - registerKeys(); - parseFile(fileName); - clearRegisteredKeywords(); - createMappings(); - Log(LogLevel::Info) << "<> " << mappings.size() << " rules loaded."; -} - -void mappers::ProvinceMapper::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& unused, std::istream& theStream) { - // We support only a single, current version, so eu4-vic2 style multiple versions - // have been cut (for now). There should only be a single, some.name={} block inside province_mappings.txt - if (mappings.empty()) - { - mappings = ProvinceMappingsVersion(theStream).getMappings(); - } - else - { - commonItems::ignoreItem(unused, theStream); - } - }); -} - -void mappers::ProvinceMapper::createMappings() -{ - for (const auto& mapping: mappings) - { - // fix deliberate errors where we leave mappings without keys (wastelands and lakes comes to mind): - if (mapping.getV3Provinces().empty()) - continue; - if (mapping.getEU4Provinces().empty()) - continue; - - for (const auto& v3Name: mapping.getV3Provinces()) - { - if (!v3Name.empty()) - V3ToEU4ProvinceMap.emplace(v3Name, mapping.getEU4Provinces()); - } - for (const auto& eu4Number: mapping.getEU4Provinces()) - { - if (eu4Number > 0) - EU4ToVic3ProvinceMap.emplace(eu4Number, mapping.getV3Provinces()); - } - } -} - -std::vector mappers::ProvinceMapper::getEU4Provinces(const std::string& v3Province) const -{ - if (V3ToEU4ProvinceMap.contains(v3Province)) - return V3ToEU4ProvinceMap.at(v3Province); - - return {}; -} - -std::vector mappers::ProvinceMapper::getV3Provinces(int eu4Province) const -{ - if (EU4ToVic3ProvinceMap.contains(eu4Province)) - return EU4ToVic3ProvinceMap.at(eu4Province); - - return {}; -} diff --git a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapper.h b/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapper.h deleted file mode 100644 index 88d725b..0000000 --- a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapper.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef PROVINCE_MAPPER_H -#define PROVINCE_MAPPER_H -#include "Parser.h" -#include "ProvinceMappingsVersion.h" -#include - -namespace mappers -{ -class ProvinceMapper: commonItems::parser -{ - public: - ProvinceMapper() = default; - void loadProvinceMappings(const std::string& fileName); - - [[nodiscard]] std::vector getEU4Provinces(const std::string& v3Province) const; - [[nodiscard]] std::vector getV3Provinces(int eu4Province) const; - [[nodiscard]] const auto& getMappings() const { return mappings; } - - private: - void registerKeys(); - void createMappings(); - - std::map> V3ToEU4ProvinceMap; - std::map> EU4ToVic3ProvinceMap; - std::vector mappings; -}; -} // namespace mappers - -#endif // PROVINCE_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapping.cpp b/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapping.cpp deleted file mode 100644 index 0ed2965..0000000 --- a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapping.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "ProvinceMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::ProvinceMapping::ProvinceMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ProvinceMapping::registerKeys() -{ - registerKeyword("eu4", [this](std::istream& theStream) { - eu4Provinces.push_back(commonItems::getInt(theStream)); - }); - registerKeyword("vic3", [this](std::istream& theStream) { - v3Provinces.push_back(commonItems::getString(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapping.h b/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapping.h deleted file mode 100644 index cc7ae5d..0000000 --- a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMapping.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef PROVINCE_MAPPING_H -#define PROVINCE_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class ProvinceMapping: commonItems::parser -{ - public: - ProvinceMapping() = default; - explicit ProvinceMapping(std::istream& theStream); - - [[nodiscard]] const auto& getEU4Provinces() const { return eu4Provinces; } - [[nodiscard]] const auto& getV3Provinces() const { return v3Provinces; } - - private: - void registerKeys(); - - std::vector eu4Provinces; - std::vector v3Provinces; -}; -} // namespace mappers - -#endif // PROVINCE_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMappingsVersion.cpp b/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMappingsVersion.cpp deleted file mode 100644 index b3c845f..0000000 --- a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMappingsVersion.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "ProvinceMappingsVersion.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::ProvinceMappingsVersion::ProvinceMappingsVersion(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ProvinceMappingsVersion::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - const auto newMapping = ProvinceMapping(theStream); - if (newMapping.getV3Provinces().empty() && newMapping.getEU4Provinces().empty()) // This is a comment or empty entry. - return; - mappings.push_back(newMapping); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMappingsVersion.h b/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMappingsVersion.h deleted file mode 100644 index 8e9540e..0000000 --- a/EU5ToVic3/Source/Mappers/ProvinceMapper/ProvinceMappingsVersion.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef PROVINCE_MAPPING_VERSION_H -#define PROVINCE_MAPPING_VERSION_H -#include "Parser.h" -#include "ProvinceMapping.h" - -namespace mappers -{ -class ProvinceMappingsVersion: commonItems::parser -{ - public: - ProvinceMappingsVersion() = default; - explicit ProvinceMappingsVersion(std::istream& theStream); - - [[nodiscard]] const auto& getMappings() { return mappings; } - - private: - void registerKeys(); - - std::vector mappings; -}; -} // namespace mappers - -#endif // PROVINCE_MAPPING_VERSION_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDef.h b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDef.h deleted file mode 100644 index 8c96f33..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDef.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef RELIGION_DEF_H -#define RELIGION_DEF_H -#include "Color.h" -#include - -namespace mappers -{ -struct ReligionDef -{ - std::string name; - std::string texture; - std::set traits; - std::optional color; - std::set taboos; - - std::map locBlock; -}; -} // namespace mappers - -#endif // RELIGION_DEF_H diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionEntry.cpp b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionEntry.cpp deleted file mode 100644 index 4daa5ba..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionEntry.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "ReligionDefinitionEntry.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::ReligionDefinitionEntry::ReligionDefinitionEntry(std::istream& theStream) -{ - registerkeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ReligionDefinitionEntry::registerkeys() -{ - registerKeyword("texture", [this](std::istream& theStream) { - religionDef.texture = commonItems::getString(theStream); - }); - registerKeyword("traits", [this](std::istream& theStream) { - for (const auto& trait: commonItems::getStrings(theStream)) - religionDef.traits.emplace(trait); - }); - registerKeyword("color", [this](std::istream& theStream) { - religionDef.color = commonItems::Color::Factory().getColor(theStream); - }); - registerKeyword("taboos", [this](std::istream& theStream) { - for (const auto& taboo: commonItems::getStrings(theStream)) - religionDef.taboos.emplace(taboo); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionEntry.h b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionEntry.h deleted file mode 100644 index 590e3c8..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionEntry.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef RELIGION_DEFINITION_ENTRY_H -#define RELIGION_DEFINITION_ENTRY_H -#include "Parser.h" -#include "ReligionDef.h" - -namespace mappers -{ -class ReligionDefinitionEntry: commonItems::parser -{ - public: - explicit ReligionDefinitionEntry(std::istream& theStream); - - [[nodiscard]] const auto& getReligionDef() const { return religionDef; } - - private: - void registerkeys(); - - ReligionDef religionDef; -}; -} // namespace mappers - -#endif // RELIGION_DEFINITION_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionLoader.cpp b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionLoader.cpp deleted file mode 100644 index 9254048..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionLoader.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "ReligionDefinitionLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "ReligionDefinitionEntry.h" - -void mappers::ReligionDefinitionLoader::loadDefinitions(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading religion refinitions."; - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/religions/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << religionDefinitions.size() << " definitions loaded."; -} - -void mappers::ReligionDefinitionLoader::loadDefinitions(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ReligionDefinitionLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& religionName, std::istream& theStream) { - auto relDef = ReligionDefinitionEntry(theStream).getReligionDef(); - relDef.name = religionName; - religionDefinitions.emplace(religionName, relDef); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::ReligionDefinitionLoader::getReligionDef(const std::string& religion) const -{ - if (religionDefinitions.contains(religion)) - return religionDefinitions.at(religion); - return std::nullopt; -} diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionLoader.h b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionLoader.h deleted file mode 100644 index bd5ad4b..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionLoader.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef RELIGION_DEFINITION_LOADER_H -#define RELIGION_DEFINITION_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include "ReligionDef.h" - -namespace mappers -{ -class ReligionDefinitionLoader: commonItems::parser -{ - public: - ReligionDefinitionLoader() = default; - void loadDefinitions(const commonItems::ModFilesystem& modFS); - void loadDefinitions(std::istream& theStream); - - [[nodiscard]] std::optional getReligionDef(const std::string& religion) const; - [[nodiscard]] const auto& getReligionDefs() const { return religionDefinitions; } - - private: - void registerKeys(); - - std::map religionDefinitions; -}; -} // namespace mappers - -#endif // RELIGION_DEFINITION_LOADER_H diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapper.cpp b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapper.cpp deleted file mode 100644 index f873f05..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapper.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "ReligionGroupMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void mappers::ReligionGroupMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Parsing religion group mapping rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << mappings.size() << " rules loaded."; -} - -void mappers::ReligionGroupMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ReligionGroupMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - mappings.emplace_back(ReligionGroupMapping(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::ReligionGroupMapper::getMappingForEU4ReligionGroup(const std::string& eu4ReligionGroup) const -{ - for (const auto& mapping: mappings) - if (mapping.getEU4Groups().contains(eu4ReligionGroup)) - return mapping; - return std::nullopt; -} diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapper.h b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapper.h deleted file mode 100644 index a7b642f..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapper.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef RELIGION_GROUP_MAPPER_H -#define RELIGION_GROUP_MAPPER_H -#include "Parser.h" -#include "ReligionGroupMapping.h" - -namespace mappers -{ -class ReligionGroupMapper: commonItems::parser -{ - public: - ReligionGroupMapper() = default; - void loadMappingRules(const std::string& filePath); - void loadMappingRules(std::istream& theStream); - - [[nodiscard]] std::optional getMappingForEU4ReligionGroup(const std::string& eu4ReligionGroup) const; - - private: - void registerKeys(); - - std::vector mappings; -}; -} // namespace mappers - -#endif // RELIGION_GROUP_MAPPER_H diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapping.cpp b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapping.cpp deleted file mode 100644 index 7e9e916..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapping.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "ReligionGroupMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::ReligionGroupMapping::ReligionGroupMapping(std::istream& theStream) -{ - registerkeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ReligionGroupMapping::registerkeys() -{ - registerKeyword("vic3", [this](std::istream& theStream) { - trait = commonItems::getString(theStream); - }); - registerKeyword("eu4", [this](std::istream& theStream) { - eu4groups.emplace(commonItems::getString(theStream)); - }); - registerKeyword("taboo", [this](std::istream& theStream) { - taboos.emplace(commonItems::getString(theStream)); - }); - registerKeyword("icon", [this](std::istream& theStream) { - icon = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapping.h b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapping.h deleted file mode 100644 index 1d94f48..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionGroupMapper/ReligionGroupMapping.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef RELIGION_GROUP_MAPPING_H -#define RELIGION_GROUP_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class ReligionGroupMapping: commonItems::parser -{ - public: - explicit ReligionGroupMapping(std::istream& theStream); - - [[nodiscard]] const auto& getTrait() const { return trait; } - [[nodiscard]] const auto& getEU4Groups() const { return eu4groups; } - [[nodiscard]] const auto& getTaboos() const { return taboos; } - [[nodiscard]] const auto& getIcon() const { return icon; } - - private: - void registerkeys(); - - std::string trait; - std::set eu4groups; - std::set taboos; - std::string icon; -}; -} // namespace mappers - -#endif // RELIGION_GROUP_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapper.cpp b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapper.cpp deleted file mode 100644 index ff24093..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapper.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#include "ReligionMapper.h" -#include "CommonRegexes.h" -#include "Loaders/ReligionLoader/Religion.h" -#include "LocalizationLoader/EU4LocalizationLoader.h" -#include "Log.h" -#include "OSCompatibilityLayer.h" -#include "ParserHelpers.h" -#include "ReligionDefinitionLoader/ReligionDefinitionLoader.h" -#include "ReligionGroupMapper/ReligionGroupMapper.h" -#include "ReligionMapping.h" -#include - -void mappers::ReligionMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Parsing religion mapping rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << eu4ToV3ReligionMap.size() << " rules loaded."; -} - -void mappers::ReligionMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ReligionMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - const ReligionMapping theMapping(theStream); - if (!theMapping.getV3Religion().empty() && !theMapping.getEU4Religions().empty()) - for (const auto& eu4Religion: theMapping.getEU4Religions()) - eu4ToV3ReligionMap.emplace(eu4Religion, theMapping.getV3Religion()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::ReligionMapper::getV3Religion(const std::string& eu4Religion) const -{ - if (eu4ToV3ReligionMap.contains(eu4Religion)) - return eu4ToV3ReligionMap.at(eu4Religion); - return std::nullopt; -} - -void mappers::ReligionMapper::expandReligionMappings(const std::map& eu4Religions) -{ - // We're looking at all eu4 religions and creating new mappings for stuff we don't recognize. - // This means all dynamic and unmapped eu4 religions will be retained and map to themselves. - - const auto curSize = eu4ToV3ReligionMap.size(); - for (const auto& eu4ReligionName: eu4Religions | std::views::keys) - { - if (!eu4ToV3ReligionMap.contains(eu4ReligionName)) - eu4ToV3ReligionMap.emplace(eu4ReligionName, eu4ReligionName); - } - Log(LogLevel::Info) << "<> Additional " << eu4ToV3ReligionMap.size() - curSize << " religions imported."; -} - -void mappers::ReligionMapper::generateReligionDefinitions(const commonItems::ModFilesystem& modFS, - const std::string& groupMapPath, - const std::map& eu4Religions, - const EU4::EU4LocalizationLoader& eu4Locs) -{ - Log(LogLevel::Info) << "-> Generating Religion Definitions."; - - ReligionDefinitionLoader religionDefinitionLoader; - religionDefinitionLoader.loadDefinitions(modFS); - ReligionGroupMapper religionGroupMapper; - religionGroupMapper.loadMappingRules(groupMapPath); - - for (const auto& [eu4ReligionName, v3ReligionName]: eu4ToV3ReligionMap) - { - if (vic3ReligionDefinitions.contains(v3ReligionName)) - continue; - - // do we have a ready definition already? - if (const auto& defMatch = religionDefinitionLoader.getReligionDef(v3ReligionName)) - { - vic3ReligionDefinitions.emplace(v3ReligionName, *defMatch); - continue; - } - - // quick sanity, though this should never fire. - if (!eu4Religions.contains(eu4ReligionName)) - { - Log(LogLevel::Warning) << "EU4 religions don't contain " << eu4ReligionName << "? What are we even doing?"; - continue; - } - - // generate a definition and file. - auto newDef = generateReligionDefinition(v3ReligionName, religionGroupMapper, religionDefinitionLoader, eu4Religions.at(eu4ReligionName), eu4Locs); - vic3ReligionDefinitions.emplace(v3ReligionName, newDef); - } - - // Do we have excess religions in vic3 we don't reference? (atheist?) - for (const auto& [v3ReligionName, religionDef]: religionDefinitionLoader.getReligionDefs()) - { - if (!vic3ReligionDefinitions.contains(v3ReligionName)) - vic3ReligionDefinitions.emplace(v3ReligionName, religionDef); - } - - Log(LogLevel::Info) << "-> Generated " << vic3ReligionDefinitions.size() << " Religion Definitions."; -} - -mappers::ReligionDef mappers::ReligionMapper::generateReligionDefinition(const std::string& v3ReligionName, - const ReligionGroupMapper& religionGroupMapper, - const ReligionDefinitionLoader& religionDefinitionLoader, - const EU4::Religion& eu4Religion, - const EU4::EU4LocalizationLoader& eu4Locs) const -{ - ReligionDef religionDef; - religionDef.name = v3ReligionName; - if (eu4Religion.color) - religionDef.color = eu4Religion.color; - - // We are indiscriminately overriding vanilla vic3 locs as well, but we'll export them with a 99 prefix so base locs should apply. - if (const auto& locs = eu4Locs.getTextInEachLanguage(eu4Religion.name)) - religionDef.locBlock = *locs; - - const auto& trappings = eu4Religion.trappings; - std::string icon; - - // can we match a group? - if (const auto& groupMatch = religionGroupMapper.getMappingForEU4ReligionGroup(eu4Religion.group)) - { - religionDef.traits.emplace(groupMatch->getTrait()); - religionDef.taboos = groupMatch->getTaboos(); - icon = groupMatch->getIcon(); - } - else - { - Log(LogLevel::Warning) << "Religion " << v3ReligionName << " is using eu4 religion group " << eu4Religion.group << " which isn't mapped!"; - return religionDef; - } - - // We now have an icon and possibly trappings. Icon is a vic3 religion where we need to grab the exact icon filepath. - // Trappings are an eu4 source religion that we need to grab the icon filepath of the vic3 religion it maps to. - if (!trappings.empty() && eu4ToV3ReligionMap.contains(trappings)) - { - if (const auto& targetDef = religionDefinitionLoader.getReligionDef(eu4ToV3ReligionMap.at(trappings))) - religionDef.texture = targetDef->texture; - // if this fails for whatever reason, we may yet silently fallback on the icon. Noone will notice anyway. - } - if (religionDef.texture.empty() && !icon.empty()) - { - if (const auto& targetDef = religionDefinitionLoader.getReligionDef(icon)) - religionDef.texture = targetDef->texture; - } - - // If all else fails, eh, it's their problem. - if (religionDef.texture.empty()) - Log(LogLevel::Warning) << "Religion " << v3ReligionName << " has a misdefined icon!"; - - return religionDef; -} diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapper.h b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapper.h deleted file mode 100644 index 9520076..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapper.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef RELIGION_MAPPER_H -#define RELIGION_MAPPER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include "ReligionMapper/ReligionDefinitionLoader/ReligionDef.h" -#include -#include -#include - -namespace EU4 -{ -struct Religion; -class EU4LocalizationLoader; -} // namespace EU4 -namespace mappers -{ -class ReligionGroupMapper; -class ReligionDefinitionLoader; -class ReligionMapper: commonItems::parser -{ - public: - ReligionMapper() = default; - void loadMappingRules(const std::string& filePath); - void loadMappingRules(std::istream& theStream); - - [[nodiscard]] std::optional getV3Religion(const std::string& eu4Religion) const; - [[nodiscard]] const auto& getV3ReligionDefinitions() const { return vic3ReligionDefinitions; } - - void expandReligionMappings(const std::map& eu4Religions); - void generateReligionDefinitions(const commonItems::ModFilesystem& modFS, - const std::string& groupMapPath, - const std::map& eu4Religions, - const EU4::EU4LocalizationLoader& eu4Locs); - - private: - void registerKeys(); - - [[nodiscard]] ReligionDef generateReligionDefinition(const std::string& v3ReligionName, - const ReligionGroupMapper& religionGroupMapper, - const ReligionDefinitionLoader& religionDefinitionLoader, - const EU4::Religion& eu4Religion, - const EU4::EU4LocalizationLoader& eu4Locs) const; - - std::map eu4ToV3ReligionMap; - std::map vic3ReligionDefinitions; -}; -} // namespace mappers - -#endif // RELIGION_MAPPER_H diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapping.cpp b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapping.cpp deleted file mode 100644 index 5ef2833..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapping.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "ReligionMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::ReligionMapping::ReligionMapping(std::istream& theStream) -{ - registerkeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::ReligionMapping::registerkeys() -{ - registerKeyword("vic3", [this](std::istream& theStream) { - v3Religion = commonItems::getString(theStream); - }); - registerKeyword("eu4", [this](std::istream& theStream) { - eu4Religions.emplace(commonItems::getString(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapping.h b/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapping.h deleted file mode 100644 index 7045ad3..0000000 --- a/EU5ToVic3/Source/Mappers/ReligionMapper/ReligionMapping.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef RELIGION_MAPPING_H -#define RELIGION_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class ReligionMapping: commonItems::parser -{ - public: - explicit ReligionMapping(std::istream& theStream); - - [[nodiscard]] const auto& getV3Religion() const { return v3Religion; } - [[nodiscard]] const auto& getEU4Religions() const { return eu4Religions; } - - private: - void registerkeys(); - - std::string v3Religion; - std::set eu4Religions; -}; -} // namespace mappers - -#endif // RELIGION_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapper.cpp b/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapper.cpp deleted file mode 100644 index 1dca91b..0000000 --- a/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapper.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "SlaveCultureMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "SlaveCultureMapping.h" - -void mappers::SlaveCultureMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Parsing Slave Culture Mapping Rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Loaded " << masterTraitToSlaveCultureMap.size() << " mapping rules."; -} - -void mappers::SlaveCultureMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - const auto mapping = SlaveCultureMapping(theStream); - masterTraitToSlaveCultureMap.emplace(mapping.getMasterTrait(), mapping.getSlaveCulture()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional mappers::SlaveCultureMapper::getSlaveCulture(const std::string& masterTrait) const -{ - if (masterTraitToSlaveCultureMap.contains(masterTrait)) - return masterTraitToSlaveCultureMap.at(masterTrait); - return std::nullopt; -} diff --git a/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapper.h b/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapper.h deleted file mode 100644 index 9aca988..0000000 --- a/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapper.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef SLAVE_CULTURE_MAPPER_H -#define SLAVE_CULTURE_MAPPER_H -#include "Parser.h" - -namespace mappers -{ -class SlaveCultureMapper: commonItems::parser -{ - public: - SlaveCultureMapper() = default; - void loadMappingRules(const std::string& filePath); - - [[nodiscard]] std::optional getSlaveCulture(const std::string& masterTrait) const; - - private: - void registerKeys(); - - std::map masterTraitToSlaveCultureMap; -}; -} // namespace mappers - -#endif // SLAVE_CULTURE_MAPPER_H diff --git a/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapping.cpp b/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapping.cpp deleted file mode 100644 index 3d6933c..0000000 --- a/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapping.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "SlaveCultureMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::SlaveCultureMapping::SlaveCultureMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::SlaveCultureMapping::registerKeys() -{ - registerKeyword("master", [this](std::istream& theStream) { - masterTrait = commonItems::getString(theStream); - }); - registerKeyword("slave", [this](std::istream& theStream) { - slaveCulture = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapping.h b/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapping.h deleted file mode 100644 index 82b952b..0000000 --- a/EU5ToVic3/Source/Mappers/SlaveCultureMapper/SlaveCultureMapping.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef SLAVE_CULTURE_MAPPING_H -#define SLAVE_CULTURE_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class SlaveCultureMapping: commonItems::parser -{ - public: - SlaveCultureMapping() = default; - explicit SlaveCultureMapping(std::istream& theStream); - - [[nodiscard]] const auto& getMasterTrait() const { return masterTrait; } - [[nodiscard]] const auto& getSlaveCulture() const { return slaveCulture; } - - private: - void registerKeys(); - - std::string masterTrait; - std::string slaveCulture; -}; -} // namespace mappers - -#endif // SLAVE_CULTURE_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/SuperGroupMapper/AssimilationParser.cpp b/EU5ToVic3/Source/Mappers/SuperGroupMapper/AssimilationParser.cpp deleted file mode 100644 index 6df8796..0000000 --- a/EU5ToVic3/Source/Mappers/SuperGroupMapper/AssimilationParser.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "AssimilationParser.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::AssimilationParser::AssimilationParser(std::istream& theStream) -{ - registerSetter("assimilation", assimilation); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - parseStream(theStream); - clearRegisteredKeywords(); -} diff --git a/EU5ToVic3/Source/Mappers/SuperGroupMapper/AssimilationParser.h b/EU5ToVic3/Source/Mappers/SuperGroupMapper/AssimilationParser.h deleted file mode 100644 index 07fc29a..0000000 --- a/EU5ToVic3/Source/Mappers/SuperGroupMapper/AssimilationParser.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ASSIMILATION_PARSER -#define ASSIMILATION_PARSER -#include "ConvenientParser.h" - -namespace mappers -{ -class AssimilationParser: commonItems::convenientParser -{ - public: - explicit AssimilationParser(std::istream& theStream); - - [[nodiscard]] auto getAssimilation() const { return assimilation; } - - private: - int assimilation = 1; -}; -} // namespace mappers - -#endif // ASSIMILATION_PARSER \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperGroupMapper.cpp b/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperGroupMapper.cpp deleted file mode 100644 index bac3c80..0000000 --- a/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperGroupMapper.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "SuperGroupMapper.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "SuperRegionParser.h" -#include - -void mappers::SuperGroupMapper::loadSuperGroups() -{ - Log(LogLevel::Info) << "-> Parsing starting supergroups."; - registerKeys(); - parseFile("configurables/world_supergroups.txt"); - clearRegisteredKeywords(); -} - -void mappers::SuperGroupMapper::loadSuperGroups(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::SuperGroupMapper::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& superGroupName, std::istream& theStream) { - const SuperRegionParser newSuperRegionBlock(theStream); - superGroups.emplace(superGroupName, newSuperRegionBlock.getSuperRegionNames()); - - const auto& aMap = newSuperRegionBlock.getSuperRegionAssimilationMap(); - assimilationMap.insert(aMap.begin(), aMap.end()); - }); -} - -std::optional mappers::SuperGroupMapper::getGroupForSuperRegion(const std::string& superRegionName) const -{ - for (const auto& [superGroupName, superGroup]: superGroups) - if (superGroup.contains(superRegionName)) - return superGroupName; - return std::nullopt; -} - -double mappers::SuperGroupMapper::getAssimilationFactor(const std::string& superRegionName) const -{ - auto rate = 1; - const auto& srIter = assimilationMap.find(superRegionName); - if (srIter != assimilationMap.end()) - rate = srIter->second; - - const auto factor = (1.0 - pow(0.75, rate)) / 100; - return factor; -} \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperGroupMapper.h b/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperGroupMapper.h deleted file mode 100644 index 0abe09c..0000000 --- a/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperGroupMapper.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef SUPER_GROUP_MAPPER_H -#define SUPER_GROUP_MAPPER_H -#include "Parser.h" -#include -#include - -namespace mappers -{ -class SuperGroupMapper: commonItems::parser -{ - public: - SuperGroupMapper() = default; - - void loadSuperGroups(); - void loadSuperGroups(std::istream& theStream); - - [[nodiscard]] std::optional getGroupForSuperRegion(const std::string& superRegionName) const; - [[nodiscard]] double getAssimilationFactor(const std::string& superRegionName) const; - - private: - void registerKeys(); - - std::map> superGroups; // name (old_world) - superregions in it - std::map assimilationMap; // superregion - assimilation rate -}; -} // namespace mappers - -#endif // SUPER_GROUP_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperRegionParser.cpp b/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperRegionParser.cpp deleted file mode 100644 index cf55eab..0000000 --- a/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperRegionParser.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "SuperRegionParser.h" -#include "AssimilationParser.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::SuperRegionParser::SuperRegionParser(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::SuperRegionParser::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& superRegionName, std::istream& theStream) { - const AssimilationParser assimilationBlock(theStream); - superRegionAssimilationMap.insert(std::make_pair(superRegionName, assimilationBlock.getAssimilation())); - superRegionNames.insert(superRegionName); - }); -} diff --git a/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperRegionParser.h b/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperRegionParser.h deleted file mode 100644 index 534add9..0000000 --- a/EU5ToVic3/Source/Mappers/SuperGroupMapper/SuperRegionParser.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef SUPERREGION_PARSER -#define SUPERREGION_PARSER -#include "Parser.h" -#include - -namespace mappers -{ -class SuperRegionParser: commonItems::parser -{ - public: - explicit SuperRegionParser(std::istream& theStream); - - [[nodiscard]] const auto& getSuperRegionAssimilationMap() const { return superRegionAssimilationMap; } - [[nodiscard]] const auto& getSuperRegionNames() const { return superRegionNames; } - - private: - void registerKeys(); - - std::map superRegionAssimilationMap; - std::set superRegionNames; -}; -} // namespace mappers - -#endif // SUPERREGION_PARSER \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapper.cpp b/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapper.cpp deleted file mode 100644 index bd8bc11..0000000 --- a/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapper.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "TechSetupMapper.h" -#include "CommonRegexes.h" -#include "Log.h" - -void mappers::TechSetupMapper::loadMappingRules(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading Tech Setup Rules."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> " << trackTechScores.size() << " tracks loaded."; -} - -void mappers::TechSetupMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::TechSetupMapper::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& trackName, std::istream& theStream) { - trackTechScores.emplace(trackName, TechSetupMapping(theStream)); - }); -} - -std::set mappers::TechSetupMapper::getTechsForScoreTrack(const std::string& track, const double score) const -{ - if (!trackTechScores.contains(track)) - { - Log(LogLevel::Warning) << "Attempting to get techs from track: " << track << " which doesn't exist in tech_setup.txt!"; - return {}; - } - - const auto& techMap = trackTechScores.at(track).getTechScores(); - std::set techs; - for (const auto& [tech, techScore]: techMap) - if (score >= techScore) - techs.emplace(tech); - return techs; -} diff --git a/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapper.h b/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapper.h deleted file mode 100644 index 1b28dd2..0000000 --- a/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapper.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef TECH_SETUP_MAPPER_H -#define TECH_SETUP_MAPPER_H -#include "Parser.h" -#include "TechSetupMapping.h" - -namespace mappers -{ -class TechSetupMapper: commonItems::parser -{ - public: - TechSetupMapper() = default; - void loadMappingRules(const std::string& filePath); - void loadMappingRules(std::istream& theStream); - - [[nodiscard]] std::set getTechsForScoreTrack(const std::string& track, double score) const; - - private: - void registerKeys(); - - std::map trackTechScores; // track->techScores -}; -} // namespace mappers - -#endif // TECH_SETUP_MAPPER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapping.cpp b/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapping.cpp deleted file mode 100644 index 7525de4..0000000 --- a/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapping.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "TechSetupMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::TechSetupMapping::TechSetupMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::TechSetupMapping::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& techName, std::istream& theStream) { - techScores.emplace(techName, commonItems::getInt(theStream)); - }); -} diff --git a/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapping.h b/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapping.h deleted file mode 100644 index fe4046f..0000000 --- a/EU5ToVic3/Source/Mappers/TechSetupMapper/TechSetupMapping.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef TECH_SETUP_MAPPING_H -#define TECH_SETUP_MAPPING_H -#include "Parser.h" - -namespace mappers -{ -class TechSetupMapping: commonItems::parser -{ - public: - TechSetupMapping() = default; - explicit TechSetupMapping(std::istream& theStream); - - [[nodiscard]] const auto& getTechScores() const { return techScores; } - - private: - void registerKeys(); - - std::map techScores; -}; -} // namespace mappers - -#endif // TECH_SETUP_MAPPING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapper.cpp b/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapper.cpp deleted file mode 100644 index bd501a1..0000000 --- a/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapper.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "VNColonialMapper.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -void mappers::VNColonialMapper::loadMappingRules(const std::string& fileName) -{ - registerKeys(); - parseFile(fileName); - clearRegisteredKeywords(); -} - -void mappers::VNColonialMapper::loadMappingRules(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::VNColonialMapper::registerKeys() -{ - registerKeyword("link", [this](std::istream& theStream) { - VNColonialMapping theMapping(theStream); - VNColonies.emplace_back(theMapping); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -bool mappers::VNColonialMapper::isStateVNColonial(const std::string& stateName) const -{ - for (const auto& colony: VNColonies) - if (colony.getStates().contains(stateName)) - return true; - return false; -} - -std::set mappers::VNColonialMapper::getVanillaOwners(const std::string& stateName) const -{ - std::set owners; - for (const auto& colony: VNColonies) - if (colony.getStates().contains(stateName)) - owners.emplace(colony.getOwner()); - return owners; -} - -std::optional mappers::VNColonialMapper::getKeyProvince(const std::string& stateName, const std::string& ownerTag) const -{ - for (const auto& colony: VNColonies) - if (colony.getStates().contains(stateName) && colony.getOwner() == ownerTag) - return colony.getKeyProvince(); - return std::nullopt; -} - -bool mappers::VNColonialMapper::isStateDecolonizable(const std::string& stateName, const std::string& ownerTag, const std::string& currentOwner) const -{ - for (const auto& colony: VNColonies) - { - if (colony.getDecolonizeBlocker().empty()) - continue; - if (colony.getStates().contains(stateName) && colony.getOwner() == ownerTag && colony.getDecolonizeBlocker() != currentOwner) - return true; - } - return false; -} diff --git a/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapper.h b/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapper.h deleted file mode 100644 index f3216b4..0000000 --- a/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapper.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef VN_COLONIAL_MAPPER -#define VN_COLONIAL_MAPPER -#include "Parser.h" -#include "VNColonialMapping.h" -#include - -namespace mappers -{ -class VNColonialMapper: commonItems::parser -{ - public: - VNColonialMapper() = default; - - void loadMappingRules(std::istream& theStream); - void loadMappingRules(const std::string& fileName); - - [[nodiscard]] const auto& getVNColonies() const { return VNColonies; } - [[nodiscard]] bool isStateVNColonial(const std::string& stateName) const; - [[nodiscard]] std::set getVanillaOwners(const std::string& stateName) const; // A state can contain multiple colonial substates. - [[nodiscard]] std::optional getKeyProvince(const std::string& stateName, const std::string& ownerTag) const; - [[nodiscard]] bool isStateDecolonizable(const std::string& stateName, const std::string& ownerTag, const std::string& currentOwner) const; - - private: - void registerKeys(); - - std::vector VNColonies; -}; -} // namespace mappers - -#endif // VN_COLONIAL_MAPPER \ No newline at end of file diff --git a/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapping.cpp b/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapping.cpp deleted file mode 100644 index 1198a2b..0000000 --- a/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapping.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "VNColonialMapping.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -mappers::VNColonialMapping::VNColonialMapping(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void mappers::VNColonialMapping::registerKeys() -{ - registerKeyword("name", [this](std::istream& theStream) { - name = commonItems::getString(theStream); - }); - registerKeyword("owner", [this](std::istream& theStream) { - owner = commonItems::getString(theStream); - }); - registerKeyword("decolonize", [this](std::istream& theStream) { - decolonizeBlocker = commonItems::getString(theStream); - }); - registerKeyword("key", [this](std::istream& theStream) { - keyProvince = commonItems::getString(theStream); - }); - registerKeyword("states", [this](std::istream& theStream) { - auto theStates = commonItems::getStrings(theStream); - states.insert(theStates.begin(), theStates.end()); - }); - registerKeyword("subjects", [this](std::istream& theStream) { - auto theSubjects = commonItems::getStrings(theStream); - subjects.insert(theSubjects.begin(), theSubjects.end()); - }); - registerKeyword("type", [this](std::istream& theStream) { - subjectType = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapping.h b/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapping.h deleted file mode 100644 index fd16112..0000000 --- a/EU5ToVic3/Source/Mappers/VNColonialMapper/VNColonialMapping.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef VN_COLONIAL_MAPPING -#define VN_COLONIAL_MAPPING -#include "Parser.h" - -namespace mappers -{ -class VNColonialMapping: commonItems::parser -{ - public: - explicit VNColonialMapping(std::istream& theStream); - - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getOwner() const { return owner; } - [[nodiscard]] const auto& getDecolonizeBlocker() const { return decolonizeBlocker; } - [[nodiscard]] const auto& getKeyProvince() const { return keyProvince; } - [[nodiscard]] const auto& getStates() const { return states; } - [[nodiscard]] const auto& getSubjects() const { return subjects; } - [[nodiscard]] const auto& getSubjectType() const { return subjectType; } - - private: - void registerKeys(); - - std::string name; - std::string owner; - std::string decolonizeBlocker; - std::string keyProvince; - std::set states; - std::set subjects; - std::string subjectType; -}; -} // namespace mappers - -#endif // VN_COLONIAL_MAPPING \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outBuildings/outBuildings.cpp b/EU5ToVic3/Source/Output/outBuildings/outBuildings.cpp deleted file mode 100644 index ae31eba..0000000 --- a/EU5ToVic3/Source/Output/outBuildings/outBuildings.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "outBuildings.h" -#include "ClayManager/State/SubState.h" -#include "CommonFunctions.h" -#include "PoliticalManager/Country/Country.h" -#include -#include - -namespace -{ -void outPMs(std::ostream& output, const V3::Building& building) -{ - output << "\t\t\t\tactivate_production_methods = {"; - for (const auto& PM: building.getPMs()) - { - output << " \"" << PM << "\""; - } - output << " }\n"; -} -void outBuilding(std::ostream& output, const V3::Building& building) -{ - output << "\t\t\tcreate_building = {\n"; - output << "\t\t\t\tbuilding = \"" << building.getName() << "\"\n"; - output << "\t\t\t\tlevel = " << building.getLevel() << "\n"; - output << "\t\t\t\treserves = " << 1 << "\n"; - - outPMs(output, building); - - output << "\t\t\t}\n"; -} -void outSubStateBuildings(std::ostream& output, const V3::SubState& subState) -{ - if (!subState.getOwner()) - return; - output << "\t\tregion_state:" << subState.getOwner()->getTag() << " = {\n"; - for (const auto& building: subState.getBuildings()) - { - if (building->getLevel() > 0) - outBuilding(output, *building); - } - for (const auto& element: subState.getVanillaBuildingElements()) - output << "\t\t\t" << element << "\n"; - output << "\t\t}\n"; -} -void outStateBuildings(std::ostream& output, const V3::State& state) -{ - output << "\ts:" << state.getName() << " = {\n"; - for (const auto& substate: state.getSubStates()) - { - if (substate->getBuildings().empty() && substate->getVanillaBuildingElements().empty()) - continue; - outSubStateBuildings(output, *substate); - } - output << "\t}\n"; -} -} // namespace - -void OUT::exportBuildings(const std::string& outputName, const std::map>& states) -{ - std::ofstream output("output/" + outputName + "/common/history/buildings/99_converted_buildings.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/buildings/99_converted_buildings.txt"); - - output << commonItems::utf8BOM << "BUILDINGS = {\n"; - for (const auto& state: states | std::views::values) - { - const auto& subs = state->getSubStates(); - if (std::all_of(subs.begin(), subs.end(), [](const auto& subState) { - return subState->getBuildings().empty() && subState->getVanillaBuildingElements().empty(); - })) - { - continue; - } - - outStateBuildings(output, *state); - } - output << "}\n"; - output.close(); -} diff --git a/EU5ToVic3/Source/Output/outBuildings/outBuildings.h b/EU5ToVic3/Source/Output/outBuildings/outBuildings.h deleted file mode 100644 index 0cbdd10..0000000 --- a/EU5ToVic3/Source/Output/outBuildings/outBuildings.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef OUT_BUILDINGS_H -#define OUT_BUILDINGS_H -#include "ClayManager/State/State.h" - -namespace OUT -{ -void exportBuildings(const std::string& outputName, const std::map>& states); -} // namespace OUT - -#endif // OUT_BUILDINGS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outCharacters/outCharacters.cpp b/EU5ToVic3/Source/Output/outCharacters/outCharacters.cpp deleted file mode 100644 index 2082c21..0000000 --- a/EU5ToVic3/Source/Output/outCharacters/outCharacters.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "outCharacters.h" -#include "CommonFunctions.h" -#include "PoliticalManager/Country/Country.h" -#include -#include - -namespace -{ -void outCharacter(std::ostream& output, const V3::Character& character) -{ - output << "\t\tcreate_character = {\n"; - if (!character.firstName.empty()) - output << "\t\t\tfirst_name = \"" << character.firstName << "\"\n"; - if (!character.lastName.empty()) - output << "\t\t\tlast_name = \"" << character.lastName << "\"\n"; - if (character.ruler) - output << "\t\t\truler = yes\n"; - if (character.heir) - output << "\t\t\their = yes\n"; - if (character.general) - output << "\t\t\tis_general = yes\n"; - if (character.admiral) - output << "\t\t\tis_admiral = yes\n"; - if (!character.commanderRank.empty()) - output << "\t\t\tcommander_rank = " << character.commanderRank << "\n"; - if (character.female) - output << "\t\t\tfemale = yes\n"; - if (!character.interestGroup.empty()) - output << "\t\t\tinterest_group = " << character.interestGroup << "\n"; - if (!character.culture.empty()) - output << "\t\t\tculture = cu:" << character.culture << "\n"; - if (!character.religion.empty()) - output << "\t\t\treligion = rel:" << character.religion << "\n"; - if (character.birthDate.isSet()) - output << "\t\t\tbirth_date = " << character.birthDate << "\n"; - if (!character.traits.empty()) - { - output << "\t\t\ttraits = {\n\t\t\t\t"; - for (const auto& trait: character.traits) - output << trait << " "; - output << "\n\t\t\t}\n"; - } - if (character.married) - { - output << "\t\t\ton_created = {\n"; - output << "\t\t\t\tset_variable = is_married\n"; - output << "\t\t\t}\n"; - } - output << "\t\t}\n\n"; -} -} // namespace - -void OUT::exportCharacters(const std::string& outputName, const std::map>& countries) -{ - for (const auto& [tag, country]: countries) - { - if (country->getSubStates().empty()) - continue; - if (country->getProcessedData().characters.empty() && country->getProcessedData().vanillaCharacterElements.empty()) - continue; - - std::ofstream output("output/" + outputName + "/common/history/characters/00_" + tag + ".txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/characters/00_" + tag + ".txt"); - - output << commonItems::utf8BOM << "CHARACTERS = {\n"; - output << "\tc:" << tag << " = {\n"; - for (const auto& character: country->getProcessedData().characters) - { - outCharacter(output, character); - } - for (const auto& element: country->getProcessedData().vanillaCharacterElements) - { - output << "\t\t" << element << "\n"; - } - output << "\t}\n"; - output << "}\n"; - output.close(); - } -} diff --git a/EU5ToVic3/Source/Output/outCharacters/outCharacters.h b/EU5ToVic3/Source/Output/outCharacters/outCharacters.h deleted file mode 100644 index 1f4e83c..0000000 --- a/EU5ToVic3/Source/Output/outCharacters/outCharacters.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef OUT_CHARACTERS_H -#define OUT_CHARACTERS_H -#include "PoliticalManager/PoliticalManager.h" - -namespace OUT -{ -void exportCharacters(const std::string& outputName, const std::map>& countries); - -} // namespace OUT - -#endif // OUT_CHARACTERS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outCoAs/outCoAa.cpp b/EU5ToVic3/Source/Output/outCoAs/outCoAa.cpp deleted file mode 100644 index a2458b5..0000000 --- a/EU5ToVic3/Source/Output/outCoAs/outCoAa.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "outCoAa.h" -#include "CommonFunctions.h" -#include "PoliticalManager/Country/Country.h" -#include -#include - -namespace -{ -void outCustomCoAs(std::ostream& output, const V3::Country& country) -{ - for (const auto& customFlag: country.getProcessedData().customFlags | std::views::values) - { - output << customFlag << " = { textured_emblem = { texture = \"custom_export/" << customFlag << ".tga\" } }\n"; - } -} -} // namespace - -void OUT::exportCustomCoAs(const std::string& outputName, const std::map>& countries) -{ - std::ofstream output("output/" + outputName + "/common/coat_of_arms/coat_of_arms/99_custom_coas.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/coat_of_arms/coat_of_arms/99_custom_coas.txt"); - output << commonItems::utf8BOM << "\n"; - - for (const auto& country: countries | std::views::values) - { - if (country->getProcessedData().customFlags.empty()) - continue; - - outCustomCoAs(output, *country); - } - output.close(); -} diff --git a/EU5ToVic3/Source/Output/outCoAs/outCoAa.h b/EU5ToVic3/Source/Output/outCoAs/outCoAa.h deleted file mode 100644 index f55257e..0000000 --- a/EU5ToVic3/Source/Output/outCoAs/outCoAa.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef OUT_COAS_H -#define OUT_COAS_H -#include "PoliticalManager/PoliticalManager.h" - -namespace OUT -{ -void exportCustomCoAs(const std::string& outputName, const std::map>& countries); - -} // namespace OUT - -#endif // OUT_COAS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outCountries/outCountries.cpp b/EU5ToVic3/Source/Output/outCountries/outCountries.cpp deleted file mode 100644 index e3ced1d..0000000 --- a/EU5ToVic3/Source/Output/outCountries/outCountries.cpp +++ /dev/null @@ -1,199 +0,0 @@ -#include "outCountries.h" -#include "ClayManager/State/SubState.h" -#include "CommonFunctions.h" -#include -#include - -namespace -{ -void outMajorFormable(std::ostream& output, const std::string& tag, const V3::MajorFormablesEntry& formable) -{ - output << tag << " = {\n"; - for (const auto& stanza: formable.getStanzas()) - output << "\t" << stanza << "\n"; - output << "\tpossible = {\n"; - output << "\t\tOR = {\n"; - for (const auto& culture: formable.getCultures()) - output << "\t\t\tcountry_has_primary_culture = cu:" << culture << "\n"; - for (const auto& possibleStanza: formable.getPossibleStanzas()) - output << "\t\t" << possibleStanza << "\n"; - output << "\t\t}\n"; - output << "\t\tany_country = {\n"; - output << "\t\t\tOR = {\n"; - for (const auto& culture: formable.getCultures()) - output << "\t\t\t\tcountry_has_primary_culture = cu:" << culture << "\n"; - output << "\t\t\t}\n"; - output << "\t\t\thas_technology_researched = " << formable.getRequiredTechnology() << "\n"; - output << "\t\t}\n"; - output << "\t}\n"; - output << "}\n\n"; -} - -void outReleasableCountry(std::ostream& output, const V3::Country& country) -{ - output << country.getTag() << " = {\n"; - output << "\tprovinces = { "; - for (const auto& province: country.getUnownedProvinces()) - output << province << " "; - output << " }\n"; - output << "\tai_will_do = { always = no }\n"; - output << "}\n\n"; -} - -void outCommonCountry(std::ostream& output, const V3::Country& country) -{ - output << country.getTag() << " = {\n"; - - if (country.getProcessedData().color) - output << "\tcolor " << *country.getProcessedData().color << "\n"; - if (!country.getProcessedData().type.empty()) - output << "\tcountry_type = " << country.getProcessedData().type << "\n"; - if (!country.getProcessedData().tier.empty()) - output << "\ttier = " << country.getProcessedData().tier << "\n"; - if (!country.getProcessedData().cultures.empty()) - { - output << "\tcultures = { "; - for (const auto& culture: country.getProcessedData().cultures) - output << culture << " "; - output << "}\n"; - } - if (!country.getProcessedData().religion.empty()) - output << "\treligion = " << country.getProcessedData().religion << "\n"; - if (!country.getProcessedData().capitalStateName.empty()) - output << "\tcapital = " << country.getProcessedData().capitalStateName << "\n"; - if (country.getProcessedData().is_named_from_capital) - output << "\tis_named_from_capital = yes\n"; - - output << "}\n\n"; -} - -void outHistoryCountry(std::ostream& output, const V3::Country& country) -{ - output << "\tc:" << country.getTag() << " = {\n"; - for (const auto& tech: country.getProcessedData().techs) - output << "\t\tadd_technology_researched = " << tech << "\n"; - for (const auto& effect: country.getProcessedData().effects) - output << "\t\t" << effect << " = yes\n"; - for (const auto& law: country.getProcessedData().laws) - output << "\t\tactivate_law = law_type:" << law << "\n"; - if (!country.getProcessedData().ideaEffect.rulingInterestGroups.empty()) - { - output << "\t\tset_ruling_interest_groups = {\n\t\t\t"; - for (const auto& ig: country.getProcessedData().ideaEffect.rulingInterestGroups) - output << ig << " "; - output << "\n\t\t}\n"; - } - for (const auto& ig: country.getProcessedData().ideaEffect.boostedInterestGroups) - { - output << "\t\tig:" << ig << " = {\n"; - output << "\t\t\tset_ig_bolstering = yes\n "; - output << "\t\t}\n"; - } - for (const auto& ig: country.getProcessedData().ideaEffect.suppressedInterestGroups) - { - output << "\t\tig:" << ig << " = {\n"; - output << "\t\t\tset_ig_suppression = yes\n"; - output << "\t\t}\n"; - } - for (const auto& [ig, modifier]: country.getProcessedData().igIdeologyModifiers) - { - if (modifier.addedIdeologies.empty() && modifier.removedIdeologies.empty()) - continue; - output << "\t\tig:" << ig << " = {\n"; - for (const auto& ideology: modifier.removedIdeologies) - output << "\t\t\tremove_ideology = " << ideology << "\n "; - for (const auto& ideology: modifier.addedIdeologies) - output << "\t\t\tadd_ideology = " << ideology << "\n "; - output << "\t\t}\n"; - } - for (const auto& element: country.getProcessedData().vanillaHistoryElements) - { - output << "\t\t" << element << "\n"; - } - for (const auto& [institution, level]: country.getProcessedData().institutions) - { - output << "\t\tset_institution_investment_level = {\n"; - output << "\t\t\tinstitution = " << institution << "\n"; - output << "\t\t\tlevel = " << level << "\n"; - output << "\t\t}\n"; - } - output << "\t}\n"; -} - -void outHistoryPopulations(std::ostream& output, const V3::Country& country) -{ - output << "\tc:" << country.getTag() << " = {\n"; - for (const auto& effect: country.getProcessedData().populationEffects) - output << "\t\t" << effect << " = yes\n"; - for (const auto& element: country.getProcessedData().vanillaPopulationElements) - output << "\t\t" << element << "\n"; - output << "\t}\n"; -} - -} // namespace - -void OUT::exportCommonCountries(const std::string& outputName, const std::map>& countries) -{ - std::ofstream output("output/" + outputName + "/common/country_definitions/99_converted_countries.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/country_definitions/99_converted_countries.txt"); - - output << commonItems::utf8BOM; - for (const auto& country: countries | std::views::values) - outCommonCountry(output, *country); - output.close(); -} - -void OUT::exportHistoryCountries(const std::string& outputName, const std::map>& countries) -{ - std::ofstream output("output/" + outputName + "/common/history/countries/99_converted_countries.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/countries/99_converted_countries.txt"); - - output << commonItems::utf8BOM << "COUNTRIES = {\n"; - for (const auto& country: countries | std::views::values) - if (!country->getSubStates().empty()) - outHistoryCountry(output, *country); - output << "}\n"; - output.close(); -} - -void OUT::exportHistoryPopulations(const std::string& outputName, const std::map>& countries) -{ - std::ofstream output("output/" + outputName + "/common/history/population/99_converted_countries.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/population/99_converted_countries.txt"); - - output << commonItems::utf8BOM << "POPULATION = {\n"; - for (const auto& country: countries | std::views::values) - if (!country->getSubStates().empty() && - (!country->getProcessedData().populationEffects.empty() || !country->getProcessedData().vanillaPopulationElements.empty())) - outHistoryPopulations(output, *country); - output << "}\n"; - output.close(); -} - -void OUT::exportReleasables(const std::string& outputName, const std::map>& countries) -{ - std::ofstream output("output/" + outputName + "/common/country_creation/99_converted_releasables.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/country_creation/99_converted_releasables.txt"); - - output << commonItems::utf8BOM; - for (const auto& country: countries | std::views::values) - if (country->getSubStates().empty() && !country->getUnownedProvinces().empty()) - outReleasableCountry(output, *country); - output.close(); -} - -void OUT::exportMajorFormables(const std::string& outputName, const std::map& formables) -{ - std::ofstream output("output/" + outputName + "/common/country_formation/00_major_formables.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/country_formation/00_major_formables.txt"); - - output << commonItems::utf8BOM; - for (const auto& [tag, formable]: formables) - outMajorFormable(output, tag, formable); - output.close(); -} diff --git a/EU5ToVic3/Source/Output/outCountries/outCountries.h b/EU5ToVic3/Source/Output/outCountries/outCountries.h deleted file mode 100644 index 3178647..0000000 --- a/EU5ToVic3/Source/Output/outCountries/outCountries.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef OUT_COMMON_COUNTRIES_H -#define OUT_COMMON_COUNTRIES_H -#include "Loaders/MajorFormablesLoader/MajorFormablesEntry.h" -#include "PoliticalManager/Country/Country.h" - -namespace OUT -{ -void exportCommonCountries(const std::string& outputName, const std::map>& countries); -void exportHistoryCountries(const std::string& outputName, const std::map>& countries); -void exportHistoryPopulations(const std::string& outputName, const std::map>& countries); -void exportReleasables(const std::string& outputName, const std::map>& countries); -void exportMajorFormables(const std::string& outputName, const std::map& formables); - -} // namespace OUT - -#endif // OUT_COMMON_COUNTRIES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outCultures/outCultures.cpp b/EU5ToVic3/Source/Output/outCultures/outCultures.cpp deleted file mode 100644 index 896be25..0000000 --- a/EU5ToVic3/Source/Output/outCultures/outCultures.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "outCultures.h" -#include "CommonFunctions.h" -#include -#include - -namespace -{ -void outCulture(std::ostream& output, const mappers::CultureDef& culture) -{ - output << culture.name << " = {\n"; - if (culture.color) - output << "\tcolor " << *culture.color << "\n"; - if (!culture.religion.empty()) - output << "\treligion = \"" << culture.religion << "\"\n"; - if (!culture.traits.empty()) - { - output << "\ttraits = { "; - for (const auto& trait: culture.traits) - output << trait << " "; - output << "}\n"; - } - if (!culture.maleCommonFirstNames.empty()) - { - output << "\tmale_common_first_names = { "; - for (const auto& name: culture.maleCommonFirstNames) - output << name << " "; - output << "}\n"; - } - if (!culture.femaleCommonFirstNames.empty()) - { - output << "\tfemale_common_first_names = { "; - for (const auto& name: culture.femaleCommonFirstNames) - output << name << " "; - output << "}\n"; - } - if (!culture.nobleLastNames.empty()) - { - output << "\tnoble_last_names = { "; - for (const auto& name: culture.nobleLastNames) - output << name << " "; - output << "}\n"; - } - if (!culture.commonLastNames.empty()) - { - output << "\tcommon_last_names = { "; - for (const auto& name: culture.commonLastNames) - output << name << " "; - output << "}\n"; - } - if (!culture.maleRegalFirstNames.empty()) - { - output << "\tmale_regal_first_names = { "; - for (const auto& name: culture.maleRegalFirstNames) - output << name << " "; - output << "}\n"; - } - if (!culture.femaleRegalFirstNames.empty()) - { - output << "\tfemale_regal_first_names = { "; - for (const auto& name: culture.femaleRegalFirstNames) - output << name << " "; - output << "}\n"; - } - if (!culture.regalLastNames.empty()) - { - output << "\tregal_last_names = { "; - for (const auto& name: culture.regalLastNames) - output << name << " "; - output << "}\n"; - } - if (!culture.ethnicities.empty()) - { - output << "\tethnicities = {\n"; - auto counter = 1; - for (const auto& ethnicity: culture.ethnicities) - output << "\t\t" << counter++ << " = " << ethnicity << "\n"; - output << "\t}\n"; - } - if (!culture.graphics.empty()) - output << "\tgraphics = " << culture.graphics << "\n"; - output << "}\n\n"; -} -} // namespace - -void OUT::exportCultures(const std::string& outputName, const std::map& cultures) -{ - std::ofstream output("output/" + outputName + "/common/cultures/99_converted_cultures.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/religions/99_converted_cultures.txt"); - - output << commonItems::utf8BOM << "\n"; - for (const auto& culture: cultures | std::views::values) - { - if (culture.skipExport) - continue; - outCulture(output, culture); - } - output << "\n"; - output.close(); - - // Copy over Decentralized World discrimination traits - auto files = commonItems::GetAllFilesInFolder("configurables/decentralized_world/common/discrimination_traits/"); - for (const auto& file: files) - commonItems::TryCopyFile("configurables/decentralized_world/common/discrimination_traits/" + file, - "output/" + outputName + "/common/discrimination_traits/" + file); -} diff --git a/EU5ToVic3/Source/Output/outCultures/outCultures.h b/EU5ToVic3/Source/Output/outCultures/outCultures.h deleted file mode 100644 index c0d2ce3..0000000 --- a/EU5ToVic3/Source/Output/outCultures/outCultures.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef OUT_CULTURES_H -#define OUT_CULTURES_H -#include "CultureMapper/CultureDefinitionLoader/CultureDef.h" - -namespace OUT -{ -void exportCultures(const std::string& outputName, const std::map& cultures); - -} // namespace OUT - -#endif // OUT_CULTURES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outDiplomacy/outDiplomacy.cpp b/EU5ToVic3/Source/Output/outDiplomacy/outDiplomacy.cpp deleted file mode 100644 index 21b958f..0000000 --- a/EU5ToVic3/Source/Output/outDiplomacy/outDiplomacy.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include "outDiplomacy.h" -#include "CommonFunctions.h" -#include "PoliticalManager/Country/Country.h" -#include -#include - -namespace -{ -void outAgreement(std::ostream& output, const V3::Agreement& agreement) -{ - output << "\tc:" << agreement.first << " = {\n"; - output << "\t\tcreate_diplomatic_pact = {\n"; - output << "\t\t\tcountry = c:" << agreement.second << "\n"; - output << "\t\t\ttype = " << agreement.type << "\n"; - output << "\t\t}\n"; - output << "\t}\n"; -} - -void outCountryRelations(std::ostream& output, const std::string& tag, const std::map& relations) -{ - output << "\tc:" << tag << " = {\n"; - for (const auto& [target, relation]: relations) - output << "\t\tset_relations = { country = c:" << target << " value = " << relation.getRelations() << " }\n"; - output << "\t}\n"; -} - -void outCountryRivals(std::ostream& output, const std::string& tag, const std::set& rivals) -{ - output << "\tc:" << tag << " = {\n"; - for (const auto& rival: rivals) - { - output << "\t\tcreate_diplomatic_pact = {\n"; - output << "\t\t\tcountry = c:" << rival << "\n"; - output << "\t\t\ttype = rivalry\n"; - output << "\t\t}\n"; - } - output << "\t}\n"; -} - -void outCountryTruces(std::ostream& output, const std::string& tag, const std::map& truces) -{ - output << "\tc:" << tag << " = {\n"; - for (const auto& [target, duration]: truces) - { - output << "\t\tcreate_truce = {\n"; - output << "\t\t\tcountry = c:" << target << "\n"; - output << "\t\t\tmonths = " << duration << "\n"; - output << "\t\t}\n"; - } - output << "\t}\n"; -} - -} // namespace - -void OUT::exportDiplomacy(const std::string& outputName, const V3::PoliticalManager& politicalManager) -{ - exportPacts(outputName, politicalManager.getAgreements()); - exportRelations(outputName, politicalManager.getCountries()); - exportRivals(outputName, politicalManager.getCountries()); - exportTruces(outputName, politicalManager.getCountries()); -} - -void OUT::exportPacts(const std::string& outputName, const std::vector& agreements) -{ - std::ofstream defensivePacts("output/" + outputName + "/common/history/diplomacy/00_defensive_pacts.txt"); - if (!defensivePacts.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/diplomacy/00_defensive_pacts.txt"); - std::ofstream subjects("output/" + outputName + "/common/history/diplomacy/00_subject_relationships.txt"); - if (!subjects.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/diplomacy/00_subject_relationships.txt"); - std::ofstream trades("output/" + outputName + "/common/history/diplomacy/00_trade_agreement.txt"); - if (!trades.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/00_trade_agreement.txt"); - std::ofstream customs("output/" + outputName + "/common/history/diplomacy/00_customs_union.txt"); - if (!customs.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/diplomacy/00_customs_union.txt"); - std::ofstream rivals("output/" + outputName + "/common/history/diplomacy/00_additional_rivalries.txt"); - if (!rivals.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/diplomacy/00_additional_rivalries.txt"); - - defensivePacts << commonItems::utf8BOM << "DIPLOMACY = {\n"; - subjects << commonItems::utf8BOM << "DIPLOMACY = {\n"; - trades << commonItems::utf8BOM << "DIPLOMACY = {\n"; - customs << commonItems::utf8BOM << "DIPLOMACY = {\n"; - rivals << commonItems::utf8BOM << "DIPLOMACY = {\n"; - - for (const auto& agreement: agreements) - { - if (agreement.type == "defensive_pact") - outAgreement(defensivePacts, agreement); - else if (agreement.type == "trade_agreement") - outAgreement(trades, agreement); - else if (agreement.type == "customs_union") - outAgreement(customs, agreement); - else if (agreement.type == "rivalry") // VN-imported rivalries are agreements, not country-bound rivalries, so they end up here. - outAgreement(rivals, agreement); - else - outAgreement(subjects, agreement); - } - - defensivePacts << "}\n"; - subjects << "}\n"; - trades << "}\n"; - customs << "}\n"; - rivals << "}\n"; - defensivePacts.close(); - subjects.close(); - trades.close(); - customs.close(); - rivals.close(); -} - -void OUT::exportRelations(const std::string& outputName, const std::map>& countries) -{ - std::ofstream relations("output/" + outputName + "/common/history/diplomacy/00_relations.txt"); - if (!relations.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/diplomacy/00_relations.txt"); - - relations << commonItems::utf8BOM << "DIPLOMACY = {\n"; - for (const auto& country: countries | std::views::values) - if (!country->getRelations().empty()) - outCountryRelations(relations, country->getTag(), country->getRelations()); - - relations << "}\n"; - relations.close(); -} - -void OUT::exportRivals(const std::string& outputName, const std::map>& countries) -{ - std::ofstream rivals("output/" + outputName + "/common/history/diplomacy/00_rivalries.txt"); - if (!rivals.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/diplomacy/00_rivalries.txt"); - - rivals << commonItems::utf8BOM << "DIPLOMACY = {\n"; - for (const auto& country: countries | std::views::values) - if (!country->getRivals().empty()) - outCountryRivals(rivals, country->getTag(), country->getRivals()); - - rivals << "}\n"; - rivals.close(); -} - -void OUT::exportTruces(const std::string& outputName, const std::map>& countries) -{ - std::ofstream truces("output/" + outputName + "/common/history/diplomacy/00_truces.txt"); - if (!truces.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/diplomacy/00_truces.txt"); - - truces << commonItems::utf8BOM << "DIPLOMACY = {\n"; - for (const auto& country: countries | std::views::values) - if (!country->getTruces().empty()) - outCountryTruces(truces, country->getTag(), country->getTruces()); - - truces << "}\n"; - truces.close(); -} diff --git a/EU5ToVic3/Source/Output/outDiplomacy/outDiplomacy.h b/EU5ToVic3/Source/Output/outDiplomacy/outDiplomacy.h deleted file mode 100644 index cb019f6..0000000 --- a/EU5ToVic3/Source/Output/outDiplomacy/outDiplomacy.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef OUT_DIPLOMACY_H -#define OUT_DIPLOMACY_H -#include "PoliticalManager/PoliticalManager.h" - -namespace OUT -{ -void exportDiplomacy(const std::string& outputName, const V3::PoliticalManager& politicalManager); -void exportPacts(const std::string& outputName, const std::vector& agreements); -void exportRelations(const std::string& outputName, const std::map>& countries); -void exportRivals(const std::string& outputName, const std::map>& countries); -void exportTruces(const std::string& outputName, const std::map>& countries); -} // namespace OUT - -#endif // OUT_DIPLOMACY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outDiplomaticPlays/outDiplomaticPlays.cpp b/EU5ToVic3/Source/Output/outDiplomaticPlays/outDiplomaticPlays.cpp deleted file mode 100644 index f19b7b7..0000000 --- a/EU5ToVic3/Source/Output/outDiplomaticPlays/outDiplomaticPlays.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "outDiplomaticPlays/outDiplomaticPlays.h" -#include "CommonFunctions.h" -#include "PoliticalManager/Country/Country.h" -#include -#include - -void OUT::exportDiplomaticPlays(const std::string& outputName, const std::map>& countries) -{ - for (const auto& [tag, country]: countries) - { - if (country->getProcessedData().vanillaDiplomaticPlayElements.empty()) - continue; - - std::ofstream output("output/" + outputName + "/common/history/diplomatic_plays/00_" + tag + ".txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/diplomatic_plays/00_" + tag + ".txt"); - - output << commonItems::utf8BOM << "DIPLOMATIC_PLAYS = {\n"; - output << "\tc:" << tag << " = {\n"; - for (const auto& element: country->getProcessedData().vanillaDiplomaticPlayElements) - { - output << "\t\t" << element << "\n"; - } - output << "\t}\n"; - output << "}\n"; - output.close(); - } -} diff --git a/EU5ToVic3/Source/Output/outDiplomaticPlays/outDiplomaticPlays.h b/EU5ToVic3/Source/Output/outDiplomaticPlays/outDiplomaticPlays.h deleted file mode 100644 index 7ec7fe4..0000000 --- a/EU5ToVic3/Source/Output/outDiplomaticPlays/outDiplomaticPlays.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef OUT_DIPLOMATIC_PLAYS_H -#define OUT_DIPLOMATIC_PLAYS_H -#include "PoliticalManager/PoliticalManager.h" - -namespace OUT -{ -void exportDiplomaticPlays(const std::string& outputName, const std::map>& countries); - -} // namespace OUT - -#endif // OUT_DIPLOMATIC_PLAYS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outFlagDefinitions/outFlagDefinitions.cpp b/EU5ToVic3/Source/Output/outFlagDefinitions/outFlagDefinitions.cpp deleted file mode 100644 index 49542a4..0000000 --- a/EU5ToVic3/Source/Output/outFlagDefinitions/outFlagDefinitions.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "outFlagDefinitions.h" -#include "CommonFunctions.h" -#include "PoliticalManager/Country/Country.h" -#include -#include - -namespace -{ -void outFlagDefinitions(std::ostream& output, const std::string& tag, const V3::Country& country) -{ - output << tag << " = {\n"; - for (const auto& [flagType, coaCode]: country.getProcessedData().flags) - { - output << "\tflag_definition = {\n"; - output << "\t\tcoa = " << coaCode << "\n"; - output << "\t\tallow_overlord_canton = yes\n"; - - if (flagType == V3::FlagCrafter::Default) - { - output << "\t\tsubject_canton = " << coaCode << "\n"; - output << "\t\tpriority = 1\n"; - } - else if (flagType == V3::FlagCrafter::Republic) - { - output << "\t\tpriority = 10\n"; - output << "\t\tsubject_canton = " << coaCode << "\n"; - output << "\t\ttrigger = { coa_def_republic_flag_trigger = yes }\n"; - } - else if (flagType == V3::FlagCrafter::Monarchy) - { - output << "\t\tpriority = 20\n"; - output << "\t\tsubject_canton = " << coaCode << "\n"; - output << "\t\toverlord_canton_scale = { 0.337 0.337 }\n"; - output << "\t\ttrigger = { coa_def_absolute_monarchy_flag_trigger = yes }\n"; - } - else if (flagType == V3::FlagCrafter::Communist) - { - output << "\t\tpriority = 1500\n"; - output << "\t\ttrigger = { coa_def_communist_flag_trigger = yes }\n"; - } - else if (flagType == V3::FlagCrafter::Fascist) - { - output << "\t\tpriority = 1500\n"; - output << "\t\tsubject_canton = " << coaCode << "\n"; - output << "\t\ttrigger = { coa_def_fascist_flag_trigger = yes }\n"; - } - output << "\t}\n"; - } - output << "}\n"; -} -} // namespace - -void OUT::exportFlagDefinitions(const std::string& outputName, const std::map>& countries) -{ - std::ofstream output("output/" + outputName + "/common/flag_definitions/99_converter_flag_definitions.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/flag_definitions/99_converter_flag_definitions.txt"); - output << commonItems::utf8BOM << "\n"; - - for (const auto& [tag, country]: countries) - { - if (country->getProcessedData().flags.empty()) - continue; - - outFlagDefinitions(output, tag, *country); - } - output.close(); -} diff --git a/EU5ToVic3/Source/Output/outFlagDefinitions/outFlagDefinitions.h b/EU5ToVic3/Source/Output/outFlagDefinitions/outFlagDefinitions.h deleted file mode 100644 index af5275c..0000000 --- a/EU5ToVic3/Source/Output/outFlagDefinitions/outFlagDefinitions.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef OUT_FLAG_DEFINITIONS_H -#define OUT_FLAG_DEFINITIONS_H -#include "PoliticalManager/PoliticalManager.h" - -namespace OUT -{ -void exportFlagDefinitions(const std::string& outputName, const std::map>& countries); - -} // namespace OUT - -#endif // OUT_CHARACTERS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outLocalizations/outLocalizations.cpp b/EU5ToVic3/Source/Output/outLocalizations/outLocalizations.cpp deleted file mode 100644 index 731230d..0000000 --- a/EU5ToVic3/Source/Output/outLocalizations/outLocalizations.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#include "outLocalizations.h" -#include "CommonFunctions.h" -#include "Loaders/LocLoader/LocalizationLoader.h" -#include -#include - -void OUT::exportCountryNamesAndAdjectives(const std::string& outputName, - const std::map>& countries, - const V3::LocalizationLoader& knownLocs) -{ - const std::set knownVic3Localizations = - {"braz_por", "english", "french", "german", "japanese", "korean", "polish", "russian", "simp_chinese", "spanish", "turkish"}; - - for (const auto& language: knownVic3Localizations) - { - std::ofstream output("output/" + outputName + "/localization/" + language + "/replace/converted_countries_l_" + language + ".yml"); - if (!output.is_open()) - throw std::runtime_error("output/" + outputName + "/localization/" + language + "/replace/converted_countries_l_" + language + ".yml"); - - output << commonItems::utf8BOM << "l_" << language << ":\n"; - for (const auto& country: countries | std::views::values) - { - if (!knownLocs.getLocMapForKey(country->getTag())) - output << " " << country->getTag() << ": \"" << country->getName(language) << "\"\n"; - if (!knownLocs.getLocMapForKey(country->getTag() + "_ADJ")) - output << " " << country->getTag() << "_ADJ: \"" << country->getAdjective(language) << "\"\n"; - } - output.close(); - } -} - -void OUT::exportCharacterLocs(const std::string& outputName, - const std::map>& countries, - const V3::LocalizationLoader& knownLocs) -{ - const std::set knownVic3Localizations = - {"braz_por", "english", "french", "german", "japanese", "korean", "polish", "russian", "simp_chinese", "spanish", "turkish"}; - - for (const auto& language: knownVic3Localizations) - { - std::ofstream output("output/" + outputName + "/localization/" + language + "/replace/converted_characters_l_" + language + ".yml"); - if (!output.is_open()) - throw std::runtime_error("output/" + outputName + "/localization/" + language + "/replace/converted_characters_l_" + language + ".yml"); - - std::set exportedKeys; - output << commonItems::utf8BOM << "l_" << language << ":\n"; - for (const auto& country: countries | std::views::values) - for (const auto& character: country->getProcessedData().characters) - for (const auto& [key, loc]: character.localizations) - if (!knownLocs.getLocMapForKey(key) && !exportedKeys.contains(key)) - { - output << " " << key << ": \"" << loc << "\"\n"; - exportedKeys.emplace(key); - } - output.close(); - } -} - -void OUT::exportReligionLocs(const std::string& outputName, - const std::map& religions, - const V3::LocalizationLoader& knownLocs) -{ - const std::set knownVic3Localizations = - {"braz_por", "english", "french", "german", "japanese", "korean", "polish", "russian", "simp_chinese", "spanish", "turkish"}; - - for (const auto& language: knownVic3Localizations) - { - std::ofstream output("output/" + outputName + "/localization/" + language + "/replace/99_converted_religions_l_" + language + ".yml"); - if (!output.is_open()) - throw std::runtime_error("output/" + outputName + "/localization/" + language + "/replace/99_converted_religions_l_" + language + ".yml"); - - output << commonItems::utf8BOM << "l_" << language << ":\n"; - for (const auto& religion: religions | std::views::values) - { - if (!knownLocs.getLocMapForKey(religion.name)) - { - if (religion.locBlock.contains(language)) - output << " " << religion.name << ": \"" << religion.locBlock.at(language) << "\"\n"; - else if (religion.locBlock.contains("english")) - output << " " << religion.name << ": \"" << religion.locBlock.at("english") << "\"\n"; - } - } - output.close(); - } -} - -void OUT::exportCultureLocs(const std::string& outputName, const std::map& cultures, const V3::LocalizationLoader& knownLocs) -{ - const std::set knownVic3Localizations = - {"braz_por", "english", "french", "german", "japanese", "korean", "polish", "russian", "simp_chinese", "spanish", "turkish"}; - - for (const auto& language: knownVic3Localizations) - { - std::ofstream output("output/" + outputName + "/localization/" + language + "/replace/99_converted_cultures_l_" + language + ".yml"); - if (!output.is_open()) - throw std::runtime_error("output/" + outputName + "/localization/" + language + "/replace/99_converted_cultures_l_" + language + ".yml"); - std::ofstream names("output/" + outputName + "/localization/" + language + "/replace/names/dw_converted_culture_names_l_" + language + ".yml"); - if (!names.is_open()) - throw std::runtime_error("output/" + outputName + "/localization/" + language + "/replace/names/dw_converted_culture_names_l_" + language + ".yml"); - - std::set seenNames; - - output << commonItems::utf8BOM << "l_" << language << ":\n"; - names << commonItems::utf8BOM << "l_" << language << ":\n"; - for (const auto& culture: cultures | std::views::values) - { - if (!knownLocs.getLocMapForKey(culture.name)) - { - if (culture.locBlock.contains(language)) - output << " " << culture.name << ": \"" << culture.locBlock.at(language) << "\"\n"; - else if (culture.locBlock.contains("english")) - output << " " << culture.name << ": \"" << culture.locBlock.at("english") << "\"\n"; - } - for (const auto& [name, locName]: culture.nameLocBlock) - { - if (!seenNames.contains(name) && !knownLocs.getLocMapForKey(name)) - { - names << " " << name << ": \"" << locName << "\"\n"; - seenNames.emplace(name); - } - } - } - output.close(); - } -} diff --git a/EU5ToVic3/Source/Output/outLocalizations/outLocalizations.h b/EU5ToVic3/Source/Output/outLocalizations/outLocalizations.h deleted file mode 100644 index ec441ae..0000000 --- a/EU5ToVic3/Source/Output/outLocalizations/outLocalizations.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef OUT_LOCALIZATIONS_H -#define OUT_LOCALIZATIONS_H -#include "CultureMapper/CultureDefinitionLoader/CultureDef.h" -#include "PoliticalManager/Country/Country.h" -#include "ReligionMapper/ReligionDefinitionLoader/ReligionDef.h" - -namespace OUT -{ -void exportCountryNamesAndAdjectives(const std::string& outputName, - const std::map>& countries, - const V3::LocalizationLoader& knownLocs); -void exportReligionLocs(const std::string& outputName, const std::map& religions, const V3::LocalizationLoader& knownLocs); -void exportCultureLocs(const std::string& outputName, const std::map& cultures, const V3::LocalizationLoader& knownLocs); -void exportCharacterLocs(const std::string& outputName, - const std::map>& countries, - const V3::LocalizationLoader& knownLocs); - -} // namespace OUT - -#endif // OUT_LOCALIZATIONS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outPops/outPops.cpp b/EU5ToVic3/Source/Output/outPops/outPops.cpp deleted file mode 100644 index 647a74a..0000000 --- a/EU5ToVic3/Source/Output/outPops/outPops.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "outPops.h" -#include "ClayManager/State/SubState.h" -#include "CommonFunctions.h" -#include "PoliticalManager/Country/Country.h" -#include -#include - -namespace -{ -void outPop(std::ostream& output, const V3::Pop& pop) -{ - if (pop.getSize() <= 0) - return; - output << "\t\t\tcreate_pop = {\n"; - if (!pop.getCulture().empty()) - output << "\t\t\t\tculture = " << pop.getCulture() << "\n"; - if (!pop.getReligion().empty()) - output << "\t\t\t\treligion = " << pop.getReligion() << "\n"; - if (!pop.getType().empty()) - output << "\t\t\t\tpop_type = " << pop.getType() << "\n"; - output << "\t\t\t\tsize = " << pop.getSize() << "\n"; - output << "\t\t\t}\n"; -} -void outSubStatePops(std::ostream& output, const V3::SubState& subState) -{ - if (!subState.getOwner()) - return; - output << "\t\tregion_state:" << subState.getOwner()->getTag() << " = {\n"; - for (const auto& pop: subState.getSubStatePops().getPops()) - { - if (pop.getSize() == 0) - continue; - outPop(output, pop); - } - output << "\t\t}\n"; -} - -void outStatePops(std::ostream& output, const V3::State& state) -{ - output << "\ts:" << state.getName() << " = {\n"; - for (const auto& substate: state.getSubStates()) - { - if (substate->getSubStatePops().getPopCount() == 0) - continue; - outSubStatePops(output, *substate); - } - output << "\t}\n"; -} -} // namespace - -void OUT::exportPops(const std::string& outputName, const std::map>& states) -{ - std::ofstream output("output/" + outputName + "/common/history/pops/99_converted_pops.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/pops/99_converted_pops.txt"); - - output << commonItems::utf8BOM << "POPS = {\n"; - for (const auto& state: states | std::views::values) - { - if (state->getStatePopCount() == 0) - continue; - outStatePops(output, *state); - } - output << "}\n"; - output.close(); -} diff --git a/EU5ToVic3/Source/Output/outPops/outPops.h b/EU5ToVic3/Source/Output/outPops/outPops.h deleted file mode 100644 index edd6735..0000000 --- a/EU5ToVic3/Source/Output/outPops/outPops.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef OUT_POPS_H -#define OUT_POPS_H -#include "ClayManager/State/State.h" - -namespace OUT -{ -void exportPops(const std::string& outputName, const std::map>& states); - -} // namespace OUT - -#endif // OUT_POPS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outReligions/outReligions.cpp b/EU5ToVic3/Source/Output/outReligions/outReligions.cpp deleted file mode 100644 index bcaee7d..0000000 --- a/EU5ToVic3/Source/Output/outReligions/outReligions.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "outReligions.h" -#include "CommonFunctions.h" -#include -#include - -namespace -{ -void outReligion(std::ostream& output, const mappers::ReligionDef& religion) -{ - output << religion.name << " = {\n"; - if (!religion.texture.empty()) - output << "\ttexture = \"" << religion.texture << "\"\n"; - if (!religion.traits.empty()) - { - output << "\ttraits = { "; - for (const auto& trait: religion.traits) - output << trait << " "; - output << "}\n"; - } - if (religion.color) - output << "\tcolor " << *religion.color << "\n"; - if (!religion.taboos.empty()) - { - output << "\ttaboos = { "; - for (const auto& taboo: religion.taboos) - output << taboo << " "; - output << "}\n"; - } - output << "}\n"; -} -} // namespace - -void OUT::exportReligions(const std::string& outputName, const std::map& religions) -{ - std::ofstream output("output/" + outputName + "/common/religions/99_converted_religions.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/religions/99_converted_religions.txt"); - - output << commonItems::utf8BOM << "\n"; - for (const auto& religion: religions | std::views::values) - { - outReligion(output, religion); - } - output << "\n"; - output.close(); -} diff --git a/EU5ToVic3/Source/Output/outReligions/outReligions.h b/EU5ToVic3/Source/Output/outReligions/outReligions.h deleted file mode 100644 index 2a675a5..0000000 --- a/EU5ToVic3/Source/Output/outReligions/outReligions.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef OUT_RELIGIONS_H -#define OUT_RELIGIONS_H -#include "ReligionMapper/ReligionDefinitionLoader/ReligionDef.h" - -namespace OUT -{ -void exportReligions(const std::string& outputName, const std::map& religions); - -} // namespace OUT - -#endif // OUT_RELIGIONS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outSecretGoals/outSecretGoals.cpp b/EU5ToVic3/Source/Output/outSecretGoals/outSecretGoals.cpp deleted file mode 100644 index 3e0b7e4..0000000 --- a/EU5ToVic3/Source/Output/outSecretGoals/outSecretGoals.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "outSecretGoals.h" -#include "CommonFunctions.h" -#include -#include - -namespace -{ -void outSecretGoals(std::ostream& output, const std::map>& countries) -{ - output << "AI = {\n"; - for (const auto& country: countries | std::views::values) - { - if (country->getProcessedData().targetSecretGoals.empty()) - continue; - - output << "\tc:" << country->getTag() << " = {\n"; - for (const auto& [target, goal]: country->getProcessedData().targetSecretGoals) - { - output << "\t\tset_secret_goal = {\n"; - output << "\t\t\tcountry = c:" << target << "\n"; - output << "\t\t\tsecret_goal = " << goal << "\n"; - output << "\t\t}\n"; - } - - output << "\t}\n"; - } - output << "}\n"; -} -} // namespace - -void OUT::exportSecretGoals(const std::string& outputName, const std::map>& countries) -{ - std::ofstream output("output/" + outputName + "/common/history/ai/99_converter_secret_goals.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/ai/99_converter_secret_goals.txt"); - - output << commonItems::utf8BOM; - outSecretGoals(output, countries); - output.close(); -} diff --git a/EU5ToVic3/Source/Output/outSecretGoals/outSecretGoals.h b/EU5ToVic3/Source/Output/outSecretGoals/outSecretGoals.h deleted file mode 100644 index c4a13d5..0000000 --- a/EU5ToVic3/Source/Output/outSecretGoals/outSecretGoals.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef OUT_SECRET_GOALS_H -#define OUT_SECRET_GOALS_H -#include "PoliticalManager/Country/Country.h" - -namespace OUT -{ -void exportSecretGoals(const std::string& outputName, const std::map>& countries); - -} // namespace OUT - -#endif // OUT_SECRET_GOALS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outStates/outCommonHistoryStates.cpp b/EU5ToVic3/Source/Output/outStates/outCommonHistoryStates.cpp deleted file mode 100644 index 633b88b..0000000 --- a/EU5ToVic3/Source/Output/outStates/outCommonHistoryStates.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "outCommonHistoryStates.h" -#include "ClayManager/State/SubState.h" -#include "CommonFunctions.h" -#include -#include - -namespace -{ -void outSubState(std::ostream& output, const V3::SubState& substate) -{ - if (!substate.getOwnerTag()) - return; // Can't craft a state without an owner. - - output << "\t\tcreate_state = {\n"; - output << "\t\t\tcountry = c:" << *substate.getOwnerTag() << "\n"; - output << "\t\t\towned_provinces = { "; - for (const auto& provinceID: substate.getProvinces() | std::views::keys) - output << provinceID << " "; - output << "}\n"; - for (const auto& stateType: substate.getSubStateTypes()) - output << "\t\t\tstate_type = " << stateType << "\n"; - - output << "\t\t}\n"; -} - -void outState(std::ostream& output, const V3::State& state) -{ - output << "\ts:" << state.getName() << " = {\n"; - for (const auto& substate: state.getSubStates()) - outSubState(output, *substate); - for (const auto& homeLand: state.getHomelands()) - output << "\t\tadd_homeland = cu:" << homeLand << "\n"; - for (const auto& tag: state.getClaims()) - output << "\t\tadd_claim = c:" << tag << "\n"; - - output << "\t}\n"; -} - -void outCommonHistoryStates(std::ostream& output, const std::map>& states) -{ - output << "STATES = {\n"; - for (const auto& state: states | std::views::values) - if (!state->getSubStates().empty()) // states without substates aren't politically interesting. - outState(output, *state); - output << "}\n"; -} -} // namespace - -void OUT::exportCommonHistoryStates(const std::string& outputName, const std::map>& states) -{ - std::ofstream output("output/" + outputName + "/common/history/states/99_converter_states.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/states/99_converter_states.txt"); - - output << commonItems::utf8BOM; - outCommonHistoryStates(output, states); - output.close(); -} diff --git a/EU5ToVic3/Source/Output/outStates/outCommonHistoryStates.h b/EU5ToVic3/Source/Output/outStates/outCommonHistoryStates.h deleted file mode 100644 index ebec508..0000000 --- a/EU5ToVic3/Source/Output/outStates/outCommonHistoryStates.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef OUT_COMMON_HISTORY_STATES_H -#define OUT_COMMON_HISTORY_STATES_H -#include "ClayManager/State/State.h" - -namespace OUT -{ -void exportCommonHistoryStates(const std::string& outputName, const std::map>& states); - -} // namespace OUT - -#endif // OUT_COMMON_HISTORY_STATES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outStrategies/outStrategies.cpp b/EU5ToVic3/Source/Output/outStrategies/outStrategies.cpp deleted file mode 100644 index 870a5c3..0000000 --- a/EU5ToVic3/Source/Output/outStrategies/outStrategies.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "outStrategies.h" -#include "CommonFunctions.h" -#include -#include - -namespace -{ -void outCountryStrategies(std::ostream& output, const std::map& strategies) -{ - - if (strategies.empty()) - return; - if (strategies.size() == 1) - { - output << "\t\tset_strategy = " << strategies.begin()->first << "\n"; - } - else - { - output << "\t\trandom_list = {\n"; - - for (const auto& [strategy, value]: strategies) - output << "\t\t\t" << value << " = { set_strategy = " << strategy << " }\n"; - - output << "\t\t}\n"; - } -} - -void outStrategies(std::ostream& output, const std::map>& countries) -{ - output << "AI = {\n"; - for (const auto& country: countries | std::views::values) - { - if (country->getProcessedData().admStrategies.empty() && country->getProcessedData().dipStrategies.empty() && - country->getProcessedData().polStrategies.empty()) - continue; - - output << "\tc:" << country->getTag() << " = {\n"; - outCountryStrategies(output, country->getProcessedData().admStrategies); - outCountryStrategies(output, country->getProcessedData().dipStrategies); - outCountryStrategies(output, country->getProcessedData().polStrategies); - output << "\t}\n"; - } - output << "}\n"; -} -} // namespace - -void OUT::exportStrategies(const std::string& outputName, const std::map>& countries) -{ - std::ofstream output("output/" + outputName + "/common/history/ai/99_converter_strategy.txt"); - if (!output.is_open()) - throw std::runtime_error("Could not create " + outputName + "/common/history/ai/99_converter_strategy.txt"); - - output << commonItems::utf8BOM; - outStrategies(output, countries); - output.close(); -} diff --git a/EU5ToVic3/Source/Output/outStrategies/outStrategies.h b/EU5ToVic3/Source/Output/outStrategies/outStrategies.h deleted file mode 100644 index d8563b3..0000000 --- a/EU5ToVic3/Source/Output/outStrategies/outStrategies.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef OUT_STRATEGIES_H -#define OUT_STRATEGIES_H -#include "PoliticalManager/Country/Country.h" - -namespace OUT -{ -void exportStrategies(const std::string& outputName, const std::map>& countries); - -} // namespace OUT - -#endif // OUT_STRATEGIES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/Output/outWorld.cpp b/EU5ToVic3/Source/Output/outWorld.cpp index dd8d39a..0de3923 100644 --- a/EU5ToVic3/Source/Output/outWorld.cpp +++ b/EU5ToVic3/Source/Output/outWorld.cpp @@ -1,27 +1,12 @@ #include "outWorld.h" #include "CommonFunctions.h" #include "OSCompatibilityLayer.h" -#include "outBuildings/outBuildings.h" -#include "outCharacters/outCharacters.h" -#include "outCoAs/outCoAa.h" -#include "outCountries/outCountries.h" -#include "outCultures/outCultures.h" -#include "outDiplomacy/outDiplomacy.h" -#include "outDiplomaticPlays/outDiplomaticPlays.h" -#include "outFlagDefinitions/outFlagDefinitions.h" -#include "outLocalizations/outLocalizations.h" #include "outMetadataFile/outMetadataFile.h" -#include "outPops/outPops.h" -#include "outReligions/outReligions.h" -#include "outSecretGoals/outSecretGoals.h" -#include "outStates/outCommonHistoryStates.h" -#include "outStrategies/outStrategies.h" #include void OUT::exportWorld(const Configuration& configuration, const V3::World& world, const commonItems::ConverterVersion& converterVersion) { const auto& outputName = configuration.getOutputName(); - const auto& knownLocs = world.getVanillaLocalizations(); Log(LogLevel::Info) << "---> Le Dump <---"; commonItems::TryCreateFolder("output"); @@ -56,64 +41,43 @@ void OUT::exportWorld(const Configuration& configuration, const V3::World& world Log(LogLevel::Progress) << "86 %"; Log(LogLevel::Info) << "<- Dumping common/history/states"; - exportCommonHistoryStates(outputName, world.getClayManager().getStates()); Log(LogLevel::Progress) << "87 %"; Log(LogLevel::Info) << "<- Copying Custom Flags"; copyCustomFlags(outputName); Log(LogLevel::Progress) << "88 %"; Log(LogLevel::Info) << "<- Writing Custom CoAs"; - exportCustomCoAs(outputName, world.getPoliticalManager().getCountries()); Log(LogLevel::Progress) << "89 %"; Log(LogLevel::Info) << "<- Writing Flag Definitions"; - exportFlagDefinitions(outputName, world.getPoliticalManager().getCountries()); Log(LogLevel::Progress) << "90 %"; Log(LogLevel::Info) << "<- Writing Localizations"; - exportCountryNamesAndAdjectives(outputName, world.getPoliticalManager().getCountries(), knownLocs); - exportReligionLocs(outputName, world.getReligionMapper().getV3ReligionDefinitions(), knownLocs); - exportCultureLocs(outputName, world.getCultureMapper().getV3CultureDefinitions(), knownLocs); - exportCharacterLocs(outputName, world.getPoliticalManager().getCountries(), knownLocs); Log(LogLevel::Progress) << "91 %"; Log(LogLevel::Info) << "<- Writing Countries"; - exportCommonCountries(outputName, world.getPoliticalManager().getCountries()); - exportHistoryCountries(outputName, world.getPoliticalManager().getCountries()); - exportHistoryPopulations(outputName, world.getPoliticalManager().getCountries()); - exportReleasables(outputName, world.getPoliticalManager().getCountries()); - exportMajorFormables(outputName, world.getPoliticalManager().getMajorFormables()); Log(LogLevel::Progress) << "92 %"; Log(LogLevel::Info) << "<- Writing Diplomacy"; - exportDiplomacy(outputName, world.getPoliticalManager()); - exportDiplomaticPlays(outputName, world.getPoliticalManager().getCountries()); Log(LogLevel::Progress) << "93 %"; // Log(LogLevel::Info) << "<- Writing Armed and Unarmed Conflicts"; Log(LogLevel::Info) << "<- Writing AI Strategies"; - exportStrategies(outputName, world.getPoliticalManager().getCountries()); - exportSecretGoals(outputName, world.getPoliticalManager().getCountries()); Log(LogLevel::Progress) << "94 %"; Log(LogLevel::Info) << "<- Writing Culture Definitions"; - exportCultures(outputName, world.getCultureMapper().getV3CultureDefinitions()); Log(LogLevel::Progress) << "95 %"; Log(LogLevel::Info) << "<- Writing Religion Definitions"; - exportReligions(outputName, world.getReligionMapper().getV3ReligionDefinitions()); Log(LogLevel::Progress) << "96 %"; Log(LogLevel::Info) << "<- Writing Pops"; - exportCharacters(outputName, world.getPoliticalManager().getCountries()); Log(LogLevel::Progress) << "97 %"; Log(LogLevel::Info) << "<- Writing Characters"; - exportPops(outputName, world.getClayManager().getStates()); Log(LogLevel::Progress) << "98 %"; Log(LogLevel::Info) << "<- Writing Buildings"; - exportBuildings(outputName, world.getClayManager().getStates()); Log(LogLevel::Progress) << "99 %"; } diff --git a/EU5ToVic3/Source/V3World/ClayManager/ClayManager.cpp b/EU5ToVic3/Source/V3World/ClayManager/ClayManager.cpp deleted file mode 100644 index 0a1510a..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/ClayManager.cpp +++ /dev/null @@ -1,909 +0,0 @@ -#include "ClayManager.h" -#include "CountryMapper/CountryMapper.h" -#include "Loaders/StateLoader/StateLoader.h" -#include "Loaders/SuperRegionLoader/SuperRegionLoader.h" -#include "Loaders/SuperRegionLoader/V3Region.h" -#include "Loaders/SuperRegionLoader/V3SuperRegion.h" -#include "Loaders/TerrainLoader/TerrainLoader.h" -#include "Loaders/VanillaStateLoader/VanillaStateLoader.h" -#include "Log.h" -#include "PoliticalManager/Country/Country.h" -#include "PoliticalManager/PoliticalManager.h" -#include "PopManager/PopManager.h" -#include "ProvinceManager/ProvinceManager.h" -#include "ProvinceMapper/ProvinceMapper.h" -#include "State/Chunk.h" -#include "State/Province.h" -#include "State/State.h" -#include "State/SubState.h" -#include -#include -#include - -void V3::ClayManager::initializeVanillaStates(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Initializing Vanilla States and Provinces."; - StateLoader stateLoader; - stateLoader.loadStates(modFS); - states = stateLoader.getStates(); - for (const auto& state: states | std::views::values) - { - for (const auto& provinceID: state->getProvinces() | std::views::keys) - provincesToStates.emplace(provinceID, state); - if (state->getID() > 0) - stateIDs.emplace(state->getID(), state->getName()); - } - Log(LogLevel::Info) << "<> " << states.size() << " states loaded with " << provincesToStates.size() << " provinces inside."; - - Log(LogLevel::Info) << "-> Loading Vanilla State Buildings."; - vanillaBuildingLoader.loadVanillaBuildings(modFS); - Log(LogLevel::Info) << "<> " << vanillaBuildingLoader.getBuildingElements().size() << " states loaded with buildings."; -} - -void V3::ClayManager::loadTerrainsIntoProvinces(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading Terrains into Provinces."; - TerrainLoader terrainLoader; - terrainLoader.loadTerrains(modFS); - const auto& terrains = terrainLoader.getTerrains(); - for (const auto& state: states | std::views::values) - { - for (const auto& [provinceName, province]: state->getProvinces()) - { - if (terrains.contains(provinceName)) - { - const auto& terrain = terrains.at(provinceName); - province->setTerrain(terrain); - if (terrain == "ocean") - province->setSea(); - else if (terrain == "lakes") - province->setLake(); - } - else - { - Log(LogLevel::Warning) << "Terrain for province " << provinceName << " cannot be found."; - } - } - - // deal with coastals. - if (state->getNavalExitID() > 0 && stateIDs.contains(state->getNavalExitID())) - { - const auto& seaState = states.at(stateIDs.at(state->getNavalExitID())); - const auto& seaProvinces = seaState->getProvinces(); - for (const auto& seaProvinceID: seaProvinces | std::views::keys) - { - auto seaProvinceNeighbors = coastalMapper.getAdjacencies(seaProvinceID); // neighbors of that province in that sea. - for (const auto& [provinceID, province]: state->getProvinces()) - { - if (seaProvinceNeighbors.contains(provinceID)) - province->setCoastal(); // this province is a direct physical neighbor to a sea province that our state has naval exit towards. - } - } - } - } -} - -void V3::ClayManager::initializeSuperRegions(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Initializing Regions and Superregions."; - SuperRegionLoader superRegionLoader; - superRegionLoader.loadSuperRegions(modFS); - superRegions = superRegionLoader.getSuperRegions(); - - const auto regionCount = std::accumulate(superRegions.begin(), superRegions.end(), 0, [](int sum, const auto& superRegion) { - return sum + static_cast(superRegion.second->getRegions().size()); - }); - Log(LogLevel::Info) << "<> " << superRegions.size() << " superregions loaded with " << regionCount << " regions inside."; -} - -void V3::ClayManager::loadStatesIntoSuperRegions() -{ - Log(LogLevel::Info) << "-> Loading States into Regions."; - for (const auto& superRegion: superRegions | std::views::values) - for (const auto& region: superRegion->getRegions() | std::views::values) - { - std::map> theStates; - for (const auto& stateName: region->getStates() | std::views::keys) - if (states.contains(stateName)) - theStates.emplace(stateName, states.at(stateName)); - else - Log(LogLevel::Warning) << "Attempting to assign state " << stateName << " which doesn't exist to region " << region->getName() << "!"; - region->replaceStates(theStates); - } -} - -void V3::ClayManager::generateChunks(const mappers::ProvinceMapper& provinceMapper, const EU4::ProvinceManager& provinceManager) -{ - Log(LogLevel::Info) << "-> Generating Clay Chunks."; - - std::set processedEU4IDs; - std::set processedV3IDs; - - // We're rolling across EU4's provinces and assigning them to chunks. We'll deal with ownership later as ownership can be shared or missing. - for (const auto& spID: provinceManager.getAllProvinces() | std::views::keys) - { - if (processedEU4IDs.contains(spID)) - continue; // We already grabbed this province earlier in some other mapping. Skip. - - auto v3provinceIDs = provinceMapper.getV3Provinces(spID); - if (v3provinceIDs.empty()) - continue; // This province is mapped into nothing. Skip. - - auto eu4ProvinceIDs = provinceMapper.getEU4Provinces(v3provinceIDs.front()); - auto chunk = std::make_shared(); - - // sum the total weight of incoming provinces. - double totalWeight = 0; - for (auto eu4ProvinceID: eu4ProvinceIDs) - if (provinceManager.getAllProvinces().contains(eu4ProvinceID)) - totalWeight += provinceManager.getAllProvinces().at(eu4ProvinceID)->getProvinceWeight(); - - // If all incoming provinces were wastelands, which is ok, sum is 0, and outgoing factors will also be 0, - // which is again ok as wastelands don't carry ANY data. - if (totalWeight == 0.0) - totalWeight = 1; - - // Mark source provinces for data transfer. - for (auto eu4ProvinceID: eu4ProvinceIDs) - { - if (provinceManager.getAllProvinces().contains(eu4ProvinceID)) - { - const auto sourceWeight = provinceManager.getAllProvinces().at(eu4ProvinceID)->getProvinceWeight(); - chunk->addSourceProvinceData(*provinceManager.getAllProvinces().at(eu4ProvinceID), sourceWeight / totalWeight); - } - else if (!provinceManager.isProvinceDiscarded(eu4ProvinceID)) - { - // Don't panic before checking if this is a lake, rnw or such. We silently skip those. - // Whatever remains is an error, mismap or some other nonsense. - Log(LogLevel::Warning) << "Existing provinceMapper mapping for eu4 province " << eu4ProvinceID << " has no match in the save! Skipping."; - } - processedEU4IDs.emplace(eu4ProvinceID); - } - // If no viable sources survive, bail on this chunk. - if (chunk->getSourceProvinceData().empty()) - continue; - - // Shove all vic3 provinces into the chunk - for (const auto& v3provinceID: v3provinceIDs) - { - if (processedV3IDs.contains(v3provinceID)) - continue; // We already grabbed this province earlier in some other mapping. Skip. - - if (!provincesToStates.contains(v3provinceID) || !provincesToStates.at(v3provinceID)->containsProvince(v3provinceID)) - { - Log(LogLevel::Warning) << "Existing provinceMapper mapping for V3 province " << v3provinceID << " has no match in reality. Skipping."; - continue; - } - const auto& state = provincesToStates.at(v3provinceID); - const auto& v3Province = state->getProvince(v3provinceID); - if (!v3Province) // ID is known but it's not initialized? This is a problem, likely due to some corruption. - { - processedV3IDs.emplace(v3provinceID); - continue; // bail. - } - chunk->addProvince(std::pair(v3provinceID, v3Province)); - - // And file. - processedV3IDs.emplace(v3provinceID); - } - // If we don't have a single target province, bail on this chunk. - if (chunk->getProvinces().empty()) - continue; - - // Store the chunk and move on. - chunks.push_back(chunk); - } - Log(LogLevel::Info) << "<> Generated " << chunks.size() << " Clay Chunks."; -} - -void V3::ClayManager::unDisputeChunkOwnership(const SourceOwners& sourceCountries) -{ - Log(LogLevel::Info) << "-> Untangling chunk ownerships."; - - // Raw chunks can link to sourceProvinces of several owners. Entire chunk goes to the owner with most source Development Weight. - // Note: This may lead to loss of actual (not historical) capitals, but this is always a risk with N-to-X mappings. - // We'd let the chunks do this themselves, but we want to immediately filter out all sea chunks and random corruption. - - std::vector> filteredChunks; - - for (const auto& chunk: chunks) - { - auto ownerWeights = chunk->calcOwnerWeights(); - - // did we get anything? anyone? - if (ownerWeights.empty()) - { - // There were no owners to the provinces (possibly sea zones or wastelands). - // If sea zones, drop the chunk - if (chunk->isSea()) - continue; - - // Otherwise, we have an unowned chunk. Technically, unowned chunk doesn't have disputed ownership. Success! - filteredChunks.push_back(chunk); - continue; - } - - const auto newOwner = std::max_element(ownerWeights.begin(), ownerWeights.end(), [](std::pair a, std::pair b) { - return a.second < b.second; - }); - - // Does that owner even exist? - if (!sourceCountries.contains(newOwner->first)) - { - // Interesting! Resolve dispute by making it unowned. - filteredChunks.push_back(chunk); - Log(LogLevel::Warning) << "Chunk owner " << newOwner->first << " is invalid. Dropping chunk ownership."; - continue; - } - // Sanity check - if (!sourceCountries.at(newOwner->first)) - { - filteredChunks.push_back(chunk); - Log(LogLevel::Warning) << "Chunk owner " << newOwner->first << " is not initialized. Dropping chunk ownership."; - continue; - } - - chunk->setSourceOwnerTag(newOwner->first); - - // is this by any chance a capital of owner? - if (chunk->getKnownCapitals().contains(newOwner->first)) - chunk->setCapital(); - - filteredChunks.push_back(chunk); - } - chunks.swap(filteredChunks); - Log(LogLevel::Info) << "<> Untangled chunk ownerships, " << chunks.size() << " of " << filteredChunks.size() << " remain."; -} - -void V3::ClayManager::splitChunksIntoSubStates() -{ - Log(LogLevel::Info) << "-> Distributing Clay across Substates."; - - // Every chunk can map to to a number of substates. We'll now transfer provinces and sourceProvince metadata from a chunk according - // to their geographical State and create substates. Every substate must belong to a single owner - or no owner - same as chunks. - // Weighted sourceProvince data is also copied and *further* weighted, according to the size of substates in regrads to the original - // chunk... and potentially other factors. - - for (const auto& chunk: chunks) - { - // split chunk into substates - auto generatedSubStates = chunkToSubStatesTransferFunction(chunk); - - // and file them. - substates.insert(substates.end(), generatedSubStates.begin(), generatedSubStates.end()); - } - - Log(LogLevel::Info) << "<> Substates organized, " << substates.size() << " produced."; -} - -std::vector> V3::ClayManager::chunkToSubStatesTransferFunction(const std::shared_ptr& chunk) const -{ - /* - * This function uses several factors, all of which are debatable and moddable later. Of note is: - * subStateSizeFactor - how much of a chunk's original metadata (dev) the substate takes when it's split - * TODO: This should be modded by something more intelligent than raw province count comparison. - */ - - // prep info - const double totalChunkWeight = chunk->getTotalSourceProvinceWeight(); - const double provincesCount = static_cast(chunk->getProvinces().size()); - const auto sortedProvinces = sortChunkProvincesIntoStates(chunk); - - // build substates - auto generatedSubStates = buildSubStates(sortedProvinces); - - // update substates with metadata - std::shared_ptr largestSubState; - double largestSubStateWeight = 0; - for (const auto& subState: generatedSubStates) - { - // for now, this is the simplest we can do. substateFactor is literally the amount of provinces / total provinces - // TODO: REFINE LATER WITH PRIME LAND, IMPASSABLES AND WHATEVER. - const double subStateSizeFactor = static_cast(subState->getProvinces().size()) / provincesCount; - - // substate weight is an *outwardly* factor, when comparing the impact of that substate's metadata against all other - // substates in the same state - or superregion. - const double subStateWeight = totalChunkWeight * subStateSizeFactor; - - // we need to return to the largest substate later to set a capital. - // TODO: Use landshare - set it up immediately after all substates are in place after shoving all remaining land into substates. - if (subStateWeight > largestSubStateWeight) - { - largestSubStateWeight = subStateWeight; - largestSubState = subState; - } - - // This here is an *inwardly* factor - we scale chunk's metadata according to the size of our substate, so we'd receive - // fewer factories etc. - std::vector> additionallyWeightedSourceProvinceData; - for (const auto& [data, weight]: chunk->getSourceProvinceData()) - additionallyWeightedSourceProvinceData.push_back(std::pair(data, weight * subStateSizeFactor)); - - // file! - subState->setWeight(subStateWeight); - subState->setSourceProvinceData(additionallyWeightedSourceProvinceData); - if (chunk->getSourceOwnerTag()) - subState->setSourceOwnerTag(*chunk->getSourceOwnerTag()); - } - - if (largestSubState) - { - if (chunk->isCapital()) - largestSubState->setCapital(); - // Also store historical capital info for eu4 countries. Relevant for dead eu4 countries. - largestSubState->addHistoricalCapitals(chunk->getKnownCapitals()); - } - - return generatedSubStates; -} - -V3::StateToProvinceMap V3::ClayManager::sortChunkProvincesIntoStates(const std::shared_ptr& chunk) const -{ - - StateToProvinceMap stateProvinces; - - // shove the provinces into baskets - for (const auto& [provinceName, province]: chunk->getProvinces()) - { - if (!provincesToStates.contains(provinceName)) - { - // We should have filtered all unviable provinces already when generating chunks, but better safe than sorry. - Log(LogLevel::Warning) << "Filtering province " << provinceName << " failed as it belongs to no state. Skipping."; - continue; - } - const auto& stateName = provincesToStates.at(provinceName)->getName(); - if (!stateProvinces.contains(stateName)) - stateProvinces.emplace(stateName, ProvinceMap{}); - stateProvinces.at(stateName).emplace(provinceName, province); - } - return stateProvinces; -} - -std::vector> V3::ClayManager::buildSubStates(const StateToProvinceMap& stateProvinceMap) const -{ - std::vector> subStates; - - for (const auto& [stateName, provinces]: stateProvinceMap) - { - if (provinces.empty()) - continue; // Unsure how this could happen, but sure, skip this substate. - - if (!states.contains(stateName)) - { - // wtf, should never happen. - Log(LogLevel::Error) << "Attempting to create a substate in " << stateName << " which does't exist?! Bailing on this clay!"; - continue; - } - // Should be ok now. - subStates.push_back(std::make_shared(states.at(stateName), provinces)); - } - - return subStates; -} - -void V3::ClayManager::assignSubStateOwnership(const std::map>& countries, const mappers::CountryMapper& countryMapper) -{ - Log(LogLevel::Info) << "-> Assigning substates to countries."; - std::vector> filteredSubstates; - - for (const auto& substate: substates) - { - // unowned substates are IRRELEVANT. We'll be filling up their spots with imported data, pops and buildings. DROP. - if (!substate->getSourceOwnerTag()) - continue; - - // all the rest must have an owner and that owner must be able to map properly. - auto eu4tag = substate->getSourceOwnerTag(); - if (!eu4tag || eu4tag->empty()) - { - Log(LogLevel::Warning) << "Substate belonging to EU4 country which we know nothing about? Ditching."; - continue; - } - - auto v3tag = countryMapper.getV3Tag(*eu4tag); - if (v3tag && countries.contains(*v3tag)) - { - const auto& owner = countries.at(*v3tag); - substate->setOwner(owner); - owner->addSubState(substate); - filteredSubstates.push_back(substate); - substate->getHomeState()->addSubState(substate); - } - else - { - // We're ditching substates of countries we haven't imported. Unsure how that'd happen but ok. - Log(LogLevel::Warning) << "Substate belonging to EU4 " << *eu4tag << " hasn't been mapped over? Ditching."; - } - - // Now for all *other* cores link to countries regardless of ownership, so we may create releasables and claims. - for (const auto& spData: substate->getSourceProvinceData() | std::views::keys) - for (const auto& core: spData.cores) - { - if (core == *eu4tag) - continue; - const auto& coreTag = countryMapper.getV3Tag(core); - if (!coreTag || !countries.contains(*coreTag)) - { - // country has been ditched by EU4World. All good. - continue; - } - const auto& coreOwner = countries.at(*coreTag); - coreOwner->addUnownedCoreSubState(substate); - substate->addClaim(*coreTag); - } - } - - substates.swap(filteredSubstates); - - Log(LogLevel::Info) << "<> " << filteredSubstates.size() << " substates assigned. " << filteredSubstates.size() - substates.size() << " substates ditched."; -} - -bool V3::ClayManager::regionIsValid(const std::string& region) const -{ - if (states.contains(region)) - return true; - if (superRegions.contains(region)) - return true; - for (const auto& superRegion: superRegions | std::views::values) - if (superRegion->getRegions().contains(region)) - return true; - - return false; -} - -bool V3::ClayManager::stateIsInRegion(const std::string& state, const std::string& region) const -{ - // "region" can be anything - state, region or even supergroup. - // Are we pinging self, and we are valid? - if (state == region && regionIsValid(state)) - return true; - - // is region some *other* state? - if (states.contains(region)) - return false; - - // let's ask supergroups and groups - for (const auto& [superGroupName, superGroup]: superRegions) - for (const auto& [regionName, theRegion]: superGroup->getRegions()) - if (theRegion->containsState(state) && (regionName == region || superGroupName == region)) - return true; - - return false; -} - -void V3::ClayManager::injectVanillaSubStates(const commonItems::ModFilesystem& modFS, - const PoliticalManager& politicalManager, - const PopManager& popManager, - const bool vn) -{ - Log(LogLevel::Info) << "-> Injecting Vanilla substates into conversion map."; - auto subCounter = substates.size(); - - VanillaStateLoader loader; - loader.loadVanillaStates(modFS); - - for (const auto& [stateName, state]: states) - { - // do we need to do anything? - if (!state->hasUnassignedProvinces()) - continue; - - // just sanity. - auto unassignedProvinces = state->getUnassignedProvinces(); - if (unassignedProvinces.empty()) - continue; - - // grab vanilla state. - if (!loader.getStates().contains(stateName)) - { - // silently skip seas and lakes. - if (state->isSea() || state->isLake()) - continue; - - Log(LogLevel::Warning) << "ModFS has no state " << stateName << ", not importing substates!"; - continue; - } - - const auto& vanillaStateEntry = loader.getStates().at(stateName); - const auto success = importVanillaSubStates(stateName, vanillaStateEntry, unassignedProvinces, politicalManager, popManager, vn); - - // If we imported anything, we should also copy any potential homelands. Unsure whom they belong to, but they surely won't do harm. - // What could possibly go wrong? - if (success) - for (const auto& homeland: vanillaStateEntry.getHomelands()) - state->addHomeland(homeland); - } - - subCounter = substates.size() - subCounter; - Log(LogLevel::Info) << "<> Imported " << subCounter << " new substates."; -} - -bool V3::ClayManager::importVanillaSubStates(const std::string& stateName, - const VanillaStateEntry& entry, - const ProvinceMap& unassignedProvinces, - const PoliticalManager& politicalManager, - const PopManager& popManager, - const bool vn) -{ - bool action = false; - for (const auto& subStateEntry: entry.getSubStates()) - { - const auto& ownerTag = subStateEntry.getOwnerTag(); - if (ownerTag.empty()) - continue; - - // We have a substate owner. Is he not vanilla-decentralized? And are we not doing VN? Then bail. - if (!politicalManager.isTagDecentralized(ownerTag) && !vn) - continue; - - // Now we have a state we can work with. Not all of its provinces are available! - ProvinceMap availableProvinces; - for (const auto& provinceID: subStateEntry.getProvinces()) - if (unassignedProvinces.contains(provinceID)) - availableProvinces.emplace(provinceID, unassignedProvinces.at(provinceID)); - // Anything to work with? - if (availableProvinces.empty()) - continue; - - // Hold the horses! VN ownership transfer situation? - std::optional replacementOwner; - if (vn && vnColonialMapper.isStateVNColonial(stateName) && vnColonialMapper.getVanillaOwners(stateName).contains(ownerTag)) - { - // who owns key province? - if (const auto& keyProvince = vnColonialMapper.getKeyProvince(stateName, ownerTag); keyProvince) - replacementOwner = getProvinceOwnerTag(*keyProvince); // We won't replace the owner yet, we still need to grab the original pops. - // is this a decolonization situation? - if (replacementOwner && vnColonialMapper.isStateDecolonizable(stateName, ownerTag, *replacementOwner)) - continue; // then simply skip any generation. - } - const auto& owner = politicalManager.getCountry(ownerTag); - const auto& homeState = states.at(stateName); - - // form new substate. - auto newSubState = std::make_shared(); - newSubState->setOwner(owner); - newSubState->setProvinces(availableProvinces); - newSubState->setSubStateTypes(subStateEntry.getSubStateTypes()); - newSubState->setHomeState(homeState); - newSubState->setVanillaSubState(); - - // How many provinces did we lose in the transfer? Ie. How many of this substate's original provinces were already assigned to some other substate? - // We can use this ratio to cut our popcount. Or we could use any other more involved function. - // TODO: Use any other more involved function. - const double subStateRatio = static_cast(availableProvinces.size()) / static_cast(subStateEntry.getProvinces().size()); - auto newPops = prepareInjectedSubStatePops(newSubState, subStateRatio, popManager); - - // Transfer original buildings, unscaled at the moment. - // TODO: Scale this if necessary. - if (vanillaBuildingLoader.getBuildingElements().contains(stateName) && vanillaBuildingLoader.getBuildingElements().at(stateName).contains(ownerTag)) - { - newSubState->setVanillaBuildingElements(vanillaBuildingLoader.getBuildingElements().at(stateName).at(ownerTag)); - } - - // and shove. - newSubState->setSubStatePops(newPops); - - // and register. - homeState->addSubState(newSubState); - - if (replacementOwner) // now we replace. - { - const auto& newOwner = politicalManager.getCountry(*replacementOwner); - newSubState->setOwner(newOwner); - newOwner->addSubState(newSubState); - } - else - { - owner->addSubState(newSubState); - } - - substates.emplace_back(newSubState); - action = true; - } - return action; -} - -V3::SubStatePops V3::ClayManager::prepareInjectedSubStatePops(const std::shared_ptr& subState, - double subStateRatio, - const PopManager& popManager) const -{ - // get its existing pops from vanilla - auto subStatePops = popManager.getDWSubStatePops(subState->getHomeStateName(), *subState->getOwnerTag()); - if (!subStatePops) - { - Log(LogLevel::Warning) << "Substate for " << *subState->getOwnerTag() << " in " << subState->getHomeStateName() << " had no DW pops! Not importing!"; - return SubStatePops(); - } - - auto importedPops = subStatePops->getPops(); - - // scale the pops. - for (auto& pop: importedPops) - { - const double newSize = round(static_cast(pop.getSize()) * subStateRatio); - pop.setSize(static_cast(newSize)); - } - subStatePops->setPops(importedPops); - - return *subStatePops; -} - -void V3::ClayManager::shoveRemainingProvincesIntoSubStates() -{ - Log(LogLevel::Info) << "-> Shoving remaining provinces into substates."; - auto subCounter = substates.size(); - - for (const auto& [stateName, state]: states) - { - // do we need to do anything? - if (!state->hasUnassignedProvinces()) - continue; - - // just sanity. - auto unassignedProvinces = state->getUnassignedProvinces(); - if (unassignedProvinces.empty()) - continue; - - // silently skip seas and lakes. - if (state->isSea() || state->isLake()) - continue; - - makeSubStateFromProvinces(stateName, unassignedProvinces); - } - - subCounter = substates.size() - subCounter; - Log(LogLevel::Info) << "<> Generated " << subCounter << " new substates."; -} - -void V3::ClayManager::makeSubStateFromProvinces(const std::string& stateName, const ProvinceMap& unassignedProvinces) -{ - const auto& homeState = states.at(stateName); - - auto newSubState = std::make_shared(); - newSubState->setProvinces(unassignedProvinces); - newSubState->setHomeState(homeState); - - homeState->addSubState(newSubState); - substates.emplace_back(newSubState); -} - -void V3::ClayManager::squashAllSubStates(const PoliticalManager& politicalManager) -{ - Log(LogLevel::Info) << "-> Squashing substates."; - auto subCount = substates.size(); - - // replacement caches - TagSubStates replacementTagSubStates; - TagSubStates replacementStateSubStates; - std::vector> newSubStates; - - for (const auto& [stateName, state]: states) - { - // sort the substates by tags. - TagSubStates tagSubStates; - for (const auto& subState: state->getSubStates()) - { - const auto& tag = subState->getOwner()->getTag(); - if (!tagSubStates.contains(tag)) - tagSubStates.emplace(tag, std::vector>{}); - tagSubStates.at(tag).emplace_back(subState); - } - - // and squash. - for (const auto& [tag, subStates]: tagSubStates) - { - if (subStates.empty()) - continue; - auto squashedSubState = squashSubStates(subStates); - - if (!replacementTagSubStates.contains(tag)) - replacementTagSubStates.emplace(tag, std::vector>{}); - replacementTagSubStates.at(tag).emplace_back(squashedSubState); - - if (!replacementStateSubStates.contains(stateName)) - replacementStateSubStates.emplace(stateName, std::vector>{}); - replacementStateSubStates.at(stateName).emplace_back(squashedSubState); - - newSubStates.emplace_back(squashedSubState); - } - } - - // file to countries. - for (const auto& [tag, country]: politicalManager.getCountries()) - if (replacementTagSubStates.contains(tag)) - country->setSubStates(replacementTagSubStates.at(tag)); - else - country->setSubStates({}); - - // file to states. - for (const auto& [stateName, state]: states) - if (replacementStateSubStates.contains(stateName)) - state->setSubStates(replacementStateSubStates.at(stateName)); - else - state->setSubStates({}); - - substates.swap(newSubStates); - - Log(LogLevel::Info) << "<> Substates squashed, " << substates.size() << " remain, " << subCount - substates.size() << " ditched."; -} - -std::shared_ptr V3::ClayManager::squashSubStates(const std::vector>& subStates) const -{ - ProvinceMap provinces; - std::set subStateTypes; - double weight = 0; - std::vector> spData; - std::vector demographics; - SubStatePops subStatePops; - std::vector pops; - int vanillaPopCount = 0; - std::vector vanillaBuildingElements; - std::set claims; - - for (const auto& subState: subStates) - { - provinces.insert(subState->getProvinces().begin(), subState->getProvinces().end()); - - // unsure about this. If one is unincorporated, all are unincorporated? - // TODO: See what this does - if (!subState->getSubStateTypes().empty()) - subStateTypes = subState->getSubStateTypes(); - - if (subState->getWeight()) - weight += *subState->getWeight(); - - spData.insert(spData.end(), subState->getSourceProvinceData().begin(), subState->getSourceProvinceData().end()); - demographics.insert(demographics.end(), subState->getDemographics().begin(), subState->getDemographics().end()); - pops.insert(pops.end(), subState->getSubStatePops().getPops().begin(), subState->getSubStatePops().getPops().end()); - vanillaPopCount += subState->getVanillaPopCount(); - vanillaBuildingElements.insert(vanillaBuildingElements.end(), - subState->getVanillaBuildingElements().begin(), - subState->getVanillaBuildingElements().end()); - claims.insert(subState->getClaims().begin(), subState->getClaims().end()); - } - auto newSubState = std::make_shared(); - newSubState->setHomeState((*subStates.begin())->getHomeState()); - newSubState->setOwner((*subStates.begin())->getOwner()); - - newSubState->setProvinces(provinces); - newSubState->setSubStateTypes(subStateTypes); - if (weight > 0) - newSubState->setWeight(weight); - newSubState->setSourceProvinceData(spData); - newSubState->setDemographics(demographics); - - subStatePops.setTag(newSubState->getOwner()->getTag()); - subStatePops.setPops(pops); - newSubState->setSubStatePops(subStatePops); - newSubState->setVanillaPopCount(vanillaPopCount); - newSubState->setVanillaBuildingElements(vanillaBuildingElements); - newSubState->setClaims(claims); - - return newSubState; -} - -std::optional V3::ClayManager::getHistoricalCapitalState(const std::string& eu4tag) const -{ - for (const auto& substate: substates) - if (substate->getHistoricalCapitals().contains(eu4tag)) - return substate->getHomeStateName(); - return std::nullopt; -} - -std::set V3::ClayManager::getStateNamesForRegion(const std::string& regionName) const -{ - std::set stateNames; - if (states.contains(regionName)) - { - stateNames.emplace(regionName); - return stateNames; - } - - if (superRegions.contains(regionName)) - { - for (const auto& region: superRegions.at(regionName)->getRegions() | std::views::values) - for (const auto& state: region->getStates() | std::views::keys) - stateNames.emplace(state); - return stateNames; - } - - for (const auto& superRegion: superRegions | std::views::values) - { - if (superRegion->getRegions().contains(regionName)) - { - for (const auto& state: superRegion->getRegions().at(regionName)->getStates() | std::views::keys) - stateNames.emplace(state); - return stateNames; - } - } - - Log(LogLevel::Warning) << "Attempting colonial lookup at " << regionName << " failed! It doesn't match anything we know!"; - return stateNames; -} - -std::optional V3::ClayManager::getProvinceOwnerTag(const std::string& provinceID) const -{ - for (const auto& state: states | std::views::values) - for (const auto& subState: state->getSubStates()) - if (subState->getProvinces().contains(provinceID)) - return subState->getOwnerTag(); - return std::nullopt; -} - -std::set V3::ClayManager::getStateProvinceIDs(const std::string& stateName) const -{ - std::set IDs; - if (!states.contains(stateName)) - return IDs; - for (const auto& subState: states.at(stateName)->getSubStates()) - { - auto subIDs = subState->getProvinceIDs(); - IDs.insert(subIDs.begin(), subIDs.end()); - } - return IDs; -} - -void V3::ClayManager::filterInvalidClaims(const PoliticalManager& politicalManager) const -{ - Log(LogLevel::Info) << "-> Filtering Invalid Claims."; - auto counter = 0; - - // dead and deleted countries get no claims. - for (const auto& substate: substates) - { - std::set validClaims; - for (const auto& claim: substate->getClaims()) - if (politicalManager.getCountry(claim) && !politicalManager.getCountry(claim)->getSubStates().empty() && - (politicalManager.getCountry(claim)->getProcessedData().type != "decentralized")) - validClaims.emplace(claim); - else - ++counter; - substate->setClaims(validClaims); - } - Log(LogLevel::Info) << "<> Filtered " << counter << " Dead Claims."; -} - -void V3::ClayManager::redistributeResourcesAndLandshares() -{ - for (const auto& state: states | std::views::values) - { - state->distributeLandshares(); - state->distributeResources(); - } -} - -void V3::ClayManager::loadAdjacencies(const std::string& filePath) -{ - coastalMapper.loadAdjacencies(filePath); -} - -std::shared_ptr V3::ClayManager::getParentSuperRegion(const std::string& regionName) const -{ - for (const auto& [superRegionName, superRegion]: superRegions) - { - if (superRegionName == regionName) - return superRegion; - for (const auto& [currentRegionName, region]: superRegion->getRegions()) - { - if (currentRegionName == regionName) - return superRegion; - for (const auto& stateName: region->getStates() | std::views::keys) - if (stateName == regionName) - return superRegion; - } - } - return nullptr; -} - -std::optional V3::ClayManager::getParentRegionName(const std::string& stateName) const -{ - for (const auto& superRegion: superRegions | std::views::values) - { - for (const auto& [currentRegionName, region]: superRegion->getRegions()) - { - if (region->getStates().contains(stateName)) - return currentRegionName; - } - } - return std::nullopt; -} diff --git a/EU5ToVic3/Source/V3World/ClayManager/ClayManager.h b/EU5ToVic3/Source/V3World/ClayManager/ClayManager.h deleted file mode 100644 index 4a028ac..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/ClayManager.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef CLAY_MANAGER_H -#define CLAY_MANAGER_H -#include "ClayMapTypedefs.h" -#include "CoastalMapper/CoastalMapper.h" -#include "Loaders/VanillaBuildingLoader/VanillaBuildingLoader.h" -#include "ModLoader/ModFilesystem.h" -#include "VNColonialMapper/VNColonialMapper.h" -#include -#include - -namespace EU4 -{ -class ProvinceManager; -} -namespace mappers -{ -class CountryMapper; -class ProvinceMapper; -} // namespace mappers -namespace V3 -{ -class Country; -class Chunk; -class SubState; -class State; -class SuperRegion; -class Region; -class VanillaStateEntry; -class PoliticalManager; -class PopManager; -class SubStatePops; -class ClayManager -{ - public: - ClayManager() = default; - - void initializeVanillaStates(const commonItems::ModFilesystem& modFS); - void loadTerrainsIntoProvinces(const commonItems::ModFilesystem& modFS); - void initializeSuperRegions(const commonItems::ModFilesystem& modFS); - void loadStatesIntoSuperRegions(); - void generateChunks(const mappers::ProvinceMapper& provinceMapper, const EU4::ProvinceManager& provinceManager); - void unDisputeChunkOwnership(const SourceOwners& sourceCountries); - void splitChunksIntoSubStates(); - void assignSubStateOwnership(const std::map>& countries, const mappers::CountryMapper& countryMapper); - void injectVanillaSubStates(const commonItems::ModFilesystem& modFS, const PoliticalManager& politicalManager, const PopManager& popManager, bool vn); - void shoveRemainingProvincesIntoSubStates(); - void squashAllSubStates(const PoliticalManager& politicalManager); - void redistributeResourcesAndLandshares(); - void addSubState(const std::shared_ptr& subState) { substates.emplace_back(subState); } - void loadAdjacencies(const std::string& filePath); - - [[nodiscard]] const auto& getStates() const { return states; } - [[nodiscard]] const auto& getSuperRegions() const { return superRegions; } - [[nodiscard]] const auto& getChunks() const { return chunks; } - [[nodiscard]] const auto& getSubStates() const { return substates; } - - [[nodiscard]] bool regionIsValid(const std::string& region) const; - [[nodiscard]] bool stateIsInRegion(const std::string& state, const std::string& region) const; - [[nodiscard]] std::optional getHistoricalCapitalState(const std::string& eu4tag) const; - [[nodiscard]] std::shared_ptr getParentSuperRegion(const std::string& regionName) const; - [[nodiscard]] std::optional getParentRegionName(const std::string& stateName) const; - [[nodiscard]] std::set getStateNamesForRegion(const std::string& regionName) const; - - void loadVNColonialRules(const std::string& fileName) { vnColonialMapper.loadMappingRules(fileName); } - [[nodiscard]] const auto& getVNColonialMapper() const { return vnColonialMapper; } - [[nodiscard]] std::optional getProvinceOwnerTag(const std::string& provinceID) const; - [[nodiscard]] std::set getStateProvinceIDs(const std::string& stateName) const; - - void filterInvalidClaims(const PoliticalManager& politicalManager) const; - - private: - [[nodiscard]] std::vector> chunkToSubStatesTransferFunction(const std::shared_ptr& chunk) const; - [[nodiscard]] StateToProvinceMap sortChunkProvincesIntoStates(const std::shared_ptr& chunk) const; - [[nodiscard]] std::vector> buildSubStates(const StateToProvinceMap& stateProvinceMap) const; - [[nodiscard]] bool importVanillaSubStates(const std::string& stateName, - const VanillaStateEntry& entry, - const ProvinceMap& unassignedProvinces, - const PoliticalManager& politicalManager, - const PopManager& popManager, - bool vn); - void makeSubStateFromProvinces(const std::string& stateName, const ProvinceMap& unassignedProvinces); - [[nodiscard]] SubStatePops prepareInjectedSubStatePops(const std::shared_ptr& subState, double subStateRatio, const PopManager& popManager) const; - [[nodiscard]] std::shared_ptr squashSubStates(const std::vector>& subStates) const; - - std::map> states; // geographical entities - std::map> superRegions; // geographical entities - std::map> provincesToStates; // handy map for quickly referencing states; - std::map stateIDs; // handy! - - std::vector> chunks; // political entities - std::vector> substates; // political entities - - mappers::VNColonialMapper vnColonialMapper; - mappers::CoastalMapper coastalMapper; - VanillaBuildingLoader vanillaBuildingLoader; -}; -} // namespace V3 -#endif // CLAY_MANAGER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/ClayManager/ClayMapTypedefs.h b/EU5ToVic3/Source/V3World/ClayManager/ClayMapTypedefs.h deleted file mode 100644 index 1d2d2ce..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/ClayMapTypedefs.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef CLAY_MAP_TYPEDEFS_H -#define CLAY_MAP_TYPEDEFS_H -#include -#include -#include -#include - -namespace EU4 -{ -class Country; -} -namespace V3 -{ -class SubState; -class Province; -class StateModifier; -using ProvinceMap = std::map>; // v3 province name->v3 province -using StateToProvinceMap = std::map; // state name -> v3 provinces -using SourceOwners = std::map>; // eu4tag, eu4country -using TagSubStates = std::map>>; // tag, substate -using StateModifiers = std::map>; // modifier name -> modifier -} // namespace V3 - -#endif // CLAY_MAP_TYPEDEFS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/ClayManager/State/Chunk.cpp b/EU5ToVic3/Source/V3World/ClayManager/State/Chunk.cpp deleted file mode 100644 index c04c77d..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/State/Chunk.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "Chunk.h" -#include "ProvinceManager/EU4Province.h" -#include "SubState.h" -#include -#include -#include - -void V3::Chunk::addSourceProvinceData(const EU4::Province& sourceProvince, double weight) -{ - SourceProvinceData data; - data.owner = sourceProvince.getOwnerTag(); - data.weight = sourceProvince.getProvinceWeight(); - data.investmentFactor = sourceProvince.getInvestmentFactor(); - data.popRatios = sourceProvince.getProvinceHistory().getPopRatios(); - data.buildings = sourceProvince.getBuildings(); - data.cores = sourceProvince.getCores(); - data.territorialCore = sourceProvince.isTerritorialCore(); - data.sea = sourceProvince.isSea(); - data.eu4Capitals = sourceProvince.getCapitals(); - - // Immediately apply weight to popratios as further splitting of this core data won't affect demographics. - for (auto& popRatio: data.popRatios) - { - popRatio.multiplyRatios(weight); - } - - weightedSourceProvinceData.emplace_back(data, weight); -} - -std::map V3::Chunk::calcOwnerWeights() const -{ - std::map ownerWeights; // ownerTag, total province weight - for (const auto& [sourceProvinceData, weight]: weightedSourceProvinceData) - { - const auto& sourceTag = sourceProvinceData.owner; - if (sourceTag.empty()) - continue; // not relevant source - wasteland etc. - if (ownerWeights.contains(sourceTag)) - ownerWeights.at(sourceTag) += weight; // this is RAW province weight - dev + buildings. - else - ownerWeights.emplace(sourceTag, weight); - } - return ownerWeights; -} - -std::set V3::Chunk::getKnownCapitals() const -{ - std::set capitals; - for (const auto& wspd: weightedSourceProvinceData | std::views::keys) - capitals.insert(wspd.eu4Capitals.begin(), wspd.eu4Capitals.end()); - return capitals; -} - -bool V3::Chunk::isSea() const -{ - return std::ranges::any_of(weightedSourceProvinceData.begin(), weightedSourceProvinceData.end(), [](const auto& sourceProvince) { - return sourceProvince.first.sea; - }); -} - -double V3::Chunk::getTotalSourceProvinceWeight() const -{ - const double totalWeight = - std::accumulate(weightedSourceProvinceData.begin(), weightedSourceProvinceData.end(), 0.0, [](double sum, const auto& sourceData) { - return sum + sourceData.first.weight; - }); - - // This is important. We're averaging the total weight of our source provinces - right here. If by any chance in the future we want to add them together - // or use some other function, alter this. - - return totalWeight / static_cast(weightedSourceProvinceData.size()); -} diff --git a/EU5ToVic3/Source/V3World/ClayManager/State/Chunk.h b/EU5ToVic3/Source/V3World/ClayManager/State/Chunk.h deleted file mode 100644 index 9042f86..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/State/Chunk.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef V3_CHUNK_H -#define V3_CHUNK_H -#include "Province.h" -#include "SourceProvinceData.h" -#include -#include -#include - -/* A Chunk is a collection of provinces defined by province_mappings.txt where a particular eu4 province maps to. - * Its defining attribute is the single owner these provinces belong to. From Chunks we can generate substates, when - * we overlay this political map over a geographical map. - * - * A chunk can be as small as a single V3 province, or as large as multiple V3 states.*/ - -namespace EU4 -{ -class Country; -class PopRatio; -class Province; -} // namespace EU4 -namespace V3 -{ -class Country; -class SubState; -class Chunk -{ - public: - Chunk() = default; - - void addProvince(const std::pair>& province) { provinces.emplace(province); } - void setSourceOwnerTag(const std::string& sourceTag) { sourceOwnerTag = sourceTag; } - void setCapital() { capital = true; } - - [[nodiscard]] const auto& getProvinces() const { return provinces; } - [[nodiscard]] const auto& getSourceOwnerTag() const { return sourceOwnerTag; } - [[nodiscard]] bool isSea() const; - [[nodiscard]] const auto& getSourceProvinceData() const { return weightedSourceProvinceData; } - [[nodiscard]] double getTotalSourceProvinceWeight() const; - [[nodiscard]] auto isCapital() const { return capital; } - - void addSourceProvinceData(const EU4::Province& sourceProvince, double weight); - [[nodiscard]] std::map calcOwnerWeights() const; - [[nodiscard]] std::set getKnownCapitals() const; - - private: - std::map> provinces; // V3 provinces - std::optional sourceOwnerTag; - std::vector> weightedSourceProvinceData; - bool capital = false; -}; -} // namespace V3 - -#endif // V3_CHUNK_H diff --git a/EU5ToVic3/Source/V3World/ClayManager/State/Province.h b/EU5ToVic3/Source/V3World/ClayManager/State/Province.h deleted file mode 100644 index 6e898c1..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/State/Province.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef V3_PROVINCE_H -#define V3_PROVINCE_H -#include - -namespace V3 -{ -class Chunk; -class Province -{ - public: - Province() = default; - - [[nodiscard]] auto getName() const { return name; } - [[nodiscard]] auto getTerrain() const { return terrain; } - [[nodiscard]] auto isSea() const { return sea; } - [[nodiscard]] auto isLake() const { return lake; } - [[nodiscard]] auto isCoastal() const { return coastal; } - [[nodiscard]] auto isPrime() const { return prime; } - [[nodiscard]] auto isImpassable() const { return impassable; } - [[nodiscard]] auto isPort() const { return port; } - - void setSea() { sea = true; } - void setLake() - { - lake = true; - impassable = true; - } - void setCoastal() { coastal = true; } - void setPrime() { prime = true; } - void setImpassable() { impassable = true; } - void setPort() { port = true; } - void setName(const std::string& theName) { name = theName; } - void setTerrain(const std::string& theTerrain) { terrain = theTerrain; }; - - private: - void registerKeys(); - - std::string name; - std::string terrain; - bool sea = false; - bool lake = false; - bool coastal = false; - bool prime = false; - bool impassable = false; - bool port = false; -}; -} // namespace V3 - -#endif // V3_PROVINCE_H diff --git a/EU5ToVic3/Source/V3World/ClayManager/State/SourceProvinceData.h b/EU5ToVic3/Source/V3World/ClayManager/State/SourceProvinceData.h deleted file mode 100644 index a291b5c..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/State/SourceProvinceData.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef V3_SOURCE_PROVINCE_DATA_H -#define V3_SOURCE_PROVINCE_DATA_H -#include "ProvinceManager/PopRatio.h" -#include -#include -#include - -/* This data is transferred from eu4 provinces to v3 chunks, then passed along to v3 substates and then processed there. */ - -namespace EU4 -{ -class PopRatio; -} -namespace V3 -{ -struct SourceProvinceData -{ - std::string owner; - double weight = 0; // absolute dev + buildings - double investmentFactor = 0; // a popshaping factor that is a log function of investedWeight in the source province - std::vector popRatios; - std::set buildings; - std::set cores; - bool territorialCore = false; - bool sea = false; - std::set eu4Capitals; -}; - -} // namespace V3 - -#endif // V3_SOURCE_PROVINCE_DATA_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/ClayManager/State/State.cpp b/EU5ToVic3/Source/V3World/ClayManager/State/State.cpp deleted file mode 100644 index a7b0b8d..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/State/State.cpp +++ /dev/null @@ -1,293 +0,0 @@ -#include "State.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "Province.h" -#include "SubState.h" -#include -#include -#include - -void V3::State::loadState(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); - updateProvinces(); - - distributeLandshares(); - distributeResources(); -} - -void V3::State::registerKeys() -{ - registerKeyword("provinces", [this](std::istream& theStream) { - for (const auto& provinceName: commonItems::getStrings(theStream)) - { - auto theProvinceName = provinceName; - std::transform(theProvinceName.begin(), theProvinceName.end(), theProvinceName.begin(), ::toupper); - if (theProvinceName.starts_with("X") && theProvinceName.size() == 7) - theProvinceName = "x" + theProvinceName.substr(1, theProvinceName.length() - 1); // from "x12345a" to x12345A - else - Log(LogLevel::Warning) << "Loading province " << theProvinceName << " in unknown format!"; - const auto province = std::make_shared(); - province->setName(theProvinceName); - provinces.emplace(theProvinceName, province); - } - }); - registerKeyword("prime_land", [this](std::istream& theStream) { - for (const auto& provinceName: commonItems::getStrings(theStream)) - { - auto theProvinceName = provinceName; - std::transform(theProvinceName.begin(), theProvinceName.end(), theProvinceName.begin(), ::toupper); - if (theProvinceName.starts_with("X") && theProvinceName.size() == 7) - theProvinceName = "x" + theProvinceName.substr(1, theProvinceName.length() - 1); - else - Log(LogLevel::Warning) << "Encountered prime province " << theProvinceName << " in unknown format!"; - primeProvinces.emplace(theProvinceName); - } - }); - registerKeyword("impassable", [this](std::istream& theStream) { - for (const auto& provinceName: commonItems::getStrings(theStream)) - { - auto theProvinceName = provinceName; - std::transform(theProvinceName.begin(), theProvinceName.end(), theProvinceName.begin(), ::toupper); - if (theProvinceName.starts_with("X") && theProvinceName.size() == 7) - theProvinceName = "x" + theProvinceName.substr(1, theProvinceName.length() - 1); - else - Log(LogLevel::Warning) << "Encountered impassable province " << theProvinceName << " in unknown format!"; - impassableProvinces.emplace(theProvinceName); - } - }); - registerKeyword("traits", [this](std::istream& theStream) { - traits = commonItems::getStrings(theStream); - }); - registerKeyword("arable_land", [this](std::istream& theStream) { - cappedResources["bg_agriculture"] = commonItems::getInt(theStream); - }); - registerKeyword("arable_resources", [this](std::istream& theStream) { - arableResources = commonItems::getStrings(theStream); - }); - registerKeyword("capped_resources", [this](std::istream& theStream) { - for (const auto& [resource, amount]: commonItems::assignments(theStream).getAssignments()) - { - try - { - cappedResources[resource] = std::stoi(amount); - } - catch (const std::exception& e) - { - Log(LogLevel::Error) << "Failed reading amount of " << resource << " in the state: " << e.what(); - } - } - }); - registerKeyword("id", [this](std::istream& theStream) { - ID = commonItems::getInt(theStream); - }); - registerKeyword("naval_exit_id", [this](std::istream& theStream) { - navalExitID = commonItems::getInt(theStream); - coastal = true; - }); - registerKeyword("port", [this](std::istream& theStream) { - auto theProvinceName = commonItems::getString(theStream); - std::transform(theProvinceName.begin(), theProvinceName.end(), theProvinceName.begin(), ::toupper); - if (theProvinceName.starts_with("X") && theProvinceName.size() == 7) - theProvinceName = "x" + theProvinceName.substr(1, theProvinceName.length() - 1); - else - Log(LogLevel::Warning) << "Encountered port " << theProvinceName << " in unknown format!"; - if (provinces.contains(theProvinceName)) - provinces.at(theProvinceName)->setPort(); - else - Log(LogLevel::Warning) << "Port province " << theProvinceName << " isn't defined in the state! (Vanilla?) Map error. Ignoring port."; - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -void V3::State::updateProvinces() const -{ - for (const auto& impassableProvince: impassableProvinces) - { - if (provinces.contains(impassableProvince)) - provinces.at(impassableProvince)->setImpassable(); - else - Log(LogLevel::Warning) << "Impassable province " << impassableProvince << " isn't defined in the state " << name << "! Ignoring."; - } - for (const auto& primeProvince: primeProvinces) - { - if (provinces.contains(primeProvince)) - provinces.at(primeProvince)->setPrime(); - else - Log(LogLevel::Warning) << "Prime province " << primeProvince << " isn't defined in the state " << name << "! Ignoring."; - } -} - -void V3::State::distributeLandshares() const -{ - const auto [stateTotal, statePrimes, stateImpassables] = countProvinceTypes(provinces); - const double weightedStatewideProvinces = getWeightedProvinceTotals(stateTotal, statePrimes, stateImpassables); - - for (const auto& subState: substates) - { - const auto [subStateTotal, subStatePrimes, subStateImpassables] = countProvinceTypes(subState->getProvinces()); - const double weightedSubStateProvinces = getWeightedProvinceTotals(subStateTotal, subStatePrimes, subStateImpassables); - - double subStateLandshare = weightedSubStateProvinces / weightedStatewideProvinces; - if (subStateLandshare < 0.05) // In defines as SPLIT_STATE_MIN_LAND_SHARE - { - subStateLandshare = 0.05; - } - subState->setLandshare(subStateLandshare); - } -} - -void V3::State::distributeResources() -{ - for (const auto& subState: substates) - { - for (const auto& [resource, amount]: cappedResources) - { - subState->setResource(resource, static_cast(floor(subState->getLandshare() * amount))); - } - } -} - -int V3::State::getWeightedProvinceTotals(const int total, const int primes, const int impassables) -{ - // prime coefficient is the define SPLIT_STATE_PRIME_LAND_WEIGHT - 1 - return total + (5 - 1) * primes - impassables; -} - -std::tuple V3::State::countProvinceTypes(ProvinceMap provinces) -{ - int primes = 0; - int impassables = 0; - - for (const auto& province: std::views::values(provinces)) - { - if (province->isPrime()) - { - ++primes; - } - if (province->isImpassable()) - { - ++impassables; - } - } - - return std::make_tuple(static_cast(provinces.size()), primes, impassables); -} - -std::shared_ptr V3::State::getProvince(const std::string& provinceName) const -{ - if (provinces.contains(provinceName)) - return provinces.at(provinceName); - return nullptr; -} - -bool V3::State::isSea() const -{ - // We allow for a sea to be mismapped along regular provinces as vanilla has a few seas so mismapped (CHAD! KORDOFAN! Literally everywhere!). - - return std::all_of(provinces.begin(), provinces.end(), [](const std::pair>& province) { - return province.second->isSea(); - }); -} - -bool V3::State::isLake() const -{ - // We allow for a lakes to be mismapped along regular provinces as vanilla has a few lakes so mismapped. - - return std::all_of(provinces.begin(), provinces.end(), [](const std::pair>& province) { - return province.second->isLake(); - }); -} - -V3::ProvinceMap V3::State::getUnassignedProvinces() const -{ - ProvinceMap unassignedProvinces; - std::set seenProvinceIDs; - - for (const auto& subState: substates) - for (const auto& provinceID: subState->getProvinces() | std::views::keys) - seenProvinceIDs.emplace(provinceID); - - for (const auto& [provinceID, province]: provinces) - if (!seenProvinceIDs.contains(provinceID)) - unassignedProvinces.emplace(provinceID, province); - - return unassignedProvinces; -} - -bool V3::State::hasUnassignedProvinces() const -{ - // it's faster to count than to filter. - const auto assignedProvinces = std::accumulate(substates.begin(), substates.end(), 0, [](int sum, const auto& subState) { - return sum + static_cast(subState->getProvinces().size()); - }); - if (provinces.size() - assignedProvinces == 0) - return false; - return true; -} - -int V3::State::getStatePopCount() const -{ - return std::accumulate(substates.begin(), substates.end(), 0, [](int sum, const auto& subState) { - return sum + subState->getSubStatePops().getPopCount(); - }); -} - -int V3::State::getStateSlavePopCount() const -{ - return std::accumulate(substates.begin(), substates.end(), 0, [](int sum, const auto& subState) { - return sum + subState->getSubStatePops().getSlavePopCount(); - }); -} - -double V3::State::getTotalSubStateWeight() const -{ - return std::accumulate(substates.begin(), substates.end(), 0.0, [](double sum, const auto& subState) { - if (subState->getWeight()) - return sum + *subState->getWeight(); - else - return sum; - }); -} - -std::set V3::State::getClaims() const -{ - std::set claims; - for (const auto& subState: substates) - claims.insert(subState->getClaims().begin(), subState->getClaims().end()); - return claims; -} - -double V3::State::getInvestmentFactor() const -{ - double toReturn = 0; - for (const auto& subState: substates) - for (const auto& [data, weight]: subState->getSourceProvinceData()) - toReturn += data.investmentFactor * weight; - toReturn /= static_cast(substates.size()); - return toReturn; -} - -void V3::State::distributeNonTreatyPortPops(int incomingPops) -{ - // We're taking pops from a treaty port in this state and distributing the number to other substates. - - for (const auto& subState: substates) - { - if (subState->isTreatyPort()) - continue; - - const auto& landShare = subState->getLandshare(); - const auto& originalSubStatePopCount = subState->getSubStatePops().getPopCount(); - const double newPopCount = originalSubStatePopCount + static_cast(std::round(landShare * incomingPops)); - const double modifyFactor = newPopCount / originalSubStatePopCount; - - auto newPops = subState->getSubStatePops(); - newPops.multiplyPops(modifyFactor); - - subState->setSubStatePops(newPops); - } -} diff --git a/EU5ToVic3/Source/V3World/ClayManager/State/State.h b/EU5ToVic3/Source/V3World/ClayManager/State/State.h deleted file mode 100644 index ab92cad..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/State/State.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef STATE_H -#define STATE_H -#include "ClayManager/ClayMapTypedefs.h" -#include "PopManager/Pops/StatePops.h" -#include - -namespace V3 -{ -class SubState; -class Province; -class State: commonItems::parser -{ - public: - State() = default; - void loadState(std::istream& theStream); - void setStateName(const std::string& theName) { name = theName; } - void addSubState(const std::shared_ptr& substate) { substates.push_back(substate); } - void setSubStates(const std::vector>& theSubStates) { substates = theSubStates; } - void distributeLandshares() const; - void distributeResources(); - void addHomeland(const auto& homeland) { homelands.emplace(homeland); } - void updateProvinces() const; - - void distributeNonTreatyPortPops(int incomingPops); - - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] bool containsProvince(const std::string& provinceName) const { return provinces.contains(provinceName); } - [[nodiscard]] std::shared_ptr getProvince(const std::string& provinceName) const; - [[nodiscard]] const auto& getProvinces() const { return provinces; } - [[nodiscard]] const auto& getSubStates() const { return substates; } - [[nodiscard]] const auto& getHomelands() const { return homelands; } - [[nodiscard]] std::set getClaims() const; - - [[nodiscard]] bool isCoastal() const { return coastal; } - [[nodiscard]] auto getNavalExitID() const { return navalExitID; } - [[nodiscard]] auto getID() const { return ID; } - [[nodiscard]] bool isSea() const; - [[nodiscard]] bool isLake() const; // yes, an entire state can be a lake. - - [[nodiscard]] const auto& getTraits() const { return traits; } - [[nodiscard]] const auto& getCappedResources() const { return cappedResources; } - [[nodiscard]] const auto& getArableResources() const { return arableResources; } - - [[nodiscard]] ProvinceMap getUnassignedProvinces() const; - [[nodiscard]] bool hasUnassignedProvinces() const; - [[nodiscard]] int getStatePopCount() const; - [[nodiscard]] int getStateSlavePopCount() const; - [[nodiscard]] double getTotalSubStateWeight() const; - [[nodiscard]] double getInvestmentFactor() const; - - private: - void registerKeys(); - - static int getWeightedProvinceTotals(int total, int primes, int impassable); - static std::tuple countProvinceTypes(ProvinceMap provinces); - - bool coastal = false; - int navalExitID = 0; - int ID = 0; - std::string name; - ProvinceMap provinces; // in xA2345A format - std::set impassableProvinces; - std::set primeProvinces; - std::vector> substates; - std::vector traits; // state_trait_natural_harbors - std::map cappedResources; // RGO and arable land potential - std::vector arableResources; // Which buildings can be built on arable land - std::set homelands; -}; -} // namespace V3 -#endif // STATE_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/ClayManager/State/StateModifier.cpp b/EU5ToVic3/Source/V3World/ClayManager/State/StateModifier.cpp deleted file mode 100644 index 0d8562e..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/State/StateModifier.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "StateModifier.h" -#include "CommonRegexes.h" -#include "EconomyManager/Building/BuildingGroups.h" -#include "ParserHelpers.h" -#include -#include - -#include "Log.h" - -void V3::StateModifier::loadStateModifier(std::istream& theStream) -{ - registerKeys(); - modifierUnwrapper.parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::StateModifier::registerKeys() -{ - modifierUnwrapper.registerKeyword("modifier", [this](std::istream& theStream) { - parseStream(theStream); - }); - modifierUnwrapper.IgnoreUnregisteredItems(); - - registerRegex("state_building_[a-zA-Z_]+_max_level_add", [this](const std::string& modifier, std::istream& theStream) { - const std::regex pattern("state_building_([a-zA-Z_]+)_max_level_add"); - std::smatch building; - if (std::regex_search(modifier, building, pattern)) // state_building_port_max_level_add -> port - { - maxBuildingLevels["building_" + building[1].str()] = commonItems::getInt(theStream); - } - else - { - Log(LogLevel::Error) << "Found a max level modifier, but could not parse it: " << modifier; - } - }); - registerKeyword("state_infrastructure_add", [this](std::istream& theStream) { - infrastructure = commonItems::getInt(theStream); - }); - registerKeyword("state_infrastructure_mult", [this](std::istream& theStream) { - infrastructureMult = commonItems::getDouble(theStream); - }); - registerRegex(R"(building_output_\w+_mult)", [this](const std::string& modifierName, std::istream& theStream) { - // Goods based throughput modifiers - const auto& id = modifierName.substr(0, modifierName.size() - 5); // name before _mult - goodsModifiers.emplace(id, commonItems::getDouble(theStream)); - }); - registerRegex(R"(building_group_\w+_mult)", [this](const std::string& modifierName, std::istream& theStream) { - // Building Group based throughput modifiers - const auto& id = modifierName.substr(15, modifierName.size() - 31); // name between building_group_ and _throughput_mult - buildingGroupModifiers.emplace(id, commonItems::getDouble(theStream)); - }); - registerRegex(R"(building_\w+_mult)", [this](const std::string& modifierName, std::istream& theStream) { - // Building based throughput modifiers - const auto& id = modifierName.substr(0, modifierName.size() - 16); // name before _throughput_mult - buildingModifiers.emplace(id, commonItems::getDouble(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional V3::StateModifier::getMaxBuildingBonus(const std::string& building) const -{ - if (maxBuildingLevels.contains(building)) - { - return maxBuildingLevels.at(building); - } - return std::nullopt; -} - -double V3::StateModifier::getAllBonuses(const std::map& modifierMap) -{ - auto modifiers = std::views::values(modifierMap); - - return std::accumulate(modifiers.begin(), modifiers.end(), 0.0); -} - -std::optional V3::StateModifier::getBuildingGroupModifier(const std::string& buildingGroup, const BuildingGroups& bgs) const -{ - std::optional currentGroup = buildingGroup; - do - { - if (const auto& mod = buildingGroupModifiers.find(currentGroup.value()); mod != buildingGroupModifiers.end()) - { - return mod->second; - } - currentGroup = bgs.tryGetParentName(currentGroup); - } while (currentGroup); - - return std::nullopt; -} - -std::optional V3::StateModifier::getBuildingModifier(const std::string& building) const -{ - if (const auto& possibleModifier = buildingModifiers.find(building); possibleModifier != buildingModifiers.end()) - { - return possibleModifier->second; - } - return std::nullopt; -} - -std::optional V3::StateModifier::getGoodsModifier(const std::string& good) const -{ - if (const auto& possibleModifier = goodsModifiers.find(good); possibleModifier != goodsModifiers.end()) - { - return possibleModifier->second; - } - return std::nullopt; -} \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/ClayManager/State/StateModifier.h b/EU5ToVic3/Source/V3World/ClayManager/State/StateModifier.h deleted file mode 100644 index ffd62c2..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/State/StateModifier.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef STATE_MODIFIER_H -#define STATE_MODIFIER_H -#include "EconomyManager/Building/BuildingGroups.h" -#include "Parser.h" - -namespace V3 -{ -class StateModifier: commonItems::parser -{ - public: - StateModifier() = default; - void loadStateModifier(std::istream& theStream); - void setName(const std::string& theName) { name = theName; } - - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getInfrastructureBonus() const { return infrastructure; } - [[nodiscard]] const auto& getInfrastructureMult() const { return infrastructureMult; } - [[nodiscard]] std::optional getMaxBuildingBonus(const std::string& building) const; - [[nodiscard]] const auto& getBuildingGroupModifiersMap() const { return buildingGroupModifiers; } - [[nodiscard]] const auto& getBuildingModifiersMap() const { return buildingModifiers; } - [[nodiscard]] const auto& getGoodsModifiersMap() const { return goodsModifiers; } - [[nodiscard]] static double getAllBonuses(const std::map& modifierMap); // Sum of all modifiers off a single type - [[nodiscard]] std::optional getBuildingGroupModifier(const std::string& buildingGroup, const BuildingGroups& bgs) const; - [[nodiscard]] std::optional getBuildingModifier(const std::string& building) const; - [[nodiscard]] std::optional getGoodsModifier(const std::string& good) const; - - private: - void registerKeys(); - parser modifierUnwrapper; - - std::string name; // state_trait_natural_harbors - - int infrastructure = 0; - double infrastructureMult = 0.0; - std::map maxBuildingLevels; // how much this trait contributes to the max cap of a building - std::map buildingGroupModifiers; // building_group to throughput modifier - std::map buildingModifiers; // building to throughput modifier - std::map goodsModifiers; // good to goods throughput modifier -}; -} // namespace V3 - -#endif // STATE_MODIFIER_H diff --git a/EU5ToVic3/Source/V3World/ClayManager/State/SubState.cpp b/EU5ToVic3/Source/V3World/ClayManager/State/SubState.cpp deleted file mode 100644 index 7bd7124..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/State/SubState.cpp +++ /dev/null @@ -1,738 +0,0 @@ -#include "SubState.h" -#include "EconomyManager/Building/Building.h" -#include "EconomyManager/Building/BuildingGroup.h" -#include "Log.h" -#include "Mappers/CultureMapper/CultureMapper.h" -#include "Mappers/ReligionMapper/ReligionMapper.h" -#include "PoliticalManager/Country/Country.h" -#include "Province.h" -#include "ProvinceManager/PopRatio.h" -#include "State.h" -#include "StateModifier.h" -#include -#include -#include -#include -#include - -namespace -{ -std::vector sortMap(const std::map& theMap) -{ - std::vector sorted; - - std::vector> pairs; - for (const auto& theElement: theMap) - pairs.emplace_back(theElement); - - std::sort(pairs.begin(), pairs.end(), [=](const std::pair& a, const std::pair& b) { - return a.second > b.second; - }); - - for (const auto& tag: pairs | std::views::keys) - sorted.emplace_back(tag); - - return sorted; -} -} // namespace - - -V3::SubState::SubState(std::shared_ptr theHomeState, ProvinceMap theProvinces): homeState(std::move(theHomeState)), provinces(std::move(theProvinces)) -{ - calculateTerrainFrequency(); -} - -void V3::SubState::setProvinces(const ProvinceMap& theProvinces) -{ - provinces = theProvinces; - calculateTerrainFrequency(); -} - -int V3::SubState::getResource(const std::string& theResource) const -{ - if (const auto resource = resources.find(theResource); resource != resources.end()) - { - return resource->second; - } - return 0; -} - -double V3::SubState::getTerrainFrequency(const std::string& theTerrain) const -{ - if (const auto terrain = terrainFrequency.find(theTerrain); terrain != terrainFrequency.end()) - { - return terrain->second; - } - return 0; -} - -double V3::SubState::getOverPopulation() const -{ - const double pops = subStatePops.getPopCount(); - const double capacity = getResource("bg_agriculture") * 5000.0; // One arable land supports roughly 5k people. - if (capacity < 5000) - { - return 10.0; - } - const auto ratio = pops / capacity; - if (ratio < 1.0) - { - return 1.0; - } - return ratio; -} - -void V3::SubState::gatherPossibleBuildings(const std::map& templateBuildings, - const BuildingGroups& buildingGroups, - const std::map>& buildingTerrainModifiers, - const mappers::BuildingMapper& buildingMapper, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap, - const double traitStrength) -{ - for (const auto& templateBuilding: templateBuildings | std::views::values) - { - if (!isBuildingValid(templateBuilding, buildingGroups, lawsMap, techMap, traitMap)) - { - continue; - } - - // New building from template. Initialize weight and add to substate - const auto building = std::make_shared(templateBuilding); - - building->setWeight(calcBuildingWeight(*building, buildingGroups, buildingTerrainModifiers, buildingMapper, lawsMap, techMap, traitMap, traitStrength)); - buildings.push_back(building); - } - sortBuildingsByWeight(); -} - -void V3::SubState::weightBuildings(const BuildingGroups& buildingGroups, - const std::map>& buildingTerrainModifiers, - const mappers::BuildingMapper& buildingMapper, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap, - const double traitStrength) -{ - for (const auto& building: buildings) - { - building->setWeight(calcBuildingWeight(*building, buildingGroups, buildingTerrainModifiers, buildingMapper, lawsMap, techMap, traitMap, traitStrength)); - } - - sortBuildingsByWeight(); -} - -void V3::SubState::sortBuildingsByWeight() -{ - std::ranges::sort(buildings, [](const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return lhs->getWeight() > rhs->getWeight(); - }); -} - -bool V3::SubState::isCoastal() const -{ - return std::ranges::any_of(provinces, [this](const auto& province) { - return province.second->isCoastal(); - }); -} - -std::optional V3::SubState::getOwnerTag() const -{ - if (owner) - return owner->getTag(); - return std::nullopt; -} - -const std::string& V3::SubState::getHomeStateName() const -{ - if (homeState) - { - return homeState->getName(); - } - else - { - static const std::string empty; - Log(LogLevel::Warning) << "Attempted to access the name of a nullptr state from a substate. Returning empty name."; - return empty; - } -} - -bool V3::SubState::greaterBudget(const std::shared_ptr& lhs, const std::shared_ptr& rhs) -{ - return lhs->getCPBudget() > rhs->getCPBudget(); -} - -void V3::SubState::calculateTerrainFrequency() -{ - for (const auto& province: std::views::values(provinces)) - { - if (province->isCoastal()) - { - // Create in effect coastal_mountains, coastal_plains, etc. terrain. - terrainFrequency["coastal"] += 0.5; - terrainFrequency[province->getTerrain()] += 0.5; - } - else - { - terrainFrequency[province->getTerrain()] += 1; - } - } - - const auto& frequencies = std::views::values(terrainFrequency); - const double total = std::reduce(frequencies.begin(), frequencies.end()); - - for (const auto& [terrain, count]: terrainFrequency) - { - terrainFrequency[terrain] = count / total; - } -} - -double V3::SubState::getPopInfrastructure(const std::map& techMap) const -{ - // INDIVIDUALS_PER_POP_INFRASTRUCTURE = 10000 - const double popInfra = subStatePops.getPopCount() * owner->getTechInfraMult(techMap) / 10000.0; - if (const int cap = owner->getTechInfraCap(techMap); popInfra > cap) - { - return cap; - } - return popInfra; -} - -std::pair V3::SubState::getStateInfrastructureModifiers(const StateModifiers& theStateModifiers) const -{ - int bonus = 0; - double mult = 0; - for (const auto& stateModifier: getHomeState()->getTraits()) - { - if (!theStateModifiers.contains(stateModifier)) - { - // should never happen - continue; - } - bonus += theStateModifiers.at(stateModifier)->getInfrastructureBonus(); - mult += theStateModifiers.at(stateModifier)->getInfrastructureMult(); - } - return std::make_pair(bonus, mult); -} - - - -double V3::SubState::calcBuildingTerrainWeight(const std::string& building, - const std::map>& buildingTerrainModifiers) const -{ - - double theWeight = 0.0; - // Weight due to terrain - for (const auto& [terrain, frequency]: terrainFrequency) - { - if (!buildingTerrainModifiers.contains(terrain)) - continue; - if (!buildingTerrainModifiers.at(terrain).contains(building)) - continue; - - theWeight += frequency * buildingTerrainModifiers.at(terrain).at(building); - } - return theWeight; -} - -double V3::SubState::calcBuildingEU4Weight(const std::string& v3BuildingName, const mappers::BuildingMapper& buildingMapper) const -{ - // Weight from having EU4 buildings that map to VIC3 buildings in SubState weighted data. - // For a substate made from 5 full chunks each containing a university, weight for building_university will be 0.5. - // Give diminishing returns past 0.5 weight - - double totalWeight = 0; - for (const auto& [weightedData, dataWeight]: weightedSourceProvinceData) - for (const auto& eu4building: weightedData.buildings) - if (buildingMapper.getVic3Buildings(eu4building).contains(v3BuildingName)) - totalWeight += dataWeight / 10; - - // Diminishing returns past 5 buildings - if (totalWeight <= 0.5) - return totalWeight; - - // The lower this coefficient the more powerful the diminishing effect - constexpr double diminishingCoefficient = 0.8; - return 0.5 + diminishingCoefficient * (totalWeight - 0.5) / log10(1 + totalWeight); -} - -double V3::SubState::calcBuildingTraitWeight(const Building& building, const std::map& traitMap, const double traitStrength) const -{ - // Weight from having state traits that boost the building or building_group of building - // Goods outputs will be done later in PM pass - - const auto& buildingGroupName = building.getBuildingGroup(); - const auto& subStateTraits = getHomeState()->getTraits(); - for (const auto& trait: subStateTraits) - { - if (!traitMap.contains(trait)) - continue; - const auto& modifier = traitMap.at(trait); - - // take building if present, otherwise take building group. Don't stack both. - if (modifier.getBuildingModifiersMap().contains(building.getName())) - return 1 + modifier.getBuildingModifiersMap().at(building.getName()) * traitStrength; - if (modifier.getBuildingGroupModifiersMap().contains(buildingGroupName)) - return 1 + modifier.getBuildingGroupModifiersMap().at(buildingGroupName) * traitStrength; - } - return 1; -} - -double V3::SubState::calcBuildingInvestmentWeight(const Building& building) const -{ - // Weight modifier due to amount already built of given Building - // Simple percentage - if (originalCPBudget <= 0) - { - return 1; - } - - return std::max(1 - building.getConstructionCost() * building.getLevel() / static_cast(originalCPBudget), 0.0); -} - -double V3::SubState::calcBuildingIndustrialWeight(const Building& building, const BuildingGroups& buildingGroups) const -{ - // Must be at least a little bit industrial for this. - // If you're industrial then check for incorporation. - if (owner->getIndustryFactor() > 0 && owner->getProcessedData().civLevel >= 40) - return calcBuildingIncorporationWeight(building, buildingGroups); - - // You're non-industrial so urban buildings are not built. - const auto& category = buildingGroups.getAncestralCategory(building.getBuildingGroup()); - if (category) - { - if (*category == "urban") - return 0; - } - - // If building isn't urban, run incorporation check. - return calcBuildingIncorporationWeight(building, buildingGroups); -} - -double V3::SubState::calcBuildingOverPopulationWeight(const Building& building, const BuildingGroups& buildingGroups) const -{ - auto overPop = getOverPopulation(); - if (overPop <= 1.0) - { - return 1.0; - } - if (buildingGroups.usesArableLand(building.getBuildingGroup())) - { - return 1.0; - } - return overPop; -} - -double V3::SubState::calcBuildingIncorporationWeight(const Building& building, const BuildingGroups& buildingGroups) const -{ - // Only adjust unincorporated states. - if (isIncorporated()) - return 1; - - // Build fewer urban and military buildings for unincorps. - auto buildingGroup = buildingGroups.getBuildingGroupMap().at(building.getBuildingGroup()); - if (buildingGroup->getCategory()) - { - if (*buildingGroup->getCategory() == "urban") - return 0.8; - } - if (buildingGroup->getName() == "bg_military") - return 0.4; - - while (buildingGroup->getParentName()) - { - buildingGroup = buildingGroups.getBuildingGroupMap().at(*buildingGroup->getParentName()); - if (buildingGroup->getCategory()) - { - if (*buildingGroup->getCategory() == "urban") - return 0.8; - } - if (buildingGroup->getName() == "bg_military") - return 0.4; - } - - // If building isn't urban or military, no effect. - return 1; -} -bool V3::SubState::isBuildingValid(const Building& building, - const BuildingGroups& buildingGroups, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap) const -{ - // Government Admin is a special case, we're not building it. - if (building.getName() == "building_government_administration") - { - return false; - } - if (const std::set coastalBuildings = {"building_naval_base", "building_port", "building_shipyards"}; - coastalBuildings.contains(building.getName())) - { - if (!isCoastal()) - return false; - } - if (!building.isBuildable()) - { - return false; - } - // We can only build what we have the tech for. - if (!getOwner()->hasAnyOfTech(building.getUnlockingTechs())) - { - return false; - } - // Important, can't build a building if we have no CP to build it. This is what ends the loop. - if (building.getConstructionCost() > CPBudget) - { - return false; - } - // Unincorporated states shouldn't build any heavy industry. - if (!isIncorporated() && building.getBuildingGroup() == "bg_heavy_industry") - { - return false; - } - if (!hasRGO(building, buildingGroups)) - { - return false; - } - if (!hasCapacity(building, buildingGroups, lawsMap, techMap, traitMap)) - { - return false; - } - return true; -} - -bool V3::SubState::hasValidBuildings(const BuildingGroups& buildingGroups, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap) const -{ - return std::ranges::any_of(buildings, [this, buildingGroups, lawsMap, techMap, traitMap](const std::shared_ptr& building) { - return isBuildingValid(*building, buildingGroups, lawsMap, techMap, traitMap); - }); -} - -int V3::SubState::getBuildingCapacity(const Building& building, - const BuildingGroups& buildingGroups, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap) const -{ - if (building.isCappedByGov()) - { - return getGovCapacity(building.getName(), lawsMap, techMap, traitMap); - } - - if (const auto& isCapped = buildingGroups.tryGetIsCapped(building.getBuildingGroup()); isCapped && isCapped.value()) - { - return getRGOCapacity(building, buildingGroups); - } - - return INT_MAX; -} - -double V3::SubState::getTotalDev() const -{ - return std::accumulate(weightedSourceProvinceData.begin(), weightedSourceProvinceData.end(), 0.0, [](double sum, const auto& sourceProv) { - return sum + sourceProv.first.weight; - }); -} - -bool V3::SubState::hasCapacity(const Building& building, - const BuildingGroups& buildingGroups, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap) const -{ - // Check building cap first. - if (building.isCappedByGov()) - { - return getGovCapacity(building.getName(), lawsMap, techMap, traitMap) > 0; - } - - // If no cap on building, return true. - if (const auto& isCapped = buildingGroups.tryGetIsCapped(building.getBuildingGroup()); isCapped && !isCapped.value() || !isCapped) - { - return true; - } - // Then check building group cap. - return getRGOCapacity(building, buildingGroups) > 0; -} - -int V3::SubState::getRGOCapacity(const Building& building, const BuildingGroups& buildingGroups) const -{ - /* - NOTE: arable_land is stored in resources as bg_agriculture = # - All arable_resources have bg_agriculture as a parent group eventually, even if not directly. - Resources is stored in SubState, already calculated from State and landshare. - - - arable_land = 120 - arable_resources = { "bg_wheat_farms" "bg_livestock_ranches" "bg_cotton_plantations" } - capped_resources = { - bg_sulfur_mining = 20 - bg_logging = 2 - bg_fishing = 6 - } - */ - - // A building uses the capacity of their building group if that capacity exists, - // otherwise they use the capacity of the parent of their building group. - // If their building group's parent doesn't have capacity keep checking up the - // chain until a capacity is found or no more parents exist. - - auto buildingGroupName = building.getBuildingGroup(); - auto buildingGroup = buildingGroups.getBuildingGroupMap().at(buildingGroupName); - - const std::set stateArables = {homeState->getArableResources().begin(), homeState->getArableResources().end()}; - - // Is this a mineral-type resource? - if (resources.contains(buildingGroupName)) - { - return resources.at(buildingGroupName); - } - - // Maybe an arable one? - if (stateArables.contains(buildingGroupName)) - { - if (resources.contains("bg_agriculture")) - return resources.at("bg_agriculture"); - else - return 0; - } - - while (buildingGroup->getParentName()) - { - buildingGroupName = *buildingGroup->getParentName(); - buildingGroup = buildingGroups.getBuildingGroupMap().at(buildingGroupName); - if (resources.contains(buildingGroupName)) - { - return resources.at(buildingGroupName); - } - } - return 0; -} - -int V3::SubState::getGovCapacity(const std::string& building, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap) const -{ - const auto nationwide = owner->getGovBuildingMax(building, lawsMap, techMap); - const auto traits = - std::accumulate(homeState->getTraits().begin(), homeState->getTraits().end(), 0, [building, traitMap](const int sum, const std::string& trait) { - if (!traitMap.contains(trait)) - { - Log(LogLevel::Error) << "Couldn't find state trait definition for: " << trait; - return sum; - } - if (const auto bonus = traitMap.at(trait).getMaxBuildingBonus(building); bonus) - { - return sum + bonus.value(); - } - - return sum; - }); - return nationwide + traits; -} - -bool V3::SubState::hasRGO(const Building& building, const BuildingGroups& buildingGroups) const -{ - if (!buildingGroups.getBuildingGroupMap().contains(building.getBuildingGroup())) - return false; - - if (const auto& isCapped = buildingGroups.tryGetIsCapped(building.getBuildingGroup()); (isCapped && !isCapped.value()) || !isCapped) - return true; - - if (const auto& arables = homeState->getArableResources(); std::ranges::find(arables, building.getBuildingGroup()) != arables.end()) - return true; - - return homeState->getCappedResources().contains(building.getBuildingGroup()); -} - -double V3::SubState::calcBuildingWeight(const Building& building, - const BuildingGroups& buildingGroups, - const std::map>& buildingTerrainModifiers, - const mappers::BuildingMapper& buildingMapper, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap, - const double traitStrength) const -{ - if (!isBuildingValid(building, buildingGroups, lawsMap, techMap, traitMap)) - { - return -1; - } - - const double terrainWeight = calcBuildingTerrainWeight(building.getName(), buildingTerrainModifiers); - const double EU4BuildingWeight = calcBuildingEU4Weight(building.getName(), buildingMapper); - const double traitWeight = calcBuildingTraitWeight(building, traitMap, traitStrength); - const double investmentWeight = calcBuildingInvestmentWeight(building); - const double industrialWeight = calcBuildingIndustrialWeight(building, buildingGroups); - const double overPopWeight = calcBuildingOverPopulationWeight(building, buildingGroups); - - return (1 + terrainWeight + EU4BuildingWeight) * traitWeight * investmentWeight * industrialWeight * overPopWeight; -} - -void V3::SubState::calculateInfrastructure(const StateModifiers& theStateModifiers, const std::map& techMap) -{ - const double popInfra = getPopInfrastructure(techMap); - auto [stateModBonus, stateModMultipliers] = getStateInfrastructureModifiers(theStateModifiers); - - // Principal = Base + isCoastal(substate lvl) + State modifier bonus + (Pop * tech)_capped. - const double infraBase = 3 + 2 * isCoastal() + stateModBonus + popInfra; - - // Multipliers are additive, market capital + incorporation status + state modifier multipliers. - double multipliers = 0.25 * marketCapital + -0.25 * !isIncorporated() + stateModMultipliers; - multipliers = std::max(0.0, multipliers + 1); - - infrastructure = infraBase * multipliers; -} - -void V3::SubState::convertDemographics(const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader) -{ - // Just a few sanity checks which should never fail. - if (!homeState || !owner) - Log(LogLevel::Error) << "Not converting demographics in insane substate!"; - - std::vector newDemographics; - for (const auto& sourceData: weightedSourceProvinceData | std::views::keys) - { - for (const auto& popratio: sourceData.popRatios) - { - Demographic newDemo; - // Religion. - auto religionMatch = religionMapper.getV3Religion(popratio.getReligion()); - if (!religionMatch) - newDemo.religion = "noreligion"; - else - newDemo.religion = *religionMatch; - - // Culture. - auto cultureMatch = cultureMapper.cultureMatch(clayManager, - cultureLoader, - religionLoader, - popratio.getCulture(), - popratio.getReligion(), - homeState->getName(), - owner->getTag(), - popratio.isNeoCulture()); - if (!cultureMatch) - { - // This should happen literally never unless there is a system error in one of the mapping rules. - newDemo.culture = "noculture"; - if (popratio.isNeoCulture()) - Log(LogLevel::Warning) << "No neoculture match for: " << popratio.getCulture() << "/" << popratio.getReligion() << " in " << homeState->getName() - << " for " << owner->getTag(); - else - Log(LogLevel::Warning) << "No culture match for: " << popratio.getCulture() << "/" << popratio.getReligion() << " in " << homeState->getName() - << " for " << owner->getTag(); - } - else - newDemo.culture = *cultureMatch; - - newDemo.upperRatio = popratio.getUpperRatio(); - newDemo.middleRatio = popratio.getMiddleRatio(); - newDemo.lowerRatio = popratio.getLowerRatio(); - - newDemographics.push_back(newDemo); - } - } - demographics.swap(newDemographics); -} - -void V3::SubState::generatePops(int totalAmount, const int slaveAmount) -{ - // At this moment we're not concerned with pop types. HOWEVER, demographics do carry a varying amount of ratios, - // which are (were?) supposed to apply to those types. - // - // For now, we'll sum those ratios together and divide by 3, averaging them out. - - if (demographics.empty()) - return; - - if (totalAmount <= 0) - return; - - // *Technically* demoTotal should always equal 1. - const auto demoTotal = std::accumulate(demographics.begin(), demographics.end(), 0.0, [](double sum, const auto& demo) { - return sum + (demo.upperRatio + demo.middleRatio + demo.lowerRatio) / 3; - }); - - // TODO: plug in poptypes via PopPoints.h. If needed. - for (const auto& demo: demographics) - { - const double demoSum = (demo.upperRatio + demo.middleRatio + demo.lowerRatio) / 3; - if (totalAmount - slaveAmount >= 0) - { - auto pop = Pop(demo.culture, demo.religion, "", static_cast(round(static_cast(totalAmount - slaveAmount) * demoSum / demoTotal))); - subStatePops.addPop(pop); - if (slaveAmount > 0) - { - auto slavePop = Pop(demo.culture, demo.religion, "slaves", static_cast(round(static_cast(slaveAmount) * demoSum / demoTotal))); - subStatePops.addPop(slavePop); - } - } - else - { - Log(LogLevel::Warning) << "Substate in " << getHomeStateName() << " wants " << slaveAmount << " slaves but only gets " << totalAmount - << " pops! Bailing!"; - } - } -} - -std::optional V3::SubState::getPrimaryCulture() const -{ - if (subStatePops.getPopCount() == 0) - return std::nullopt; - - std::map census; - for (const auto& pop: subStatePops.getPops()) - { - if (pop.getCulture().empty()) - continue; - census[pop.getCulture()] += pop.getSize(); - } - auto sorted = sortMap(census); - return *sorted.begin(); -} - -std::set V3::SubState::getProvinceIDs() const -{ - std::set IDs; - for (const auto& province: provinces | std::views::keys) - IDs.emplace(province); - return IDs; -} - -void V3::SubState::setIncorporated(bool status) -{ - subStateTypes.clear(); - if (status) - subStateTypes.emplace("incorporated"); - else - subStateTypes.emplace("unincorporated"); -} - -void V3::SubState::setTreatyPort() -{ - subStateTypes.clear(); - subStateTypes.emplace("unincorporated"); - subStateTypes.emplace("treaty_port"); -} - -void V3::SubState::vacateTreatyPortPops() -{ - // Goal of this function is to shift 80% of pops from this substate, which is a treaty port, to other substates in this homestate. - // Otherwise the pops will starve. - - const auto totalPops = getSubStatePops().getPopCount(); - const auto popsToVacate = static_cast(std::round(totalPops * 0.8)); - - subStatePops.multiplyPops(0.2); - homeState->distributeNonTreatyPortPops(popsToVacate); -} diff --git a/EU5ToVic3/Source/V3World/ClayManager/State/SubState.h b/EU5ToVic3/Source/V3World/ClayManager/State/SubState.h deleted file mode 100644 index a18e8e1..0000000 --- a/EU5ToVic3/Source/V3World/ClayManager/State/SubState.h +++ /dev/null @@ -1,228 +0,0 @@ -#ifndef V3_SUBSTATE_H -#define V3_SUBSTATE_H -#include "ClayManager/ClayMapTypedefs.h" -#include "EconomyManager/Building/Building.h" -#include "Loaders/LawLoader/Law.h" -#include "Loaders/TechLoader/Tech.h" -#include "Mappers/BuildingMapper/BuildingMapper.h" -#include "PopManager/Demographic.h" -#include "PopManager/Pops/SubStatePops.h" -#include "SourceProvinceData.h" -#include "StateModifier.h" -#include - -/* A Substate is a cross-section across a set of chunks where all relevant chunk provinces fall within a geographical V3 state. - * This means, if 5 eu4 provinces generated 5 vic3 chunks, those portions of those chunks that fall within a STATE_ALABAMA and belong - * to a single owner would merge into a single TAG's STATE_ALABAMA substate, (bound by its single owner - TAG). - * A substate can be as big as a geographical state, or as small as a single province within it. - */ - -namespace EU4 -{ -class CultureLoader; -class ReligionLoader; -} // namespace EU4 -namespace mappers -{ -class CultureMapper; -class ReligionMapper; -class SlaveCultureMapper; -} // namespace mappers -namespace V3 -{ -class Country; -class Chunk; -class State; -class ClayManager; -class SubState -{ - public: - SubState() = default; - SubState(std::shared_ptr theHomeState, ProvinceMap theProvinces); - - void setHomeState(const std::shared_ptr& theState) { homeState = theState; } - void setOwner(const std::shared_ptr& theOwner) { owner = theOwner; } - void setCapital() { capital = true; } - void addHistoricalCapitals(const std::set& theCapitals) { eu4capitals = theCapitals; } - void setProvinces(const ProvinceMap& theProvinces); - void setSubStateTypes(const std::set& theTypes) { subStateTypes = theTypes; } - void addClaim(const std::string& tag) { claims.emplace(tag); } - void setClaims(const std::set& theClaims) { claims = theClaims; } - - void setSourceOwnerTag(const std::string& sourceTag) { sourceOwnerTag = sourceTag; } - void setWeight(double theWeight) { weight = theWeight; } - void setSourceProvinceData(const std::vector>& theData) { weightedSourceProvinceData = theData; } - - void setMarketCapital() { marketCapital = true; } - void setVanillaSubState() { vanillaSubState = true; } - void setLandshare(const double theLandshare) { landshare = theLandshare; } - void setResource(const std::string& theResource, const int theAmount) { resources[theResource] = theAmount; } - void setDemographics(const std::vector& demos) { demographics = demos; } - void setSubStatePops(const SubStatePops& thePops) { subStatePops = thePops; } - void addPop(const Pop& pop) { subStatePops.addPop(pop); } - void addPops(const std::vector& pops) { subStatePops.addPops(pops); } - void setVanillaPopCount(const int popCount) { vanillaPopCount = popCount; } - - void setIndustryWeight(const double theIndustryWeight) { industryWeight = theIndustryWeight; } - void setCPBudget(const int theCPBudget) { CPBudget = theCPBudget; } - void setOriginalCPBudget(const int theCPBudget) { originalCPBudget = theCPBudget; } - void spendCPBudget(const int theCPExpense) { CPBudget -= theCPExpense; } - void addBuilding(const std::shared_ptr& building) { buildings.push_back(building); } - void setVanillaBuildingElements(const std::vector& elements) { vanillaBuildingElements = elements; } - void calculateInfrastructure(const StateModifiers& theStateModifiers, const std::map& techMap); - - void gatherPossibleBuildings(const std::map& templateBuildings, - const BuildingGroups& buildingGroups, - const std::map>& buildingTerrainModifiers, - const mappers::BuildingMapper& buildingMapper, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap, - double traitStrength); - void weightBuildings(const BuildingGroups& buildingGroups, - const std::map>& buildingTerrainModifiers, - const mappers::BuildingMapper& buildingMapper, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap, - double traitStrength); - - void convertDemographics(const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader); - - void generatePops(int totalAmount, int slaveAmount); - - [[nodiscard]] const auto& getHomeState() const { return homeState; } - [[nodiscard]] const auto& getOwner() const { return owner; } - [[nodiscard]] auto isCapital() const { return capital; } - [[nodiscard]] const auto& getHistoricalCapitals() const { return eu4capitals; } - [[nodiscard]] std::set getProvinceIDs() const; - [[nodiscard]] const auto& getProvinces() const { return provinces; } - [[nodiscard]] const auto& getSubStateTypes() const { return subStateTypes; } - [[nodiscard]] const auto& getClaims() const { return claims; } - - [[nodiscard]] const auto& getSourceOwnerTag() const { return sourceOwnerTag; } - [[nodiscard]] const auto& getWeight() const { return weight; } - [[nodiscard]] const auto& getSourceProvinceData() const { return weightedSourceProvinceData; } - - [[nodiscard]] const auto& getLandshare() const { return landshare; } - [[nodiscard]] const auto& getInfrastructure() const { return infrastructure; } - [[nodiscard]] int getResource(const std::string& theResource) const; - [[nodiscard]] double getTerrainFrequency(const std::string& theTerrain) const; - [[nodiscard]] double getOverPopulation() const; - [[nodiscard]] const auto& getTerrainFrequencies() { return terrainFrequency; } - [[nodiscard]] const auto& getDemographics() const { return demographics; } - [[nodiscard]] const auto& getSubStatePops() const { return subStatePops; } - [[nodiscard]] const auto& getVanillaPopCount() const { return vanillaPopCount; } - [[nodiscard]] std::optional getPrimaryCulture() const; - - [[nodiscard]] const auto& getIndustryWeight() const { return industryWeight; } - [[nodiscard]] const auto& getCPBudget() const { return CPBudget; } - [[nodiscard]] const auto& getBuildings() const { return buildings; } - [[nodiscard]] const auto& getVanillaBuildingElements() const { return vanillaBuildingElements; } - [[nodiscard]] double calcBuildingWeight(const Building& building, - const BuildingGroups& buildingGroups, - const std::map>& buildingTerrainModifiers, - const mappers::BuildingMapper& buildingMapper, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap, - double traitStrength) const; - [[nodiscard]] bool hasValidBuildings(const BuildingGroups& buildingGroups, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap) const; - [[nodiscard]] int getBuildingCapacity(const Building& building, - const BuildingGroups& buildingGroups, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap) const; - [[nodiscard]] double getTotalDev() const; - - [[nodiscard]] auto isVanillaSubState() const { return vanillaSubState; } - [[nodiscard]] auto isIncorporated() const { return subStateTypes.contains("incorporated"); } - [[nodiscard]] auto isTreatyPort() const { return subStateTypes.contains("treaty_port"); } - [[nodiscard]] auto isMarketCapital() const { return marketCapital; } - [[nodiscard]] bool isCoastal() const; - - [[nodiscard]] std::optional getOwnerTag() const; - [[nodiscard]] const std::string& getHomeStateName() const; - - [[nodiscard]] bool isStagedForMinorities() const { return stageForMinorities; } - void setStageForMinorities(const bool stage) { stageForMinorities = stage; } - - [[nodiscard]] static bool greaterBudget(const std::shared_ptr& lhs, const std::shared_ptr& rhs); - - void setIncorporated(bool status); - void setTreatyPort(); - void vacateTreatyPortPops(); - - private: - void calculateTerrainFrequency(); - [[nodiscard]] double getPopInfrastructure(const std::map& techMap) const; - [[nodiscard]] std::pair getStateInfrastructureModifiers(const StateModifiers& theStateModifiers) const; - - void sortBuildingsByWeight(); - - [[nodiscard]] double calcBuildingTerrainWeight(const std::string& building, - const std::map>& buildingTerrainModifiers) const; - [[nodiscard]] double calcBuildingEU4Weight(const std::string& v3BuildingName, const mappers::BuildingMapper& buildingMapper) const; - [[nodiscard]] double calcBuildingTraitWeight(const Building& building, const std::map& traitMap, double traitStrength) const; - [[nodiscard]] double calcBuildingInvestmentWeight(const Building& building) const; - [[nodiscard]] double calcBuildingIndustrialWeight(const Building& building, const BuildingGroups& buildingGroups) const; - [[nodiscard]] double calcBuildingIncorporationWeight(const Building& building, const BuildingGroups& buildingGroups) const; - [[nodiscard]] double calcBuildingOverPopulationWeight(const Building& building, const BuildingGroups& buildingGroups) const; - [[nodiscard]] bool isBuildingValid(const Building& building, - const BuildingGroups& buildingGroups, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap) const; - [[nodiscard]] bool hasCapacity(const Building& building, - const BuildingGroups& buildingGroups, - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap) const; - [[nodiscard]] int getRGOCapacity(const Building& building, const BuildingGroups& buildingGroups) const; - [[nodiscard]] int getGovCapacity(const std::string& building, // barracks, ports things that have max capacities based on laws/tech/traits - const std::map& lawsMap, - const std::map& techMap, - const std::map& traitMap) const; - [[nodiscard]] bool hasRGO(const Building& building, const BuildingGroups& buildingGroups) const; - - std::shared_ptr homeState; // home state - std::shared_ptr owner; - bool capital = false; - std::set eu4capitals; // these eu4 tags had a capital in roughly this spot. - ProvinceMap provinces; // V3 province codes - std::set subStateTypes; // unincorporated, treat_port... - - std::optional sourceOwnerTag; // we may or may not have this, depending on where substate is imported from. - std::optional weight; // imported scaled sourceProvinceWeight from whatever source province(s) point generally here. - std::vector> weightedSourceProvinceData; - - bool vanillaSubState = false; // Is this substate imported from vanilla? - bool marketCapital = false; - double landshare = 0.0; // % of State's resources that are substate's - double infrastructure = 0.0; // limits the amount of industry a substate can support - std::map resources; // potential for a given resource based on landshare. {building_group -> #} - std::map terrainFrequency; // Normalized vector (math-wise) of terrain in substate as % - std::vector demographics; - SubStatePops subStatePops; - int vanillaPopCount = 0; // What pop of substate would be without adjustments - - double industryWeight = 0; // Share of owner's industry a substate should get, not normalized - int CPBudget = 0; // Construction Points for a substate to spend on its development - int originalCPBudget = 0; // Used in Building Weight calculations - std::vector> buildings; // buildings available to build in the subState - - std::vector vanillaBuildingElements; // vanilla buildings for this substate, ready for direct dump. - std::set claims; - - bool stageForMinorities = false; // runtime flag for pop processing -}; -} // namespace V3 - -#endif // V3_SUBSTATE_H diff --git a/EU5ToVic3/Source/V3World/EconomyManager/Building/Building.cpp b/EU5ToVic3/Source/V3World/EconomyManager/Building/Building.cpp deleted file mode 100644 index f94b9d1..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/Building/Building.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "Building.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void V3::Building::loadBuilding(std::istream& theStream, const std::map& costTiers) -{ - registerKeys(costTiers); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::Building::registerKeys(const std::map& costTiers) -{ - registerKeyword("building_group", [this](std::istream& theStream) { - buildingGroup = commonItems::getString(theStream); - }); - registerKeyword("buildable", [this](std::istream& theStream) { - if (commonItems::getString(theStream) == "no") - { - buildable = false; - } - }); - registerKeyword("has_max_level", [this](std::istream& theStream) { - if (commonItems::getString(theStream) == "yes") - { - governmentCapped = true; - } - }); - registerKeyword("production_method_groups", [this](std::istream& theStream) { - for (const auto& PMGroup: commonItems::getStrings(theStream)) - PMGroups.emplace(PMGroup); - }); - registerKeyword("unlocking_technologies", [this](std::istream& theStream) { - for (const auto& tech: commonItems::getStrings(theStream)) - unlockingTechs.emplace(tech); - }); - registerKeyword("required_construction", [this, &costTiers](std::istream& theStream) { - if (const auto costTier = commonItems::getString(theStream); costTiers.contains(costTier)) - { - constructionCost = costTiers.at(costTier); - } - else - { - // Maybe its a literal instead of a constant variable? - try - { - constructionCost = std::stoi(costTier); - } - catch (const std::exception& e) - { - Log(LogLevel::Error) << "Failed to understand building cost " << costTier << ": " << e.what(); - } - } - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/EconomyManager/Building/Building.h b/EU5ToVic3/Source/V3World/EconomyManager/Building/Building.h deleted file mode 100644 index 2e9060a..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/Building/Building.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef V3_BUILDING_H -#define V3_BUILDING_H -#include "Parser.h" - -namespace V3 -{ -class Building: commonItems::parser -{ - public: - Building() = default; - void loadBuilding(std::istream& theStream, const std::map& costTiers); - void setName(const std::string& theName) { name = theName; } - void setLevel(const int theLevel) { level = theLevel; } - void setWeight(const double theWeight) { weight = theWeight; } - void addPM(const std::string& pm) { PMs.emplace(pm); } - void setPMGroups(const std::set& pmgs) { PMGroups = pmgs; } - - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getBuildingGroup() const { return buildingGroup; } - [[nodiscard]] const auto& getPMGroups() const { return PMGroups; } - [[nodiscard]] const auto& getPMs() const { return PMs; } - [[nodiscard]] const auto& getConstructionCost() const { return constructionCost; } - [[nodiscard]] const auto& getUnlockingTechs() const { return unlockingTechs; } - [[nodiscard]] const auto& isBuildable() const { return buildable; } - [[nodiscard]] const auto& isCappedByGov() const { return governmentCapped; } - - [[nodiscard]] const auto& getLevel() const { return level; } - [[nodiscard]] const auto& getWeight() const { return weight; } - - private: - void registerKeys(const std::map& costTiers); - - // Static per type of building e.g. "building_port" - std::string name; - std::string buildingGroup; - std::set PMGroups; - int constructionCost = 50; - std::set unlockingTechs; - bool buildable = true; - bool governmentCapped = false; // barracks, ports, other caps done at the building not building group level by techs/laws/traits. - - // Specific to instance of building in SubState e.g. The port in New York - std::set PMs; // Only Production Methods that are different from default - int level = 0; - double weight = 0; -}; -} // namespace V3 - -#endif // V3_BUILDING_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroup.cpp b/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroup.cpp deleted file mode 100644 index 186c383..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroup.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "BuildingGroup.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -void V3::BuildingGroup::loadBuildingGroup(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::BuildingGroup::registerKeys() -{ - registerKeyword("parent_group", [this](std::istream& theStream) { - parent = commonItems::getString(theStream); - }); - registerKeyword("capped_by_resources", [this](std::istream& theStream) { - resourceCapped = (commonItems::getString(theStream) == "yes"); - }); - registerKeyword("land_usage", [this](std::istream& theStream) { - arableCapped = (commonItems::getString(theStream) == "rural"); - if (arableCapped) - { - resourceCapped = true; - } - }); - registerKeyword("parent_group", [this](std::istream& theStream) { - parent = commonItems::getString(theStream); - }); - registerKeyword("category", [this](std::istream& theStream) { - category = commonItems::getString(theStream); - }); - registerKeyword("infrastructure_usage_per_level", [this](std::istream& theStream) { - infrastructureCost = commonItems::getDouble(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroup.h b/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroup.h deleted file mode 100644 index 7d2ba79..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroup.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef V3_BUILDING_GROUP_H -#define V3_BUILDING_GROUP_H -#include "Parser.h" - -namespace V3 -{ -class BuildingGroup: commonItems::parser -{ - public: - BuildingGroup() = default; - void loadBuildingGroup(std::istream& theStream); - void setName(const std::string& theName) { name = theName; } - void setInfrastructureCost(const std::optional theCost) { infrastructureCost = theCost; } - void setResourceCap(const std::optional isCapped) { resourceCapped = isCapped; } - - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getParentName() const { return parent; } - [[nodiscard]] const auto& getCategory() const { return category; } - [[nodiscard]] const auto& getInfrastructureCost() const { return infrastructureCost; } - [[nodiscard]] const auto& possibleIsResourceCapped() const { return resourceCapped; } - [[nodiscard]] const auto& usesArableLand() const { return arableCapped; } - - private: - void registerKeys(); - std::string name; - std::optional parent; - std::optional category; - std::optional infrastructureCost; - std::optional resourceCapped; - std::optional arableCapped; -}; -} // namespace V3 - -#endif // V3_BUILDING_GROUP_H diff --git a/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroups.cpp b/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroups.cpp deleted file mode 100644 index 8532506..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroups.cpp +++ /dev/null @@ -1,148 +0,0 @@ -#include "BuildingGroups.h" -#include "BuildingGroup.h" -#include - -void V3::BuildingGroups::setInfrastructureCosts() -{ - for (const auto& buildingGroup: std::views::values(buildingGroups)) - { - auto parentGroupName = buildingGroup->getParentName(); - while (!buildingGroup->getInfrastructureCost() && parentGroupName) - { - buildingGroup->setInfrastructureCost(tryGetInfraCost(parentGroupName)); - parentGroupName = tryGetParentName(parentGroupName); - } - } -} - -void V3::BuildingGroups::setResourceCaps() -{ - for (const auto& buildingGroup: std::views::values(buildingGroups)) - { - auto parentGroupName = buildingGroup->getParentName(); - while (!buildingGroup->possibleIsResourceCapped() && parentGroupName) - { - buildingGroup->setResourceCap(tryGetIsCapped(parentGroupName)); - parentGroupName = tryGetParentName(parentGroupName); - } - } -} - -void V3::BuildingGroups::addBuildingGroup(const std::shared_ptr& theBuildingGroup) -{ - buildingGroups[theBuildingGroup->getName()] = theBuildingGroup; -} - -std::optional V3::BuildingGroups::getAncestralCategory(const std::optional& theGroupName) const -{ - if (!theGroupName) - { - return std::nullopt; - } - auto name = theGroupName.value(); - while (!name.empty()) - { - const auto& possibleGroup = buildingGroups.find(name); - if (possibleGroup == buildingGroups.end()) - { - break; - } - const auto cat = possibleGroup->second->getCategory(); - if (cat) - { - return *cat; - } - const auto& parentName = possibleGroup->second->getParentName(); - if (!parentName) - { - break; - } - name = parentName.value(); - } - - return std::nullopt; -} - -bool V3::BuildingGroups::usesArableLand(const std::optional& theGroupName) const -{ - if (!theGroupName) - { - return false; - } - auto name = theGroupName.value(); - while (!name.empty()) - { - const auto& possibleGroup = buildingGroups.find(name); - if (possibleGroup == buildingGroups.end()) - { - break; - } - const auto& cat = possibleGroup->second->getCategory(); - if (possibleGroup->second->usesArableLand()) - { - return true; - } - const auto& parentName = possibleGroup->second->getParentName(); - if (!parentName) - { - break; - } - name = parentName.value(); - } - - return false; -} - -std::optional V3::BuildingGroups::tryGetParentName(const std::optional& theGroupName) const -{ - if (!theGroupName) - return std::nullopt; - - const auto& possibleGroup = buildingGroups.find(theGroupName.value()); - if (possibleGroup != buildingGroups.end()) - { - return possibleGroup->second->getParentName(); - } - - return std::nullopt; -} - -std::optional V3::BuildingGroups::tryGetInfraCost(const std::optional& theGroupName) const -{ - if (!theGroupName) - return std::nullopt; - - const auto& possibleGroup = buildingGroups.find(theGroupName.value()); - if (possibleGroup != buildingGroups.end()) - { - return possibleGroup->second->getInfrastructureCost(); - } - - return std::nullopt; -} - -std::optional V3::BuildingGroups::tryGetIsCapped(const std::optional& theGroupName) const -{ - if (!theGroupName) - return std::nullopt; - - auto possibleGroup = buildingGroups.find(theGroupName.value()); - if (possibleGroup != buildingGroups.end()) - { - if (possibleGroup->second->possibleIsResourceCapped() && !*possibleGroup->second->possibleIsResourceCapped()) - return false; - if (possibleGroup->second->possibleIsResourceCapped() && *possibleGroup->second->possibleIsResourceCapped()) - return true; - while (possibleGroup->second->getParentName()) - possibleGroup = buildingGroups.find(*possibleGroup->second->getParentName()); - { - if (possibleGroup->second->possibleIsResourceCapped() && !*possibleGroup->second->possibleIsResourceCapped()) - return false; - if (possibleGroup->second->possibleIsResourceCapped() && *possibleGroup->second->possibleIsResourceCapped()) - return true; - } - return possibleGroup->second->possibleIsResourceCapped(); - } - - return std::nullopt; -} diff --git a/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroups.h b/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroups.h deleted file mode 100644 index 3e925b8..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/Building/BuildingGroups.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef V3_BUILDING_GROUPS_H -#define V3_BUILDING_GROUPS_H -#include "Parser.h" - -namespace V3 -{ -class BuildingGroup; -class BuildingGroups -{ - public: - BuildingGroups() = default; - void addBuildingGroup(const std::shared_ptr& theBuildingGroup); - void setInfrastructureCosts(); - void setResourceCaps(); - - [[nodiscard]] std::optional getAncestralCategory(const std::optional& theGroupName) const; - [[nodiscard]] const auto& getBuildingGroupMap() const { return buildingGroups; } - [[nodiscard]] std::optional tryGetParentName(const std::optional& theGroupName) const; - [[nodiscard]] std::optional tryGetInfraCost(const std::optional& theGroupName) const; - [[nodiscard]] std::optional tryGetIsCapped(const std::optional& theGroupName) const; - [[nodiscard]] bool usesArableLand(const std::optional& theGroupName) const; - - private: - std::map> buildingGroups; -}; -} // namespace V3 - -#endif // V3_BUILDING_GROUPS_H diff --git a/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethod.cpp b/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethod.cpp deleted file mode 100644 index beb5f49..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethod.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "ProductionMethod.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void V3::ProductionMethod::loadProductionMethod(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::ProductionMethod::registerKeys() -{ - registerKeyword("unlocking_technologies", [this](std::istream& theStream) { - for (const auto& tech: commonItems::getStrings(theStream)) - unlockingTechs.emplace(tech); - }); - registerKeyword("country_modifiers", [this](std::istream& theStream) { - cModUnwrapper.parseStream(theStream); - }); - registerKeyword("building_modifiers", [this](std::istream& theStream) { - bModUnwrapper.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - cModUnwrapper.registerKeyword("workforce_scaled", [this](std::istream& theStream) { - const auto& theAssignments = commonItems::assignments(theStream).getAssignments(); - if (!theAssignments.contains("country_bureaucracy_add")) - { - return; - } - - const std::string& bureaucracyString = theAssignments.at("country_bureaucracy_add"); - try - { - bureaucracy = std::stoi(bureaucracyString); - } - catch (const std::exception& e) - { - Log(LogLevel::Error) << "Failed to read bureaucracy output value " << bureaucracyString << ": " << e.what(); - } - }); - cModUnwrapper.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - bModUnwrapper.registerKeyword("level_scaled", [this](std::istream& theStream) { - const auto& theAssignments = commonItems::assignments(theStream).getAssignments(); - const std::regex pattern("building_employment_([a-zA-Z_]+)_add"); - - for (const auto& [jobEffect, employmentNumber]: theAssignments) - { - std::smatch job; - if (std::regex_search(jobEffect, job, pattern)) // building_employment_clerks_add -> clerks - { - try - { - employment[job[1].str()] = std::stoi(employmentNumber); - } - catch (const std::exception& e) - { - Log(LogLevel::Error) << "Failed to read employment number " << employmentNumber << ": " << e.what(); - } - } - } - }); - bModUnwrapper.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethod.h b/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethod.h deleted file mode 100644 index f9642c1..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethod.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef V3_PRODUCTION_METHOD_H -#define V3_PRODUCTION_METHOD_H -#include "Parser.h" - -namespace V3 -{ -class ProductionMethod: commonItems::parser -{ - public: - ProductionMethod() = default; - void loadProductionMethod(std::istream& theStream); - void setName(const std::string& theName) { name = theName; } - - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getEmployment() const { return employment; } - [[nodiscard]] const auto& getBureaucracy() const { return bureaucracy; } - [[nodiscard]] const auto& getUnlockingTechs() const { return unlockingTechs; } - - private: - void registerKeys(); - - parser cModUnwrapper; - parser bModUnwrapper; - - std::string name; - std::map employment; - int bureaucracy = 0; - std::set unlockingTechs; -}; -} // namespace V3 - -#endif // V3_PRODUCTION_METHOD_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethodGroup.cpp b/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethodGroup.cpp deleted file mode 100644 index 2a73f4c..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethodGroup.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "ProductionMethodGroup.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -void V3::ProductionMethodGroup::loadProductionMethodGroup(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::ProductionMethodGroup::registerKeys() -{ - registerKeyword("production_methods", [this](std::istream& theStream) { - PMs = commonItems::getStrings(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethodGroup.h b/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethodGroup.h deleted file mode 100644 index 24ec9bf..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/Building/ProductionMethods/ProductionMethodGroup.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef V3_PRODUCTION_METHOD_GROUP_H -#define V3_PRODUCTION_METHOD_GROUP_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class ProductionMethodGroup: commonItems::parser -{ - public: - ProductionMethodGroup() = default; - void loadProductionMethodGroup(std::istream& theStream); - void setName(const std::string& theName) { name = theName; } - - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getPMs() const { return PMs; } - - private: - void registerKeys(); - - std::string name; - std::vector PMs; -}; -} // namespace V3 - -#endif // V3_PRODUCTION_METHOD_GROUP_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/EconomyManager/EconomyManager.cpp b/EU5ToVic3/Source/V3World/EconomyManager/EconomyManager.cpp deleted file mode 100644 index dae6575..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/EconomyManager.cpp +++ /dev/null @@ -1,772 +0,0 @@ -#include "EconomyManager.h" -#include "Building/Building.h" -#include "Building/BuildingGroups.h" -#include "Building/ProductionMethods/ProductionMethod.h" -#include "Building/ProductionMethods/ProductionMethodGroup.h" -#include "ClayManager/State/State.h" -#include "ClayManager/State/StateModifier.h" -#include "ClayManager/State/SubState.h" -#include "EU5World/CountryManager/EU4Country.h" -#include "Loaders/BuildingLoader/BuildingGroupLoader.h" -#include "Loaders/BuildingLoader/BuildingLoader.h" -#include "Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodGroupLoader.h" -#include "Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodLoader.h" -#include "Loaders/DefinesLoader/EconDefinesLoader.h" -#include "Loaders/StateModifierLoader/StateModifierLoader.h" -#include "Loaders/TerrainLoader/TerrainModifierLoader.h" -#include "Log.h" -#include "PoliticalManager/Country/Country.h" -#include "PoliticalManager/PoliticalManager.h" -#include -#include -#include -#include - -void V3::EconomyManager::loadCentralizedStates(const std::map>& countries) -{ - Log(LogLevel::Info) << "-> Loading Centralized Countries for Economy Application."; - for (const auto& country: std::views::values(countries)) - { - if (!country) - continue; - if (country->getProcessedData().type == "decentralized") - continue; - if (country->getSubStates().empty()) - continue; - if (!country->getSourceCountry()) - continue; - if (country->getPopCount() <= 0) - continue; - - centralizedCountries.push_back(country); - } - Log(LogLevel::Info) << "<> Loaded " << centralizedCountries.size() << " Centralized Countries."; -} - -void V3::EconomyManager::loadMappersAndConfigs(const commonItems::ModFilesystem& modFS, const std::string& filePath) -{ - // If anything else ends up needing these, pass them in from World instead of loading direct in Econ - - loadTerrainModifierMatrices(filePath); - loadStateTraits(modFS); - loadBuildingInformation(modFS); - loadBuildingMappings(filePath); - loadPMMappings(filePath); - loadEconDefines(filePath); - loadNationalBudgets(filePath); - loadTechMap(modFS); -} - -void V3::EconomyManager::establishBureaucracy(const PoliticalManager& politicalManager) const -{ - Log(LogLevel::Info) << "-> Establishing Bureaucracy."; - if (!buildings.contains("building_government_administration")) - { - Log(LogLevel::Error) << "No building definition found for: building_government_administration."; - return; - } - - const auto& govAdmin = buildings.at("building_government_administration"); - - for (const auto& country: centralizedCountries) - { - // Check tech requirement for government administrations. - if (!country->hasAnyOfTech(govAdmin.getUnlockingTechs())) - { - continue; - } - - // Give 5% extra for trade routes - cap at +400 - const double usage = country->calculateBureaucracyUsage(politicalManager.getLawsMap()); - const double generationTarget = std::min(usage * 1.05, usage + 400) - 100; - - // Use the PM with the most generation available - int PMGeneration = 35; - const auto& PMName = pickBureaucracyPM(*country); - if (PMs.contains(PMName)) - { - PMGeneration = PMs.at(PMName).getBureaucracy(); - } - - country->distributeGovAdmins(generationTarget, PMGeneration, techMap.getTechs()); - } - Log(LogLevel::Info) << "<> Bureaucracy Established."; -} - -void V3::EconomyManager::hardcodePorts() const -{ - Log(LogLevel::Info) << "-> Hardcoding Ports."; - auto counter = 0; - - for (const auto& country: centralizedCountries) - { - for (const auto& subState: country->getSubStates()) - { - if (!subState->getVanillaBuildingElements().empty()) - continue; // don't affect states imported from vanilla. - if (!subState->isCoastal()) - continue; - - auto port = std::make_shared(); - port->setName("building_port"); - port->setPMGroups({"pmg_base_building_port"}); - port->setLevel(1); - - subState->addBuilding(port); - ++counter; - subState->getOwner()->addTech("navigation"); - } - } - Log(LogLevel::Info) << "<> Hardcoded " << counter << " ports."; -} - -void V3::EconomyManager::assignCountryCPBudgets(const Configuration::ECONOMY economyType, - const Configuration::STARTDATE startDate, - const DatingData& dateData, - const PoliticalManager& politicalManager, - const bool vn) const -{ - Log(LogLevel::Info) << "-> Assigning CP Budgets to Countries."; - // Some global value of CP to spend - double globalCP; - if (!vn) - globalCP = econDefines.getGlobalCP(); - else - globalCP = econDefines.getVNGlobalCP(); - const double dateFactor = calculateDateFactor(startDate, dateData); - const double globalPopFactor = calculateGlobalPopFactor(politicalManager); // Adjust based on amount of world centralized by population - - // Each country figures out its CP budget weight and reports back - auto [totalIndustryWeight, specialFactors] = countryBudgetCalcs(economyType); - - // distribute each country its budget - globalCP *= (1 + dateFactor + globalPopFactor + specialFactors); - distributeBudget(globalCP, totalIndustryWeight); - Log(LogLevel::Info) << std::fixed << std::setprecision(0) << "<> The world has " << globalCP << " CP to spend on industry."; -} - -void V3::EconomyManager::assignSubStateCPBudgets(const Configuration::ECONOMY economyType) const -{ - Log(LogLevel::Info) << "-> Distributing Economy Budgets to Substates."; - auto counter = 0; - // Distribute CP budget from a country to its substates - for (const auto& country: centralizedCountries) - { - double totalIndustryWeight = 0.0; // accumulate - for (const auto& subState: country->getSubStates()) - { - if (!subState) - continue; - if (subState->getProvinces().empty()) - continue; - - const double base = getBaseSubStateWeight(subState, economyType); - - // Adjust for terrain, incorporation status & state traits - const double terrainMultiplier = calculateTerrainMultiplier(subState); - const double stateTraitMultiplier = calculateStateTraitMultiplier(subState); - const double incorporatedMultiplier = subState->isIncorporated() ? 0.0 : econDefines.getIncorporatedModifier(); - - subState->setIndustryWeight(std::max(0.0, base * (1 + terrainMultiplier + stateTraitMultiplier + incorporatedMultiplier))); - totalIndustryWeight += subState->getIndustryWeight(); - } - - // Now back through substates, give each a percentage of country's budget based on percent of total industry score - for (const auto& subState: country->getSubStates()) - { - const double stateBudget = country->getCPBudget() * subState->getIndustryWeight() / totalIndustryWeight; - subState->setCPBudget(static_cast(std::round(stateBudget))); - subState->setOriginalCPBudget(subState->getCPBudget()); - ++counter; - } - } - Log(LogLevel::Info) << "<> Primed " << counter << " Substates for construction."; -} - -void V3::EconomyManager::balanceNationalBudgets() const -{ - Log(LogLevel::Info) << "-> Balancing Sub-National Budgets into Industry Sectors."; - for (const auto& country: centralizedCountries) - { - double totalWeight = 0; - - for (const auto& blueprint: nationalBudgets.getSectorBlueprints()) - { - const auto sector = std::make_shared(blueprint, *country); - country->addSector(blueprint.getName(), sector); - totalWeight += sector->getWeight(); - } - - for (const auto& sector: country->getProcessedData().industrySectors | std::views::values) - { - sector->calculateBudget(totalWeight, country->getCPBudget()); - } - } - Log(LogLevel::Info) << "<> Industry Sectors Primed."; -} - -void V3::EconomyManager::buildBuildings(const std::map& lawsMap) const -{ - Log(LogLevel::Info) << "-> Building buildings."; - auto counter = 0; - - // The great negotiation - // 1. The substate w/ the most CP asks to build its highest scoring building - // 2. The country checks if the sector that building belongs to has enough CP for at least 1 building - // 2b. If not, the substate moves on to the next highest scoring building until it exhausts its list. - // 2c. If a substate exhausts its building list without matching with a country's sector, it gets to ignore the country budget. - // 2d. The CP then comes out of the country's biggest sector - // 3. The state then builds as many buildings of that kind as it can, limited by capacity, packet size and sector CP - // 3b. capacity is RGO/arable land capacity, or can be law/tech based. - // 3c. packet size is based on the mean amount of CP states have left to build and is configurable - // 4. If a substate ends up with less CP than the cost for any possible valid building, they relinquish it to the next sector/substate - - for (const auto& country: centralizedCountries) - { - const auto& sectors = country->getProcessedData().industrySectors; - auto subStatesByBudget = prepareSubStatesByBudget(country, lawsMap); - - // Until every substate is unable to build anything - while (!subStatesByBudget.empty()) - { - // Enter negotiation - // Pick the substate with the most budget - negotiateBuilding(subStatesByBudget[0], sectors, lawsMap, subStatesByBudget); - ++counter; - - // A Building has now been built, process for next round - std::sort(subStatesByBudget.begin(), subStatesByBudget.end(), SubState::greaterBudget); - removeSubStateIfFinished(subStatesByBudget, subStatesByBudget.end() - 1, lawsMap); - } - } - Log(LogLevel::Info) << "<> Built " << counter << " buildings world-wide."; -} - -double V3::EconomyManager::calculatePopDistanceFactor(const int countryPopulation, const double geoMeanPopulation) -{ - if (const double popPercent = geoMeanPopulation / countryPopulation; popPercent >= 1) - { - return log(popPercent) + 1; - } - else - { - return log1p(popPercent) + 0.7; - } -} - -double V3::EconomyManager::calculateDateFactor(const Configuration::STARTDATE startDate, const DatingData& dateData) -{ - if (startDate == Configuration::STARTDATE::Dynamic) - { - const double factor = Country::yearCapFactor(dateData.lastEU4Date) - 1.0; - Log(LogLevel::Info) << std::fixed << std::setprecision(0) << "Altering global industry by " << factor * 100 << "% due to start date of " - << dateData.lastEU4Date << "."; - return factor; - } - return 0.0; -} - -std::pair V3::EconomyManager::countryBudgetCalcs(const Configuration::ECONOMY economyType) const -{ - // Returns total weight, and any special multiplicative factors specific to the method. - double totalWeight = 0; - - if (Configuration::ECONOMY::CivLevel == economyType) - return civLevelCountryBudgets(); - if (Configuration::ECONOMY::DevPopVanilla == economyType || Configuration::ECONOMY::DevPopActual == economyType) - return devCountryBudgets(economyType); - - return {totalWeight, 0.0}; -} - -std::pair V3::EconomyManager::civLevelCountryBudgets() const -{ - // The default way. - double accumulatedWeight = 0; - double totalCivLevel = 0.0; - const double geoMeanPop = calculateGeoMeanCentralizedPops(); - // While determining individual countries' industry scores, accumulate total industry factor and weight. - - for (const auto& country: centralizedCountries) - { - const int popCount = country->getPopCount(); - double weight = popCount * (country->getProcessedData().civLevel * 0.01); - weight *= calculatePopDistanceFactor(popCount, geoMeanPop); - weight *= country->getOverPopulation(); - country->setIndustryWeight(weight); - accumulatedWeight += country->getIndustryWeight(); - totalCivLevel += country->getProcessedData().civLevel; - } - - // Adjust global total by average industry factor compared to baseline. - const double globalIndustryFactor = (totalCivLevel / static_cast(centralizedCountries.size()) / econDefines.getMeanCivlevel()) - 1; - - Log(LogLevel::Info) << std::fixed << std::setprecision(0) << "<> The world is " << (globalIndustryFactor + 1) * 100 - << "% industrial compared to baseline. Compensating."; - - return {accumulatedWeight, globalIndustryFactor}; -} - -std::pair V3::EconomyManager::devCountryBudgets(const Configuration::ECONOMY perCapitaType) const -{ - double accumulatedWeight = 0; - - for (const auto& country: centralizedCountries) - { - if (perCapitaType == Configuration::ECONOMY::DevPopVanilla) - { - if (country->getVanillaPopCount() <= 0) - continue; - country->setPerCapitaDev(country->getTotalDev() / country->getVanillaPopCount()); - } - if (perCapitaType == Configuration::ECONOMY::DevPopActual) - { - if (country->getPopCount() <= 0) - continue; - country->setPerCapitaDev(country->getTotalDev() / country->getPopCount()); - } - const double techFactor = std::min(0.5, country->getProcessedData().productionTechPercentile) + 0.2; - const double densityFactor = getDensityFactor(country->getProcessedData().perCapitaDev); - - country->setIndustryWeight(country->getTotalDev() * densityFactor * techFactor); - accumulatedWeight += country->getIndustryWeight(); - } - - return {accumulatedWeight, 0}; -} - -double V3::EconomyManager::calculateGeoMeanCentralizedPops() const -{ - double sum = 0; - - for (const auto& country: centralizedCountries) - { - sum += log(country->getPopCount()); - } - - sum /= static_cast(centralizedCountries.size()); - - // Log(LogLevel::Debug) << "The Geometric Mean of all centralized countries population is : " << exp(sum); - return exp(sum); -} - -std::string V3::EconomyManager::pickBureaucracyPM(const Country& country) const -{ - int generation = 0; - std::string bestPMName = "pm_simple_organization"; - - if (!PMGroups.contains("pmg_base_building_government_administration")) - { - Log(LogLevel::Error) << "pmg_base_building_government_administration: Not in loaded Production Method Groups"; - return bestPMName; - } - - for (const auto& PMName: PMGroups.at("pmg_base_building_government_administration").getPMs()) - { - if (!PMs.contains(PMName)) - { - Log(LogLevel::Error) << PMName << ": Not in loaded Production Methods"; - return bestPMName; - } - - const auto& PM = PMs.at(PMName); - - // Only use PMs we have unlocked - if (!country.hasAnyOfTech(PM.getUnlockingTechs())) - { - continue; - } - - // Update best if the PM has a higher bureaucracy value - if (PM.getBureaucracy() > generation) - { - generation = PM.getBureaucracy(); - bestPMName = PM.getName(); - } - } - - return bestPMName; -} - -double V3::EconomyManager::calculateGlobalPopFactor(const PoliticalManager& politicalManager) const -{ - const double centralizedPopRatio = static_cast(PoliticalManager::getCountriesPopCount(centralizedCountries)) / politicalManager.getWorldPopCount(); - const double globalPopFactor = centralizedPopRatio / econDefines.getCentralizedPopRatio() - 1; - - Log(LogLevel::Info) << std::fixed << std::setprecision(0) << "<> The world is " << centralizedPopRatio * 100 - << "% Centralized by population. Adjusting global CP values by: " << globalPopFactor * 100 << "%."; - return globalPopFactor; -} - -double V3::EconomyManager::calculateTerrainMultiplier(const std::shared_ptr& subState) const -{ - const auto& country = subState->getOwner(); - double terrainMultiplier = 0; - - for (const auto& [terrain, frequency]: subState->getTerrainFrequencies()) - { - if (!stateTerrainModifiers.contains(terrain)) - { - if (terrain == "ocean" || terrain == "lake") - { - // Silently ignore oceans in Sahara. Yes, there are oceans in Sahara. - } - else - { - Log(LogLevel::Warning) << "Unrecognized terrain, " << terrain << ", in " << country->getTag() << "'s SubState " - << subState->getHomeState()->getName() << ". Ignoring."; - } - continue; - } - // 55% desert 45% plains state has a modifier that is 0.55*desert_modifer + 0.45*plains_modifier - terrainMultiplier += stateTerrainModifiers.at(terrain) * frequency; - } - - return terrainMultiplier; -} - -double V3::EconomyManager::calculateStateTraitMultiplier(const std::shared_ptr& subState) const -{ - double stateTraitMultiplier = 0; - for (const auto& trait: subState->getHomeState()->getTraits()) - { - if (!stateTraits.contains(trait)) - { - Log(LogLevel::Warning) << "Unrecognized state trait in " << subState->getHomeState()->getName() << ". Ignoring."; - continue; - } - const auto& stateTrait = stateTraits.at(trait); - - // Throughput bonuses to goods, buildings or whole building groups factor in - const double goodsModifiers = stateTrait.getAllBonuses(stateTrait.getGoodsModifiersMap()); - const double buildingsModifiers = stateTrait.getAllBonuses(stateTrait.getBuildingModifiersMap()); - const double buildingGroupsModifiers = stateTrait.getAllBonuses(stateTrait.getBuildingGroupModifiersMap()); - - // (20% goods bonus + -30% building bonus + 15% building group bonus) @ half strength = 2.5% Bonus = 0.025 - stateTraitMultiplier += (goodsModifiers + buildingsModifiers + buildingGroupsModifiers) * econDefines.getStateTraitStrength(); - } - return stateTraitMultiplier; -} - -double V3::EconomyManager::getDensityFactor(const double perCapitaDev) const -{ - // Plot a line between min and max per capita dev. Return a factor between minFactor and 1 based on % position on that line. - constexpr double minFactor = 0.3; - const double p = (perCapitaDev - econDefines.getMinDevPerPop() / econDefines.getMaxDevPerPop() - econDefines.getMinDevPerPop()); - if (p < 0) - return minFactor; - if (p > 1) - return 1; - return p + (1 - p) * minFactor; -} - -void V3::EconomyManager::distributeBudget(const double globalCP, const double totalIndustryScore) const -{ - for (const auto& country: centralizedCountries) - { - country->setCPBudget(static_cast(std::round(globalCP * (country->getIndustryWeight() / totalIndustryScore)))); - } -} - -void V3::EconomyManager::setPMs() const -{ - for (const auto& country: centralizedCountries) - { - PMMapper.applyRules(*country, PMs, PMGroups); - - // Gov Admin are special - const auto& adminPMName = pickBureaucracyPM(*country); - for (const auto& subState: country->getSubStates()) - { - for (const auto& building: subState->getBuildings()) - { - if (building->getName() != "building_government_administration") - continue; - - building->addPM(adminPMName); - } - } - } -} - -double V3::EconomyManager::getBaseSubStateWeight(const std::shared_ptr& subState, const Configuration::ECONOMY economyType) const -{ - if (economyType == Configuration::ECONOMY::CivLevel) - { - // Score is based on population - return subState->getSubStatePops().getPopCount(); - } - if (economyType == Configuration::ECONOMY::DevPopVanilla) - { - // Score is based on Dev, penalized by unadjusted population - return subState->getTotalDev() * getDensityFactor(subState->getTotalDev() / subState->getVanillaPopCount()); - } - if (economyType == Configuration::ECONOMY::DevPopActual) - { - // Score is based on Dev, penalized by actual population present - return subState->getTotalDev() * getDensityFactor(subState->getTotalDev() / subState->getSubStatePops().getPopCount()); - } - return 0; -} - -std::vector> V3::EconomyManager::prepareSubStatesByBudget(const std::shared_ptr& country, - const std::map& lawsMap) const -{ - // Copy substate vector. We will be sorting this one and removing finished substates until it is empty - auto subStatesByBudget(country->getSubStates()); - std::sort(subStatesByBudget.begin(), subStatesByBudget.end(), SubState::greaterBudget); - - // Make buildings from template buildings - // Only valid building will be added to the vector - for (const auto& subState: subStatesByBudget) - { - subState->gatherPossibleBuildings(buildings, - buildingGroups, - buildingTerrainModifiers, - buildingMapper, - lawsMap, - techMap.getTechs(), - stateTraits, - econDefines.getStateTraitStrength()); - } - - // For logging and possibly compensating purposes. - /* - const auto removedBudget = - std::accumulate(subStatesByBudget.begin(), subStatesByBudget.end(), 0, [this, lawsMap](const int sum, const std::shared_ptr& substate) { - if (!substate->hasValidBuildings(buildingGroups, lawsMap, techMap.getTechs(), stateTraits)) - { - return sum + substate->getCPBudget(); - } - return sum; - }); - */ - - // Eliminate states with no building options - std::erase_if(subStatesByBudget, [this, lawsMap](const std::shared_ptr& subState) { - return !subState->hasValidBuildings(buildingGroups, lawsMap, techMap.getTechs(), stateTraits); - }); - - return subStatesByBudget; -} - -void V3::EconomyManager::negotiateBuilding(const std::shared_ptr& subState, - const std::map>& sectors, - const std::map& lawsMap, - const std::vector>& subStates) const -{ - // Whether or not the negotiation succeeds, a building MUST be built. - - // Flag to see if negotiation was successful - bool talksFail = true; - - // Find the building the state wants most that is in the country budget - subState->weightBuildings(buildingGroups, - buildingTerrainModifiers, - buildingMapper, - lawsMap, - techMap.getTechs(), - stateTraits, - econDefines.getStateTraitStrength()); - for (const auto& building: subState->getBuildings()) - { - const int baseCost = building->getConstructionCost(); - const auto& sector = nationalBudgets.getSectorName(building->getName()); - if (!sector) - { - continue; // silently skip buildings we're deliberately ignoring. - } - if (!sectors.contains(sector.value())) - { - Log(LogLevel::Error) << "Unknown Industrial Sector : " << sector.value() << "."; - continue; - } - if (baseCost > sectors.at(sector.value())->getCPBudget()) - { - continue; - } - - // So we're a valid building in a valid sector and there is budget for us. Great! - buildBuilding(building, subState, sectors.at(sector.value()), lawsMap, subStates); - talksFail = false; - break; - } - - if (talksFail) - { - // Negotiation failed - // State picks its favorite building, takes from biggest sector - buildBuilding(subState->getBuildings()[0], subState, getSectorWithMostBudget(sectors), lawsMap, subStates); - } -} - -std::shared_ptr V3::EconomyManager::getSectorWithMostBudget(const std::map>& sectors) -{ - auto maxIter = std::max_element(sectors.begin(), sectors.end(), [](const auto& lhs, const auto& rhs) { - return lhs.second->getCPBudget() < rhs.second->getCPBudget(); - }); - - return maxIter->second; -} - -void V3::EconomyManager::buildBuilding(const std::shared_ptr& building, - const std::shared_ptr& subState, - const std::shared_ptr& sector, - const std::map& lawsMap, - const std::vector>& subStates) const -{ - // SUBSTATE MUST SPEND ITS CP OR WE GET INFINITE LOOPS - // Spend sector CP if possible - - // Pick a packet size! - const int p = determinePacketSize(building, sector, subState, lawsMap, subStates); - - int cost = building->getConstructionCost() * p; - subState->spendCPBudget(cost); - sector->spendCP(cost); - building->setLevel(building->getLevel() + p); - - // If arable, decrease arable land. This does have a side effect of no arable building being able to use more than 50% of the arable land - const auto& arables = subState->getHomeState()->getArableResources(); - if (const auto& isArable = std::ranges::find(arables, building->getBuildingGroup()); isArable != arables.end()) - { - subState->setResource("bg_agriculture", subState->getResource("bg_agriculture") - p); - } -} - -void V3::EconomyManager::removeSubStateIfFinished(std::vector>& subStates, - const std::vector>::iterator& subState, - const std::map& lawsMap) const -{ - if (!subState->get()->hasValidBuildings(buildingGroups, lawsMap, techMap.getTechs(), stateTraits)) - { - if (subStates.size() >= 2) - { - // Carry over budget to current highest budgeted state. - subStates[0]->spendCPBudget(-subState->get()->getCPBudget()); - } - subStates.erase(subState); - } -} - -int V3::EconomyManager::determinePacketSize(const std::shared_ptr& building, - const std::shared_ptr& sector, - const std::shared_ptr& subState, - const std::map& lawsMap, - const std::vector>& subStates) const -{ - // Packet size is the minimum of (Sector CP budget/cost, SubState CP budget/cost, SubState capacity, and our clustering metric) - const int sectorPacket = sector->getCPBudget() / building->getConstructionCost(); - const int subStatePacket = subState->getCPBudget() / building->getConstructionCost(); - const int capacityPacket = subState->getBuildingCapacity(*building, buildingGroups, lawsMap, techMap.getTechs(), stateTraits) - building->getLevel(); - const int clusterPacket = getClusterPacket(building->getConstructionCost(), subStates); - - const int packet = std::max(std::min({sectorPacket, subStatePacket, capacityPacket, clusterPacket}), 1); - - return packet; -} - -int V3::EconomyManager::getClusterPacket(const int baseCost, const std::vector>& subStates) const -{ - const int CPAll = std::accumulate(subStates.begin(), subStates.end(), 0, [](const int sum, const std::shared_ptr& subState) { - return sum + subState->getCPBudget(); - }); - const double CPMean = static_cast(CPAll) / static_cast(subStates.size()); - - - const int maxCP = subStates[0]->getCPBudget(); - const int minCP = std::max(subStates.back()->getCPBudget(), baseCost); - - // Default, when factor is 0 - int packet = static_cast(CPMean / baseCost); - const double factor = econDefines.getPacketFactor(); - if (factor < 0) - { - // Trends toward only building 1 building at a time - packet = static_cast(std::floor(CPMean * (1.0 + factor) + minCP * -factor) / baseCost); - } - if (factor > 0) - { - // Trends toward building as many buildings as the substate can get away with at a time - packet = static_cast(std::floor(CPMean * (1 - factor) + maxCP * factor) / baseCost); - } - - return packet; -} - -void V3::EconomyManager::loadTerrainModifierMatrices(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading Terrain Modifier Matrices."; - - TerrainModifierLoader terrainModifierLoader; - terrainModifierLoader.loadTerrainModifiers(filePath + "configurables/economy/terrain_econ_modifiers.txt"); - - stateTerrainModifiers = terrainModifierLoader.getTerrainStateModifiers(); - buildingTerrainModifiers = terrainModifierLoader.getTerrainBuildingModifiers(); - - Log(LogLevel::Info) << "<> Loaded " << stateTerrainModifiers.size() << " state and " << buildingTerrainModifiers.size() << " building terrain modifiers."; -} - -void V3::EconomyManager::loadStateTraits(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading State Traits."; - - StateModifierLoader stateModifierLoader; - stateModifierLoader.loadStateModifiers(modFS); - stateTraits = stateModifierLoader.getStateModifiers(); - - Log(LogLevel::Info) << "<> Loaded " << stateTraits.size() << " state traits."; -} - -void V3::EconomyManager::loadBuildingInformation(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading building information."; - - BuildingLoader buildingLoader; - BuildingGroupLoader buildingGroupLoader; - ProductionMethodLoader PMLoader; - ProductionMethodGroupLoader PMGroupLoader; - - buildingLoader.loadBuildings(modFS); - buildingGroupLoader.loadBuildingGroups(modFS); - PMLoader.loadPMs(modFS); - PMGroupLoader.loadPMGroups(modFS); - - buildings = buildingLoader.getBuildings(); - buildingGroups = buildingGroupLoader.getBuildingGroups(); - PMs = PMLoader.getPMs(); - PMGroups = PMGroupLoader.getPMGroups(); - - Log(LogLevel::Info) << "<> Loaded " << buildings.size() << " buildings, " << buildingGroups.getBuildingGroupMap().size() << " building groups, " - << PMs.size() << " PMs and " << PMGroups.size() << " PM groups."; -} - -void V3::EconomyManager::loadBuildingMappings(const std::string& filePath) -{ - buildingMapper.loadBuildingMappings(filePath + "configurables/economy/buildings_map.txt"); -} - -void V3::EconomyManager::loadPMMappings(const std::string& filePath) -{ - PMMapper.loadRules(filePath + "configurables/economy/production_method_rules.txt"); -} - -void V3::EconomyManager::loadEconDefines(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading economy defines."; - - econDefines.loadEconDefines(filePath + "configurables/economy/econ_defines.txt"); - - Log(LogLevel::Info) << "<> Economy defines loaded."; -} - -void V3::EconomyManager::loadNationalBudgets(const std::string& filePath) -{ - nationalBudgets.loadNationalBudget(filePath + "configurables/economy/national_budget.txt"); - nationalBudgets.buildBuildingSectorMap(); -} - -void V3::EconomyManager::loadTechMap(const commonItems::ModFilesystem& modFS) -{ - techMap.loadTechs(modFS); -} diff --git a/EU5ToVic3/Source/V3World/EconomyManager/EconomyManager.h b/EU5ToVic3/Source/V3World/EconomyManager/EconomyManager.h deleted file mode 100644 index af7f4ca..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/EconomyManager.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef ECONOMY_MANAGER_H -#define ECONOMY_MANAGER_H -#include "Building/Building.h" -#include "Building/BuildingGroups.h" -#include "BuildingMapper/BuildingMapper.h" -#include "BuildingMapper/ProductionMethodMapper/ProductionMethodMapper.h" -#include "ClayManager/State/StateModifier.h" -#include "Configuration.h" -#include "EconomyManager/Building/ProductionMethods/ProductionMethod.h" -#include "EconomyManager/Building/ProductionMethods/ProductionMethodGroup.h" -#include "Loaders/DefinesLoader/EconDefinesLoader.h" -#include "Loaders/NationalBudgetLoader/NationalBudgetLoader.h" -#include "Loaders/TechLoader/TechLoader.h" -#include "PoliticalManager/PoliticalManager.h" - -namespace V3 -{ -class Country; -class Sector; -/* - * PreReqs: Clay(Substates merged under the right country), Pops, Laws, Tech - * all must be converted first. - * - * - * Primarily handles buildings - * 1. Load in centralized countries. - * 2. Read in Mappers & Configs. - * 3. Bureaucracy! Have to handle it separate for game balance. Hand out generation that ~ matches need. - * 4. For each centralized country get a CP budget based on fronter option. - * 5. For each substate in a centralized country get a CP budget based on fronter option and terrain/state modifiers. - * 6. Figure out the "national budget" of each country using the sector blueprints in NationalBudgetLoader. - * 6b. NationalBudget is a list of sectors like 30% Farming, 25% Light Industry, etc. - * 6c. Each Sector has a list of buildings that fall under it. - * 7. Each Substate scores buildings based on EU4 buildings, terrain, state modifiers, and other factors. - * 7b. Only buildings that are valid (resource/tech-wise) are scored. - * 8. A negotiation between the states and their country about what to build. - * 8b. The state w/ the most CP asks to build it's highest scoring building. - * 8c. The country says that building is in sector A and as a country we have X CP to spend in that sector. - * 8d. The state then builds as many buildings of that kind as it can, limited by capacity, packet size and sector CP. - * 8e. A bunch of small details that make this flow until all CP is assigned. Repeat for each country. - * - * 9. Set Production Methods from a config file. - * - * This *should* give nice diverse, sensible, game-balanced economies while maintaining a reasonable configuration footprint. - */ -class EconomyManager -{ - public: - EconomyManager() = default; - void loadCentralizedStates(const std::map>& countries); - void loadMappersAndConfigs(const commonItems::ModFilesystem& modFS, const std::string& filePath = ""); - - void establishBureaucracy(const PoliticalManager& politicalManager) const; - void hardcodePorts() const; - - void assignCountryCPBudgets(Configuration::ECONOMY economyType, - Configuration::STARTDATE startDate, - const DatingData& dateData, - const PoliticalManager& politicalManager, - bool vn = false) const; - void assignSubStateCPBudgets(Configuration::ECONOMY economyType) const; - void balanceNationalBudgets() const; - void buildBuildings(const std::map& lawsMap) const; - void setPMs() const; - - [[nodiscard]] const auto& getCentralizedCountries() const { return centralizedCountries; } - - private: - static double calculatePopDistanceFactor(int countryPopulation, double geoMeanPopulation); - static double calculateDateFactor(Configuration::STARTDATE startDate, const DatingData& dateData); - - // Budget fxns set weight for all countries, accumulates the total weight, and returns a modifier to the globalCP pool (if any). - [[nodiscard]] std::pair countryBudgetCalcs(Configuration::ECONOMY economyType) const; // Return total weight, any special factors - [[nodiscard]] std::pair civLevelCountryBudgets() const; - [[nodiscard]] std::pair devCountryBudgets(Configuration::ECONOMY perCapitaType) const; - [[nodiscard]] double getBaseSubStateWeight(const std::shared_ptr& subState, Configuration::ECONOMY economyType) const; - - [[nodiscard]] double calculateGeoMeanCentralizedPops() const; - [[nodiscard]] std::string pickBureaucracyPM(const Country& country) const; - [[nodiscard]] double calculateGlobalPopFactor(const PoliticalManager& politicalManager) const; - [[nodiscard]] double calculateTerrainMultiplier(const std::shared_ptr& subState) const; - [[nodiscard]] double calculateStateTraitMultiplier(const std::shared_ptr& subState) const; - [[nodiscard]] double getDensityFactor(double perCapitaDev) const; - - void distributeBudget(double globalCP, double totalIndustryScore) const; - - [[nodiscard]] std::vector> prepareSubStatesByBudget(const std::shared_ptr& country, - const std::map& lawsMap) const; - void negotiateBuilding(const std::shared_ptr& subState, - const std::map>& sectors, - const std::map& lawsMap, - const std::vector>& subStates) const; - [[nodiscard]] static std::shared_ptr getSectorWithMostBudget(const std::map>& sectors); - void buildBuilding(const std::shared_ptr& building, - const std::shared_ptr& subState, - const std::shared_ptr& sector, - const std::map& lawsMap, - const std::vector>& subStates) const; - void removeSubStateIfFinished(std::vector>& subStates, - const std::vector>::iterator& subState, - const std::map& lawsMap) const; - - [[nodiscard]] int determinePacketSize(const std::shared_ptr& building, - const std::shared_ptr& sector, - const std::shared_ptr& subState, - const std::map& lawsMap, - const std::vector>& subStates) const; - [[nodiscard]] int getClusterPacket(int baseCost, const std::vector>& subStates) const; - - void loadTerrainModifierMatrices(const std::string& filePath = ""); - void loadStateTraits(const commonItems::ModFilesystem& modFS); - void loadBuildingInformation(const commonItems::ModFilesystem& modFS); - void loadBuildingMappings(const std::string& filePath = ""); - void loadPMMappings(const std::string& filePath = ""); - void loadEconDefines(const std::string& filePath = ""); - void loadNationalBudgets(const std::string& filePath = ""); - void loadTechMap(const commonItems::ModFilesystem& modFS); - - - std::vector> centralizedCountries; - - EconDefinesLoader econDefines; - NationalBudgetLoader nationalBudgets; - mappers::ProductionMethodMapper PMMapper; - - TechLoader techMap; - - std::map stateTraits; - std::map stateTerrainModifiers; - std::map> buildingTerrainModifiers; - - mappers::BuildingMapper buildingMapper; - std::map buildings; - BuildingGroups buildingGroups; - std::map PMs; - std::map PMGroups; -}; -} // namespace V3 - - -#endif // ECONOMY_MANAGER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/EconomyManager/NationalBudget/Sector.cpp b/EU5ToVic3/Source/V3World/EconomyManager/NationalBudget/Sector.cpp deleted file mode 100644 index 697577c..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/NationalBudget/Sector.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "Sector.h" -#include "Loaders/NationalBudgetLoader/SectorLoader.h" -#include "PoliticalManager/Country/Country.h" -#include - -V3::Sector::Sector(const SectorLoader& sectorRules, const Country& country): name(sectorRules.getName()), buildings(sectorRules.getBuildings()) -{ - weight = sectorRules.calculateWeight(country); -} - -void V3::Sector::calculateBudget(const double totalWeight, const int countryCPBudget) -{ - CPBudget = static_cast(std::round(countryCPBudget * weight / totalWeight)); -} - -bool V3::Sector::hasBuilding(const std::string& building) const -{ - return buildings.contains(building); -} diff --git a/EU5ToVic3/Source/V3World/EconomyManager/NationalBudget/Sector.h b/EU5ToVic3/Source/V3World/EconomyManager/NationalBudget/Sector.h deleted file mode 100644 index c7f8f4b..0000000 --- a/EU5ToVic3/Source/V3World/EconomyManager/NationalBudget/Sector.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef V3_SECTOR_H -#define V3_SECTOR_H -#include "Parser.h" - -namespace V3 -{ -// A Sector of industry is a group of vic3 buildings with similar characteristics and distribution -class SectorLoader; -class Country; -class Sector -{ - public: - Sector(const SectorLoader& sectorRules, const Country& country); - void calculateBudget(double totalWeight, int countryCPBudget); - void spendCP(const int CPExpenditure) { CPBudget -= CPExpenditure; } - - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getCPBudget() const { return CPBudget; } - [[nodiscard]] const auto& getBuildings() const { return buildings; } - [[nodiscard]] bool hasBuilding(const std::string& building) const; - [[nodiscard]] auto getWeight() const { return weight; } - - private: - std::string name; - double weight = 0; - int CPBudget = 0; - std::set buildings; -}; -} // namespace V3 - -#endif // V3_MATH_SCRIPT_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/FlagCrafter/FlagColorLoader/FlagColorLoader.cpp b/EU5ToVic3/Source/V3World/FlagCrafter/FlagColorLoader/FlagColorLoader.cpp deleted file mode 100644 index bf37bf8..0000000 --- a/EU5ToVic3/Source/V3World/FlagCrafter/FlagColorLoader/FlagColorLoader.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "FlagColorLoader.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void V3::FlagColorLoader::loadFlagColors(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading EU4 custom flag colors."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Loaded " << flagColorMapping.size() << " EU4 custom flag colors."; -} - -void V3::FlagColorLoader::registerKeys() -{ - registerKeyword("flag_color", [this](std::istream& theStream) { - const auto theColor = commonItems::Color::Factory{}.getColor(theStream); - flagColorMapping.emplace_back(theColor); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional V3::FlagColorLoader::getFlagColorByIndex(int index) const -{ - if (flagColorMapping.empty() || static_cast(index) > flagColorMapping.size() - 1) - return std::nullopt; - - return flagColorMapping.at(index); -} diff --git a/EU5ToVic3/Source/V3World/FlagCrafter/FlagColorLoader/FlagColorLoader.h b/EU5ToVic3/Source/V3World/FlagCrafter/FlagColorLoader/FlagColorLoader.h deleted file mode 100644 index 58c8437..0000000 --- a/EU5ToVic3/Source/V3World/FlagCrafter/FlagColorLoader/FlagColorLoader.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef FLAG_COLOR_LOADER_H -#define FLAG_COLOR_LOADER_H -#include "Color.h" -#include "Parser.h" - -namespace V3 -{ -class FlagColorLoader: commonItems::parser -{ - public: - FlagColorLoader() = default; - void loadFlagColors(const std::string& filePath); - - [[nodiscard]] auto getNumFlagColors() const { return flagColorMapping.size(); } - [[nodiscard]] std::optional getFlagColorByIndex(int index) const; - - private: - void registerKeys(); - - std::vector flagColorMapping; -}; -}; // namespace V3 - -#endif // FLAG_COLOR_LOADER_H diff --git a/EU5ToVic3/Source/V3World/FlagCrafter/FlagCrafter.cpp b/EU5ToVic3/Source/V3World/FlagCrafter/FlagCrafter.cpp deleted file mode 100644 index 66b67c3..0000000 --- a/EU5ToVic3/Source/V3World/FlagCrafter/FlagCrafter.cpp +++ /dev/null @@ -1,414 +0,0 @@ -#include "FlagCrafter.h" -#include "CountryManager/EU4Country.h" -#include "CountryMapper/CountryMapper.h" -#include "FlagNameLoader/FlagNameLoader.h" -#include "Log.h" -#include "OSCompatibilityLayer.h" -#include "PoliticalManager/Country/Country.h" -#include "targa.h" - -void V3::FlagCrafter::loadAvailableFlags(const std::string& blankModPath, const std::string& vanillaPath) -{ - Log(LogLevel::Info) << "-> Loading Available Flags."; - - loadKnownFlags(blankModPath, vanillaPath); - filterKnownFlags(); - - Log(LogLevel::Info) << "<> Loaded " << knownFlags.size() << " available flags for " << availableFlags.size() << " entitites, and " - << knownVanillaFlags.size() << " vanilla flagsets."; -} - -void V3::FlagCrafter::loadCustomColors(const std::string& filePath) -{ - flagColorLoader.loadFlagColors(filePath); -} - -void V3::FlagCrafter::loadKnownFlags(const std::string& blankModPath, const std::string& vanillaPath) -{ - FlagNameLoader flagNameLoader; - flagNameLoader.loadKnownFlags(blankModPath); // we're loading our COA DEFINITIONS, not flag definitions! - knownFlags = flagNameLoader.getKnownFlags(); - FlagNameLoader vanillaFlagNameLoader; - vanillaFlagNameLoader.loadKnownFlags(vanillaPath); // Now we're loading vanilla flag DEFINITIONS for tags, directly. - knownVanillaFlags = vanillaFlagNameLoader.getKnownFlags(); -} - -void V3::FlagCrafter::filterKnownFlags() -{ - for (const auto& flag: knownFlags) - { - auto flagName = flag; - FLAGTYPE flagType = Default; - - if (flagName.starts_with("legacy_") && flagName.size() > 7) - flagName = flagName.substr(7, flagName.size()); - if (flag.ends_with("_republic") && flag.size() > 10) - { - flagName = flagName.substr(0, flagName.size() - 9); - flagType = Republic; - } - else if (flag.ends_with("_monarchy") && flag.size() > 10) - { - flagName = flagName.substr(0, flagName.size() - 9); - flagType = Monarchy; - } - else if (flag.ends_with("_communist") && flag.size() > 10) - { - flagName = flagName.substr(0, flagName.size() - 10); - flagType = Communist; - } - else if (flag.ends_with("_fascist") && flag.size() > 10) - { - flagName = flagName.substr(0, flagName.size() - 8); - flagType = Fascist; - } - - if (!availableFlags.contains(flagName)) - availableFlags.emplace(flagName, std::map{}); - availableFlags.at(flagName).emplace(flagType, flag); - } -} - -std::optional> V3::FlagCrafter::getFlagsForEntity(const std::string& name) -{ - if (const auto& itr = availableFlags.find(name); itr != availableFlags.end() && !spentFlags.contains(name)) - { - spentFlags.emplace(name); - return itr->second; - } - // Now get creative. - if (const auto& itr = availableFlags.find("e_" + name); itr != availableFlags.end() && !spentFlags.contains("e_" + name)) - { - spentFlags.emplace("e_" + name); - return itr->second; - } - if (const auto& itr = availableFlags.find("k_" + name); itr != availableFlags.end() && !spentFlags.contains("k_" + name)) - { - spentFlags.emplace("k_" + name); - return itr->second; - } - if (const auto& itr = availableFlags.find("d_" + name); itr != availableFlags.end() && !spentFlags.contains("d_" + name)) - { - spentFlags.emplace("d_" + name); - return itr->second; - } - if (const auto& itr = availableFlags.find("c_" + name); itr != availableFlags.end() && !spentFlags.contains("c_" + name)) - { - spentFlags.emplace("c_" + name); - return itr->second; - } - - return std::nullopt; -} - -void V3::FlagCrafter::distributeAvailableFlags(const std::map>& countries, - const mappers::CountryMapper& countryMapper, - const commonItems::ModFilesystem& eu4ModFS) -{ - Log(LogLevel::Info) << "-> Distributing Available Flags."; - - // prep the battleground. - if (!commonItems::DeleteFolder("flags.tmp")) - throw std::runtime_error("Could not delete flags.tmp folder!"); - if (!commonItems::TryCreateFolder("flags.tmp")) - throw std::runtime_error("Could not create flags.tmp folder!"); - - auto flagCodeCounter = 0; - auto tagCounter = 0; - auto nameCounter = 0; - auto vanillaCounter = 0; - auto eu4Counter = 0; - - for (const auto& [tag, country]: countries) - { - // are we already set? - if (knownVanillaFlags.contains(tag)) - { - ++vanillaCounter; - continue; - } - - // do we have a flagcode? That'd be super helpful. - if (const auto& flagCode = countryMapper.getFlagCode(tag); flagCode && tryAssigningFlagViaValue(country, *flagCode)) - { - ++flagCodeCounter; - continue; - } - - // try straight tag. - if (tryAssigningFlagViaValue(country, tag)) - { - ++tagCounter; - continue; - } - - // umm. english name? yes? - auto name = country->getName("english"); - std::transform(name.begin(), name.end(), name.begin(), ::tolower); - if (tryAssigningFlagViaValue(country, name)) - { - ++nameCounter; - continue; - } - - // do we need special attention? - if (country->getProcessedData().customColors) - { - craftCustomFlag(country); - continue; - } - - // Can we use EU4 flag? - if (tryAssigningEU4Flag(country, eu4ModFS)) - { - ++eu4Counter; - } - } - - Log(LogLevel::Info) << "<> Distributed flags for " << vanillaCounter + flagCodeCounter + tagCounter + nameCounter << " out of " << countries.size() - << " countries."; - Log(LogLevel::Debug) << "Specifically, " << flagCodeCounter << " via flag codes, " << tagCounter << " via tag matches, " << nameCounter - << " via name matches, " << eu4Counter << " via EU4 flags, and " << vanillaCounter << " have vanilla flags."; -} - -bool V3::FlagCrafter::tryAssigningEU4Flag(const std::shared_ptr& country, const commonItems::ModFilesystem& eu4ModFS) -{ - // Do we have EU4 nation and does it have a flag? - if (!country->getSourceCountry()) - return false; - - const auto& eu4Tag = country->getSourceCountry()->getTag(); - - // These would be full-path files. Let's trim and match. - const auto& eu4Flags = eu4ModFS.GetAllFilesInFolder("gfx/flags/"); - - std::string eu4FlagAbsolutePath; - for (const auto& incomingEU4Flag: eu4Flags) - { - if (trimExtension(trimPath(incomingEU4Flag)) == eu4Tag) - { - eu4FlagAbsolutePath = incomingEU4Flag; - break; - } - } - - if (eu4FlagAbsolutePath.empty()) - return false; - - // Try and copy EU4 flag over to temp folder, rename to V3 tag. - if (!commonItems::TryCopyFile(eu4FlagAbsolutePath, "flags.tmp/" + country->getTag() + ".tga")) - return false; - - // finally, add coa/flag record for the copied eu4 flag. - country->addFlag(Default, country->getTag()); - country->addCustomFlag(Default, country->getTag()); - - return true; -} - -bool V3::FlagCrafter::tryAssigningFlagViaValue(const std::shared_ptr& country, const std::string& value) -{ - // strip legacy if we have one. - auto actualValue = value; - if (actualValue.starts_with("legacy_") && value.size() > 7) - actualValue = value.substr(7, value.size()); - - if (const auto& match = getFlagsForEntity(actualValue); match) - { - country->setFlags(*match); - return true; - } - return false; -} - -void V3::FlagCrafter::craftCustomFlag(const std::shared_ptr& country) -{ - std::string baseFlagFolder = "blankMod/output/gfx/coat_of_arms/textured_emblems/"; - - const auto& v3Tag = country->getTag(); - const auto& customColors = *country->getProcessedData().customColors; - - auto baseFlagIndex = customColors.flagIndex; - auto baseFlagStr = std::to_string(baseFlagIndex); - auto emblem = customColors.symbolIndex; - auto flagColor = customColors.flagColors; - if (!flagColor) - { - Log(LogLevel::Error) << v3Tag << "'s flag colors are missing."; - return; - } - auto [r, g, b] = flagColor->getRgbComponents(); - - auto colourCount = static_cast(flagColorLoader.getNumFlagColors()); - - if (r > colourCount || g > colourCount || b > colourCount) - { - Log(LogLevel::Error) << v3Tag << "'s flag has some invalid colors."; - return; - } - - // We have 5 flags for every tag - for (auto i = 0; i < 5; i++) - { - if (baseFlagIndex == 0) - baseFlagStr = "tricolor"; - - // For custom/revolutionary flags we only create the fascist, absolutist and communist - if (baseFlagIndex == 0 && i != 0 && i != 4) - continue; - - const auto& suffix = flagFileSuffixes[i]; - const auto suffixExtension = suffix + ".tga"; - auto sourceEmblemPath = baseFlagFolder + "/eu4_custom_emblems/" + std::to_string(emblem) + suffixExtension; - auto sourceFlagPath = baseFlagFolder + "/eu4_custom_bases/" + baseFlagStr + ".tga"; - - if (const auto flagFileFound = commonItems::DoesFileExist(sourceFlagPath) && commonItems::DoesFileExist(sourceEmblemPath); flagFileFound) - { - auto destFlagPath = "flags.tmp/" + v3Tag + suffixExtension; - - auto rColor = flagColorLoader.getFlagColorByIndex(r); - auto gColor = flagColorLoader.getFlagColorByIndex(g); - auto bColor = flagColorLoader.getFlagColorByIndex(b); - if (!rColor) - rColor = commonItems::Color(); - if (!gColor) - gColor = commonItems::Color(); - if (!bColor) - bColor = commonItems::Color(); - auto success = createCustomFlag(*rColor, *gColor, *bColor, sourceEmblemPath, sourceFlagPath, destFlagPath); - if (!success) - Log(LogLevel::Error) << "Flagcrafting of " << destFlagPath << " failed!"; - else - { - if (i == 0) - { - country->addFlag(Default, v3Tag + suffix); - country->addCustomFlag(Default, v3Tag + suffix); - } - else if (i == 1) - { - country->addFlag(Communist, v3Tag + suffix); - country->addCustomFlag(Communist, v3Tag + suffix); - } - else if (i == 2) - { - country->addFlag(Fascist, v3Tag + suffix); - country->addCustomFlag(Fascist, v3Tag + suffix); - } - else if (i == 3) - { - country->addFlag(Monarchy, v3Tag + suffix); - country->addCustomFlag(Monarchy, v3Tag + suffix); - } - else if (i == 4) - { - country->addFlag(Republic, v3Tag + suffix); - country->addCustomFlag(Republic, v3Tag + suffix); - } - } - } - else - { - if (!commonItems::DoesFileExist(sourceFlagPath)) - throw std::runtime_error("Could not find " + sourceFlagPath); - throw std::runtime_error("Could not find " + sourceEmblemPath); - } - } -} - -bool V3::FlagCrafter::createCustomFlag(const commonItems::Color& c1, - const commonItems::Color& c2, - const commonItems::Color& c3, - const std::string& emblemPath, - const std::string& basePath, - const std::string& targetPath) -{ - tga_image base; - tga_image emblem; - - auto res = tga_read(&base, basePath.c_str()); - if (res) - { - Log(LogLevel::Error) << "Failed to create custom flag: could not open " << basePath; - Log(LogLevel::Error) << "Error message from targa: " << tga_error(res); - return false; - } - - res = tga_read(&emblem, emblemPath.c_str()); - if (res) - { - Log(LogLevel::Error) << "Failed to create custom flag: could not open " << emblemPath; - Log(LogLevel::Error) << "Error message from targa: " << tga_error(res); - return false; - } - - for (auto y = 0; y < base.height; y++) - { - for (auto x = 0; x < base.width; x++) - { - auto* targetAddress = tga_find_pixel(&base, x, y); - - uint8_t r = 0, g = 0, b = 0; - - res = tga_unpack_pixel(targetAddress, base.pixel_depth, &b, &g, &r, nullptr); - if (res) - { - Log(LogLevel::Error) << "Failed to create custom flag: could not read pixel data"; - Log(LogLevel::Error) << "Error message from targa: " << tga_error(res); - return false; - } - - const uint8_t c = ~r; - const uint8_t m = ~g; - const uint8_t z = ~b; - - auto tr = int(m * c1.r()) + int(c * c2.r()) + int(z * c3.r()); - auto tg = int(m * c1.g()) + int(c * c2.g()) + int(z * c3.g()); - auto tb = int(m * c1.b()) + int(c * c2.b()) + int(z * c3.b()); - - tr /= 255; - tg /= 255; - tb /= 255; - - uint8_t oRed = 0, oGreen = 0, oBlue = 0, oAlpha = 0; - - auto* targetOverlayAddress = tga_find_pixel(&emblem, x, y); - if (targetOverlayAddress) - { - res = tga_unpack_pixel(targetOverlayAddress, emblem.pixel_depth, &oBlue, &oGreen, &oRed, &oAlpha); - if (res) - { - Log(LogLevel::Error) << "Failed to create custom flag: could not read pixel data"; - Log(LogLevel::Error) << "Error message from targa: " << tga_error(res); - return false; - } - - tr = oRed * oAlpha / 255 + tr * (255 - oAlpha) / 255; - tg = oGreen * oAlpha / 255 + tg * (255 - oAlpha) / 255; - tb = oBlue * oAlpha / 255 + tb * (255 - oAlpha) / 255; - } - else - { - Log(LogLevel::Warning) << "No targetOverlayAddress, error with targa handling."; - } - - res = tga_pack_pixel(targetAddress, base.pixel_depth, tb, tg, tr, 255); - if (res) - { - Log(LogLevel::Error) << "Failed to create custom flag: could not write pixel data"; - Log(LogLevel::Error) << "Error message from targa: " << tga_error(res); - return false; - } - } - } - - res = tga_write(targetPath.c_str(), &base); - if (res) - { - Log(LogLevel::Error) << "Failed to create custom flag: could not write to " << targetPath; - Log(LogLevel::Error) << "Error message from targa: " << tga_error(res); - return false; - } - - return true; -} diff --git a/EU5ToVic3/Source/V3World/FlagCrafter/FlagCrafter.h b/EU5ToVic3/Source/V3World/FlagCrafter/FlagCrafter.h deleted file mode 100644 index ea9ec37..0000000 --- a/EU5ToVic3/Source/V3World/FlagCrafter/FlagCrafter.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef FLAG_CRAFTER -#define FLAG_CRAFTER -#include "FlagColorLoader/FlagColorLoader.h" -#include "ModLoader/ModFilesystem.h" -#include -#include -#include -#include -#include - -namespace mappers -{ -class CountryMapper; -} -namespace V3 -{ -class Country; -class FlagCrafter -{ - public: - enum FLAGTYPE - { - Default, - Republic, - Monarchy, - Fascist, - Communist - }; - - FlagCrafter() = default; - - void loadAvailableFlags(const std::string& blankModPath, const std::string& vanillaPath); - void loadCustomColors(const std::string& filePath); - void distributeAvailableFlags(const std::map>& countries, - const mappers::CountryMapper& countryMapper, - const commonItems::ModFilesystem& eu4ModFS); - - [[nodiscard]] std::optional> getFlagsForEntity(const std::string& name); - - private: - [[nodiscard]] bool tryAssigningFlagViaValue(const std::shared_ptr& country, const std::string& value); - [[nodiscard]] bool tryAssigningEU4Flag(const std::shared_ptr& country, const commonItems::ModFilesystem& eu4ModFS); - void loadKnownFlags(const std::string& blankModPath, const std::string& vanillaPath); - void filterKnownFlags(); - void craftCustomFlag(const std::shared_ptr& country); - - // FLAGUTILS - [[nodiscard]] static bool createCustomFlag(const commonItems::Color& c1, - const commonItems::Color& c2, - const commonItems::Color& c3, - const std::string& emblemPath, - const std::string& basePath, - const std::string& targetPath); - - FlagColorLoader flagColorLoader; - - std::set spentFlags; - std::set knownFlags; - std::set knownVanillaFlags; - std::map> availableFlags; - - std::vector flagFileSuffixes = {"", "_communist", "_fascist", "_monarchy", "_republic"}; -}; -} // namespace V3 - -#endif // FLAG_NAME_LOADER \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/FlagCrafter/FlagNameLoader/FlagNameLoader.cpp b/EU5ToVic3/Source/V3World/FlagCrafter/FlagNameLoader/FlagNameLoader.cpp deleted file mode 100644 index de69a6b..0000000 --- a/EU5ToVic3/Source/V3World/FlagCrafter/FlagNameLoader/FlagNameLoader.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "FlagNameLoader.h" -#include "CommonRegexes.h" -#include "OSCompatibilityLayer.h" -#include "ParserHelpers.h" - -void V3::FlagNameLoader::loadKnownFlags(const std::string& folderPath) -{ - registerKeys(); - for (const auto& filename: commonItems::GetAllFilesInFolder(folderPath)) - parseFile(folderPath + "/" + filename); - clearRegisteredKeywords(); -} - -void V3::FlagNameLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& flagName, std::istream& theStream) { - knownFlags.emplace(flagName); - commonItems::ignoreItem(flagName, theStream); - }); -} diff --git a/EU5ToVic3/Source/V3World/FlagCrafter/FlagNameLoader/FlagNameLoader.h b/EU5ToVic3/Source/V3World/FlagCrafter/FlagNameLoader/FlagNameLoader.h deleted file mode 100644 index c51c448..0000000 --- a/EU5ToVic3/Source/V3World/FlagCrafter/FlagNameLoader/FlagNameLoader.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef FLAG_NAME_LOADER -#define FLAG_NAME_LOADER -#include "Parser.h" - -namespace V3 -{ -class FlagNameLoader: commonItems::parser -{ - public: - FlagNameLoader() = default; - void loadKnownFlags(const std::string& folderPath); - - [[nodiscard]] const auto& getKnownFlags() const { return knownFlags; } - - private: - void registerKeys(); - - std::set knownFlags; -}; -} // namespace V3 - -#endif // FLAG_NAME_LOADER \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingGroupLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingGroupLoader.cpp deleted file mode 100644 index e794b09..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingGroupLoader.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "BuildingGroupLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "EconomyManager/Building/BuildingGroup.h" -#include "OSCompatibilityLayer.h" -#include "ParserHelpers.h" - -void V3::BuildingGroupLoader::loadBuildingGroups(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/building_groups/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); - buildingGroups.setInfrastructureCosts(); - buildingGroups.setResourceCaps(); -} - -void V3::BuildingGroupLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& buildingGroupName, std::istream& theStream) { - auto newBuildingGroup = std::make_unique(); - newBuildingGroup->loadBuildingGroup(theStream); - newBuildingGroup->setName(buildingGroupName); - buildingGroups.addBuildingGroup(std::move(newBuildingGroup)); - }); -} \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingGroupLoader.h b/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingGroupLoader.h deleted file mode 100644 index 9cf88aa..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingGroupLoader.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef BUILDING_GROUP_LOADER_H -#define BUILDING_GROUP_LOADER_H -#include "EconomyManager/Building/BuildingGroups.h" -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class BuildingGroupLoader: commonItems::parser -{ - public: - BuildingGroupLoader() = default; - - void loadBuildingGroups(const commonItems::ModFilesystem& modFS); - [[nodiscard]] const auto& getBuildingGroups() const { return buildingGroups; } - - private: - void registerKeys(); - - BuildingGroups buildingGroups; -}; -} // namespace V3 -#endif // BUILDING_GROUP_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingLoader.cpp deleted file mode 100644 index c3a37fa..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingLoader.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "BuildingLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "Loaders/DefinesLoader/BuildingScriptValuesLoader.h" -#include "ParserHelpers.h" - -void V3::BuildingLoader::loadBuildings(const commonItems::ModFilesystem& modFS) -{ - BuildingScriptValuesLoader bsvl; - bsvl.loadBuildingScriptValues(modFS); - - registerKeys(bsvl.getBuildingCostConstants()); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/buildings/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::BuildingLoader::registerKeys(const std::map& costTiers) -{ - registerRegex(commonItems::catchallRegex, [this, costTiers](const std::string& buildingName, std::istream& theStream) { - Building newBuilding; - newBuilding.loadBuilding(theStream, costTiers); - newBuilding.setName(buildingName); - buildings.emplace(buildingName, newBuilding); - }); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingLoader.h b/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingLoader.h deleted file mode 100644 index 59aa81d..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/BuildingLoader.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef BUILDING_LOADER_H -#define BUILDING_LOADER_H -#include "EconomyManager/Building/Building.h" -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class BuildingLoader: commonItems::parser -{ - public: - BuildingLoader() = default; - - void loadBuildings(const commonItems::ModFilesystem& modFS); - [[nodiscard]] const auto& getBuildings() const { return buildings; } - - private: - void registerKeys(const std::map& costTiers); - - std::map buildings; -}; -} // namespace V3 -#endif // BUILDING_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodGroupLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodGroupLoader.cpp deleted file mode 100644 index c985b08..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodGroupLoader.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "ProductionMethodGroupLoader.h" -#include "CommonFunctions.h" -#include - -void V3::ProductionMethodGroupLoader::loadPMGroups(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/production_method_groups/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::ProductionMethodGroupLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& PMGroupName, std::istream& theStream) { - ProductionMethodGroup newPMGroup; - newPMGroup.loadProductionMethodGroup(theStream); - newPMGroup.setName(PMGroupName); - PMGroups.emplace(PMGroupName, newPMGroup); - }); -} \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodGroupLoader.h b/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodGroupLoader.h deleted file mode 100644 index 989d311..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodGroupLoader.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef PRODUCTION_METHOD_GROUP_LOADER_H -#define PRODUCTION_METHOD_GROUP_LOADER_H - -#include "EconomyManager/Building/ProductionMethods/ProductionMethodGroup.h" -#include "Parser.h" - - -namespace V3 -{ -class ProductionMethodGroupLoader: commonItems::parser -{ - public: - ProductionMethodGroupLoader() = default; - - void loadPMGroups(const commonItems::ModFilesystem& modFS); - [[nodiscard]] const auto& getPMGroups() const { return PMGroups; } - - private: - void registerKeys(); - - std::map PMGroups; -}; -} // namespace V3 -#endif // PRODUCTION_METHOD_GROUP_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodLoader.cpp deleted file mode 100644 index 3145a30..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodLoader.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "ProductionMethodLoader.h" -#include "CommonFunctions.h" -#include "ModLoader/ModFilesystem.h" -#include - -void V3::ProductionMethodLoader::loadPMs(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/production_methods/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::ProductionMethodLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& PMName, std::istream& theStream) { - ProductionMethod newPM; - newPM.loadProductionMethod(theStream); - newPM.setName(PMName); - PMs.emplace(PMName, newPM); - }); -} \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodLoader.h b/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodLoader.h deleted file mode 100644 index bf52c8e..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodLoader.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef PRODUCTION_METHOD_LOADER_H -#define PRODUCTION_METHOD_LOADER_H -#include "EconomyManager/Building/ProductionMethods/ProductionMethod.h" -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class ProductionMethodLoader: commonItems::parser -{ - public: - ProductionMethodLoader() = default; - - void loadPMs(const commonItems::ModFilesystem& modFS); - [[nodiscard]] const auto& getPMs() const { return PMs; } - - private: - void registerKeys(); - - std::map PMs; -}; -} // namespace V3 -#endif // PRODUCTION_METHOD_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/CountryDefinitionLoader/CountryDefinitionLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/CountryDefinitionLoader/CountryDefinitionLoader.cpp deleted file mode 100644 index f41c427..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/CountryDefinitionLoader/CountryDefinitionLoader.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "CountryDefinitionLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "PoliticalManager/Country/Country.h" -#include - -void V3::CountryDefinitionLoader::loadCommonCountries(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/country_definitions/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::CountryDefinitionLoader::reloadCommonCountries(const commonItems::ModFilesystem& vanillaFS) -{ - registerReloadKeys(); - for (const auto& fileName: vanillaFS.GetAllFilesInFolder("/common/country_definitions/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::CountryDefinitionLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& countryTag, std::istream& theStream) { - const auto newCountry = std::make_shared(); - newCountry->setTag(countryTag); - newCountry->initializeCountry(theStream); - if (!newCountry->isCountryDynamic()) // don't use their dynamic tags! Just ignore them. - countries[countryTag] = newCountry; - }); -} - -void V3::CountryDefinitionLoader::registerReloadKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& countryTag, std::istream& theStream) { - if (countries.contains(countryTag)) - { - const auto& country = countries.at(countryTag); - country->storeVanillaCountryType(theStream); - } - else - { - // one of those dynamic countries we ignore. - commonItems::ignoreItem("unused", theStream); - } - }); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/CountryDefinitionLoader/CountryDefinitionLoader.h b/EU5ToVic3/Source/V3World/Loaders/CountryDefinitionLoader/CountryDefinitionLoader.h deleted file mode 100644 index 8d0eece..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/CountryDefinitionLoader/CountryDefinitionLoader.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef COUNTRY_DEFINITION_LOADER_H -#define COUNTRY_DEFINITION_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include -#include - -namespace V3 -{ -class Country; -class CountryDefinitionLoader: commonItems::parser -{ - public: - CountryDefinitionLoader() = default; - - void loadCommonCountries(const commonItems::ModFilesystem& modFS); - void reloadCommonCountries(const commonItems::ModFilesystem& vanillaFS); - [[nodiscard]] const auto& getCountries() const { return countries; } - - private: - void registerKeys(); - void registerReloadKeys(); - - std::map> countries; -}; -} // namespace V3 -#endif // COUNTRY_DEFINITION_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/BuildingScriptValuesLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/BuildingScriptValuesLoader.cpp deleted file mode 100644 index fad6e35..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/BuildingScriptValuesLoader.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "BuildingScriptValuesLoader.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -void V3::BuildingScriptValuesLoader::loadBuildingScriptValues(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/script_values")) - { - if (fileName.find("building_values") == std::string::npos) - continue; - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::BuildingScriptValuesLoader::registerKeys() -{ - registerRegex(R"(construction_cost_\w+)", [this](const std::string& costTier, std::istream& theStream) { - buildingCostConstants.emplace(costTier, commonItems::getInt(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/BuildingScriptValuesLoader.h b/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/BuildingScriptValuesLoader.h deleted file mode 100644 index e7d811d..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/BuildingScriptValuesLoader.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef BUILDING_SCRIPT_VALUES_LOADER_H -#define BUILDING_SCRIPT_VALUES_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class BuildingScriptValuesLoader: commonItems::parser -{ - public: - BuildingScriptValuesLoader() = default; - - void loadBuildingScriptValues(const commonItems::ModFilesystem& modFS); - [[nodiscard]] const auto& getBuildingCostConstants() const { return buildingCostConstants; } - - private: - void registerKeys(); - - std::map buildingCostConstants; -}; -} // namespace V3 -#endif // BUILDING_SCRIPT_VALUES_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/EconDefinesLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/EconDefinesLoader.cpp deleted file mode 100644 index ba79393..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/EconDefinesLoader.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "EconDefinesLoader.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -void V3::EconDefinesLoader::loadEconDefines(const std::string& filePath) -{ - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); -} - -void V3::EconDefinesLoader::registerKeys() -{ - registerKeyword("global_construction_points", [this](std::istream& theStream) { - globalCP = commonItems::getInt(theStream); - }); - registerKeyword("vn_global_construction_points", [this](std::istream& theStream) { - VNGlobalCP = commonItems::getInt(theStream); - }); - registerKeyword("centralized_population_ratio", [this](std::istream& theStream) { - centralizedPopRatio = commonItems::getDouble(theStream); - }); - registerKeyword("mean_civlevel", [this](std::istream& theStream) { - meanCivlevel = commonItems::getDouble(theStream); - }); - registerKeyword("state_trait_strength", [this](std::istream& theStream) { - stateTraitStrength = commonItems::getDouble(theStream); - }); - registerKeyword("packet_factor", [this](std::istream& theStream) { - packetFactor = commonItems::getDouble(theStream); - }); - registerKeyword("unincorporated_penalty", [this](std::istream& theStream) { - incorpModifier = commonItems::getDouble(theStream); - }); - registerKeyword("min_dev_per_pop", [this](std::istream& theStream) { - minDevPerPop = commonItems::getDouble(theStream); - }); - registerKeyword("max_dev_per_pop", [this](std::istream& theStream) { - maxDevPerPop = commonItems::getDouble(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/EconDefinesLoader.h b/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/EconDefinesLoader.h deleted file mode 100644 index bd96e22..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/DefinesLoader/EconDefinesLoader.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef ECON_DEFINES_LOADER_H -#define ECON_DEFINES_LOADER_H -#include "Parser.h" - -namespace V3 -{ -class EconDefinesLoader: commonItems::parser -{ - public: - EconDefinesLoader() = default; - - void loadEconDefines(const std::string& filePath); - [[nodiscard]] const auto& getGlobalCP() const { return globalCP; } - [[nodiscard]] const auto& getVNGlobalCP() const { return VNGlobalCP; } - [[nodiscard]] const auto& getCentralizedPopRatio() const { return centralizedPopRatio; } - [[nodiscard]] const auto& getMeanCivlevel() const { return meanCivlevel; } - [[nodiscard]] const auto& getStateTraitStrength() const { return stateTraitStrength; } - [[nodiscard]] const auto& getPacketFactor() const { return packetFactor; } - [[nodiscard]] const auto& getIncorporatedModifier() const { return incorpModifier; } - [[nodiscard]] const auto& getMinDevPerPop() const { return minDevPerPop; } - [[nodiscard]] const auto& getMaxDevPerPop() const { return maxDevPerPop; } - - private: - void registerKeys(); - - int globalCP = 0; - int VNGlobalCP = 0; - double centralizedPopRatio = 0; - double meanCivlevel = 0; - double stateTraitStrength = 0; - double packetFactor = 0; - double incorpModifier = 0.0; - double minDevPerPop = 0.0; - double maxDevPerPop = 1.0; -}; -} // namespace V3 -#endif // ECON_DEFINES_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/LawLoader/Law.h b/EU5ToVic3/Source/V3World/Loaders/LawLoader/Law.h deleted file mode 100644 index 178b87a..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/LawLoader/Law.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef LAW_H -#define LAW_H -#include -#include -#include - -namespace V3 -{ -struct Law -{ - std::string name; - std::string group; - std::string institution; - int progressiveness = 0; - double bureaucracyCostMult = 0; - std::set requiredTechs; - std::set requiredLaws; - std::set blockingLaws; - std::map maxBuildingLevels; -}; -} // namespace V3 -#endif // LAW_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawEntry.cpp b/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawEntry.cpp deleted file mode 100644 index 9ff7672..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawEntry.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "LawEntry.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -V3::LawEntry::LawEntry(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::LawEntry::registerKeys() -{ - registerKeyword("group", [this](std::istream& theStream) { - law.group = commonItems::getString(theStream); - }); - registerKeyword("progressiveness", [this](std::istream& theStream) { - law.progressiveness = commonItems::getInt(theStream); - }); - registerKeyword("unlocking_technologies", [this](std::istream& theStream) { - for (const auto& entry: commonItems::getStrings(theStream)) - law.requiredTechs.emplace(entry); - }); - registerKeyword("unlocking_laws", [this](std::istream& theStream) { - for (const auto& entry: commonItems::getStrings(theStream)) - law.requiredLaws.emplace(entry); - }); - registerKeyword("disallowing_laws", [this](std::istream& theStream) { - for (const auto& entry: commonItems::getStrings(theStream)) - law.blockingLaws.emplace(entry); - }); - registerKeyword("institution", [this](std::istream& theStream) { - law.institution = commonItems::getString(theStream); - }); - registerKeyword("modifier", [this](std::istream& theStream) { - modifierParser.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - modifierParser.registerKeyword("state_bureaucracy_population_base_cost_factor_mult", [this](std::istream& theStream) { - law.bureaucracyCostMult = commonItems::getDouble(theStream); - }); - modifierParser.registerRegex("state_building_[a-zA-Z_]+_max_level_add", [this](const std::string& modifier, std::istream& theStream) { - const std::regex pattern("state_building_([a-zA-Z_]+)_max_level_add"); - std::smatch building; - if (std::regex_search(modifier, building, pattern)) // state_building_barracks_max_level_add -> barracks - { - law.maxBuildingLevels["building_" + building[1].str()] = commonItems::getInt(theStream); - } - else - { - Log(LogLevel::Error) << "Found a max level modifier, but could not parse it: " << modifier; - } - }); - modifierParser.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawEntry.h b/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawEntry.h deleted file mode 100644 index 675eadb..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawEntry.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef LAW_ENTRY_H -#define LAW_ENTRY_H -#include "Law.h" -#include "Parser.h" - -namespace V3 -{ -class LawEntry: commonItems::parser -{ - - public: - LawEntry() = default; - explicit LawEntry(std::istream& theStream); - - [[nodiscard]] const auto& getLaw() const { return law; } - - private: - void registerKeys(); - - parser modifierParser; - - Law law; -}; -} // namespace V3 -#endif // LAW_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawLoader.cpp deleted file mode 100644 index 31c01da..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawLoader.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "LawLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "LawEntry.h" -#include "Log.h" -#include "ParserHelpers.h" - -void V3::LawLoader::loadLaws(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading Laws."; - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/laws/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Loaded " << laws.size() << " laws."; -} - -void V3::LawLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& lawName, std::istream& theStream) { - laws.emplace(lawName, LawEntry(theStream).getLaw()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawLoader.h b/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawLoader.h deleted file mode 100644 index ac5ead5..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/LawLoader/LawLoader.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef LAW_LOADER_H -#define LAW_LOADER_H -#include "Law.h" -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class LawLoader: commonItems::parser -{ - public: - LawLoader() = default; - void loadLaws(const commonItems::ModFilesystem& modFS); - - [[nodiscard]] const auto& getLaws() const { return laws; } - - private: - void registerKeys(); - - std::map laws; -}; -} // namespace V3 -#endif // LAW_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/LocLoader/LocalizationLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/LocLoader/LocalizationLoader.cpp deleted file mode 100644 index 31701fc..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/LocLoader/LocalizationLoader.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "LocalizationLoader.h" -#include "Log.h" -#include - -void V3::LocalizationLoader::scrapeLocalizations(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading Vic3 localizations."; - - knownLanguages = {"braz_por", "english", "french", "german", "japanese", "korean", "polish", "russian", "simp_chinese", "spanish", "turkish"}; - - for (const auto& lang: knownLanguages) - scrapeLanguage(lang, modFS); - - Log(LogLevel::Info) << ">> " << localizations.size() << " words read."; -} - -void V3::LocalizationLoader::scrapeLanguage(const std::string& language, const commonItems::ModFilesystem& modFS) -{ - const auto fileNames = modFS.GetAllFilesInFolderRecursive("localization/" + language + "/"); - for (const auto& file: fileNames) - { - std::ifstream fileStream(file); - if (fileStream.is_open()) - scrapeStream(fileStream, language); - fileStream.close(); - } -} - -void V3::LocalizationLoader::scrapeStream(std::istream& theStream, const std::string& language) -{ - std::string line; - std::getline(theStream, line); // Dropping first line and BOM with it. - - while (!theStream.eof()) - { - std::getline(theStream, line); - const auto [key, value] = determineKeyLocalizationPair(line); - if (!key.empty() && !value.empty()) - { - if (localizations.contains(key)) - { - localizations[key][language] = value; - } - else - { - LocMap newMap; - newMap[language] = value; - localizations.emplace(key, newMap); - } - } - } -} - -std::pair V3::LocalizationLoader::determineKeyLocalizationPair(const std::string& text) -{ - std::pair blankReturn; - - if (text.size() > 2 && (text[0] == '#' || text[1] == '#')) - return blankReturn; - - const auto keyBeginPos = text.find_first_not_of(' '); - if (keyBeginPos == std::string::npos) - return blankReturn; - - const auto keyEndPos = text.find_first_of(':', keyBeginPos + 1); - const auto quotePos = text.find_first_of('"', keyEndPos); - if (quotePos == std::string::npos) - return blankReturn; - - const auto localizationBeginPos = quotePos + 1; - const auto localizationEndPos = text.find_last_of('"', text.size()); - return std::make_pair(text.substr(keyBeginPos, keyEndPos - keyBeginPos), text.substr(localizationBeginPos, localizationEndPos - localizationBeginPos)); -} - -std::optional V3::LocalizationLoader::getLocMapForKey(const std::string& key) const -{ - const auto& keyItr = localizations.find(key); - if (keyItr == localizations.end()) - return std::nullopt; - return keyItr->second; -} - -std::optional V3::LocalizationLoader::getLocForKey(const std::string& key, const std::string& language) const -{ - const auto& keyItr = localizations.find(key); - if (keyItr == localizations.end()) - return std::nullopt; - - const auto& locMap = keyItr->second; - if (locMap.contains(language)) - return locMap.at(language); - if (locMap.contains("english")) - return locMap.at("english"); - - // If we don't have anything but turkish, we might as well not respond. - return std::nullopt; -} diff --git a/EU5ToVic3/Source/V3World/Loaders/LocLoader/LocalizationLoader.h b/EU5ToVic3/Source/V3World/Loaders/LocLoader/LocalizationLoader.h deleted file mode 100644 index 70b0667..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/LocLoader/LocalizationLoader.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef LOCALIZATION_LOADER -#define LOCALIZATION_LOADER -#include "ModLoader/ModFilesystem.h" -#include -#include -#include -#include - -namespace V3 -{ -using LocMap = std::map; // language - loc -class LocalizationLoader -{ - public: - LocalizationLoader() = default; - void scrapeLocalizations(const commonItems::ModFilesystem& modFS); - void scrapeStream(std::istream& theStream, const std::string& language); - - [[nodiscard]] std::optional getLocMapForKey(const std::string& key) const; - [[nodiscard]] std::optional getLocForKey(const std::string& key, const std::string& language) const; - - private: - void scrapeLanguage(const std::string& language, const commonItems::ModFilesystem& modFS); - - [[nodiscard]] static std::pair determineKeyLocalizationPair(const std::string& text); - - std::map localizations; - - std::set knownLanguages; -}; -} // namespace V3 - -#endif // LOCALIZATION_LOADER \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesEntry.cpp b/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesEntry.cpp deleted file mode 100644 index 9d42e16..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesEntry.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "MajorFormablesEntry.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -V3::MajorFormablesEntry::MajorFormablesEntry(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::MajorFormablesEntry::registerKeys() -{ - registerKeyword("possible", [this](std::istream& theStream) { - possibleParser.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, [this](const std::string& stanzaKey, std::istream& theStream) { - stanzas.emplace_back(stanzaKey + " " + commonItems::stringOfItem(theStream).getString()); - }); - - possibleParser.registerKeyword("OR", [this](std::istream& theStream) { - orParser.parseStream(theStream); - }); - possibleParser.registerKeyword("any_country", [this](std::istream& theStream) { - anyCountryParser.parseStream(theStream); - }); - possibleParser.registerRegex(commonItems::catchallRegex, [this](const std::string& stanzaKey, std::istream& theStream) { - possibleStanzas.emplace_back(stanzaKey + " " + commonItems::stringOfItem(theStream).getString()); - }); - - anyCountryParser.registerKeyword("OR", [this](std::istream& theStream) { - orParser.parseStream(theStream); - }); - anyCountryParser.registerKeyword("filter", [this](std::istream& theStream) { - filterParser.parseStream(theStream); - }); - anyCountryParser.registerKeyword("has_technology_researched", [this](std::istream& theStream) { - requiredTechnology = commonItems::getString(theStream); - }); - anyCountryParser.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - filterParser.registerKeyword("OR", [this](std::istream& theStream) { - orParser.parseStream(theStream); - }); - filterParser.registerKeyword("has_technology_researched", [this](std::istream& theStream) { - requiredTechnology = commonItems::getString(theStream); - }); - filterParser.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - orParser.registerKeyword("country_has_primary_culture", [this](std::istream& theStream) { - auto culture = commonItems::getString(theStream); - if (culture.starts_with("cu:") && culture.size() > 3) - culture = culture.substr(3, culture.size()); - else - Log(LogLevel::Warning) << "Major formable culture " << culture << " is malformed! It should be cu:!"; - cultures.emplace(culture); - }); - orParser.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesEntry.h b/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesEntry.h deleted file mode 100644 index e991d61..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesEntry.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef MAJOR_FORMABLES_ENTRY_H -#define MAJOR_FORMABLES_ENTRY_H -#include "Parser.h" - -namespace V3 -{ -class MajorFormablesEntry: commonItems::parser -{ - public: - MajorFormablesEntry() = default; - explicit MajorFormablesEntry(std::istream& theStream); - - [[nodiscard]] const auto& getStanzas() const { return stanzas; } - [[nodiscard]] const auto& getPossibleStanzas() const { return possibleStanzas; } - [[nodiscard]] const auto& getCultures() const { return cultures; } - [[nodiscard]] const auto& getRequiredTechnology() const { return requiredTechnology; } - void addCulture(const std::string& culture) { cultures.emplace(culture); } - - private: - void registerKeys(); - - parser possibleParser; - parser anyCountryParser; - parser orParser; - parser filterParser; - std::string activeTag; - - std::vector stanzas; // unparsed stanzas. - std::vector possibleStanzas; // unparsed stanzas in possible block. - std::set cultures; - std::string requiredTechnology; -}; -} // namespace V3 -#endif // MAJOR_FORMABLES_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesLoader.cpp deleted file mode 100644 index 6128d4c..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesLoader.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "MajorFormablesLoader.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "MajorFormablesEntry.h" - -void V3::MajorFormablesLoader::loadMajorFormables(const std::string& filePath) -{ - Log(LogLevel::Info) << "-> Loading Major formables."; - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Loaded " << majorFormables.size() << " major formables."; -} - -void V3::MajorFormablesLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& tag, std::istream& theStream) { - majorFormables.emplace(tag, MajorFormablesEntry(theStream)); - }); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesLoader.h b/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesLoader.h deleted file mode 100644 index 41f40a6..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/MajorFormablesLoader/MajorFormablesLoader.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MAJOR_FORMABLES_LOADER_H -#define MAJOR_FORMABLES_LOADER_H -#include "MajorFormablesEntry.h" -#include "Parser.h" - -namespace V3 -{ -class MajorFormablesLoader: commonItems::parser -{ - public: - MajorFormablesLoader() = default; - void loadMajorFormables(const std::string& filePath); - - [[nodiscard]] const auto& getMajorFormables() const { return majorFormables; } - void setFormables(const std::map& theFormables) { majorFormables = theFormables; } - - private: - void registerKeys(); - - std::map majorFormables; -}; -} // namespace V3 -#endif // MAJOR_FORMABLES_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/NationalBudgetLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/NationalBudgetLoader.cpp deleted file mode 100644 index 219e23f..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/NationalBudgetLoader.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "NationalBudgetLoader.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -void V3::NationalBudgetLoader::loadNationalBudget(const std::string& filePath) -{ - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); - Log(LogLevel::Info) << sectorBlueprints.size() << " sectors of industry loaded."; -} - -void V3::NationalBudgetLoader::buildBuildingSectorMap() -{ - for (const auto& blueprint: sectorBlueprints) - for (const auto& building: blueprint.getBuildings()) - buildingSectorMap[building] = blueprint.getName(); -} - -std::optional V3::NationalBudgetLoader::getSectorName(const std::string& buildingName) const -{ - if (buildingSectorMap.contains(buildingName)) - { - return buildingSectorMap.at(buildingName); - } - return std::nullopt; -} - -void V3::NationalBudgetLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& sectorName, std::istream& theStream) { - SectorLoader newSectorBlueprint; - newSectorBlueprint.loadSector(theStream); - newSectorBlueprint.setName(sectorName); - sectorBlueprints.push_back(newSectorBlueprint); - }); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/NationalBudgetLoader.h b/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/NationalBudgetLoader.h deleted file mode 100644 index 31e7e9f..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/NationalBudgetLoader.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef V3_NATIONAL_BUDGET_LOADER_H -#define V3_NATIONAL_BUDGET_LOADER_H -#include "Parser.h" -#include "SectorLoader.h" - -namespace V3 -{ -class NationalBudgetLoader: commonItems::parser -{ - public: - NationalBudgetLoader() = default; - void loadNationalBudget(const std::string& filePath); - void buildBuildingSectorMap(); - - [[nodiscard]] const auto& getSectorBlueprints() const { return sectorBlueprints; } - [[nodiscard]] const auto& getBuildingSectorMap() const { return buildingSectorMap; } - [[nodiscard]] std::optional getSectorName(const std::string& buildingName) const; - - private: - void registerKeys(); - - std::vector sectorBlueprints; - std::map buildingSectorMap; // Building Name -> Name of Sector Building is in -}; -} // namespace V3 - -#endif // V3_NATIONAL_BUDGET_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/AddScript.cpp b/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/AddScript.cpp deleted file mode 100644 index 21ec859..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/AddScript.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "AddScript.h" - -double V3::AddScript::operator+(const double rhs) const -{ - return value + rhs; -} - -V3::AddScript V3::AddScript::combine(const std::vector& addVector) -{ - AddScript newAdd{}; - - for (const auto& add: addVector) - { - newAdd.value += add.value; - } - - return newAdd; -} \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/AddScript.h b/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/AddScript.h deleted file mode 100644 index 4c26f1b..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/AddScript.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef V3_ADD_SCRIPT_H -#define V3_ADD_SCRIPT_H -#include "MathScript.h" - -namespace V3 -{ -class AddScript: public MathScript -{ - public: - AddScript() = default; - - double operator+(double rhs) const; - [[nodiscard]] static AddScript combine(const std::vector& addVector); -}; -} // namespace V3 - -#endif // V3_ADD_SCRIPT_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MathScript.cpp b/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MathScript.cpp deleted file mode 100644 index dc0a280..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MathScript.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "MathScript.h" -#include "CommonRegexes.h" -#include "CountryManager/EU4Country.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "PoliticalManager/Country/Country.h" - -void V3::MathScript::loadMathScript(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::MathScript::registerKeys() -{ - registerKeyword("value", [this](std::istream& theStream) { - value = commonItems::getDouble(theStream); - }); - registerRegex(commonItems::catchallRegex, [this](const std::string& triggerName, std::istream& theStream) { - trigger = triggerName; - triggerValue = commonItems::getString(theStream); - }); -} - -bool V3::MathScript::isValid(const Country& country) const -{ - if (trigger == "is_colony") - { - return country.getSourceCountry()->isColony() == (triggerValue == "yes"); - } - if (trigger == "is_trade_company") - { - return country.getSourceCountry()->isTradeCompany() == (triggerValue == "yes"); - } - if (trigger == "vic3_law") - { - return country.getProcessedData().laws.contains(triggerValue); - } - if (trigger == "vic3_tech") - { - return country.getProcessedData().techs.contains(triggerValue); - } - if (trigger == "is_eu4_gp") - { - return country.getSourceCountry()->isGP() == (triggerValue == "yes"); - } - if (trigger == "industry_score_less_than") - { - try - { - return country.getIndustryFactor() * 5 < std::stoi(triggerValue); - } - catch (const std::exception& e) - { - Log(LogLevel::Error) << "Failed to understand industry score " << triggerValue << ": " << e.what(); - } - } - - Log(LogLevel::Error) << "Unknown trigger: " << trigger << " in MathScript."; - return false; -} \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MathScript.h b/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MathScript.h deleted file mode 100644 index 163b59c..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MathScript.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef V3_MATH_SCRIPT_H -#define V3_MATH_SCRIPT_H -#include "Parser.h" - -namespace V3 -{ -/* A Math script is a primitive form of Paradox's weight modifier script - * It only supports a single trigger. - */ -class Country; -class MathScript: commonItems::parser -{ - public: - MathScript() = default; - void loadMathScript(std::istream& theStream); - - [[nodiscard]] bool isValid(const Country& country) const; - - protected: - double value = 0; - - private: - void registerKeys(); - - std::string trigger; // is_colony, vic3_law - std::string triggerValue; // yes, law_serfdom -}; -} // namespace V3 - -#endif // V3_MATH_SCRIPT_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MultiplyScript.cpp b/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MultiplyScript.cpp deleted file mode 100644 index 85d0ae4..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MultiplyScript.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "MultiplyScript.h" - -double V3::MultiplyScript::operator*(const double rhs) const -{ - return value * rhs; -} - -V3::MultiplyScript V3::MultiplyScript::combine(const std::vector& multiplyVector) -{ - MultiplyScript newMultiply{}; - - for (const auto& mult: multiplyVector) - { - newMultiply.value += (mult.value - 1); - } - newMultiply.value += 1; - - return newMultiply; -} diff --git a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MultiplyScript.h b/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MultiplyScript.h deleted file mode 100644 index 6e8e6d8..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/Script/MultiplyScript.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef V3_MULTIPLY_SCRIPT_H -#define V3_MULTIPLY_SCRIPT_H -#include "MathScript.h" - -namespace V3 -{ -class MultiplyScript: public MathScript -{ - public: - MultiplyScript() = default; - - double operator*(double rhs) const; - [[nodiscard]] static MultiplyScript combine(const std::vector& multiplyVector); -}; -} // namespace V3 - -#endif // V3_MULTIPLY_SCRIPT_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/SectorLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/SectorLoader.cpp deleted file mode 100644 index 4319b56..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/SectorLoader.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "SectorLoader.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "PoliticalManager/Country/Country.h" - -void V3::SectorLoader::loadSector(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -double V3::SectorLoader::calculateWeight(const Country& country) const -{ - double theWeight = weight; - theWeight = mergeValidAdds(country) + theWeight; - theWeight = mergeValidMults(country) * theWeight; - - // Severely penalize unrecognized countries for these sectors - if (industrial) // TODO(Gawquon) Might want to create 2 stages of this? Circle back after seeing it in action. - { - theWeight *= country.getProcessedData().civLevel / 100.0 * country.getIndustryFactor(); - } - - return theWeight; -} - -void V3::SectorLoader::registerKeys() -{ - registerKeyword("industrial", [this](std::istream& theStream) { - if (commonItems::getString(theStream) == "yes") - industrial = true; - }); - registerKeyword("weight", [this](std::istream& theStream) { - weight = commonItems::getDouble(theStream); - }); - registerKeyword("add", [this](std::istream& theStream) { - AddScript newAdder; - newAdder.loadMathScript(theStream); - adders.push_back(newAdder); - }); - registerKeyword("multiply", [this](std::istream& theStream) { - MultiplyScript newMulti; - newMulti.loadMathScript(theStream); - multipliers.push_back(newMulti); - }); - registerRegex(R"(building_\w+)", [this](const std::string& building, std::istream& theStream) { - buildings.emplace(building); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -V3::AddScript V3::SectorLoader::mergeValidAdds(const Country& country) const -{ - std::vector validAdds; - for (const auto& add: adders) - { - if (add.isValid(country)) - { - validAdds.push_back(add); - } - } - return AddScript::combine(validAdds); -} - -V3::MultiplyScript V3::SectorLoader::mergeValidMults(const Country& country) const -{ - std::vector validMults; - for (const auto& mult: multipliers) - { - if (mult.isValid(country)) - { - validMults.push_back(mult); - } - } - return MultiplyScript::combine(validMults); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/SectorLoader.h b/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/SectorLoader.h deleted file mode 100644 index 3e59156..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/NationalBudgetLoader/SectorLoader.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef V3_SECTOR_LOADER_H -#define V3_SECTOR_LOADER_H -#include "Parser.h" -#include "Script/AddScript.h" -#include "Script/MultiplyScript.h" - -namespace V3 -{ -// A Sector of industry is a group of vic3 buildings with similar characteristics and distribution - -class SectorLoader: commonItems::parser -{ - public: - SectorLoader() = default; - void loadSector(std::istream& theStream); - void setName(const std::string& theName) { name = theName; } - - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getBuildings() const { return buildings; } - [[nodiscard]] double calculateWeight(const Country& country) const; - - private: - void registerKeys(); - [[nodiscard]] AddScript mergeValidAdds(const Country& country) const; - [[nodiscard]] MultiplyScript mergeValidMults(const Country& country) const; - - std::string name; - double weight = 0; - std::set buildings; - bool industrial = false; - - std::vector adders; - std::vector multipliers; -}; -} // namespace V3 - -#endif // V3_SECTOR_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopEntry.cpp b/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopEntry.cpp deleted file mode 100644 index eb2178d..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopEntry.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "PopEntry.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -void V3::PopEntry::loadPop(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::PopEntry::registerKeys() -{ - registerKeyword("culture", [this](std::istream& theStream) { - pop.setCulture(commonItems::getString(theStream)); - }); - registerKeyword("religion", [this](std::istream& theStream) { - pop.setReligion(commonItems::getString(theStream)); - }); - registerKeyword("size", [this](std::istream& theStream) { - pop.setSize(commonItems::getInt(theStream)); - }); - registerKeyword("pop_type", [this](std::istream& theStream) { - pop.setType(commonItems::getString(theStream)); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopEntry.h b/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopEntry.h deleted file mode 100644 index b2e0d7c..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopEntry.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef POP_ENTRY_H -#define POP_ENTRY_H -#include "Parser.h" -#include "PopManager/Pops/Pop.h" - -namespace V3 -{ -class PopEntry: commonItems::parser -{ - public: - PopEntry() = default; - - void loadPop(std::istream& theStream); - [[nodiscard]] const auto& getPop() const { return pop; } - - private: - void registerKeys(); - - Pop pop; -}; -} // namespace V3 -#endif // POP_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopLoader.cpp deleted file mode 100644 index d7d92fe..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopLoader.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "PopLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "OSCompatibilityLayer.h" -#include "ParserHelpers.h" -#include "StateEntries.h" - -void V3::PopLoader::loadPops(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/history/pops/")) - { - if (getExtension(fileName) != "txt") - continue; - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::PopLoader::registerKeys() -{ - registerKeyword("POPS", [this](std::istream& theStream) { - StateEntries stateEntries; - stateEntries.loadStates(theStream); - auto grabbedPops = stateEntries.getStatePops(); - grabbedPops.merge(statePops); // merging this way so we override previous entries. - statePops.swap(grabbedPops); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopLoader.h b/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopLoader.h deleted file mode 100644 index 9f1141f..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/PopLoader/PopLoader.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef POP_LOADER_H -#define POP_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include "PopManager/Pops/StatePops.h" - -namespace V3 -{ -class PopLoader: commonItems::parser -{ - public: - PopLoader() = default; - - void loadPops(const commonItems::ModFilesystem& modFS); - [[nodiscard]] const auto& getStatePops() const { return statePops; } - - private: - void registerKeys(); - - std::map statePops; -}; -} // namespace V3 -#endif // POP_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/PopLoader/StateEntries.cpp b/EU5ToVic3/Source/V3World/Loaders/PopLoader/StateEntries.cpp deleted file mode 100644 index 8dbc7c0..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/PopLoader/StateEntries.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "StateEntries.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "SubStateEntries.h" - -void V3::StateEntries::loadStates(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::StateEntries::registerKeys() -{ - registerRegex(R"(s:\w+)", [this](const std::string& stateName, std::istream& theStream) { - SubStateEntries subStateEntries; - subStateEntries.loadSubStates(theStream); - StatePops theStatePops; - theStatePops.setSubStatePops(subStateEntries.getSubStatePops()); - if (const auto state = getStateFromName(stateName); state) - { - theStatePops.setStateName(*state); - statePops.emplace(*state, theStatePops); - } - else - { - Log(LogLevel::Warning) << "Incoming pops within state " << stateName << " have no parsable state. Deleting Pops!"; - } - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional V3::StateEntries::getStateFromName(const std::string& name) -{ - const auto colonPos = name.find_last_of(':'); - if (colonPos != 1 || name.size() <= 3) // needs to be second char, and single-letter states just won't cut it. - return std::nullopt; - return name.substr(colonPos + 1, name.size()); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/PopLoader/StateEntries.h b/EU5ToVic3/Source/V3World/Loaders/PopLoader/StateEntries.h deleted file mode 100644 index 022542b..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/PopLoader/StateEntries.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef STATE_ENTRIES_H -#define STATE_ENTRIES_H -#include "Parser.h" -#include "PopManager/Pops/StatePops.h" - -namespace V3 -{ -class StateEntries: commonItems::parser -{ - public: - StateEntries() = default; - - void loadStates(std::istream& theStream); - [[nodiscard]] const auto& getStatePops() const { return statePops; } - - private: - void registerKeys(); - [[nodiscard]] static std::optional getStateFromName(const std::string& name); - - std::map statePops; // state, StatePops -}; -} // namespace V3 -#endif // STATE_ENTRIES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStateEntries.cpp b/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStateEntries.cpp deleted file mode 100644 index d29f89c..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStateEntries.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "SubStateEntries.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "SubStatePopEntries.h" - -void V3::SubStateEntries::loadSubStates(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::SubStateEntries::registerKeys() -{ - registerRegex(R"(region_state:\w+)", [this](const std::string& subStateName, std::istream& theStream) { - SubStatePopEntries subStatePopEntries; - subStatePopEntries.loadPops(theStream); - SubStatePops theSubStatePops; - theSubStatePops.setPops(subStatePopEntries.getPops()); - if (getTagFromName(subStateName)) - theSubStatePops.setTag(*getTagFromName(subStateName)); - else - Log(LogLevel::Warning) << "Incoming pops within substate " << subStateName << " have no parsable TAG. Filing pops as unclaimed."; - subStatePops.push_back(theSubStatePops); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -std::optional V3::SubStateEntries::getTagFromName(const std::string& name) -{ - const auto colonPos = name.find_last_of(':'); - if (colonPos == std::string::npos || colonPos >= name.size() - 3) // save room for the tag. - return std::nullopt; - return name.substr(colonPos + 1, name.size()); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStateEntries.h b/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStateEntries.h deleted file mode 100644 index 909a41e..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStateEntries.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef SUBSTATE_ENTRIES_H -#define SUBSTATE_ENTRIES_H -#include "Parser.h" -#include "PopManager/Pops/SubStatePops.h" - -namespace V3 -{ -typedef std::map> ownedPops; - -class SubStateEntries: commonItems::parser -{ - public: - SubStateEntries() = default; - - void loadSubStates(std::istream& theStream); - [[nodiscard]] const auto& getSubStatePops() const { return subStatePops; } - - private: - void registerKeys(); - [[nodiscard]] static std::optional getTagFromName(const std::string& name); - - std::vector subStatePops; -}; -} // namespace V3 -#endif // SUBSTATE_ENTRIES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStatePopEntries.cpp b/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStatePopEntries.cpp deleted file mode 100644 index 5c12297..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStatePopEntries.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "SubStatePopEntries.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "PopEntry.h" - -void V3::SubStatePopEntries::loadPops(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::SubStatePopEntries::registerKeys() -{ - registerKeyword("create_pop", [this](std::istream& theStream) { - PopEntry popEntry; - popEntry.loadPop(theStream); - pops.push_back(popEntry.getPop()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStatePopEntries.h b/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStatePopEntries.h deleted file mode 100644 index 0e311b4..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/PopLoader/SubStatePopEntries.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef SUBSTATE_POP_ENTRIES_H -#define SUBSTATE_POP_ENTRIES_H -#include "Parser.h" -#include "PopManager/Pops/Pop.h" - -namespace V3 -{ -class SubStatePopEntries: commonItems::parser -{ - public: - SubStatePopEntries() = default; - - void loadPops(std::istream& theStream); - [[nodiscard]] const auto& getPops() const { return pops; } - - private: - void registerKeys(); - - std::vector pops; -}; -} // namespace V3 -#endif // SUBSTATE_POP_ENTRIES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/StateLoader/StateLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/StateLoader/StateLoader.cpp deleted file mode 100644 index a5e967c..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/StateLoader/StateLoader.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "StateLoader.h" -#include "ClayManager/State/State.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" - -void V3::StateLoader::loadStates(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/map_data/state_regions/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::StateLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& stateName, std::istream& theStream) { - const auto newState = std::make_shared(); - newState->loadState(theStream); - newState->setStateName(stateName); - states.emplace(stateName, newState); - }); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/StateLoader/StateLoader.h b/EU5ToVic3/Source/V3World/Loaders/StateLoader/StateLoader.h deleted file mode 100644 index 74af02a..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/StateLoader/StateLoader.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef STATE_LOADER_H -#define STATE_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class State; -class StateLoader: commonItems::parser -{ - public: - StateLoader() = default; - - void loadStates(const commonItems::ModFilesystem& modFS); - [[nodiscard]] const auto& getStates() const { return states; } - - private: - void registerKeys(); - - std::map> states; -}; -} // namespace V3 -#endif // STATE_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/StateModifierLoader/StateModifierLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/StateModifierLoader/StateModifierLoader.cpp deleted file mode 100644 index 9f3bb71..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/StateModifierLoader/StateModifierLoader.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "StateModifierLoader.h" -#include "ClayManager/State/StateModifier.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "OSCompatibilityLayer.h" - -void V3::StateModifierLoader::loadStateModifiers(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/state_traits/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::StateModifierLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& modifierName, std::istream& theStream) { - StateModifier newModifier; - newModifier.loadStateModifier(theStream); - newModifier.setName(modifierName); - stateModifiers.emplace(modifierName, newModifier); - }); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/StateModifierLoader/StateModifierLoader.h b/EU5ToVic3/Source/V3World/Loaders/StateModifierLoader/StateModifierLoader.h deleted file mode 100644 index cc714e6..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/StateModifierLoader/StateModifierLoader.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef STATE_MODIFIER_LOADER_H -#define STATE_MODIFIER_LOADER_H -#include "ClayManager/State/StateModifier.h" -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class StateModifierLoader: commonItems::parser -{ - public: - StateModifierLoader() = default; - - void loadStateModifiers(const commonItems::ModFilesystem& modFS); - [[nodiscard]] const auto& getStateModifiers() const { return stateModifiers; } - - private: - void registerKeys(); - - std::map stateModifiers; -}; -} // namespace V3 -#endif // STATE_MODIFIER_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/SuperRegionLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/SuperRegionLoader.cpp deleted file mode 100644 index d23651a..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/SuperRegionLoader.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "SuperRegionLoader.h" -#include "CommonFunctions.h" -#include "V3SuperRegion.h" -#include -#include -namespace fs = std::filesystem; - -void V3::SuperRegionLoader::loadSuperRegions(const commonItems::ModFilesystem& modFS) -{ - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/strategic_regions/")) - { - if (getExtension(fileName) != "txt") - continue; - std::ifstream superRegionStream(fs::u8path(fileName)); - if (!superRegionStream.is_open()) - throw std::runtime_error("Could not open " + fileName + " !"); - - const auto superRegion = std::make_shared(); - const auto superRegionName = trimPath(trimExtension(fileName)); - superRegion->initializeSuperRegion(superRegionStream); - superRegion->setName(superRegionName); - superRegions.emplace(superRegionName, superRegion); - } -} diff --git a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/SuperRegionLoader.h b/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/SuperRegionLoader.h deleted file mode 100644 index 79d9106..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/SuperRegionLoader.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef SUPERREGION_LOADER_H -#define SUPERREGION_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class SuperRegion; -class SuperRegionLoader: commonItems::parser -{ - public: - SuperRegionLoader() = default; - - void loadSuperRegions(const commonItems::ModFilesystem& modFS); - [[nodiscard]] const auto& getSuperRegions() const { return superRegions; } - - private: - std::map> superRegions; -}; -} // namespace V3 -#endif // SUPERREGION_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3Region.cpp b/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3Region.cpp deleted file mode 100644 index 74cd804..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3Region.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "V3Region.h" -#include "ClayManager/State/State.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include - -void V3::Region::initializeRegion(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::Region::registerKeys() -{ - registerKeyword("states", [this](std::istream& theStream) { - for (const auto& stateName: commonItems::getStrings(theStream)) - states.emplace(stateName, nullptr); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -double V3::Region::getTotalSubStateWeight() const -{ - return std::accumulate(states.begin(), states.end(), 0.0, [](double sum, const auto& state) { - return sum + state.second->getTotalSubStateWeight(); - }); -} \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3Region.h b/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3Region.h deleted file mode 100644 index 1441f8f..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3Region.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef V3_REGION_H -#define V3_REGION_H -#include "Parser.h" - -namespace V3 -{ -class State; -class Region: commonItems::parser -{ - public: - Region() = default; - - void initializeRegion(std::istream& theStream); - void setName(const std::string& theName) { name = theName; } - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getStates() const { return states; } - [[nodiscard]] bool containsState(const std::string& state) const { return states.contains(state); } - void replaceStates(const std::map>& theStates) { states = theStates; } - - [[nodiscard]] double getTotalSubStateWeight() const; - - private: - void registerKeys(); - - std::string name; - std::map> states; -}; -} // namespace V3 -#endif // V3_REGION_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3SuperRegion.cpp b/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3SuperRegion.cpp deleted file mode 100644 index 3a1439c..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3SuperRegion.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "V3SuperRegion.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "V3Region.h" -#include - -void V3::SuperRegion::initializeSuperRegion(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::SuperRegion::registerKeys() -{ - registerKeyword(commonItems::utf8BOM, [](std::istream& theStream) { - }); - registerRegex(commonItems::catchallRegex, [this](const std::string& regionName, std::istream& theStream) { - const auto region = std::make_shared(); - region->initializeRegion(theStream); - region->setName(regionName); - regions.emplace(regionName, region); - }); -} - -double V3::SuperRegion::getTotalSubStateWeight() const -{ - return std::accumulate(regions.begin(), regions.end(), 0.0, [](double sum, const auto& region) { - return sum + region.second->getTotalSubStateWeight(); - }); -} \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3SuperRegion.h b/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3SuperRegion.h deleted file mode 100644 index c207832..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/SuperRegionLoader/V3SuperRegion.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef V3_SUPERREGION_H -#define V3_SUPERREGION_H -#include "Parser.h" - -namespace V3 -{ -class Region; -class SuperRegion: commonItems::parser -{ - public: - SuperRegion() = default; - - void initializeSuperRegion(std::istream& theStream); - void setName(const std::string& theName) { name = theName; } - [[nodiscard]] const auto& getName() const { return name; } - [[nodiscard]] const auto& getRegions() const { return regions; } - [[nodiscard]] bool containsRegion(const std::string& region) const { return regions.contains(region); } - [[nodiscard]] double getTotalSubStateWeight() const; - - - private: - void registerKeys(); - - std::string name; - std::map> regions; -}; -} // namespace V3 -#endif // V3_SUPERREGION_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/TechLoader/Tech.h b/EU5ToVic3/Source/V3World/Loaders/TechLoader/Tech.h deleted file mode 100644 index 7264f45..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/TechLoader/Tech.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef TECH_H -#define TECH_H - -namespace V3 -{ -struct Tech -{ - int infrastructureMax = 0; - double infrastructureMult = 0.0; - int throughputMax = 0; - std::map maxBuildingLevels; -}; -} // namespace V3 -#endif // LAW_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechEntry.cpp b/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechEntry.cpp deleted file mode 100644 index fa7c26b..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechEntry.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "TechEntry.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -V3::TechEntry::TechEntry(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::TechEntry::registerKeys() -{ - registerKeyword("modifier", [this](std::istream& theStream) { - modifierParser.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - modifierParser.registerKeyword("state_infrastructure_from_population_add", [this](std::istream& theStream) { - tech.infrastructureMult = commonItems::getDouble(theStream); - }); - modifierParser.registerKeyword("state_infrastructure_from_population_max_add", [this](std::istream& theStream) { - tech.infrastructureMax = commonItems::getInt(theStream); - }); - modifierParser.registerRegex("state_building_[a-zA-Z_]+_max_level_add", [this](const std::string& modifier, std::istream& theStream) { - const std::regex pattern("state_building_([a-zA-Z_]+)_max_level_add"); - std::smatch building; - if (std::regex_search(modifier, building, pattern)) // state_building_port_max_level_add -> port - { - tech.maxBuildingLevels["building_" + building[1].str()] = commonItems::getInt(theStream); - } - else - { - Log(LogLevel::Error) << "Found a max level modifier, but could not parse it: " << modifier; - } - }); - modifierParser.registerKeyword("building_economy_of_scale_level_cap_add", [this](std::istream& theStream) { - tech.throughputMax = commonItems::getInt(theStream); - }); - modifierParser.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechEntry.h b/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechEntry.h deleted file mode 100644 index ea21326..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechEntry.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TECH_ENTRY_H -#define TECH_ENTRY_H -#include "Parser.h" -#include "Tech.h" - -namespace V3 -{ -class TechEntry: commonItems::parser -{ - - public: - TechEntry() = default; - explicit TechEntry(std::istream& theStream); - - [[nodiscard]] const auto& getTech() const { return tech; } - - private: - void registerKeys(); - - parser modifierParser; - - Tech tech; -}; -} // namespace V3 -#endif // TECH_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechLoader.cpp deleted file mode 100644 index 59991b9..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechLoader.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "TechLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "TechEntry.h" - -void V3::TechLoader::loadTechs(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading Techs."; - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/technology/technologies")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); - Log(LogLevel::Info) << "<> Loaded " << techs.size() << " techs."; -} - -void V3::TechLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& techName, std::istream& theStream) { - techs.emplace(techName, TechEntry(theStream).getTech()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechLoader.h b/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechLoader.h deleted file mode 100644 index 7d6fec2..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/TechLoader/TechLoader.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef TECH_LOADER_H -#define TECH_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include "Tech.h" - -namespace V3 -{ -class TechLoader: commonItems::parser -{ - public: - TechLoader() = default; - void loadTechs(const commonItems::ModFilesystem& modFS); - - [[nodiscard]] const auto& getTechs() const { return techs; } - - private: - void registerKeys(); - - std::map techs; -}; -} // namespace V3 -#endif // TECH_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainLoader.cpp deleted file mode 100644 index e0a9832..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainLoader.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "TerrainLoader.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "StringUtils.h" - -void V3::TerrainLoader::loadTerrains(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - parseFile(*modFS.GetActualFileLocation("/map_data/province_terrains.txt")); - clearRegisteredKeywords(); -} - -void V3::TerrainLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& provinceName, std::istream& theStream) { - const auto theTerrain = commonItems::getString(theStream); - auto theProvinceName = commonItems::remQuotes(provinceName); - std::transform(theProvinceName.begin(), theProvinceName.end(), theProvinceName.begin(), ::toupper); - if (theProvinceName.starts_with("X") && theProvinceName.size() == 7) - theProvinceName = "x" + theProvinceName.substr(1, theProvinceName.length() - 1); - else - Log(LogLevel::Warning) << "Encountered terrain for province " << theProvinceName << " in unknown format!"; - provincialTerrains.emplace(theProvinceName, theTerrain); - }); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainLoader.h b/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainLoader.h deleted file mode 100644 index 24d7e45..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainLoader.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef TERRAIN_LOADER_H -#define TERRAIN_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include -#include - -namespace V3 -{ -class TerrainLoader: commonItems::parser -{ - public: - TerrainLoader() = default; - - void loadTerrains(const commonItems::ModFilesystem& modFS); - [[nodiscard]] const auto& getTerrains() const { return provincialTerrains; } - - private: - void registerKeys(); - - std::map provincialTerrains; -}; -} // namespace V3 -#endif // TERRAIN_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainModifierLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainModifierLoader.cpp deleted file mode 100644 index 4795763..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainModifierLoader.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "TerrainModifierLoader.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include - -void V3::TerrainModifierLoader::loadTerrainModifiers(const std::string& filePath) -{ - registerKeys(); - parseFile(filePath); - clearRegisteredKeywords(); -} - -void V3::TerrainModifierLoader::loadTerrainModifiers(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::TerrainModifierLoader::registerKeys() -{ - registerRegex(commonItems::catchallRegex, [this](const std::string& terrain, std::istream& theStream) { - stateTerrainModifiers[terrain] = 0; - - for (const auto& [type, multiplier]: commonItems::assignments(theStream).getAssignments()) - { - try - { - if (type == "priority") - { - stateTerrainModifiers[terrain] = std::stod(multiplier); - } - else - { - buildingTerrainModifiers[terrain][type] = std::stod(multiplier); - } - } - catch (const std::exception& e) - { - Log(LogLevel::Error) << "Failed read " << type << " under " << terrain << " modifier: " << e.what(); - } - } - }); -} \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainModifierLoader.h b/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainModifierLoader.h deleted file mode 100644 index f52eaa9..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/TerrainLoader/TerrainModifierLoader.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef TERRAIN_MODIFIER_LOADER_H -#define TERRAIN_MODIFIER_LOADER_H -#include "Parser.h" -#include -#include - -namespace V3 -{ -class TerrainModifierLoader: commonItems::parser -{ - public: - TerrainModifierLoader() = default; - - void loadTerrainModifiers(const std::string& filePath); - void loadTerrainModifiers(std::istream& theStream); - [[nodiscard]] const auto& getTerrainStateModifiers() const { return stateTerrainModifiers; } - [[nodiscard]] const auto& getTerrainBuildingModifiers() const { return buildingTerrainModifiers; } - - private: - void registerKeys(); - - std::map stateTerrainModifiers; - std::map> buildingTerrainModifiers; -}; -} // namespace V3 -#endif // TERRAIN_MODIFIER_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingEntries.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingEntries.cpp deleted file mode 100644 index bd09bac..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingEntries.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "VanillaBuildingEntries.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -V3::VanillaBuildingEntries::VanillaBuildingEntries(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::VanillaBuildingEntries::registerKeys() -{ - registerRegex(R"(region_state:\w+)", [this](const std::string& sourceTag, std::istream& theStream) { - activeTag = sourceTag.substr(13, sourceTag.size()); - entryParser.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - entryParser.registerRegex(commonItems::catchallRegex, [this](const std::string& elementName, std::istream& theStream) { - const auto elementValue = commonItems::stringOfItem(theStream); - buildingElements[activeTag].emplace_back(elementName + " " + elementValue.getString()); - }); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingEntries.h b/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingEntries.h deleted file mode 100644 index c7b8f72..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingEntries.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef VANILLA_BUILDING_ENTRIES_H -#define VANILLA_BUILDING_ENTRIES_H -#include "Parser.h" - -namespace V3 -{ -class VanillaBuildingEntries: commonItems::parser -{ - public: - VanillaBuildingEntries() = default; - explicit VanillaBuildingEntries(std::istream& theStream); - - [[nodiscard]] const auto& getBuildingElements() const { return buildingElements; } - - private: - void registerKeys(); - - parser entryParser; - std::string activeTag; - - std::map> buildingElements; // unparsed elements from the file, ready for direct dump. -}; -} // namespace V3 -#endif // VANILLA_BUILDING_ENTRIES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingLoader.cpp deleted file mode 100644 index bf5c4dd..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingLoader.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "VanillaBuildingLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "VanillaBuildingEntries.h" - -void V3::VanillaBuildingLoader::loadVanillaBuildings(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/history/buildings/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::VanillaBuildingLoader::registerKeys() -{ - registerKeyword("BUILDINGS", [this](std::istream& theStream) { - stateParser.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - stateParser.registerRegex(R"([s,S]:\w+)", [this](const std::string& stateName, std::istream& theStream) { - const auto activeState = stateName.substr(2, stateName.size()); - const auto entries = VanillaBuildingEntries(theStream).getBuildingElements(); - buildingElements[activeState] = entries; - }); - stateParser.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingLoader.h b/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingLoader.h deleted file mode 100644 index ee9f752..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaBuildingLoader/VanillaBuildingLoader.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef VANILLA_BUILDING_LOADER_H -#define VANILLA_BUILDING_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class VanillaBuildingLoader: commonItems::parser -{ - public: - VanillaBuildingLoader() = default; - void loadVanillaBuildings(const commonItems::ModFilesystem& modFS); - - [[nodiscard]] const auto& getBuildingElements() const { return buildingElements; } - - private: - void registerKeys(); - parser stateParser; - - std::map>> buildingElements; -}; -} // namespace V3 -#endif // VANILLA_BUILDING_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterEntries.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterEntries.cpp deleted file mode 100644 index bf029bf..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterEntries.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "VanillaCharacterEntries.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -V3::VanillaCharacterEntries::VanillaCharacterEntries(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::VanillaCharacterEntries::registerKeys() -{ - registerRegex(R"([c,C]:\w+)", [this](const std::string& sourceTag, std::istream& theStream) { - activeTag = sourceTag.substr(2, sourceTag.size()); - entryParser.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - entryParser.registerRegex(commonItems::catchallRegex, [this](const std::string& elementName, std::istream& theStream) { - const auto elementValue = commonItems::stringOfItem(theStream); - characterElements[activeTag].emplace_back(elementName + " " + elementValue.getString()); - }); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterEntries.h b/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterEntries.h deleted file mode 100644 index fa94bc5..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterEntries.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef VANILLA_CHARACTER_ENTRIES_H -#define VANILLA_CHARACTER_ENTRIES_H -#include "Parser.h" - -namespace V3 -{ -class VanillaCharacterEntries: commonItems::parser -{ - public: - VanillaCharacterEntries() = default; - explicit VanillaCharacterEntries(std::istream& theStream); - - [[nodiscard]] const auto& getCharacterElements() const { return characterElements; } - - private: - void registerKeys(); - - parser entryParser; - std::string activeTag; - - std::map> characterElements; // unparsed elements from the file, ready for direct dump. -}; -} // namespace V3 -#endif // VANILLA_CHARACTER_ENTRIES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterLoader.cpp deleted file mode 100644 index 7d3f89b..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterLoader.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "VanillaCharacterLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "VanillaCharacterEntries.h" - -void V3::VanillaCharacterLoader::loadVanillaCharacters(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/history/characters/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::VanillaCharacterLoader::registerKeys() -{ - registerKeyword("CHARACTERS", [this](std::istream& theStream) { - const auto entries = VanillaCharacterEntries(theStream); - // Append. They don't necessarily overwrite eachother. - for (const auto& [tag, elements]: entries.getCharacterElements()) - characterElements[tag].insert(characterElements[tag].end(), elements.begin(), elements.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterLoader.h b/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterLoader.h deleted file mode 100644 index f3bcd33..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaCharacterLoader/VanillaCharacterLoader.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef VANILLA_CHARACTER_LOADER_H -#define VANILLA_CHARACTER_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class VanillaCharacterLoader: commonItems::parser -{ - public: - VanillaCharacterLoader() = default; - void loadVanillaCharacters(const commonItems::ModFilesystem& modFS); - - [[nodiscard]] const auto& getCharacterElements() const { return characterElements; } - - private: - void registerKeys(); - - std::map> characterElements; -}; -} // namespace V3 -#endif // VANILLA_CHARACTER_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryEntries.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryEntries.cpp deleted file mode 100644 index b83f956..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryEntries.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "VanillaCountryHistoryEntries.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -V3::VanillaCountryHistoryEntries::VanillaCountryHistoryEntries(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::VanillaCountryHistoryEntries::registerKeys() -{ - registerRegex(R"([c,C]:\w+)", [this](const std::string& sourceTag, std::istream& theStream) { - activeTag = sourceTag.substr(2, sourceTag.size()); - entryParser.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - entryParser.registerRegex(commonItems::catchallRegex, [this](const std::string& elementName, std::istream& theStream) { - const auto elementValue = commonItems::stringOfItem(theStream); - countryHistoryElements[activeTag].emplace_back(elementName + " " + elementValue.getString()); - }); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryEntries.h b/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryEntries.h deleted file mode 100644 index 849d575..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryEntries.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef VANILLA_COUNTRY_HISTORY_ENTRIES_H -#define VANILLA_COUNTRY_HISTORY_ENTRIES_H -#include "Parser.h" - -namespace V3 -{ -class VanillaCountryHistoryEntries: commonItems::parser -{ - public: - VanillaCountryHistoryEntries() = default; - explicit VanillaCountryHistoryEntries(std::istream& theStream); - - [[nodiscard]] const auto& getCountryHistoryElements() const { return countryHistoryElements; } - - private: - void registerKeys(); - - parser entryParser; - std::string activeTag; - - std::map> countryHistoryElements; // unparsed elements from the file, ready for direct dump. -}; -} // namespace V3 -#endif // VANILLA_COUNTRY_HISTORY_ENTRIES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryLoader.cpp deleted file mode 100644 index e0bfe8d..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryLoader.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "VanillaCountryHistoryLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "VanillaCountryHistoryEntries.h" - -void V3::VanillaCountryHistoryLoader::loadVanillaCountryHistories(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/history/countries/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::VanillaCountryHistoryLoader::registerKeys() -{ - registerKeyword("COUNTRIES", [this](std::istream& theStream) { - const auto entries = VanillaCountryHistoryEntries(theStream); - // Append. They don't necessarily overwrite eachother. - for (const auto& [tag, elements]: entries.getCountryHistoryElements()) - countryHistoryElements[tag].insert(countryHistoryElements[tag].end(), elements.begin(), elements.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryLoader.h b/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryLoader.h deleted file mode 100644 index 9f94d17..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryLoader.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef VANILLA_COUNTRY_HISTORY_LOADER_H -#define VANILLA_COUNTRY_HISTORY_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class VanillaCountryHistoryLoader: commonItems::parser -{ - public: - VanillaCountryHistoryLoader() = default; - void loadVanillaCountryHistories(const commonItems::ModFilesystem& modFS); - - [[nodiscard]] const auto& getCountryHistoryElements() const { return countryHistoryElements; } - - private: - void registerKeys(); - - std::map> countryHistoryElements; -}; -} // namespace V3 -#endif // VANILLA_COUNTRY_HISTORY_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaAgreementEntry.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaAgreementEntry.cpp deleted file mode 100644 index 0a3a554..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaAgreementEntry.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "VanillaAgreementEntry.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -V3::VanillaAgreementEntry::VanillaAgreementEntry(std::istream& theStream, std::string sourceTag): sourceTag(std::move(sourceTag)) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::VanillaAgreementEntry::registerKeys() -{ - registerKeyword("country", [this](std::istream& theStream) { - targetTag = commonItems::getString(theStream); - if ((targetTag.starts_with("c:") || targetTag.starts_with("C:")) && targetTag.size() == 5) // very specific about this. - targetTag = targetTag.substr(2, 3); - else - Log(LogLevel::Warning) << "Unrecognized target truce country: " << targetTag << "!"; - }); - registerKeyword("type", [this](std::istream& theStream) { - agreementType = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaAgreementEntry.h b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaAgreementEntry.h deleted file mode 100644 index 8f07006..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaAgreementEntry.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef VANILLA_AGREEMENT_ENTRY_H -#define VANILLA_AGREEMENT_ENTRY_H -#include "Parser.h" - -namespace V3 -{ -class VanillaAgreementEntry: commonItems::parser -{ - public: - VanillaAgreementEntry() = default; - explicit VanillaAgreementEntry(std::istream& theStream, std::string sourceTag); - - [[nodiscard]] const auto& getSourceTag() const { return sourceTag; } - [[nodiscard]] const auto& getTargetTag() const { return targetTag; } - [[nodiscard]] const auto& getAgreementType() const { return agreementType; } - - private: - void registerKeys(); - - std::string sourceTag; - std::string targetTag; - std::string agreementType; -}; -} // namespace V3 -#endif // VANILLA_AGREEMENT_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyEntries.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyEntries.cpp deleted file mode 100644 index 577ee35..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyEntries.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "VanillaDiplomacyEntries.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -V3::VanillaDiplomacyEntries::VanillaDiplomacyEntries(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::VanillaDiplomacyEntries::registerKeys() -{ - registerRegex(R"([c,C]:\w+)", [this](const std::string& sourceTag, std::istream& theStream) { - activeTag = sourceTag.substr(2, sourceTag.size()); - entryParser.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - entryParser.registerKeyword("create_diplomatic_pact", [this](std::istream& theStream) { - agreementEntries.emplace_back(VanillaAgreementEntry(theStream, activeTag)); - }); - entryParser.registerKeyword("set_relations", [this](std::istream& theStream) { - relationEntries.emplace_back(VanillaRelationEntry(theStream, activeTag)); - }); - entryParser.registerKeyword("create_truce", [this](std::istream& theStream) { - truceEntries.emplace_back(VanillaTruceEntry(theStream, activeTag)); - }); - entryParser.registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyEntries.h b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyEntries.h deleted file mode 100644 index d4bc164..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyEntries.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef VANILLA_DIPLOMACY_ENTRIES_H -#define VANILLA_DIPLOMACY_ENTRIES_H -#include "Parser.h" -#include "VanillaAgreementEntry.h" -#include "VanillaRelationEntry.h" -#include "VanillaTruceEntry.h" - -namespace V3 -{ -class VanillaDiplomacyEntries: commonItems::parser -{ - public: - VanillaDiplomacyEntries() = default; - explicit VanillaDiplomacyEntries(std::istream& theStream); - - [[nodiscard]] const auto& getAgreementEntries() const { return agreementEntries; } - [[nodiscard]] const auto& getRelationEntries() const { return relationEntries; } - [[nodiscard]] const auto& getTruceEntries() const { return truceEntries; } - - private: - void registerKeys(); - - parser entryParser; - std::string activeTag; - - std::vector agreementEntries; - std::vector relationEntries; - std::vector truceEntries; -}; -} // namespace V3 -#endif // VANILLA_DIPLOMACY_ENTRIES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyLoader.cpp deleted file mode 100644 index 311fb4b..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyLoader.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "VanillaDiplomacyLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "VanillaDiplomacyEntries.h" - -void V3::VanillaDiplomacyLoader::loadVanillaDiplomacy(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/history/diplomacy/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::VanillaDiplomacyLoader::registerKeys() -{ - registerKeyword("DIPLOMACY", [this](std::istream& theStream) { - const auto entries = VanillaDiplomacyEntries(theStream); - const auto& theAgreements = entries.getAgreementEntries(); - const auto& theRelations = entries.getRelationEntries(); - const auto& theTruces = entries.getTruceEntries(); - agreementEntries.insert(agreementEntries.end(), theAgreements.begin(), theAgreements.end()); - relationEntries.insert(relationEntries.end(), theRelations.begin(), theRelations.end()); - truceEntries.insert(truceEntries.end(), theTruces.begin(), theTruces.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyLoader.h b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyLoader.h deleted file mode 100644 index 7365b23..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaDiplomacyLoader.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef VANILLA_DIPLOMACY_LOADER_H -#define VANILLA_DIPLOMACY_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include "VanillaAgreementEntry.h" -#include "VanillaRelationEntry.h" -#include "VanillaTruceEntry.h" - -namespace V3 -{ -class VanillaDiplomacyLoader: commonItems::parser -{ - public: - VanillaDiplomacyLoader() = default; - void loadVanillaDiplomacy(const commonItems::ModFilesystem& modFS); - - [[nodiscard]] const auto& getAgreementEntries() const { return agreementEntries; } - [[nodiscard]] const auto& getRelationEntries() const { return relationEntries; } - [[nodiscard]] const auto& getTruceEntries() const { return truceEntries; } - - private: - void registerKeys(); - - std::vector agreementEntries; - std::vector relationEntries; - std::vector truceEntries; -}; -} // namespace V3 -#endif // VANILLA_DIPLOMACY_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaRelationEntry.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaRelationEntry.cpp deleted file mode 100644 index ce504e4..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaRelationEntry.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "VanillaRelationEntry.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -V3::VanillaRelationEntry::VanillaRelationEntry(std::istream& theStream, std::string sourceTag): sourceTag(std::move(sourceTag)) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::VanillaRelationEntry::registerKeys() -{ - registerKeyword("country", [this](std::istream& theStream) { - targetTag = commonItems::getString(theStream); - if ((targetTag.starts_with("c:") || targetTag.starts_with("C:")) && targetTag.size() == 5) // very specific about this. - targetTag = targetTag.substr(2, 3); - else - Log(LogLevel::Warning) << "Unrecognized target relation country: " << targetTag << "!"; - }); - registerKeyword("value", [this](std::istream& theStream) { - relationValue = commonItems::getInt(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaRelationEntry.h b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaRelationEntry.h deleted file mode 100644 index 92d95e0..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaRelationEntry.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef VANILLA_RELATION_ENTRY_H -#define VANILLA_RELATION_ENTRY_H -#include "Parser.h" - -namespace V3 -{ -class VanillaRelationEntry: commonItems::parser -{ - public: - VanillaRelationEntry() = default; - explicit VanillaRelationEntry(std::istream& theStream, std::string sourceTag); - - [[nodiscard]] const auto& getSourceTag() const { return sourceTag; } - [[nodiscard]] const auto& getTargetTag() const { return targetTag; } - [[nodiscard]] const auto& getRelationValue() const { return relationValue; } - - private: - void registerKeys(); - - std::string sourceTag; - std::string targetTag; - int relationValue = 0; -}; -} // namespace V3 -#endif // VANILLA_RELATION_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaTruceEntry.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaTruceEntry.cpp deleted file mode 100644 index 6aa4508..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaTruceEntry.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "VanillaTruceEntry.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -V3::VanillaTruceEntry::VanillaTruceEntry(std::istream& theStream, std::string sourceTag): sourceTag(std::move(sourceTag)) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::VanillaTruceEntry::registerKeys() -{ - registerKeyword("country", [this](std::istream& theStream) { - targetTag = commonItems::getString(theStream); - if ((targetTag.starts_with("c:") || targetTag.starts_with("C:")) && targetTag.size() == 5) // very specific about this. - targetTag = targetTag.substr(2, 3); - else - Log(LogLevel::Warning) << "Unrecognized target truce country: " << targetTag << "!"; - }); - registerKeyword("months", [this](std::istream& theStream) { - duration = commonItems::getInt(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaTruceEntry.h b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaTruceEntry.h deleted file mode 100644 index 41f2494..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomacyLoader/VanillaTruceEntry.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef VANILLA_TRUCE_ENTRY_H -#define VANILLA_TRUCE_ENTRY_H -#include "Parser.h" - -namespace V3 -{ -class VanillaTruceEntry: commonItems::parser -{ - public: - VanillaTruceEntry() = default; - explicit VanillaTruceEntry(std::istream& theStream, std::string sourceTag); - - [[nodiscard]] const auto& getSourceTag() const { return sourceTag; } - [[nodiscard]] const auto& getTargetTag() const { return targetTag; } - [[nodiscard]] const auto& getDuration() const { return duration; } - - private: - void registerKeys(); - - std::string sourceTag; - std::string targetTag; - int duration = 0; -}; -} // namespace V3 -#endif // VANILLA_TRUCE_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayEntries.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayEntries.cpp deleted file mode 100644 index c75eb68..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayEntries.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "VanillaDiplomaticPlayEntries.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -V3::VanillaDiplomaticPlayEntries::VanillaDiplomaticPlayEntries(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::VanillaDiplomaticPlayEntries::registerKeys() -{ - registerRegex(R"([c,C]:\w+)", [this](const std::string& sourceTag, std::istream& theStream) { - activeTag = sourceTag.substr(2, sourceTag.size()); - entryParser.parseStream(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); - - entryParser.registerRegex(commonItems::catchallRegex, [this](const std::string& elementName, std::istream& theStream) { - const auto elementValue = commonItems::stringOfItem(theStream); - diploPlayElements[activeTag].emplace_back(elementName + " " + elementValue.getString()); - }); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayEntries.h b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayEntries.h deleted file mode 100644 index 72e1649..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayEntries.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef VANILLA_DIPLOMATIC_PLAY_ENTRIES_H -#define VANILLA_DIPLOMATIC_PLAY_ENTRIES_H -#include "Parser.h" - -namespace V3 -{ -class VanillaDiplomaticPlayEntries: commonItems::parser -{ - public: - VanillaDiplomaticPlayEntries() = default; - explicit VanillaDiplomaticPlayEntries(std::istream& theStream); - - [[nodiscard]] const auto& getDiploPlayElements() const { return diploPlayElements; } - - private: - void registerKeys(); - - parser entryParser; - std::string activeTag; - - std::map> diploPlayElements; // unparsed elements from the file, ready for direct dump. -}; -} // namespace V3 -#endif // VANILLA_DIPLOMATIC_PLAY_ENTRIES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayLoader.cpp deleted file mode 100644 index 7bd8181..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayLoader.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "VanillaDiplomaticPlayLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "VanillaDiplomaticPlayEntries.h" - -void V3::VanillaDiplomaticPlayLoader::loadVanillaDiplomaticPlays(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/history/diplomatic_plays/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::VanillaDiplomaticPlayLoader::registerKeys() -{ - registerKeyword("DIPLOMATIC_PLAYS", [this](std::istream& theStream) { - const auto entries = VanillaDiplomaticPlayEntries(theStream); - // Append. They don't necessarily overwrite eachother. - for (const auto& [tag, elements]: entries.getDiploPlayElements()) - diploPlayElements[tag].insert(diploPlayElements[tag].end(), elements.begin(), elements.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayLoader.h b/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayLoader.h deleted file mode 100644 index 8f69639..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayLoader.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef VANILLA_DIPLOMATIC_PLAY_LOADER_H -#define VANILLA_DIPLOMATIC_PLAY_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class VanillaDiplomaticPlayLoader: commonItems::parser -{ - public: - VanillaDiplomaticPlayLoader() = default; - void loadVanillaDiplomaticPlays(const commonItems::ModFilesystem& modFS); - - [[nodiscard]] const auto& getDiploPlayElements() const { return diploPlayElements; } - - private: - void registerKeys(); - - std::map> diploPlayElements; -}; -} // namespace V3 -#endif // VANILLA_DIPLOMATIC_PLAY_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaPopulationHistoryLoader/VanillaPopulationHistoryLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaPopulationHistoryLoader/VanillaPopulationHistoryLoader.cpp deleted file mode 100644 index 0899924..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaPopulationHistoryLoader/VanillaPopulationHistoryLoader.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "VanillaPopulationHistoryLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryEntries.h" -#include "Log.h" -#include "ParserHelpers.h" - -void V3::VanillaPopulationHistoryLoader::loadVanillaPopulationHistories(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/history/population/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::VanillaPopulationHistoryLoader::registerKeys() -{ - registerKeyword("POPULATION", [this](std::istream& theStream) { - const auto entries = VanillaCountryHistoryEntries(theStream); - // Append. They don't necessarily overwrite eachother. - for (const auto& [tag, elements]: entries.getCountryHistoryElements()) - populationHistoryElements[tag].insert(populationHistoryElements[tag].end(), elements.begin(), elements.end()); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaPopulationHistoryLoader/VanillaPopulationHistoryLoader.h b/EU5ToVic3/Source/V3World/Loaders/VanillaPopulationHistoryLoader/VanillaPopulationHistoryLoader.h deleted file mode 100644 index 9f03f3a..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaPopulationHistoryLoader/VanillaPopulationHistoryLoader.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef VANILLA_POPULATION_HISTORY_LOADER_H -#define VANILLA_POPULATION_HISTORY_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" - -namespace V3 -{ -class VanillaPopulationHistoryLoader: commonItems::parser -{ - public: - VanillaPopulationHistoryLoader() = default; - void loadVanillaPopulationHistories(const commonItems::ModFilesystem& modFS); - - [[nodiscard]] const auto& getPopulationHistoryElements() const { return populationHistoryElements; } - - private: - void registerKeys(); - - std::map> populationHistoryElements; -}; -} // namespace V3 -#endif // VANILLA_POPULATION_HISTORY_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntries.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntries.cpp deleted file mode 100644 index 3e05e5e..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntries.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "VanillaStateEntries.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -V3::VanillaStateEntries::VanillaStateEntries(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::VanillaStateEntries::registerKeys() -{ - registerRegex(R"([s,S]:\w+)", [this](const std::string& theStateName, std::istream& theStream) { - auto state = VanillaStateEntry(theStream); - auto stateName = theStateName.substr(2, theStateName.size()); - stateEntries.emplace(stateName, state); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntries.h b/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntries.h deleted file mode 100644 index dfddaa7..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntries.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef VANILLA_STATE_ENTRIES_H -#define VANILLA_STATE_ENTRIES_H -#include "Parser.h" -#include "VanillaStateEntry.h" - -namespace V3 -{ -class VanillaStateEntries: commonItems::parser -{ - public: - VanillaStateEntries() = default; - explicit VanillaStateEntries(std::istream& theStream); - - [[nodiscard]] const auto& getStates() const { return stateEntries; } - - private: - void registerKeys(); - - std::map stateEntries; -}; -} // namespace V3 -#endif // VANILLA_STATE_ENTRIES_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntry.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntry.cpp deleted file mode 100644 index bc229bb..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntry.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "VanillaStateEntry.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" - -V3::VanillaStateEntry::VanillaStateEntry(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::VanillaStateEntry::registerKeys() -{ - registerKeyword("create_state", [this](std::istream& theStream) { - subStateEntries.emplace_back(VanillaSubStateEntry(theStream)); - }); - registerKeyword("add_homeland", [this](std::istream& theStream) { - auto homelandString = commonItems::getString(theStream); - if (homelandString.starts_with("cu:")) - homelands.emplace(homelandString.substr(3, homelandString.length())); - else - homelands.emplace(homelandString); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntry.h b/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntry.h deleted file mode 100644 index 5af5e5a..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateEntry.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef VANILLA_STATE_ENTRY_H -#define VANILLA_STATE_ENTRY_H -#include "Parser.h" -#include "VanillaSubStateEntry.h" - -namespace V3 -{ -class VanillaStateEntry: commonItems::parser -{ - public: - VanillaStateEntry() = default; - explicit VanillaStateEntry(std::istream& theStream); - - [[nodiscard]] const auto& getHomelands() const { return homelands; } - [[nodiscard]] const auto& getSubStates() const { return subStateEntries; } - - private: - void registerKeys(); - - std::set homelands; - std::vector subStateEntries; -}; -} // namespace V3 -#endif // VANILLA_STATE_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateLoader.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateLoader.cpp deleted file mode 100644 index 62ffb54..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateLoader.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "VanillaStateLoader.h" -#include "CommonFunctions.h" -#include "CommonRegexes.h" -#include "ParserHelpers.h" -#include "VanillaStateEntries.h" - -void V3::VanillaStateLoader::loadVanillaStates(const commonItems::ModFilesystem& modFS) -{ - registerKeys(); - for (const auto& fileName: modFS.GetAllFilesInFolder("/common/history/states/")) - { - if (getExtension(fileName) == "txt") - parseFile(fileName); - } - clearRegisteredKeywords(); -} - -void V3::VanillaStateLoader::registerKeys() -{ - registerKeyword("STATES", [this](std::istream& theStream) { - auto entries = VanillaStateEntries(theStream).getStates(); - entries.merge(stateEntries); // merging backwards to override older entries. - stateEntries.swap(entries); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateLoader.h b/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateLoader.h deleted file mode 100644 index d076998..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaStateLoader.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef VANILLA_STATE_LOADER_H -#define VANILLA_STATE_LOADER_H -#include "ModLoader/ModFilesystem.h" -#include "Parser.h" -#include "VanillaStateEntry.h" - -namespace V3 -{ -class VanillaStateLoader: commonItems::parser -{ - public: - VanillaStateLoader() = default; - void loadVanillaStates(const commonItems::ModFilesystem& modFS); - - [[nodiscard]] const auto& getStates() const { return stateEntries; } - - private: - void registerKeys(); - - std::map stateEntries; -}; -} // namespace V3 -#endif // VANILLA_STATE_LOADER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaSubStateEntry.cpp b/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaSubStateEntry.cpp deleted file mode 100644 index dbe9764..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaSubStateEntry.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "VanillaSubStateEntry.h" -#include "CommonRegexes.h" -#include "Log.h" -#include "ParserHelpers.h" - -V3::VanillaSubStateEntry::VanillaSubStateEntry(std::istream& theStream) -{ - registerKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::VanillaSubStateEntry::registerKeys() -{ - registerKeyword("country", [this](std::istream& theStream) { - ownerTag = commonItems::getString(theStream); - if ((ownerTag.starts_with("c:") || ownerTag.starts_with("C:")) && ownerTag.size() == 5) // very specific about this. - ownerTag = ownerTag.substr(2, 3); - else - Log(LogLevel::Warning) << "Unrecognized substate country for " << ownerTag << "!"; - }); - registerKeyword("state_type", [this](std::istream& theStream) { - subStateTypes.emplace(commonItems::getString(theStream)); - }); - registerKeyword("owned_provinces", [this](std::istream& theStream) { - const auto theProvinces = commonItems::getStrings(theStream); - for (const auto& province: theProvinces) - { - auto theProvinceName = province; - std::transform(theProvinceName.begin(), theProvinceName.end(), theProvinceName.begin(), ::toupper); - if (theProvinceName.starts_with("X") && theProvinceName.size() == 7) - theProvinceName = "x" + theProvinceName.substr(1, theProvinceName.length() - 1); // from "x12345a" to x12345A - else - Log(LogLevel::Warning) << "Loading province " << theProvinceName << " in unknown format!"; - provinces.emplace(theProvinceName); - } - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} diff --git a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaSubStateEntry.h b/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaSubStateEntry.h deleted file mode 100644 index 01e1782..0000000 --- a/EU5ToVic3/Source/V3World/Loaders/VanillaStateLoader/VanillaSubStateEntry.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef VANILLA_SUBSTATE_ENTRY_H -#define VANILLA_SUBSTATE_ENTRY_H -#include "Parser.h" - -namespace V3 -{ -class VanillaSubStateEntry: commonItems::parser -{ - public: - VanillaSubStateEntry() = default; - explicit VanillaSubStateEntry(std::istream& theStream); - - [[nodiscard]] const auto& getOwnerTag() const { return ownerTag; } - [[nodiscard]] const auto& getSubStateTypes() const { return subStateTypes; } - [[nodiscard]] const auto& getProvinces() const { return provinces; } - - private: - void registerKeys(); - - std::string ownerTag; - std::set subStateTypes; - std::set provinces; -}; -} // namespace V3 -#endif // VANILLA_SUBSTATE_ENTRY_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/PoliticalManager/Country/Character.cpp b/EU5ToVic3/Source/V3World/PoliticalManager/Country/Character.cpp deleted file mode 100644 index 63d3db7..0000000 --- a/EU5ToVic3/Source/V3World/PoliticalManager/Country/Character.cpp +++ /dev/null @@ -1,241 +0,0 @@ -#include "Character.h" -#include "CharacterTraitMapper/CharacterTraitMapper.h" -#include "CultureMapper/CultureMapper.h" -#include "OSCompatibilityLayer.h" -#include "ReligionMapper/ReligionMapper.h" -#include -#include - -namespace -{ -std::string normalizeString(const std::string& input) -{ - auto toReturn = commonItems::normalizeUTF8Path(input); - std::ranges::replace(toReturn, ' ', '_'); - std::ranges::replace(toReturn, '\'', '_'); - std::ranges::replace(toReturn, '`', '_'); - std::ranges::replace(toReturn, '(', '_'); - std::ranges::replace(toReturn, ')', '_'); - return toReturn; -} -} // namespace - -V3::Character::Character(const EU4::Character& character, - const mappers::CharacterTraitMapper& characterTraitMapper, - float ageShift, - const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& capitalStateName, - const std::string& tag, - const date& conversionDate) -{ - // name! - convertName(character); - if (firstName.empty()) - { - // We CAN get people without a normalizable name. Mods and whatnot. Not my problem. - if (!character.female) - firstName = "Bob"; - else - firstName = "Bobbina"; - localizations.emplace(firstName, firstName); - if (lastName.empty()) - { - lastName = "BobbyPants"; - localizations.emplace(lastName, lastName); - } - } - - // rulership - convertRulership(character); - - // leadership - convertLeadership(character, characterTraitMapper); - - // dates - convertAge(character, ageShift, conversionDate); - - // traits - convertTraits(character, characterTraitMapper); - - // are we dry and incompetent? - if (isCharacterDryAndIncompetent(character)) - { - const int seed = static_cast(firstName[0]) * 17 + 11; - traits.emplace(characterTraitMapper.getGratisIncompetency(seed)); - } - - // are we a leader that's semi-dry and hypercompetent? - if (isLeaderSemiDryAndHyperCompetent(character)) - { - const int seed = static_cast(firstName[0]) * 14 + 82; - traits.emplace(characterTraitMapper.getGratisVeterancy(seed)); - } - - // are we semi-dry and OLD? - if (isCharacterSemiDryAndOld()) - { - const int seed = static_cast(firstName[0]) * 11 + 51; - traits.emplace(characterTraitMapper.getGratisAgeism(seed)); - } - - // Are we young? - if (age < 15) - traits.emplace("trait_child"); - - // are we *still* dry? - if (traits.empty()) - { - const int seed = static_cast(firstName[0]) * 19 + 31; - if (seed % 3 == 0) - traits.emplace(characterTraitMapper.getGratisDisorder(seed)); - } - - // culture & religion - if (!character.culture.empty()) - { - if (const auto& cultureMatch = - cultureMapper.suspiciousCultureMatch(clayManager, cultureLoader, religionLoader, character.culture, character.religion, capitalStateName, tag); - cultureMatch) - culture = *cultureMatch; - } - if (!character.religion.empty()) - { - if (const auto& religionMatch = religionMapper.getV3Religion(character.religion); religionMatch) - religion = *religionMatch; - } - - // rest is up to country. -} - -void V3::Character::convertName(const EU4::Character& character) -{ - if (character.name.empty()) - { - // this is a leader. It only has a composite name which we would need to .. break at a sane position. Yeah. - // Need to .. uhh.. dammit. - const auto utf8 = commonItems::convertWin1252ToUTF8(character.leaderName); - firstName = normalizeString(utf8); - localizations.emplace(firstName, utf8); - } - else - { - // maybe better name? - std::string utf8; - if (character.ruler && !character.futureMonarchName.empty()) - utf8 = commonItems::convertWin1252ToUTF8(character.futureMonarchName); - else - utf8 = commonItems::convertWin1252ToUTF8(character.name); - firstName = normalizeString(utf8); - localizations.emplace(firstName, utf8); - - if (!character.dynasty.empty()) - { - utf8 = commonItems::convertWin1252ToUTF8(character.dynasty); - lastName = normalizeString(utf8); - localizations.emplace(lastName, utf8); - } - } -} - -void V3::Character::convertRulership(const EU4::Character& character) -{ - if (character.ruler) - ruler = true; - else if (character.heir) - heir = true; - - // eh. rulership. - if (character.female) - female = true; -} - -void V3::Character::convertLeadership(const EU4::Character& character, const mappers::CharacterTraitMapper& characterTraitMapper) -{ - if (!character.leaderType.empty()) - { - if (character.leaderType == "general" || character.leaderType == "conquistador") - general = true; - else if (character.leaderType == "admiral" || character.leaderType == "explorer") - admiral = true; - - // rank - const auto rank = static_cast(std::round(static_cast(character.fire + character.shock + character.fire + character.siege) / 4.8)); - if (rank > 0) - commanderRank = "commander_rank_" + std::to_string(rank); - - if (!character.leaderTrait.empty()) - { - if (const auto& personalityMatch = characterTraitMapper.getPersonality(character.leaderTrait); personalityMatch) - traits.emplace(*personalityMatch); - } - } -} - -void V3::Character::convertAge(const EU4::Character& character, float ageShift, const date& conversionDate) -{ - birthDate = character.birthDate; - age = static_cast(std::round(conversionDate.diffInYears(birthDate))); - - birthDate.ChangeByYears(static_cast(std::round(ageShift))); -} - -void V3::Character::convertTraits(const EU4::Character& character, const mappers::CharacterTraitMapper& characterTraitMapper) -{ - // usually rulers have up to three personality traits. We can't map all of them, so pick just the first. - if (!character.traits.empty()) - { - if (const auto& personalityMatch = characterTraitMapper.getPersonality(*character.traits.begin()); personalityMatch) - traits.emplace(*personalityMatch); - } - - // get some skilltrait. - if (const auto& skillTraits = characterTraitMapper.getSkillTraits(character); !skillTraits.empty()) - traits.insert(skillTraits.begin(), skillTraits.end()); -} - -bool V3::Character::isCharacterDryAndIncompetent(const EU4::Character& character) const -{ - if (!traits.empty()) - return false; - - if (character.ruler || character.heir || character.consort) - { - const auto sum = character.adm + character.dip + character.mil; - if (sum <= 4) - return true; - } - - if (!character.leaderType.empty()) - { - const auto sum = character.fire + character.shock + character.maneuver + character.siege; - if (sum <= 5) - return true; - } - - return false; -} - -bool V3::Character::isLeaderSemiDryAndHyperCompetent(const EU4::Character& character) const -{ - if (traits.size() > 1) - return false; - if (character.leaderType.empty()) - return false; - const auto sum = character.fire + character.shock + character.maneuver + character.siege; - if (sum >= 22) - return true; - return false; -} - -bool V3::Character::isCharacterSemiDryAndOld() const -{ - if (traits.size() > 1) - return false; - if (age > 70) - return true; - return false; -} diff --git a/EU5ToVic3/Source/V3World/PoliticalManager/Country/Character.h b/EU5ToVic3/Source/V3World/PoliticalManager/Country/Character.h deleted file mode 100644 index f9b59ad..0000000 --- a/EU5ToVic3/Source/V3World/PoliticalManager/Country/Character.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef CHARACTER_H -#define CHARACTER_H -#include "CountryManager/CountryLeader/EU4Character.h" -#include "Date.h" -#include "Loaders/LocLoader/LocalizationLoader.h" -#include -#include - -namespace EU4 -{ -class CultureLoader; -class ReligionLoader; -} // namespace EU4 -namespace mappers -{ -class CharacterTraitMapper; -class CultureMapper; -class ReligionMapper; -} // namespace mappers -namespace V3 -{ -class ClayManager; -struct Character -{ - Character() = default; - explicit Character(const EU4::Character& character, - const mappers::CharacterTraitMapper& characterTraitMapper, - float ageShift, - const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const std::string& capitalStateName, - const std::string& tag, - const date& conversionDate); - - void convertName(const EU4::Character& character); - void convertRulership(const EU4::Character& character); - void convertLeadership(const EU4::Character& character, const mappers::CharacterTraitMapper& characterTraitMapper); - void convertAge(const EU4::Character& character, float ageShift, const date& conversionDate); - void convertTraits(const EU4::Character& character, const mappers::CharacterTraitMapper& characterTraitMapper); - [[nodiscard]] bool isCharacterDryAndIncompetent(const EU4::Character& character) const; - [[nodiscard]] bool isLeaderSemiDryAndHyperCompetent(const EU4::Character& character) const; - [[nodiscard]] bool isCharacterSemiDryAndOld() const; - - std::string firstName; // KEY - std::string lastName; // KEY - bool ruler = false; - bool igLeader = false; - bool noble = false; // ?? - bool heir = false; - bool admiral = false; - bool general = false; - std::string hq; // leave dry for now. Or set to capital. - std::string commanderRank; // key! - bool married = false; // set from outside. - bool female = false; - - int age = 0; // if unchanged, won't get exported. - std::string culture; // culture = cu:culture ! - std::string religion; // religion = rel:religion ! - date birthDate; - std::string dnaKey; // unset for now. Can't map this easily. - std::string interestGroup; - std::string ideology; - std::set traits; - std::map localizations; // coming from save, this is all english. Also UTF8ied. -}; -} // namespace V3 - -#endif // CHARACTER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/PoliticalManager/Country/Country.cpp b/EU5ToVic3/Source/V3World/PoliticalManager/Country/Country.cpp deleted file mode 100644 index ba33c8a..0000000 --- a/EU5ToVic3/Source/V3World/PoliticalManager/Country/Country.cpp +++ /dev/null @@ -1,1082 +0,0 @@ -#include "Country.h" -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/SubState.h" -#include "CommonRegexes.h" -#include "CountryManager/EU4Country.h" -#include "CountryTierMapper/CountryTierMapper.h" -#include "CultureMapper/CultureMapper.h" -#include "Loaders/LawLoader/Law.h" -#include "Loaders/LocLoader/LocalizationLoader.h" -#include "Loaders/LocalizationLoader/EU4LocalizationLoader.h" -#include "Log.h" -#include "ParserHelpers.h" -#include "PopulationSetupMapper/PopulationSetupMapper.h" -#include "ReligionMapper/ReligionMapper.h" -#include "TechSetupMapper/TechSetupMapper.h" -#include -#include -#include - -namespace -{ -commonItems::Color generateDecentralizedColors(const std::string& tag) -{ - if (tag.size() < 3) - return commonItems::Color{std::array{15, 86, 112}}; // I just like these numbers. - int r = static_cast(tag[0]) * 17 % 256; // should be random enough. - int g = static_cast(tag[1]) * 43 % 256; - int b = static_cast(tag[2]) * 11 % 256; - if (r < 50) // make them brighter. - r += 50; - if (g < 50) - g += 50; - if (b < 50) - b += 50; - return commonItems::Color{std::array{r, g, b}}; -} -} // namespace - -void V3::Country::initializeCountry(std::istream& theStream) -{ - registerKeys(); - vanillaData = VanillaCommonCountryData(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -void V3::Country::storeVanillaCountryType(std::istream& theStream) -{ - registerVanillaTypeKeys(); - parseStream(theStream); - clearRegisteredKeywords(); -} - -std::vector> V3::Country::topPercentileStatesByPop(const double percentile) const -{ - std::vector> incorporatedStates; - for (const auto& state: subStates) - if (state->isIncorporated()) - incorporatedStates.emplace_back(state); - if (incorporatedStates.empty()) - return incorporatedStates; - - // Ranks this country's substates by population then returns the top x% of them by population, the largest state will always be returned. - auto sortedSubStates = incorporatedStates; - - // descending order - auto popComparison = [](const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return lhs->getSubStatePops().getPopCount() > rhs->getSubStatePops().getPopCount(); - }; - - std::sort(sortedSubStates.begin(), sortedSubStates.end(), popComparison); - - const int numTopSubStates = std::max(static_cast(static_cast(sortedSubStates.size()) * percentile), 1); - - return std::vector>{sortedSubStates.begin(), sortedSubStates.begin() + numTopSubStates}; -} - -double V3::Country::calculateBureaucracyUsage(const std::map& lawsMap) const -{ - // None of the hard-coded Vic3 values needed to calc this are in the defines for some reason. - double usage = 0.0; - - usage += calcSubStateBureaucracy(lawsMap); - usage += calcInstitutionBureaucracy(); - usage += calcCharacterBureaucracy(); - - return usage; -} - -int V3::Country::getTechInfraCap(const std::map& techMap) const -{ - return std::accumulate(processedData.techs.begin(), processedData.techs.end(), 0, [this, techMap](int sum, const std::string& techName) { - if (const auto& tech = getTechFromMap(techName, techMap); tech) - { - return sum + tech.value().infrastructureMax; - } - return sum; - }); -} - -double V3::Country::getTechInfraMult(const std::map& techMap) const -{ - return std::accumulate(processedData.techs.begin(), processedData.techs.end(), 0.0, [this, techMap](double sum, const std::string& techName) { - if (const auto& tech = getTechFromMap(techName, techMap); tech) - { - return sum + tech.value().infrastructureMult; - } - return sum; - }); -} - -int V3::Country::getThroughputMax(const std::map& techMap) const -{ - // 20 is base level Economy of Scale NOT a define. - return 20 + std::accumulate(processedData.techs.begin(), processedData.techs.end(), 0, [this, techMap](int sum, const std::string& techName) { - if (const auto& tech = getTechFromMap(techName, techMap); tech) - { - return sum + tech.value().throughputMax; - } - return sum; - }); -} - -bool V3::Country::hasAnyOfTech(const std::set& techs) const -{ - if (techs.empty()) - { - return true; - } - - return std::ranges::any_of(techs, [&](const std::string& tech) { - return processedData.techs.contains(tech); - }); -} - -int V3::Country::getGovBuildingMax(const std::string& building, const std::map& lawsMap, const std::map& techMap) const -{ - const auto tech = std::accumulate(processedData.techs.begin(), processedData.techs.end(), 0, [building, techMap](const int sum, const std::string& tech) { - if (!techMap.contains(tech)) - { - Log(LogLevel::Error) << "Couldn't find tech definition for: " << tech; - return sum; - } - if (!techMap.at(tech).maxBuildingLevels.contains(building)) - { - return sum; - } - - return sum + techMap.at(tech).maxBuildingLevels.at(building); - }); - - const auto laws = std::accumulate(processedData.laws.begin(), processedData.laws.end(), 0, [building, lawsMap](const int sum, const std::string& law) { - if (!lawsMap.contains(law)) - { - Log(LogLevel::Error) << "Couldn't find law definition for: " << law; - return sum; - } - if (!lawsMap.at(law).maxBuildingLevels.contains(building)) - { - return sum; - } - - return sum + lawsMap.at(law).maxBuildingLevels.at(building); - }); - return tech + laws; -} - -void V3::Country::distributeGovAdmins(const double target, const int PMGeneration, const std::map& techMap) const -{ - const auto topSubstates = topPercentileStatesByPop(0.3); - if (topSubstates.empty()) - return; - const auto topPop = getPopCount(topSubstates); - - // Pass out buildings by pop proportion of this subset of States. Generate production targets and account for throughput bonuses. - double generated = 0; - for (const auto& substate: topSubstates) - { - const double popProportion = static_cast(substate->getSubStatePops().getPopCount()) / topPop; - const double stateTarget = target * popProportion; - - // Calc levels for generation - int levels = static_cast(stateTarget * 100 / 101 / PMGeneration); - double generation = levels * PMGeneration; - if (const int throughputMax = getThroughputMax(techMap); levels > throughputMax) - { - levels = static_cast(stateTarget / (PMGeneration + PMGeneration * (throughputMax / 100.0))); - generation = levels * PMGeneration * (1 + throughputMax / 100.0); - } - - const auto govAdmin = std::make_shared(); - govAdmin->setName("building_government_administration"); - govAdmin->setLevel(levels); - - substate->addBuilding(govAdmin); - - generated += generation; - } - - // Handing out remainders, should be less than # of topSubstates - // Treating throughput bonuses as negligible here - for (const auto& substate: topSubstates) - { - auto isGovAdmin = [](const std::shared_ptr& b) { - return b->getName() == "building_government_administration"; - }; - - if (auto govAdmin = std::ranges::find_if(substate->getBuildings(), isGovAdmin); govAdmin != substate->getBuildings().end()) - { - const auto levels = govAdmin->get()->getLevel(); - govAdmin->get()->setLevel(levels + 1); - generated += PMGeneration; - - if (target <= generated + PMGeneration) - { - break; - } - } - else - { - Log(LogLevel::Error) << "Failed to find building_government_administration in: " << substate->getHomeStateName(); - } - } -} - -void V3::Country::registerKeys() -{ - registerKeyword("dynamic_country_definition", [this](std::istream& theStream) { - dynamicCountry = true; - commonItems::ignoreItem("unused", theStream); - }); - registerKeyword("country_type", [this](std::istream& theStream) { - vanillaData->type = commonItems::getString(theStream); - }); - registerKeyword("tier", [this](std::istream& theStream) { - vanillaData->tier = commonItems::getString(theStream); - }); - registerKeyword("cultures", [this](std::istream& theStream) { - for (const auto& culture: commonItems::getStrings(theStream)) - vanillaData->cultures.emplace(culture); - }); - registerKeyword("religion", [this](std::istream& theStream) { - vanillaData->religion = commonItems::getString(theStream); - }); - registerKeyword("capital", [this](std::istream& theStream) { - vanillaData->capitalStateName = commonItems::getString(theStream); - }); - registerKeyword("color", [this](std::istream& theStream) { - vanillaData->color = commonItems::Color::Factory().getColor(theStream); - }); - registerKeyword("is_named_from_capital", [this](const std::string& unused, std::istream& theStream) { - commonItems::ignoreItem(unused, theStream); - vanillaData->is_named_from_capital = true; - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -void V3::Country::registerVanillaTypeKeys() -{ - registerKeyword("country_type", [this](std::istream& theStream) { - vanillaData->vanillaType = commonItems::getString(theStream); - }); - registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); -} - -bool V3::Country::humanPlayed() const -{ - if (!sourceCountry) - { - return false; - } - return sourceCountry->humanPlayed(); -} - -void V3::Country::convertFromEU4Country(const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const mappers::IdeaEffectsMapper& ideaEffectMapper, - const mappers::CountryTierMapper& countryTierMapper, - const bool downTiers, - const bool vn) -{ - // color - using eu4 colors so people don't lose their shit over red venice and orange england. - if (sourceCountry->getNationalColors().getMapColor()) - { - processedData.color = sourceCountry->getNationalColors().getMapColor(); - } - else - { - if (vanillaData) - processedData.color = vanillaData->color; - } - - // eu4 locs - processedData.name = sourceCountry->getName(); - processedData.namesByLanguage = sourceCountry->getAllNameLocalizations(); - processedData.adjective = sourceCountry->getAdjective(); - processedData.adjectivesByLanguage = sourceCountry->getAllAdjectiveLocalizations(); - - // TODO: UNTESTED - TESTS IF POSSIBLE WHEN CONVERSION DONE - - // Capital - convertCapital(clayManager); - - // Religion - convertReligion(religionMapper); - - // Culture - convertCulture(clayManager, cultureMapper, cultureLoader, religionLoader); - - // tier - convertTier(countryTierMapper, downTiers, vn); - - // country type is determined after westernization is set. - - // namedaftercapital ? Unsure what to do with this. - processedData.is_named_from_capital = false; - - // idea effects. - processedData.ideaEffect = ideaEffectMapper.getEffectForIdeas(sourceCountry->getNationalIdeas()); - - // slavery - we're setting this law right here and now as it's a base for further laws later when we have techs. - if (sourceCountry->hasModifier("the_abolish_slavery_act")) - processedData.laws.emplace("law_slavery_banned"); - - // state atheism - we're setting this law right here and now as it's a base for further laws later when we have techs. - if (sourceCountry->hasModifier("cult_of_reason")) - { - processedData.techs.emplace("rationalism"); - processedData.techs.emplace("academia"); - processedData.techs.emplace("empiricism"); - processedData.laws.emplace("law_state_atheism"); - } - - // (ex-)colonial countries require colonization to continue expanding. - if (sourceCountry->isColony()) - { - processedData.laws.emplace("law_colonial_resettlement"); // exploatation is more for africa, imho. - processedData.techs.emplace("colonization"); - processedData.techs.emplace("international_relations"); - processedData.techs.emplace("tech_bureaucracy"); - processedData.techs.emplace("urbanization"); - } - - // custom flag? - if (sourceCountry->getNationalColors().getCustomColors()) - processedData.customColors = sourceCountry->getNationalColors().getCustomColors(); - if (sourceCountry->isRevolutionary() && sourceCountry->getNationalColors().getRevolutionaryColor()) - processedData.revolutionaryColor = sourceCountry->getNationalColors().getRevolutionaryColor(); -} - -void V3::Country::convertTier(const mappers::CountryTierMapper& countryTierMapper, bool downTiers, const bool vn) -{ - if (downTiers && vanillaData && !vanillaData->tier.empty()) - { - processedData.tier = vanillaData->tier; - return; - } - - auto startingRank = sourceCountry->getGovernmentRank(); - if (downTiers) - { - if (startingRank > 2) - --startingRank; - } - - if (const auto& match = countryTierMapper.matchCountryTier(startingRank, subStates.size(), vn); match) - { - processedData.tier = *match; - } - else - Log(LogLevel::Warning) << "No match for government rank " << sourceCountry->getGovernmentRank() << " (size " << subStates.size() - << ") in country_tiers.txt!"; -} - -void V3::Country::convertCulture(const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader) -{ - // Cultures can be tricky. We may have neocultures generated for our pops, meaning we need to account for being a neoculture country. - // We also can easily have a primary culture with 0 actual pops in our country. - // Again, as for Vic2, we're *ignoring* accepted cultures completely. - - if (sourceCountry->getPrimaryCulture().empty()) - { - Log(LogLevel::Warning) << "EU4 " << sourceCountry->getTag() << " had no primary culture!"; - return; - } - - // Do we have a capital? - if (processedData.capitalStateName.empty()) - { - // We already resurrected dead capitals... Default. - // TODO: Try to figure out where's a majority of cores? Maybe? - const auto& cultureMatch = cultureMapper.cultureMatch(clayManager, - cultureLoader, - religionLoader, - sourceCountry->getPrimaryCulture(), - sourceCountry->getReligion(), - "", - tag, - false, - false); - if (cultureMatch) - processedData.cultures.emplace(*cultureMatch); - else - Log(LogLevel::Warning) << "Could not set primary culture for " << tag << "!"; - return; - } - - // We have a capital. This is good. Is by any chance the capital in some colonial region, where the eu4 primary culture is an invasive species? - // We leave such questions to the cultureMapper. - const auto& cultureMatch = cultureMapper.suspiciousCultureMatch(clayManager, - cultureLoader, - religionLoader, - sourceCountry->getPrimaryCulture(), - sourceCountry->getReligion(), - processedData.capitalStateName, - tag); - if (cultureMatch) - processedData.cultures.emplace(*cultureMatch); - - // if this fails... do nothing for now. - if (processedData.cultures.empty()) - Log(LogLevel::Warning) << "Could not determine culture for country: " << tag; -} - -void V3::Country::convertReligion(const mappers::ReligionMapper& religionMapper) -{ - if (sourceCountry->getReligion().empty()) - { - Log(LogLevel::Warning) << "EU4 " << sourceCountry->getTag() << " had no religion!"; - return; - } - - if (const auto& religionMatch = religionMapper.getV3Religion(sourceCountry->getReligion()); religionMatch) - processedData.religion = *religionMatch; - - // if this fails... do nothing for now. - if (processedData.religion.empty()) - Log(LogLevel::Warning) << "Could not determine religion for country: " << tag; -} - -void V3::Country::convertCapital(const ClayManager& clayManager) -{ - for (const auto& subState: subStates) - if (subState->isCapital()) - { - processedData.capitalStateName = subState->getHomeStateName(); - return; - } - - // If that fails (capitals can get lost in transition, dead countries have no substates...), try anything. - // maybe historical? - if (const auto& historicalMatch = clayManager.getHistoricalCapitalState(sourceCountry->getTag()); historicalMatch) - { - processedData.capitalStateName = *historicalMatch; - return; - } - - // still nothing? - if (processedData.capitalStateName.empty() && !subStates.empty()) - processedData.capitalStateName = subStates[0]->getHomeStateName(); - - // TODO: Try anything harder. At least try to determine the majority of land? - // TODO: After resource calc is called (call it early along with landshares!) use that. -} - -void V3::Country::generateDecentralizedData(const LocalizationLoader& v3LocLoader, const EU4::EU4LocalizationLoader& eu4LocLoader) -{ - // COMMON/COUNTRY DATA - processedData.color = generateDecentralizedColors(tag); - processedData.tier = "principality"; // this appears to be common for decentralized nations. - if (!subStates.empty()) // this really shouldn't be empty. - processedData.capitalStateName = subStates.front()->getHomeStateName(); // any will do. - generateDecentralizedLocs(v3LocLoader, eu4LocLoader); - setDecentralizedEffects(); -} - -void V3::Country::setDecentralizedEffects() -{ - // COMMON/HISTORY/COUNTRY - for now, let's default everything to tier: bottom regardless of geography. - processedData.effects.clear(); - processedData.effects.emplace("effect_starting_technology_tier_7_tech"); // tech - processedData.effects.emplace("effect_starting_politics_traditional"); // politics - processedData.effects.emplace("effect_native_conscription_3"); // conscription - processedData.laws.clear(); - processedData.laws.emplace("law_debt_slavery"); // slavery - processedData.populationEffects.clear(); - processedData.populationEffects.emplace("effect_starting_pop_literacy_baseline"); // no literacy - processedData.populationEffects.emplace("effect_starting_pop_wealth_low"); // no wealth -} - -void V3::Country::generateDecentralizedLocs(const LocalizationLoader& v3LocLoader, const EU4::EU4LocalizationLoader& eu4LocLoader) -{ - // We're basing the name off culture. Trouble is, culture can be either eu4 or vic3. - if (processedData.cultures.empty()) - return; // uh-huh. - - const auto& culture = *processedData.cultures.begin(); - - const auto eu4Locs = eu4LocLoader.getTextForKey(culture, "english"); - const auto v3Locs = v3LocLoader.getLocForKey(culture, "english"); - - if (eu4Locs) - processedData.name = *eu4Locs; - else if (v3Locs) - processedData.name = *v3Locs; - else - processedData.name = culture; - - processedData.adjective = processedData.name; - processedData.name[0] = static_cast(std::toupper(processedData.name[0])); // capitalize first letter. This is why this has to be english. - - // Let's spruce it up. - const std::vector suffixes = {"Territory", - "Expanse", - "Plains", - "Void", - "Dominion", - "Hegemony", - "Tribe", - "Horde", - "Alliance", - "Federation", - "Union", - "Collective", - "Council", - "Nation", - "Imperium"}; - - const auto seed = std::accumulate(culture.begin(), culture.end(), 0, [](int sum, const char& letter) { - return sum + letter; - }); - const int selection = seed % static_cast(suffixes.size()); - processedData.name += " " + suffixes[selection]; -} - -void V3::Country::copyVanillaData(const LocalizationLoader& v3LocLoader, const EU4::EU4LocalizationLoader& eu4LocLoader, bool vn) -{ - // this is done when conversion from eu4 source is impossible - likely because this country doesn't exist in eu4. - if (!vanillaData) - return; - - processedData.color = vanillaData->color; - if (!vanillaData->vanillaType.empty() && vn) // restore *vanilla* vanilla country type. - processedData.type = vanillaData->vanillaType; - else - processedData.type = vanillaData->type; - processedData.tier = vanillaData->tier; - processedData.cultures = vanillaData->cultures; - processedData.religion = vanillaData->religion; - processedData.capitalStateName = vanillaData->capitalStateName; - processedData.is_named_from_capital = vanillaData->is_named_from_capital; - - // By default we're copying DECENTRALIZED nations. This means their effects should be set as if they were decentralized. - if (!vn) - { - setDecentralizedEffects(); - } - else - { - // When VN imports non-decentralized countries, we want entire history, such as it is. - processedData.vanillaHistoryElements = unprocessedData.vanillaHistoryElements; - processedData.vanillaPopulationElements = unprocessedData.vanillaPopulationElements; - processedData.vanillaCharacterElements = unprocessedData.vanillaCharacterElements; - processedData.vanillaDiplomaticPlayElements = unprocessedData.vanillaDiplomaticPlayElements; - } - - // do we have a name waiting for us? - const auto& tagName = v3LocLoader.getLocMapForKey(tag); - const auto& tagAdj = v3LocLoader.getLocMapForKey(tag + "_ADJ"); - if (tagName && tagAdj) - { - processedData.namesByLanguage = *tagName; - processedData.adjectivesByLanguage = *tagAdj; - } - else - { - // check for eu4 locs, in case for modded decentralized inputs. - const auto& eu4Name = eu4LocLoader.getTextInEachLanguage(tag); - const auto& eu4Adj = eu4LocLoader.getTextInEachLanguage(tag + "_ADJ"); - if (eu4Name && eu4Adj) - { - processedData.namesByLanguage = *eu4Name; - processedData.adjectivesByLanguage = *eu4Adj; - } - } -} - -std::string V3::Country::getName(const std::string& language) const -{ - if (processedData.namesByLanguage.contains(language)) - return processedData.namesByLanguage.at(language); - - // if we're lacking a specific language, try with english. - if (processedData.namesByLanguage.contains("english")) - return processedData.namesByLanguage.at("english"); - - // custom name? - if (!processedData.name.empty()) - return processedData.name; - - // otherwise, eh. - return tag; -} - -std::string V3::Country::getAdjective(const std::string& language) const -{ - if (processedData.adjectivesByLanguage.contains(language)) - return processedData.adjectivesByLanguage.at(language); - - // if we're lacking a specific language, try with english. - if (processedData.adjectivesByLanguage.contains("english")) - return processedData.adjectivesByLanguage.at("english"); - - // custom adj? - if (!processedData.adjective.empty()) - return processedData.adjective; - - // wing it. - return tag + "_ADJ"; -} - -double V3::Country::getTotalDev() const -{ - return std::accumulate(subStates.begin(), subStates.end(), 0.0, [](double sum, const auto& substate) { - return sum + substate->getTotalDev(); - }); -} - -double V3::Country::getOverPopulation() const -{ - double pops = 0; - double capacity = 0; - for (const auto& subState: subStates) - { - pops += subState->getSubStatePops().getPopCount(); - capacity += subState->getResource("bg_agriculture"); - } - capacity *= 5000; - if (capacity < 5000) - { - return 10.0; - } - const auto ratio = pops / capacity; - if (ratio < 1.0) - { - return 1.0; - } - return ratio; -} - -void V3::Country::determineWesternizationWealthAndLiteracy(double topTech, - double topInstitutions, - const mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - Configuration::EUROCENTRISM eurocentrism, - Configuration::STARTDATE startDate, - const DatingData& datingData, - const mappers::PopulationSetupMapper& populationSetupMapper) -{ - if (!sourceCountry) - return; // don't do non-imports. - - calculateBaseLiteracy(religionMapper); - calculateWesternization(topTech, topInstitutions, cultureMapper, eurocentrism); - if (startDate != Configuration::STARTDATE::Vanilla) - adjustLiteracy(datingData, cultureMapper, eurocentrism); - applyLiteracyAndWealthEffects(populationSetupMapper); - determineCountryType(); -} - -void V3::Country::determineCountryType() -{ - if (!processedData.westernized) - { - // 20 is the cutoff so american natives that heavily invest into tech - // end up with more than 20 civLevel score and remain unrecognized. - if (processedData.civLevel <= 20) - { - processedData.type = "decentralized"; - setDecentralizedEffects(); - } - else - processedData.type = "unrecognized"; - } - else - { - // civilized/westernized nations can either be recognized or colonial. - if (sourceCountry->isColony()) - processedData.type = "colonial"; - else - processedData.type = "recognized"; - } -} - -[[nodiscard]] double V3::Country::calcSubStateBureaucracy(const std::map& lawsMap) const -{ - double lawsMult = 0; - for (const auto& law: processedData.laws) - { - if (!lawsMap.contains(law)) - { - Log(LogLevel::Warning) << "Finding bureaucracy multiplier of law: " << law << " that has no definition! Skipping."; - continue; - } - - lawsMult += lawsMap.at(law).bureaucracyCostMult; - } - lawsMult = std::max(lawsMult + 1.0, 0.0); - - - double usage = 0; - for (const auto& subState: subStates) - { - if (!subState->isIncorporated()) - { - continue; - } - // Incorporated States - 10 per incorporated state - usage += 10; - - // Pops - only pops in incorporated states count - // Modified by laws - game caps this at 0 - usage += subState->getSubStatePops().getPopCount() / 25000.0 * lawsMult; - } - return usage; -} - -double V3::Country::calcInstitutionBureaucracy() const -{ - double usage = 0; - const double cost = getIncorporatedPopCount() / 100000.0; - for (const auto& level: processedData.institutions | std::views::values) - { - usage += cost * level; // If we end up mapping institution levels, it is cost * levels - } - return usage; -} - -double V3::Country::calcCharacterBureaucracy() const -{ - double usage = 0; - - for (const auto& character: processedData.characters) - { - if (!character.admiral && !character.general) - continue; - - // Defaulted commanders & rulers - if (character.commanderRank.empty() || character.commanderRank.find("ruler") != std::string::npos) - { - usage += 10; - continue; - } - - // Commanders with ranks 1->5 - try - { - const int rank = std::stoi(character.commanderRank.substr(character.commanderRank.length() - 1)); - usage += 5 * (rank + 1); - } - catch (std::exception& e) - { - Log(LogLevel::Error) << "Broken military leader rank: " << character.commanderRank << " - " << e.what(); - } - } - - return usage; -} - -std::optional V3::Country::getTechFromMap(const std::string& techName, const std::map& techMap) const -{ - if (!techMap.contains(techName)) - { - Log(LogLevel::Error) << tag << "'s technology: " << techName << ", is not a recognized technology."; - return std::nullopt; - } - return techMap.at(techName); -} - -void V3::Country::applyLiteracyAndWealthEffects(const mappers::PopulationSetupMapper& populationSetupMapper) -{ - auto literacyEffect = populationSetupMapper.getLiteracyEffectForLiteracy(processedData.literacy); - if (literacyEffect.empty()) - Log(LogLevel::Warning) << "Literacy effect for " << tag << " is empty! Something's wrong!"; - else - processedData.populationEffects.emplace(literacyEffect); - - const auto& averageDev = sourceCountry->getAverageDevelopment(); - auto wealthEffect = populationSetupMapper.getWealthEffectForDev(averageDev); - if (wealthEffect.empty()) - Log(LogLevel::Warning) << "Wealth effect for " << tag << " is empty! Something's wrong!"; - else - processedData.populationEffects.emplace(wealthEffect); -} - -void V3::Country::adjustLiteracy(const DatingData& datingData, const mappers::CultureMapper& cultureMapper, const Configuration::EUROCENTRISM eurocentrism) -{ - auto lastDate = datingData.lastEU4Date; - if (lastDate > datingData.hardEndingDate) - lastDate = datingData.hardEndingDate; - - processedData.literacy *= yearCapFactor(lastDate); - - // Apply cultural mod. - if (eurocentrism == Configuration::EUROCENTRISM::EuroCentric) - processedData.literacy *= 1 + (static_cast(cultureMapper.getLiteracyScoreForCulture(*processedData.cultures.begin())) - 5.0) * 10.0 / 100.0; - - // Reduce the literacy for non-westernized nations according to their civLevel score. - // -> Hardcoded exception to non-westernized literacy reduction for shinto countries so japan-likes may retain high industrialization potential. - if (sourceCountry->getReligion() != "shinto") - processedData.literacy *= pow(10, processedData.civLevel / 100 * 0.9 + 0.1) / 10; -} - -double V3::Country::yearCapFactor(const date& targetDate) -{ - /* - Drop nominal literacy or industry according to starting date. The curve is crafted to hit the following literacy percentage points: - 1836: 1 - 1821: 0.85 - 1750: 0.5 - 1650: 0.3 - 1490: 0.2 - 1350: 0.15 - It will fail to hit those points exactly but won't err by much. - */ - const auto currentYear = std::fmax(targetDate.diffInYears(date("0.1.1")), 0); - const auto yearFactor = (0.1 + 4'614'700 * currentYear) / (1 + static_cast(103'810'000.0f) * currentYear - 54'029 * pow(currentYear, 2)); - return yearFactor; -} - -void V3::Country::calculateWesternization(double topTech, - double topInstitutions, - const mappers::CultureMapper& cultureMapper, - Configuration::EUROCENTRISM eurocentrism) -{ - // This is base calc, from EU4. Even western countries in severe tech deficit will have a lower civLevel score. - const auto totalTechs = sourceCountry->getMilTech() + sourceCountry->getAdmTech() + sourceCountry->getDipTech() + processedData.ideaEffect.getTechMod(); - // default cutoff point for civilization is ... 6! techs/ideas behind (total). (31 - 6) * 4 = 100 which is civilized, assuming no institution deficit. - processedData.civLevel = (totalTechs + 31.0 - topTech) * 4; - processedData.civLevel += (static_cast(sourceCountry->getNumEmbracedInstitutions()) - topInstitutions) * 8; - - // If we're eurocentric, we're *ignoring* tech deficits and artificially deflating whatever score was achieved earlier for non-western countries. - if (eurocentrism == Configuration::EUROCENTRISM::EuroCentric) - { - if (processedData.cultures.empty()) - Log(LogLevel::Warning) << "Trying to determine westernization of " << tag << " with no cultures!"; - else - { - const auto eurociv = cultureMapper.getWesternizationScoreForCulture(*processedData.cultures.begin()); - if (eurociv == 10) - { - processedData.civLevel = 100; - } - else - { - // Try to preserve eu4 centralized countries that suffer from *shit* tech. - if (processedData.civLevel >= 20) - processedData.civLevel = std::min(processedData.civLevel, eurociv * 10.0); - else - processedData.civLevel = std::max(processedData.civLevel, eurociv * 10.0); - } - processedData.industryFactor = cultureMapper.getIndustryScoreForCulture(*processedData.cultures.begin()) / 5.0; // ranges 0.0-2.0 - } - } - - if (processedData.civLevel < 0) - { - processedData.civLevel = 0; - } - if (processedData.civLevel >= 100) - { - processedData.civLevel = 100; - processedData.westernized = true; - } -} - -void V3::Country::calculateBaseLiteracy(const mappers::ReligionMapper& religionMapper) -{ - auto literacy = 0.4; - - if (religionMapper.getV3ReligionDefinitions().contains(processedData.religion)) - { - const auto& religion = religionMapper.getV3ReligionDefinitions().at(processedData.religion); - const auto& traits = religion.traits; - if (religion.name == "protestant" || traits.contains("eastern")) - literacy += 0.1; - } - - if (sourceCountry->hasModifier("sunday_schools")) - literacy += 0.05; - if (sourceCountry->hasModifier("the_education_act")) - literacy += 0.05; - if (sourceCountry->hasModifier("monastic_education_system")) - literacy += 0.05; - if (sourceCountry->hasModifier("western_embassy_mission")) - literacy += 0.05; - - // Universities grant at most 10% literacy, with either having 10 or when having them in 10% of provinces, whichever comes sooner. - - const auto& provinces = sourceCountry->getProvinces(); - const auto numProvinces = provinces.size(); - auto numUniversities = 0; - - for (const auto& province: provinces | std::views::values) - if (province->hasBuilding("university")) - numUniversities++; - - double universityBonus1 = 0; - if (numProvinces > 0) - { - universityBonus1 = static_cast(numUniversities) / static_cast(numProvinces); - } - const auto universityBonus2 = numUniversities * 0.01; - - const auto universityBonus = std::min(std::max(universityBonus1, universityBonus2), 0.1); - - literacy += universityBonus; - - // Adding whatever literacy bonus or malus we have from eu4 ideas. - processedData.literacy = literacy + static_cast(processedData.ideaEffect.literacy) / 100.0; -} - -void V3::Country::setTechs(const mappers::TechSetupMapper& techSetupMapper, double productionScore, double militaryScore, double societyScore) -{ - auto productionTechs = techSetupMapper.getTechsForScoreTrack("production", productionScore); - auto militaryTechs = techSetupMapper.getTechsForScoreTrack("military", militaryScore); - auto societyTechs = techSetupMapper.getTechsForScoreTrack("society", societyScore); - - processedData.techs.insert(productionTechs.begin(), productionTechs.end()); - processedData.techs.insert(militaryTechs.begin(), militaryTechs.end()); - processedData.techs.insert(societyTechs.begin(), societyTechs.end()); -} - -V3::Relation& V3::Country::getRelation(const std::string& target) -{ - const auto& relation = processedData.relations.find(target); - if (relation != processedData.relations.end()) - return relation->second; - Relation newRelation(target); - processedData.relations.emplace(target, newRelation); - const auto& newRelRef = processedData.relations.find(target); - return newRelRef->second; -} - -void V3::Country::convertCharacters(const mappers::CharacterTraitMapper& characterTraitMapper, - const float ageShift, - const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const date& conversionDate) -{ - bool ruler = false; - bool consort = false; - // check for married status. - for (const auto& eu4Character: sourceCountry->getCharacters()) - if (eu4Character.ruler) - ruler = true; - else if (eu4Character.consort) - consort = true; - - for (const auto& eu4Character: sourceCountry->getCharacters()) - { - if (eu4Character.name.empty() && eu4Character.leaderName.empty()) - continue; // start-date regencies and similar - auto character = Character(eu4Character, - characterTraitMapper, - ageShift, - clayManager, - cultureMapper, - religionMapper, - cultureLoader, - religionLoader, - processedData.capitalStateName, - tag, - conversionDate); - if (character.ruler && ruler) - { - if (consort) - { - character.married = true; - } - if (!processedData.ideaEffect.rulingInterestGroups.empty()) - { - character.interestGroup = *processedData.ideaEffect.rulingInterestGroups.begin(); - } - } - - processedData.characters.emplace_back(character); - } -} - -int V3::Country::getPopCount() const -{ - return getPopCount(subStates); -} - -int V3::Country::getIncorporatedPopCount() const -{ - std::vector> incorporatedSubStates; - for (const auto& subState: subStates) - if (subState->isIncorporated()) - incorporatedSubStates.emplace_back(subState); - return getPopCount(incorporatedSubStates); -} - -int V3::Country::getPopCount(const std::vector>& theSubStates) -{ - return std::accumulate(theSubStates.begin(), theSubStates.end(), 0, [](int sum, const auto& substate) { - return sum + substate->getSubStatePops().getPopCount(); - }); -} - -int V3::Country::getVanillaPopCount() const -{ - return std::accumulate(subStates.begin(), subStates.end(), 0, [](int sum, const auto& substate) { - return sum + substate->getVanillaPopCount(); - }); -} - -void V3::Country::leaveIsolationism() -{ - if (processedData.laws.contains("law_isolationism")) - { - processedData.laws.erase("law_isolationism"); - processedData.laws.emplace("law_mercantilism"); - processedData.techs.emplace("international_trade"); - processedData.techs.emplace("tech_bureaucracy"); - processedData.techs.emplace("urbanization"); - } -} - -bool V3::Country::isCultureDiscriminated(const std::string& culture, const mappers::CultureMapper& cultureMapper) const -{ - if (processedData.cultures.contains(culture)) - return false; - - if (processedData.discriminationLevel == ProcessedData::DISCRIMINATION_LEVEL::National_Supremacy) - { - for (const auto& primaryCulture: processedData.cultures) - { - if (cultureMapper.doCulturesShareHeritageTrait(primaryCulture, culture) && *cultureMapper.doCulturesShareHeritageTrait(primaryCulture, culture) && - cultureMapper.doCulturesShareNonHeritageTrait(primaryCulture, culture) && *cultureMapper.doCulturesShareNonHeritageTrait(primaryCulture, culture)) - return false; - } - } - - if (processedData.discriminationLevel == ProcessedData::DISCRIMINATION_LEVEL::Racial_Segregation) - { - for (const auto& primaryCulture: processedData.cultures) - { - if (cultureMapper.doCulturesShareHeritageTrait(primaryCulture, culture) && *cultureMapper.doCulturesShareHeritageTrait(primaryCulture, culture)) - return false; - } - } - - if (processedData.discriminationLevel == ProcessedData::DISCRIMINATION_LEVEL::Cultural_Exclusion) - { - for (const auto& primaryCulture: processedData.cultures) - { - if (cultureMapper.doCulturesShareHeritageTrait(primaryCulture, culture) && *cultureMapper.doCulturesShareHeritageTrait(primaryCulture, culture) || - cultureMapper.doCulturesShareNonHeritageTrait(primaryCulture, culture) && *cultureMapper.doCulturesShareNonHeritageTrait(primaryCulture, culture)) - { - return false; - } - } - } - - if (processedData.discriminationLevel == ProcessedData::DISCRIMINATION_LEVEL::Multicultural) - { - return false; - } - - return true; -} diff --git a/EU5ToVic3/Source/V3World/PoliticalManager/Country/Country.h b/EU5ToVic3/Source/V3World/PoliticalManager/Country/Country.h deleted file mode 100644 index 2639dc9..0000000 --- a/EU5ToVic3/Source/V3World/PoliticalManager/Country/Country.h +++ /dev/null @@ -1,279 +0,0 @@ -#ifndef V3_COUNTRY_H -#define V3_COUNTRY_H -#include "Character.h" -#include "Color.h" -#include "Configuration.h" -#include "CountryManager/NationalSymbol/EU4CustomColors.h" -#include "DatingData.h" -#include "EconomyManager/NationalBudget/Sector.h" -#include "FlagCrafter/FlagCrafter.h" -#include "IGIdeologiesMapper/IGIdeologiesMapping.h" -#include "IdeaEffectsMapper/IdeaEffectsMapper.h" -#include "Loaders/TechLoader/Tech.h" -#include "Parser.h" -#include "PoliticalManager/Diplomacy/Relation.h" -#include -#include - -namespace EU4 -{ -class Country; -class EU4LocalizationLoader; -class CultureLoader; -class ReligionLoader; -} // namespace EU4 -namespace mappers -{ -class ReligionMapper; -class CultureMapper; -class PopulationSetupMapper; -class TechSetupMapper; -class CharacterTraitMapper; -class CountryTierMapper; -} // namespace mappers -namespace V3 -{ -class ClayManager; -class LocalizationLoader; -class SubState; -struct Law; -struct VanillaCommonCountryData -{ - std::string type; - std::string vanillaType; - std::string tier; - std::set cultures; - std::string religion; - std::string capitalStateName; - std::optional color; - bool is_named_from_capital = false; -}; - -struct UnprocessedData -{ - std::vector vanillaHistoryElements; - std::vector vanillaPopulationElements; - std::vector vanillaCharacterElements; - std::vector vanillaDiplomaticPlayElements; -}; - -struct ProcessedData -{ - enum class DISCRIMINATION_LEVEL - { - Ethnostate = 1, - National_Supremacy = 2, - Racial_Segregation = 3, - Cultural_Exclusion = 4, - Multicultural = 5, - Unknown = 6 - }; - - std::string type; - std::string tier; - std::set cultures; - std::string religion; - std::string capitalStateName; - std::optional color; - bool is_named_from_capital = false; - std::set effects; - std::set populationEffects; - std::set laws; - std::map institutions; - double literacy = 0; - double civLevel = 0; - bool westernized = false; - double industryFactor = 1.0; // Modifier changed if EuroCentrism enabled - mappers::IdeaEffect ideaEffect; - std::map igIdeologyModifiers; - std::set techs; - std::map relations; - std::string overlordTag; - std::set rivals; - std::map truces; - std::vector characters; - std::vector vanillaHistoryElements; // stanzas from vanilla country histories, ready for direct dump. - std::vector vanillaPopulationElements; // stanzas from vanilla population histories, ready for direct dump. - std::vector vanillaCharacterElements; // stanzas from vanilla character histories, ready for direct dump. - std::vector vanillaDiplomaticPlayElements; // stanzas from vanilla diplomatic play histories, ready for direct dump. - - double industryWeight = 0; // share of global industry a country should get, not normalized - int CPBudget = 0; // Construction Points for a country to spend on it's development - std::map> industrySectors; - double productionTechPercentile = 0; - double perCapitaDev = 0; - - std::string name; - std::string adjective; - std::map namesByLanguage; // language, name - std::map adjectivesByLanguage; // language, adj - - std::map flags; - std::optional customColors; // used for flag generation for custom flag. - std::optional revolutionaryColor; // used for flag generation for revolutionary flag. - std::map customFlags; // stuff we crafted ourselves. - - std::map admStrategies; - std::map dipStrategies; - std::map polStrategies; - std::map targetSecretGoals; - - DISCRIMINATION_LEVEL discriminationLevel = DISCRIMINATION_LEVEL::Unknown; -}; - -class Country: commonItems::parser -{ - public: - Country() = default; - void initializeCountry(std::istream& theStream); - void storeVanillaCountryType(std::istream& theStream); - void setTag(const std::string& theTag) { tag = theTag; } - void setIndustryWeight(const double theIndustryWeight) { processedData.industryWeight = theIndustryWeight; } - void setCPBudget(const int theBudget) { processedData.CPBudget = theBudget; } - void setSourceCountry(const std::shared_ptr& theCountry) { sourceCountry = theCountry; } - void setReligion(const std::string& religion) { processedData.religion = religion; } - void setProductionTechPercentile(const double productionScore) { processedData.productionTechPercentile = productionScore; } - void setPerCapitaDev(const double pDev) { processedData.perCapitaDev = pDev; } - - void convertFromEU4Country(const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const mappers::IdeaEffectsMapper& ideaEffectMapper, - const mappers::CountryTierMapper& countryTierMapper, - bool downTiers, - bool vn = false); - void copyVanillaData(const LocalizationLoader& v3LocLoader, const EU4::EU4LocalizationLoader& eu4LocLoader, bool vn = false); - void generateDecentralizedData(const LocalizationLoader& v3LocLoader, const EU4::EU4LocalizationLoader& eu4LocLoader); - - [[nodiscard]] const auto& getTag() const { return tag; } - [[nodiscard]] const auto& getVanillaData() const { return vanillaData; } - [[nodiscard]] const auto& getProcessedData() const { return processedData; } - [[nodiscard]] const auto& getIndustryFactor() const { return processedData.industryFactor; } - [[nodiscard]] const auto& getIndustryWeight() const { return processedData.industryWeight; } - [[nodiscard]] const auto& getCPBudget() const { return processedData.CPBudget; } - [[nodiscard]] const auto& getSourceCountry() const { return sourceCountry; } - [[nodiscard]] const auto& getSubStates() const { return subStates; } - [[nodiscard]] const auto& getUnownedCoreSubStates() const { return unownedCoreSubStates; } - [[nodiscard]] const auto& getUnownedProvinces() const { return unownedProvinces; } - void addSubState(const std::shared_ptr& theSubState) { subStates.push_back(theSubState); } - void addUnownedCoreSubState(const std::shared_ptr& theSubState) { unownedCoreSubStates.push_back(theSubState); } - void addUnownedProvinces(const std::set& theProvinces) { unownedProvinces.insert(theProvinces.begin(), theProvinces.end()); } - void setSubStates(const std::vector>& theSubStates) { subStates = theSubStates; } - void setProcessedData(const ProcessedData& data) { processedData = data; } - void setIGIdeologyModifiers(const std::map& modifiers) { processedData.igIdeologyModifiers = modifiers; } - - [[nodiscard]] std::string getName(const std::string& language) const; - [[nodiscard]] std::string getAdjective(const std::string& language) const; - [[nodiscard]] double getTotalDev() const; - [[nodiscard]] double getOverPopulation() const; - [[nodiscard]] int getPopCount() const; - [[nodiscard]] int getVanillaPopCount() const; // vanilla pop count of all the provinces this country holds - [[nodiscard]] int getIncorporatedPopCount() const; - [[nodiscard]] static int getPopCount(const std::vector>& theSubStates); - - void determineWesternizationWealthAndLiteracy(double topTech, - double topInstitutions, - const mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - Configuration::EUROCENTRISM eurocentrism, - Configuration::STARTDATE startDate, - const DatingData& datingData, - const mappers::PopulationSetupMapper& populationSetupMapper); - void setTechs(const mappers::TechSetupMapper& techSetupMapper, double productionScore, double militaryScore, double societyScore); - void addTech(const std::string& tech) { processedData.techs.emplace(tech); } - void addLaw(const auto& lawName) { processedData.laws.emplace(lawName); } - bool hasLaw(const auto& lawName) const { return processedData.laws.contains(lawName); }; - bool humanPlayed() const; - void addInstitution(const auto& institutionName, const int level = 1) { processedData.institutions.emplace(institutionName, level); } - [[nodiscard]] Relation& getRelation(const std::string& target); - [[nodiscard]] const auto& getRelations() const { return processedData.relations; } - void setRivals(const std::set& theRivals) { processedData.rivals = theRivals; } - [[nodiscard]] const auto& getRivals() const { return processedData.rivals; } - void addTruce(const std::string& target, int months) { processedData.truces.emplace(target, months); } - [[nodiscard]] const auto& getTruces() const { return processedData.truces; } - void setVanillaHistoryElements(const std::vector& elements) { unprocessedData.vanillaHistoryElements = elements; } - void setVanillaPopulationElements(const std::vector& elements) { unprocessedData.vanillaPopulationElements = elements; } - void setVanillaCharacterElements(const std::vector& elements) { unprocessedData.vanillaCharacterElements = elements; } - void setVanillaDiplomaticPlayElements(const std::vector& elements) { unprocessedData.vanillaDiplomaticPlayElements = elements; } - - void convertCharacters(const mappers::CharacterTraitMapper& characterTraitMapper, - float ageShift, - const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const date& conversionDate); - - void setFlags(const std::map& flags) { processedData.flags = flags; } - void addFlag(const FlagCrafter::FLAGTYPE flagType, const std::string& flag) { processedData.flags.emplace(flagType, flag); } - [[nodiscard]] const auto& getFlags() const { return processedData.flags; } - void addCustomFlag(FlagCrafter::FLAGTYPE flagType, const std::string& flagName) { processedData.customFlags.emplace(flagType, flagName); } - [[nodiscard]] const auto& getCustomFlags() const { return processedData.customFlags; } - - [[nodiscard]] static double yearCapFactor(const date& targetDate); - [[nodiscard]] int getTechInfraCap(const std::map& techMap) const; - [[nodiscard]] double getTechInfraMult(const std::map& techMap) const; - [[nodiscard]] int getThroughputMax(const std::map& techMap) const; - [[nodiscard]] bool hasAnyOfTech(const std::set& techs) const; - [[nodiscard]] int getGovBuildingMax(const std::string& building, - const std::map& lawsMap, - const std::map& techMap) const; - - void distributeGovAdmins(double target, int PMGeneration, const std::map& techMap) const; - [[nodiscard]] std::vector> topPercentileStatesByPop(double percentile) const; - [[nodiscard]] double calculateBureaucracyUsage(const std::map& lawsMap) const; - void addSector(const std::string& sectorName, const std::shared_ptr& sector) { processedData.industrySectors.emplace(sectorName, sector); } - - void leaveIsolationism(); - - void setAdmStrategies(const std::map& strategies) { processedData.admStrategies = strategies; } - void setDipStrategies(const std::map& strategies) { processedData.dipStrategies = strategies; } - void setPolStrategies(const std::map& strategies) { processedData.polStrategies = strategies; } - - void setOverlord(const std::string& overlordTag) { processedData.overlordTag = overlordTag; } - void addGoal(const std::string& target, const std::string& goal) { processedData.targetSecretGoals.emplace(target, goal); } - - void setDiscriminationLevel(const ProcessedData::DISCRIMINATION_LEVEL& discrimination) { processedData.discriminationLevel = discrimination; } - [[nodiscard]] bool isCultureDiscriminated(const std::string& culture, const mappers::CultureMapper& cultureMapper) const; - [[nodiscard]] bool isCountryDynamic() const { return dynamicCountry; } - - private: - void registerKeys(); - void registerVanillaTypeKeys(); - - void convertCapital(const ClayManager& clayManager); - void convertReligion(const mappers::ReligionMapper& religionMapper); - void convertCulture(const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader); - void convertTier(const mappers::CountryTierMapper& countryTierMapper, bool downTiers, bool vn); - void generateDecentralizedLocs(const LocalizationLoader& v3LocLoader, const EU4::EU4LocalizationLoader& eu4LocLoader); - void calculateBaseLiteracy(const mappers::ReligionMapper& religionMapper); - void calculateWesternization(double topTech, double topInstitutions, const mappers::CultureMapper& cultureMapper, Configuration::EUROCENTRISM eurocentrism); - void adjustLiteracy(const DatingData& datingData, const mappers::CultureMapper& cultureMapper, Configuration::EUROCENTRISM eurocentrism); - void applyLiteracyAndWealthEffects(const mappers::PopulationSetupMapper& populationSetupMapper); - void setDecentralizedEffects(); - void determineCountryType(); - [[nodiscard]] double calcSubStateBureaucracy(const std::map& lawsMap) const; - [[nodiscard]] double calcInstitutionBureaucracy() const; - [[nodiscard]] double calcCharacterBureaucracy() const; - [[nodiscard]] std::optional getTechFromMap(const std::string& techName, const std::map& techMap) const; - - std::string tag; - std::optional vanillaData; - ProcessedData processedData; - UnprocessedData unprocessedData; - bool dynamicCountry = false; - - std::shared_ptr sourceCountry; - std::vector> subStates; - std::vector> unownedCoreSubStates; // substates this country has eu4 cores on but does *not* own. - std::set unownedProvinces; // Derived provinces we want released. Doesn't necessarily match unownedCoreSubStates! We tweak for borders! -}; -} // namespace V3 - -#endif // V3_COUNTRY_H diff --git a/EU5ToVic3/Source/V3World/PoliticalManager/Diplomacy/Agreement.h b/EU5ToVic3/Source/V3World/PoliticalManager/Diplomacy/Agreement.h deleted file mode 100644 index cc12664..0000000 --- a/EU5ToVic3/Source/V3World/PoliticalManager/Diplomacy/Agreement.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef AGREEMENT_H -#define AGREEMENT_H -#include "Date.h" - -namespace V3 -{ -struct Agreement -{ - Agreement() = default; - explicit Agreement(std::string _first, std::string _second, std::string _type, const date& _start_date): - type(std::move(_type)), first(std::move(_first)), second(std::move(_second)), start_date(_start_date) - { - } - std::string type; - std::string first; - std::string second; - date start_date; - int duration = 0; -}; -} // namespace V3 - -#endif // AGREEMENT_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/PoliticalManager/Diplomacy/Relation.h b/EU5ToVic3/Source/V3World/PoliticalManager/Diplomacy/Relation.h deleted file mode 100644 index 5b13e9f..0000000 --- a/EU5ToVic3/Source/V3World/PoliticalManager/Diplomacy/Relation.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef RELATION_H -#define RELATION_H -#include "CountryManager/CountryRelations/EU4Relations.h" - -namespace V3 -{ -class Relation -{ - public: - Relation(std::string _target): target(std::move(_target)) {} - Relation(std::string _target, const EU4::EU4RelationDetails& oldRelations): target(std::move(_target)), relations(oldRelations.getRelations()) {} - - void setLevel(int lvl); - void setRelations(int value) { relations = value; } - void increaseRelations(int value) { relations += value; } - - [[nodiscard]] const auto& getTarget() const { return target; } - [[nodiscard]] auto getRelations() const { return relations; } - - private: - std::string target; - int relations = 0; -}; -} // namespace V3 - -#endif // RELATIONS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/PoliticalManager/PoliticalManager.cpp b/EU5ToVic3/Source/V3World/PoliticalManager/PoliticalManager.cpp deleted file mode 100644 index 31d4d02..0000000 --- a/EU5ToVic3/Source/V3World/PoliticalManager/PoliticalManager.cpp +++ /dev/null @@ -1,1281 +0,0 @@ -#include "PoliticalManager.h" -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/Province.h" -#include "ClayManager/State/State.h" -#include "ClayManager/State/SubState.h" -#include "ColonialRegionMapper/ColonialRegionMapper.h" -#include "Country/Country.h" -#include "CountryManager/EU4Country.h" -#include "CultureMapper/CultureMapper.h" -#include "DiplomacyParser/EU4Agreement.h" -#include "Loaders/CountryDefinitionLoader/CountryDefinitionLoader.h" -#include "Loaders/LawLoader/LawLoader.h" -#include "Log.h" -#include "Mappers/CountryMapper/CountryMapper.h" -#include "PopManager/PopManager.h" -#include "TechValues/TechValues.h" -#include -#include -#include - -namespace -{ -std::vector sortMap(const std::map& theMap) -{ - std::vector sorted; - - std::vector> pairs; - for (const auto& theElement: theMap) - pairs.emplace_back(theElement); - - std::sort(pairs.begin(), pairs.end(), [=](const std::pair& a, const std::pair& b) { - return a.second > b.second; - }); - - for (const auto& tag: pairs | std::views::keys) - sorted.emplace_back(tag); - - return sorted; -} -} // namespace - - -void V3::PoliticalManager::initializeVanillaCountries(const commonItems::ModFilesystem& modFS, const commonItems::ModFilesystem& vanillaFS) -{ - Log(LogLevel::Info) << "-> Loading Vanilla Countries."; - CountryDefinitionLoader definitionLoader; - definitionLoader.loadCommonCountries(modFS); - definitionLoader.reloadCommonCountries(vanillaFS); - countries = definitionLoader.getCountries(); - Log(LogLevel::Info) << "<> " << countries.size() << " vanilla countries loaded."; - - Log(LogLevel::Info) << "-> Loading Vanilla Country Histories."; - vanillaCountryHistoryLoader.loadVanillaCountryHistories(modFS); - for (const auto& [tag, historyElements]: vanillaCountryHistoryLoader.getCountryHistoryElements()) - if (countries.contains(tag)) - countries.at(tag)->setVanillaHistoryElements(historyElements); - Log(LogLevel::Info) << "<> " << vanillaCountryHistoryLoader.getCountryHistoryElements().size() << " vanilla country histories loaded."; - - Log(LogLevel::Info) << "-> Loading Vanilla Population Histories."; - vanillaPopulationHistoryLoader.loadVanillaPopulationHistories(modFS); - for (const auto& [tag, historyElements]: vanillaPopulationHistoryLoader.getPopulationHistoryElements()) - if (countries.contains(tag)) - countries.at(tag)->setVanillaPopulationElements(historyElements); - Log(LogLevel::Info) << "<> " << vanillaCountryHistoryLoader.getCountryHistoryElements().size() << " vanilla country histories loaded."; - - Log(LogLevel::Info) << "-> Loading Vanilla Characters."; - vanillaCharacterLoader.loadVanillaCharacters(modFS); - for (const auto& [tag, historyElements]: vanillaCharacterLoader.getCharacterElements()) - if (countries.contains(tag)) - countries.at(tag)->setVanillaCharacterElements(historyElements); - Log(LogLevel::Info) << "<> " << vanillaCharacterLoader.getCharacterElements().size() << " vanilla characters loaded."; - - Log(LogLevel::Info) << "-> Loading Vanilla Diplomacy."; - vanillaDiplomacyLoader.loadVanillaDiplomacy(modFS); - Log(LogLevel::Info) << "<> Loaded " << vanillaDiplomacyLoader.getAgreementEntries().size() << " vanilla agreements, " - << vanillaDiplomacyLoader.getRelationEntries().size() << " vanilla relations and " << vanillaDiplomacyLoader.getTruceEntries().size() - << " vanilla truces."; - - Log(LogLevel::Info) << "-> Loading Vanilla Diplomatic Plays."; - vanillaDiplomaticPlayLoader.loadVanillaDiplomaticPlays(modFS); - for (const auto& [tag, historyElements]: vanillaDiplomaticPlayLoader.getDiploPlayElements()) - if (countries.contains(tag)) - countries.at(tag)->setVanillaDiplomaticPlayElements(historyElements); - Log(LogLevel::Info) << "<> " << vanillaDiplomaticPlayLoader.getDiploPlayElements().size() << " vanilla characters loaded."; -} - -void V3::PoliticalManager::loadCountryMapper(const std::shared_ptr& theCountryMapper) -{ - countryMapper = theCountryMapper; - for (const auto& countryTag: countries | std::views::keys) - countryMapper->registerKnownVanillaV3Tag(countryTag); -} - -void V3::PoliticalManager::loadPopulationSetupMapperRules(const std::string& filePath) -{ - populationSetupMapper.loadMappingRules(filePath); -} - -void V3::PoliticalManager::loadIdeaEffectMapperRules(const std::string& filePath) -{ - ideaEffectMapper.loadMappingRules(filePath); -} - -void V3::PoliticalManager::loadTechSetupMapperRules(const std::string& filePath) -{ - techSetupMapper.loadMappingRules(filePath); -} - -void V3::PoliticalManager::loadCountryTierMapperRules(const std::string& filePath) -{ - countryTierMapper.loadMappingRules(filePath); -} - -void V3::PoliticalManager::loadLawMapperRules(const std::string& filePath) -{ - lawMapper.loadMappingRules(filePath); -} - -void V3::PoliticalManager::loadLawDefinitions(const commonItems::ModFilesystem& modFS) -{ - LawLoader loader; - loader.loadLaws(modFS); - lawMapper.loadLawDefinitions(loader.getLaws()); -} - -void V3::PoliticalManager::loadDiplomaticMapperRules(const std::string& filePath) -{ - diplomaticMapper.loadMappingRules(filePath); -} - -void V3::PoliticalManager::loadCharacterTraitMapperRules(const std::string& filePath) -{ - characterTraitMapper.loadMappingRules(filePath); -} - -void V3::PoliticalManager::loadColonialTagMapperRules(const std::string& filePath) -{ - colonialTagMapper.loadMappingRules(filePath); -} - -void V3::PoliticalManager::loadAIStrategies(const std::string& filePath) -{ - aiStrategyMapper.loadMappingRules(filePath); -} - -void V3::PoliticalManager::loadAISecretGoals(const std::string& filePath) -{ - aiSecretGoalMapper.loadMappingRules(filePath); -} - -void V3::PoliticalManager::importEU4Countries(const std::map>& eu4Countries) -{ - Log(LogLevel::Info) << "-> Moving over EU4 Countries."; - - for (const auto& eu4country: eu4Countries | std::views::values) - { - auto v3Tag = countryMapper->assignV3TagToEU4Country(eu4country); - - std::shared_ptr country; - if (countries.contains(v3Tag)) - { - country = countries.at(v3Tag); - } - else - { - country = std::make_shared(); - country->setTag(v3Tag); - countries.emplace(v3Tag, country); - } - - country->setSourceCountry(eu4country); - } - - Log(LogLevel::Info) << "<> Vic3 now has " << countries.size() << " known countries."; -} - -void V3::PoliticalManager::generateDecentralizedCountries(const ClayManager& clayManager, const PopManager& popManager) -{ - Log(LogLevel::Info) << "-> Generating decentralized countries."; - - // How do we generate decentralized states? We look at states and their unowned substates. - // Those substates with a particular culture are banded together and shoved into a new country. - // If there's no demographic available (mapping from a wasteland or out of scope), we load - // cultural information (not demographics!) from vanilla sources. - - auto sortedSubstates = sortSubStatesByCultures(clayManager, popManager); - - for (const auto& [culture, subStates]: sortedSubstates) - { - generateDecentralizedCountry(culture, subStates); - } - - Log(LogLevel::Info) << "<> Generated " << sortedSubstates.size() << " decentralized countries."; -} - -void V3::PoliticalManager::generateDecentralizedCountry(const std::string& culture, const std::vector>& subStates) -{ - auto v3tag = countryMapper->requestNewV3Tag(); - auto newCountry = std::make_shared(); - newCountry->setTag(v3tag); - newCountry->setSubStates(subStates); - ProcessedData data; - data.cultures.emplace(culture); - data.type = "decentralized"; - newCountry->setProcessedData(data); - for (const auto& subState: newCountry->getSubStates()) - subState->setOwner(newCountry); - - countries.emplace(v3tag, newCountry); - // ... fingers crossed? -} - -V3::PoliticalManager::CulturalSubStates V3::PoliticalManager::sortSubStatesByCultures(const ClayManager& clayManager, const PopManager& popManager) -{ - CulturalSubStates culturalSubStates; - - for (const auto& [stateName, state]: clayManager.getStates()) - { - for (const auto& subState: state->getSubStates()) - { - if (subState->getOwner()) // don't need owned substates. - continue; - - // Does this substate have a leading demographic? Or any demographic? - std::string leadCulture; - if (!subState->getDemographics().empty()) - { - leadCulture = getDominantDemographic(subState->getDemographics()); - } - else - { - // Ask popmanager for something vanillaish for the entire state (can't use our substates for this). - leadCulture = popManager.getDominantDWCulture(stateName); - } - if (!culturalSubStates.contains(leadCulture)) - culturalSubStates.emplace(leadCulture, std::vector>{}); - culturalSubStates.at(leadCulture).push_back(subState); - } - } - - return culturalSubStates; -} - -std::string V3::PoliticalManager::getDominantDemographic(const std::vector& demographics) -{ - std::map cultureScores; - - for (const auto& demo: demographics) - { - if (cultureScores.contains(demo.culture)) - cultureScores.at(demo.culture) += demo.lowerRatio; // using lower ratio to represent farmers - the majority. - else - cultureScores.emplace(demo.culture, demo.lowerRatio); - } - - const auto highest = std::max_element(std::begin(cultureScores), std::end(cultureScores), [](const auto& p1, const auto& p2) { - return p1.second < p2.second; - }); - - return highest->first; -} - -void V3::PoliticalManager::convertAllCountries(const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const LocalizationLoader& v3LocLoader, - const EU4::EU4LocalizationLoader& eu4LocLoader, - const bool downTiers, - const bool vn) const -{ - Log(LogLevel::Info) << "-> Converting countries."; - - for (const auto& [tag, country]: countries) - { - // this is a freshly-generated decentralized country with no source data whatsoever. - if (!country->getVanillaData() && country->getProcessedData().type == "decentralized") - country->generateDecentralizedData(v3LocLoader, eu4LocLoader); - - // this is a vic3-only (vanilla) country with no EU4 match. It's likely extinct. - else if (country->getVanillaData() && !country->getSourceCountry()) - country->copyVanillaData(v3LocLoader, eu4LocLoader, vn); - - // otherwise, this is a regular imported EU4 country - else if (country->getSourceCountry()) - country->convertFromEU4Country(clayManager, - cultureMapper, - religionMapper, - cultureLoader, - religionLoader, - ideaEffectMapper, - countryTierMapper, - downTiers, - vn); - - else - Log(LogLevel::Warning) << "Country " << tag << " has no known sources! Not importing!"; - } -} - -bool V3::PoliticalManager::isTagDecentralized(const std::string& v3Tag) const -{ - if (!countries.contains(v3Tag)) - return false; - const auto& country = countries.at(v3Tag); - - // this means it's loaded from disk, and it's decentralized. - if (country->getVanillaData() && (*country->getVanillaData()).type == "decentralized") - return true; - return false; -} - -std::shared_ptr V3::PoliticalManager::getCountry(const std::string& v3Tag) const -{ - if (countries.contains(v3Tag)) - return countries.at(v3Tag); - return nullptr; -} - -void V3::PoliticalManager::determineAndApplyWesternization(const mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const Configuration::EUROCENTRISM eurocentrism, - const Configuration::STARTDATE startDate, - const DatingData& datingData) -{ - Log(LogLevel::Info) << "-> Determining Westernization."; - double topTech = 0; - double topInstitutions = 0; - - // Determine top tech/institutions. - for (const auto& country: countries | std::views::values) - { - if (!country->getSourceCountry()) - continue; // we need only eu4 imports - const auto& sourceCountry = country->getSourceCountry(); - if (sourceCountry->getProvinces().empty()) - continue; // dead nations are stuck. - const auto totalTechs = - sourceCountry->getMilTech() + sourceCountry->getAdmTech() + sourceCountry->getDipTech() + country->getProcessedData().ideaEffect.getTechMod(); - if (totalTechs > topTech) - topTech = totalTechs; - const auto currInstitutions = sourceCountry->getNumEmbracedInstitutions(); - if (currInstitutions > topInstitutions) - topInstitutions = currInstitutions; - } - - // and distribute tech level. - int civs = 0; - int uncivs = 0; - for (const auto& country: countries | std::views::values) - { - country->determineWesternizationWealthAndLiteracy(topTech, - topInstitutions, - cultureMapper, - religionMapper, - eurocentrism, - startDate, - datingData, - populationSetupMapper); - - // Bookkeeping. - if (!country->getSubStates().empty()) - { - if (country->getProcessedData().westernized) - ++civs; - else - ++uncivs; - } - } - Log(LogLevel::Info) << "<> There are " << civs << " westernized and " << uncivs << " unwesternized landed nations."; -} - -void V3::PoliticalManager::setupTech() -{ - Log(LogLevel::Info) << "-> Setting up tech for landed EU4 countries."; - - const TechValues techValues(countries); - auto counter = 0; - for (const auto& [tag, country]: countries) - { - if (!TechValues::isValidCountryForTechConversion(*country)) - continue; - - const auto productionScore = techValues.getProductionTechPercentile(tag); - const auto militaryScore = techValues.getMilitaryTechPercentile(tag); - const auto societyScore = techValues.getSocietyTechPercentile(tag); - country->setTechs(techSetupMapper, productionScore, militaryScore, societyScore); - country->setProductionTechPercentile(productionScore); - ++counter; - } - - Log(LogLevel::Info) << "<> " << counter << " countries initialized."; -} - -void V3::PoliticalManager::setupLaws() -{ - Log(LogLevel::Info) << "-> Setting up laws for landed EU4 countries."; - auto counter = 0; - auto serf = 0; - auto tenet = 0; - auto home = 0; - auto noschool = 0; - auto relig = 0; - auto priv = 0; - auto univ = 0; - for (const auto& country: countries | std::views::values) - { - if (!TechValues::isValidCountryForTechConversion(*country)) - continue; - - // ORDER matters! We can set some laws without having other blocking them if we set them first. - // We go by what's *important*. Political first! - grantLawFromGroup("lawgroup_governance_principles", country); - grantLawFromGroup("lawgroup_distribution_of_power", country); - grantLawFromGroup("lawgroup_slavery", country); - grantLawFromGroup("lawgroup_citizenship", country); - grantLawFromGroup("lawgroup_education_system", country); // exception to the rule, education is important to block serfdoms and other problematic reforms. - grantLawFromGroup("lawgroup_land_reform", country); - grantLawFromGroup("lawgroup_colonization", country); - grantLawFromGroup("lawgroup_church_and_state", country); - grantLawFromGroup("lawgroup_economic_system", country); - grantLawFromGroup("lawgroup_bureaucracy", country); - grantLawFromGroup("lawgroup_army_model", country); - grantLawFromGroup("lawgroup_taxation", country); - grantLawFromGroup("lawgroup_trade_policy", country); - grantLawFromGroup("lawgroup_internal_security", country); - grantLawFromGroup("lawgroup_migration", country); - grantLawFromGroup("lawgroup_policing", country); - grantLawFromGroup("lawgroup_rights_of_women", country); - // Social LAST. - grantLawFromGroup("lawgroup_labor_rights", country); - grantLawFromGroup("lawgroup_free_speech", country); - grantLawFromGroup("lawgroup_health_system", country); - grantLawFromGroup("lawgroup_welfare", country); - ++counter; - - // Laws are set, figure out which institutions our laws have - setupInstitutions(country); - - // Some debugging logs to help with debugging on forums. - if (country->getProcessedData().laws.contains("law_serfdom")) - { - serf++; - } - if (country->getProcessedData().laws.contains("law_tenant_farmers")) - tenet++; - if (country->getProcessedData().laws.contains("law_homesteading")) - home++; - if (country->getProcessedData().laws.contains("law_no_schools")) - noschool++; - if (country->getProcessedData().laws.contains("law_religious_schools")) - relig++; - if (country->getProcessedData().laws.contains("law_private_schools")) - priv++; - if (country->getProcessedData().laws.contains("law_public_schools")) - univ++; - } - Log(LogLevel::Info) << "<> " << counter << " countries codified."; - Log(LogLevel::Debug) << "<> " << serf << " serfdom, " << tenet << " tenant farmers, " << home << " homesteading."; - Log(LogLevel::Debug) << "<> " << noschool << " no schooling, " << relig << " religious schools, " << priv << " private schools, " << univ - << " public schools."; -} - -void V3::PoliticalManager::setupInstitutions(const std::shared_ptr& country) const -{ - for (const auto& law: country->getProcessedData().laws) - { - if (auto institution = lawMapper.getLaws().at(law).institution; !institution.empty()) - { - if (institution == "institution_schools") - country->addInstitution(institution, 3); // boost to max to generate starting literacy. - else - country->addInstitution(institution, 1); // otherwise don't. - } - } -} - -void V3::PoliticalManager::grantLawFromGroup(const std::string& lawGroup, const std::shared_ptr& country) const -{ - if (const auto law = lawMapper.grantLawFromGroup(lawGroup, *country); law) - { - country->addLaw(*law); - - // Knowing what's discrimination level in a country is relevant when incorporating or not incorporating states. - if (lawGroup == "lawgroup_citizenship") - { - ProcessedData::DISCRIMINATION_LEVEL discrimination; - if (*law == "law_ethnostate") - discrimination = ProcessedData::DISCRIMINATION_LEVEL::Ethnostate; - else if (*law == "law_national_supremacy") - discrimination = ProcessedData::DISCRIMINATION_LEVEL::National_Supremacy; - else if (*law == "law_racial_segregation") - discrimination = ProcessedData::DISCRIMINATION_LEVEL::Racial_Segregation; - else if (*law == "law_cultural_exclusion") - discrimination = ProcessedData::DISCRIMINATION_LEVEL::Cultural_Exclusion; - else if (*law == "law_multicultural") - discrimination = ProcessedData::DISCRIMINATION_LEVEL::Multicultural; - else - discrimination = ProcessedData::DISCRIMINATION_LEVEL::Unknown; - - country->setDiscriminationLevel(discrimination); - } - } -} - -void V3::PoliticalManager::convertDiplomacy(const std::vector& eu4Agreements) -{ - Log(LogLevel::Info) << "-> Transcribing diplomatic agreements."; - - const std::set subjects = {"dominion", "protectorate", "tributary", "personal_union", "puppet", "vassal"}; - - for (auto& agreement: eu4Agreements) - { - const auto& EU4Tag1 = agreement.getOriginTag(); - auto ifV3Tag1 = countryMapper->getV3Tag(EU4Tag1); - if (!ifV3Tag1) - continue; - auto V3Tag1 = *ifV3Tag1; - - const auto& EU4Tag2 = agreement.getTargetTag(); - auto ifV3Tag2 = countryMapper->getV3Tag(EU4Tag2); - if (!ifV3Tag2) - continue; - auto V3Tag2 = *ifV3Tag2; - - const auto& country1 = countries.find(V3Tag1); - const auto& country2 = countries.find(V3Tag2); - if (country1 == countries.end()) - { - Log(LogLevel::Warning) << "Vic3 country " << V3Tag1 << " used in diplomatic agreement doesn't exist"; - continue; - } - if (country2 == countries.end()) - { - Log(LogLevel::Warning) << "Vic3 country " << V3Tag2 << " used in diplomatic agreement doesn't exist"; - continue; - } - - // Don't create for/with nations that didn't survive province conversion! - if (country1->second->getSubStates().empty()) - continue; - if (country2->second->getSubStates().empty()) - continue; - - auto& r1 = country1->second->getRelation(V3Tag2); // relation TO target - auto& r2 = country2->second->getRelation(V3Tag1); // relation TO source - - Agreement newAgreement; - newAgreement.first = V3Tag1; - newAgreement.second = V3Tag2; - newAgreement.start_date = agreement.getStartDate(); - - // translate eu4 to vic3 agreement. - if (const auto& newType = diplomaticMapper.getAgreementType(agreement.getAgreementType()); newType) - newAgreement.type = *newType; - - // boost relations. - const auto boost = diplomaticMapper.getRelationshipBoost(agreement.getAgreementType()); - r1.increaseRelations(boost); - r2.increaseRelations(boost); - - // fix specifics - if (agreement.getAgreementType() == "private_enterprise" && country2->second->getSourceCountry()->isTradeCompany()) - { - // if this is a TC agreement, push everyone out of isolationism into mercantilism! - country1->second->leaveIsolationism(); - country2->second->leaveIsolationism(); - } - if (newAgreement.type == "vassal") - { - // Watch for westernization! - if (country1->second->getProcessedData().type != "unrecognized") - newAgreement.type = "puppet"; - } - if (newAgreement.type == "puppet") - { - // Watch for westernization! - if (country1->second->getProcessedData().type == "unrecognized") - newAgreement.type = "vassal"; - } - if (newAgreement.type == "tributary") - { - // Watch for westernization! - if (country1->second->getProcessedData().type != "unrecognized") - newAgreement.type = "protectorate"; - } - if (newAgreement.type == "protectorate") - { - // Watch for westernization! - if (country1->second->getProcessedData().type == "unrecognized") - newAgreement.type = "tributary"; - } - if (newAgreement.type == "customs_union") - { - // vic3 has this reversed - newAgreement.first = V3Tag2; - newAgreement.second = V3Tag1; - - // if someone's isolationist, bail. - if (country1->second->getProcessedData().laws.contains("law_isolationism") || country2->second->getProcessedData().laws.contains("law_isolationism")) - continue; - } - if (newAgreement.type == "double_defensive_pact") - { - // fix and file twice. - newAgreement.type = "defensive_pact"; - agreements.push_back(newAgreement); - newAgreement.first = V3Tag2; - newAgreement.second = V3Tag1; - - // if anyone doesn't have required diplotech, bail. - if (!country1->second->getProcessedData().techs.contains("international_relations") || - !country2->second->getProcessedData().techs.contains("international_relations")) - continue; - } - - // store agreement - if (!newAgreement.type.empty()) - { - agreements.push_back(newAgreement); - - // and record overlordship locally for further use. - if (subjects.contains(newAgreement.type)) - country2->second->setOverlord(V3Tag1); - } - } - Log(LogLevel::Info) << "<> Transcribed " << agreements.size() << " agreements."; -} - -void V3::PoliticalManager::convertRivals() -{ - Log(LogLevel::Info) << "-> Transcribing rivalries."; - auto counter = 0; - - for (const auto& [tag, country]: countries) - { - if (!country->getSourceCountry()) - continue; - if (country->getSubStates().empty()) - continue; - const auto& eu4Rivals = country->getSourceCountry()->getRivals(); - std::set newRivals; - for (const auto& rival: eu4Rivals) - { - if (!isEU4CountryConvertedAndLanded(rival)) - continue; - - const auto& rivalTag = countryMapper->getV3Tag(rival); - const auto& rivalCountry = countries.at(*rivalTag); - if (rivalCountry->getSubStates().empty()) - continue; - - auto& r1 = country->getRelation(*rivalTag); - auto& r2 = rivalCountry->getRelation(tag); - - r1.increaseRelations(-100); - r2.increaseRelations(-100); - - // only create an actual rivalry if it's a same-westernization country, or it'll autobreak at game start. - if (country->getProcessedData().westernized == rivalCountry->getProcessedData().westernized) - newRivals.emplace(*rivalTag); - ++counter; - } - country->setRivals(newRivals); // rivals are one-way, but relations suck both ways. - } - Log(LogLevel::Info) << "<> Transcribed " << counter << " rivalries."; -} - -void V3::PoliticalManager::convertTruces(const date& lastEU4Date) -{ - Log(LogLevel::Info) << "-> Transcribing truces."; - auto counter = 0; - - for (const auto& country: countries | std::views::values) - { - if (!country->getSourceCountry()) - continue; - if (country->getSubStates().empty()) - continue; - for (const auto& [target, relation]: country->getSourceCountry()->getRelations()) - { - if (!relation.getTruceExpiry()) - continue; - if (!isEU4CountryConvertedAndLanded(target)) - continue; - const auto& targetTag = countryMapper->getV3Tag(target); - - auto nominalExpiry = *relation.getTruceExpiry(); - const int conversionDateDays = lastEU4Date.getYear() * 365 + lastEU4Date.getMonth() * 30 + lastEU4Date.getDay(); // approximating - - const auto remainingTruceDays = nominalExpiry.getYear() * 365 + nominalExpiry.getMonth() * 12 + nominalExpiry.getDay() - conversionDateDays; - const auto remainingTruceMonths = static_cast(std::round(static_cast(remainingTruceDays) / 30.417)); // let's .. approximate. - - country->addTruce(*targetTag, remainingTruceMonths); - counter++; - } - } - Log(LogLevel::Info) << "<> Transcribed " << counter << " truces."; -} - -bool V3::PoliticalManager::isEU4CountryConvertedAndLanded(const std::string& eu4Tag) const -{ - const auto& targetTag = countryMapper->getV3Tag(eu4Tag); - if (!targetTag) - return false; - if (!countries.contains(*targetTag)) - return false; - const auto& targetCountry = countries.at(*targetTag); - if (targetCountry->getSubStates().empty()) - return false; - return true; -} - -void V3::PoliticalManager::convertCharacters(const date& conversionDate, - Configuration::STARTDATE startDate, - const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader) -{ - Log(LogLevel::Info) << "-> Importing Characters."; - auto counter = 0; - - float ageShift = 0; // how much do we shift the character's ages forward? We don't want a bunch of 200-year olds. - if (startDate == Configuration::STARTDATE::Vanilla) - ageShift = date("1836.1.1").diffInYears(conversionDate); - - for (const auto& country: countries | std::views::values) - { - if (!TechValues::isValidCountryForTechConversion(*country)) - continue; - country->convertCharacters(characterTraitMapper, ageShift, clayManager, cultureMapper, religionMapper, cultureLoader, religionLoader, conversionDate); - counter += static_cast(country->getProcessedData().characters.size()); - } - Log(LogLevel::Info) << "<> Imported " << counter << " Characters. Some died along the way. We buried those."; - Log(LogLevel::Debug) << "You won't find the corpses."; -} - -void V3::PoliticalManager::attemptColonialTagReplacement(const mappers::ColonialRegionMapper& colonialRegionMapper, const ClayManager& clayManager) -{ - Log(LogLevel::Info) << "-> Attempting colonial tag replacement."; - - std::map tagsToUpdate; // new->old - - for (const auto& [tag, country]: countries) - { - if (!TechValues::isValidCountryForTechConversion(*country)) - continue; - if (!country->getSourceCountry()->isColony()) - continue; - - // focus only on CXX countries. On vic3 side as well! We don't want to delete canonical vic3 countries! - const auto& eu4tag = country->getSourceCountry()->getTag(); - if (!eu4tag.starts_with("C") || !countryMapper->tagIsDynamic(eu4tag) || !countryMapper->tagIsDynamic(tag)) - continue; - - if (const auto replacement = colonialTagMapper.matchColonialTag(*country, colonialRegionMapper, clayManager); replacement) - { - if (isValidForColonialReplacement(*replacement) && !tagsToUpdate.contains(*replacement)) - tagsToUpdate.emplace(*replacement, tag); - } - } - - for (const auto& [replacement, tag]: tagsToUpdate) - changeTag(replacement, tag); - - Log(LogLevel::Info) << "<> Swapped " << tagsToUpdate.size() << " countries for colonial tags."; -} - -bool V3::PoliticalManager::isValidForColonialReplacement(const std::string& tag) const -{ - if (!countries.contains(tag)) - return true; - if (!countries.at(tag)->getSourceCountry()) - return true; - return false; -} - -void V3::PoliticalManager::changeTag(const std::string& replacement, const std::string& tag) -{ - if (countries.contains(replacement)) - countries[replacement] = countries[tag]; - else - countries.emplace(replacement, countries.at(tag)); - countries.erase(tag); - - countries[replacement]->setTag(replacement); - - countryMapper->relink(countries.at(replacement)->getSourceCountry()->getTag(), tag, replacement); -} - -void V3::PoliticalManager::importVNColonialDiplomacy(const ClayManager& clayManager) -{ - Log(LogLevel::Info) << "-> Importing VN Colonial Diplomacy"; - auto counter = 0; - - for (const auto& colonyRule: clayManager.getVNColonialMapper().getVNColonies()) - { - if (colonyRule.getSubjects().empty()) - continue; - const auto& keyProvince = colonyRule.getKeyProvince(); - const auto keyOwnerTag = clayManager.getProvinceOwnerTag(keyProvince); - if (!keyOwnerTag || !countries.contains(*keyOwnerTag)) - continue; - const auto& keyOwner = countries.at(*keyOwnerTag); - - for (const auto& targetTag: colonyRule.getSubjects()) - { - if (!countries.contains(targetTag)) - continue; - const auto& target = countries.at(targetTag); - - auto& r1 = keyOwner->getRelation(targetTag); - auto& r2 = target->getRelation(*keyOwnerTag); - r1.increaseRelations(50); - r2.increaseRelations(50); - - Agreement newAgreement; - newAgreement.first = *keyOwnerTag; - newAgreement.second = targetTag; - newAgreement.type = colonyRule.getSubjectType(); - agreements.push_back(newAgreement); - ++counter; - } - } - - Log(LogLevel::Info) << "<> Imported " << counter << " subject agreements."; -} - -int V3::PoliticalManager::getWorldPopCount() const -{ - auto theCountries = std::views::values(countries); - return getCountriesPopCount({theCountries.begin(), theCountries.end()}); -} - -int V3::PoliticalManager::getCountriesPopCount(std::vector> theCountries) -{ - return std::accumulate(theCountries.begin(), theCountries.end(), 0, [](int sum, const auto& country) { - return sum + country->getPopCount(); - }); -} - -void V3::PoliticalManager::importVanillaDiplomacy() -{ - Log(LogLevel::Info) << "-> Importing VN Vanilla Diplomacy"; - auto agrCounter = 0; - auto relCounter = 0; - auto truCounter = 0; - - for (const auto& agreement: vanillaDiplomacyLoader.getAgreementEntries()) - { - if (!isVanillaCountryAndLanded(agreement.getSourceTag())) - continue; - if (!isVanillaCountryAndLanded(agreement.getTargetTag())) - continue; - Agreement newAgreement; - newAgreement.first = agreement.getSourceTag(); - newAgreement.second = agreement.getTargetTag(); - newAgreement.type = agreement.getAgreementType(); - agreements.push_back(newAgreement); - ++agrCounter; - } - - for (const auto& relation: vanillaDiplomacyLoader.getRelationEntries()) - { - if (!isVanillaCountryAndLanded(relation.getSourceTag())) - continue; - if (!isVanillaCountryAndLanded(relation.getTargetTag())) - continue; - auto& rel = countries.at(relation.getSourceTag())->getRelation(relation.getTargetTag()); - rel.setRelations(relation.getRelationValue()); - ++relCounter; - } - - for (const auto& truce: vanillaDiplomacyLoader.getTruceEntries()) - { - if (!isVanillaCountryAndLanded(truce.getSourceTag())) - continue; - if (!isVanillaCountryAndLanded(truce.getTargetTag())) - continue; - countries.at(truce.getSourceTag())->addTruce(truce.getTargetTag(), truce.getDuration()); - ++truCounter; - } - - Log(LogLevel::Info) << "<> Imported " << agrCounter << " vanilla agreements, " << relCounter << " vanilla relations and " << truCounter - << " vanilla truces."; -} - -bool V3::PoliticalManager::isVanillaCountryAndLanded(const std::string& tag) const -{ - if (!countries.contains(tag)) - return false; - const auto& country = countries.at(tag); - if (country->getSourceCountry()) - return false; - if (country->getSubStates().empty()) - return false; - return true; -} - -void V3::PoliticalManager::injectDynamicCulturesIntoFormables(const mappers::CultureMapper& cultureMapper) -{ - Log(LogLevel::Info) << "-> Injecting dynamic cultures into formables."; - auto counter = 0; - const auto& related = cultureMapper.getRelatedCultures(); - - // The difference between formables and releasables, is that formables never existed. No cores. - - for (const auto& country: countries | std::views::values) - { - if (!country->getSubStates().empty()) - continue; // only need dead people. - if (!country->getUnownedCoreSubStates().empty()) - continue; // without cores. - - bool updated = false; - auto data = country->getProcessedData(); - for (const auto& culture: country->getProcessedData().cultures) - { - if (!related.contains(culture)) - continue; - data.cultures.insert(related.at(culture).begin(), related.at(culture).end()); - updated = true; - } - if (updated) - { - ++counter; - country->setProcessedData(data); - } - } - Log(LogLevel::Info) << "<> Updated " << counter << " formable countries."; -} - -void V3::PoliticalManager::expandReleasablesFootprint(const ClayManager& clayManager) -{ - Log(LogLevel::Info) << "-> Expanding Releasables footprint."; - auto counter = 0; - - // For releasables that have cores on >60% state provinces, we want to release entire state, not just the provinces they owned. - // Only reason for this is cleaner borders. - - for (const auto& country: countries | std::views::values) - { - bool expanded = false; - // releasables own no states but have unowned cores somewhere. - if (!country->getSubStates().empty() || country->getUnownedCoreSubStates().empty()) - continue; - std::map> stateProvinces; - for (const auto& subState: country->getUnownedCoreSubStates()) - { - if (!stateProvinces.contains(subState->getHomeStateName())) - stateProvinces.emplace(subState->getHomeStateName(), std::set{}); - auto stateProvinceIDs = subState->getProvinceIDs(); - stateProvinces.at(subState->getHomeStateName()).insert(stateProvinceIDs.begin(), stateProvinceIDs.end()); - } - - for (const auto& [stateName, provinces]: stateProvinces) - { - auto allProvinceIDs = clayManager.getStateProvinceIDs(stateName); - if (static_cast(provinces.size()) / static_cast(allProvinceIDs.size()) > 0.6) - { - stateProvinces.at(stateName) = allProvinceIDs; - expanded = true; - } - } - for (const auto& provinces: stateProvinces | std::views::values) - country->addUnownedProvinces(provinces); - if (expanded) - ++counter; - } - Log(LogLevel::Info) << "<> Expanded " << counter << " releasables."; -} - -void V3::PoliticalManager::alterReleasablesReligion() -{ - Log(LogLevel::Info) << "-> Altering Releasables state religions."; - auto counter = 0; - - // Releasables are dead. We look at their core territories, make a census of their primary cultures' religions there, - // and pick the dominant one. - for (const auto& country: countries | std::views::values) - { - // releasables own no states but have unowned cores somewhere. - if (!country->getSubStates().empty() || country->getUnownedCoreSubStates().empty()) - continue; - - // the census. - const auto& stateCultures = country->getProcessedData().cultures; - std::map religionCounts; - for (const auto& subState: country->getUnownedCoreSubStates()) - for (const auto& pop: subState->getSubStatePops().getPops()) - if (stateCultures.contains(pop.getCulture()) && !pop.getReligion().empty()) - religionCounts[pop.getReligion()] += pop.getSize(); - - const auto sortedReligions = sortMap(religionCounts); - if (sortedReligions.empty()) // possible with 0 pops, but bad. Not our problem, this is legitimate under "don't delete dead nations". - continue; - - if (*sortedReligions.begin() == country->getProcessedData().religion) - continue; - - country->setReligion(*sortedReligions.begin()); - ++counter; - } - Log(LogLevel::Info) << "<> Updated religion for " << counter << " releasables."; -} - -void V3::PoliticalManager::loadMajorFormables(const std::string& filePath) -{ - majorFormablesLoader.loadMajorFormables(filePath); -} - -void V3::PoliticalManager::alterMajorFormables() -{ - Log(LogLevel::Info) << "-> Altering Major Formables Requirements."; - auto counter = 0; - - auto formables = majorFormablesLoader.getMajorFormables(); - for (auto& [tag, formable]: formables) - { - if (!countries.contains(tag)) - continue; - const auto& cultures = countries.at(tag)->getProcessedData().cultures; - bool altered = false; - for (const auto& culture: cultures) - if (!formable.getCultures().contains(culture)) - { - altered = true; - formable.addCulture(culture); - } - if (altered) - ++counter; - } - majorFormablesLoader.setFormables(formables); - Log(LogLevel::Info) << "<> Altered " << counter << " major formables."; -} - -void V3::PoliticalManager::loadIGIdeologiesMapperRules(const std::string& filePath) -{ - igIdeologiesMapper.loadMappingRules(filePath); -} - -void V3::PoliticalManager::alterIGIdeologies(const mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const ClayManager& clayManager) -{ - Log(LogLevel::Info) << "-> Altering IG Ideologies."; - auto counter = 0; - for (const auto& country: countries | std::views::values) - { - const auto igMods = igIdeologiesMapper.getIGIdeologyMods(*country, cultureMapper, religionMapper, clayManager); - if (!igMods.empty()) - { - ++counter; - country->setIGIdeologyModifiers(igMods); - } - } - Log(LogLevel::Info) << "<> " << counter << " countries had IGs altered."; -} - -void V3::PoliticalManager::generateAIStrategies(const ClayManager& clayManager) -{ - Log(LogLevel::Info) << "-> Generating AI Strategies."; - size_t counter = 0; - - for (const auto& country: countries | std::views::values) - { - if (!country->getSourceCountry() || country->getProcessedData().type == "decentralized" || country->getSubStates().empty()) - continue; - - country->setAdmStrategies(aiStrategyMapper.getAdmStrategies(*country, clayManager)); - country->setDipStrategies(aiStrategyMapper.getDipStrategies(*country, clayManager)); - country->setPolStrategies(aiStrategyMapper.getPolStrategies(*country, clayManager)); - - counter += country->getProcessedData().admStrategies.size() + country->getProcessedData().dipStrategies.size() + - country->getProcessedData().polStrategies.size(); - } - Log(LogLevel::Info) << "<> Generated a total of " << counter << " strategies."; -} - -void V3::PoliticalManager::generateAISecretGoals(const ClayManager& clayManager) -{ - Log(LogLevel::Info) << "-> Generating AI Secret Goals."; - auto counter = 0; - - std::vector> neededCountries; - - for (const auto& country: countries | std::views::values) - { - if (!country->getSourceCountry() || country->getProcessedData().type == "decentralized" || country->getSubStates().empty()) - continue; - neededCountries.emplace_back(country); - } - - // O(n^2), but... no other way to do it. - for (const auto& country: neededCountries) - for (const auto& target: neededCountries) - { - if (country->getTag() == target->getTag()) - continue; - if (const auto goal = aiSecretGoalMapper.matchSecretGoal(*country, *target, clayManager); goal) - { - country->addGoal(target->getTag(), *goal); - ++counter; - } - } - - Log(LogLevel::Info) << "<> Generated a total of " << counter << " secret goals."; -} - -void V3::PoliticalManager::incorporateStates(const mappers::CultureMapper& cultureMapper, const ClayManager& clayManager) -{ - Log(LogLevel::Info) << "-> Incorporating States."; - - auto incorporated = 0; - auto unIncorporated = 0; - - for (const auto& country: countries | std::views::values) - { - const auto capitalState = country->getProcessedData().capitalStateName; - const auto capitalRegionName = clayManager.getParentRegionName(capitalState); - - for (const auto& subState: country->getSubStates()) - { - // If the state is in same region as capital, incorporate. - - if (capitalRegionName) - { - const auto actualRegionName = clayManager.getParentRegionName(subState->getHomeStateName()); - if (*actualRegionName == *capitalRegionName) - { - subState->setIncorporated(true); - ++incorporated; - continue; - } - } - - // Otherwise check if any of its homelands are not discriminated. If there's at least some accepted people (via homeland status), incorporate. - - bool match = false; - for (const auto& culture: subState->getHomeState()->getHomelands()) - { - if (!country->isCultureDiscriminated(culture, cultureMapper)) - { - subState->setIncorporated(true); - match = true; - ++incorporated; - break; - } - } - if (!match) - { - subState->setIncorporated(false); - ++unIncorporated; - } - } - } - - Log(LogLevel::Info) << "<> Incorporated " << incorporated << " states, " << unIncorporated << " are unincorporated."; -} - -void V3::PoliticalManager::designateTreatyPorts(const ClayManager& clayManager) -{ - Log(LogLevel::Info) << "-> Designating Treaty Ports and Vacating Pops."; - - auto count = 0; - - for (const auto& country: countries | std::views::values) - { - const auto capitalState = country->getProcessedData().capitalStateName; - const auto capitalRegionName = clayManager.getParentRegionName(capitalState); - - for (const auto& subState: country->getSubStates()) - { - // If the state is in same region as capital, skip! - - if (capitalRegionName) - { - const auto actualRegionName = clayManager.getParentRegionName(subState->getHomeStateName()); - if (*actualRegionName == *capitalRegionName) - { - continue; - } - } - - // Otherwise check if it's a single-province state and a named port. - - if (subState->getProvinces().size() != 1) - continue; - - const auto& theProvince = subState->getProvinces().begin()->second; - - if (theProvince->isPort()) - { - subState->setTreatyPort(); - subState->vacateTreatyPortPops(); - ++count; - } - } - } - - Log(LogLevel::Info) << "<> Designated " << count << " treaty ports."; -} - -void V3::PoliticalManager::distributeColonialClaims(const ClayManager& clayManager) -{ - Log(LogLevel::Info) << "-> Distributing Colonial Claims."; - auto colonialCounter = 0; - auto destinyCounter = 0; - - // sort all states with decentralized nations in them into a registry. - std::map>> colonizableStates; - // And also all substates in a colonial region regardless of ownership. - std::map>> manifestDestinyRegions; - - for (const auto& [stateName, state]: clayManager.getStates()) - { - for (const auto& subState: state->getSubStates()) - { - if (subState->getOwner()->getProcessedData().type == "decentralized") - { - - if (!colonizableStates.contains(stateName)) - colonizableStates.emplace(stateName, std::vector>{}); - colonizableStates.at(stateName).emplace_back(subState); - } - - if (const auto& regionName = clayManager.getParentRegionName(subState->getHomeStateName()); regionName) - { - if (!manifestDestinyRegions.contains(*regionName)) - manifestDestinyRegions.emplace(*regionName, std::vector>{}); - manifestDestinyRegions.at(*regionName).emplace_back(subState); - } - } - } - - // Now, for all countries, that are colonial, if they have a state (presence) in one of these states, claim all the uncolonized substates in the region. - // Also, for capital location, claim all substates in capital region. - - for (const auto& country: countries | std::views::values) - { - if (country->getProcessedData().type == "colonial") // this affects both indeps and deps, no worries. - { - std::set statesToClaim; - for (const auto& subState: country->getSubStates()) - statesToClaim.emplace(subState->getHomeStateName()); - - const auto& capitalRegion = clayManager.getParentRegionName(country->getProcessedData().capitalStateName); - - // now for all subStates in that state, that contain uncolonized clay (in the registry above), file a claim. - - for (const auto& stateName: statesToClaim) - { - if (colonizableStates.contains(stateName)) - { - for (const auto& subState: colonizableStates.at(stateName)) - { - subState->addClaim(country->getTag()); - ++colonialCounter; - } - } - - if (const auto& regionName = clayManager.getParentRegionName(stateName); regionName) - { - if (capitalRegion && *regionName == *capitalRegion) - { - for (const auto& subState: manifestDestinyRegions.at(*regionName)) - { - subState->addClaim(country->getTag()); - ++destinyCounter; - } - } - } - } - } - } - - Log(LogLevel::Info) << "<> Distributed " << colonialCounter << " colonial claims and " << destinyCounter << " manifest destiny claims."; -} diff --git a/EU5ToVic3/Source/V3World/PoliticalManager/PoliticalManager.h b/EU5ToVic3/Source/V3World/PoliticalManager/PoliticalManager.h deleted file mode 100644 index 294af7b..0000000 --- a/EU5ToVic3/Source/V3World/PoliticalManager/PoliticalManager.h +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef POLITICAL_MANAGER_H -#define POLITICAL_MANAGER_H -#include "AISecretGoalMapper/AISecretGoalMapper.h" -#include "AIStrategyMapper/AIStrategyMapper.h" -#include "CharacterTraitMapper/CharacterTraitMapper.h" -#include "ColonialTagMapper/ColonialTagMapper.h" -#include "Configuration.h" -#include "CountryTierMapper/CountryTierMapper.h" -#include "DatingData.h" -#include "Diplomacy/Agreement.h" -#include "DiplomaticMapper/DiplomaticMapper.h" -#include "IGIdeologiesMapper/IGIdeologiesMapper.h" -#include "IdeaEffectsMapper/IdeaEffectsMapper.h" -#include "LawMapper/LawMapper.h" -#include "Loaders/MajorFormablesLoader/MajorFormablesLoader.h" -#include "Loaders/VanillaCharacterLoader/VanillaCharacterLoader.h" -#include "Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryLoader.h" -#include "Loaders/VanillaDiplomacyLoader/VanillaDiplomacyLoader.h" -#include "Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayLoader.h" -#include "Loaders/VanillaPopulationHistoryLoader/VanillaPopulationHistoryLoader.h" -#include "ModLoader/ModFilesystem.h" -#include "PopulationSetupMapper/PopulationSetupMapper.h" -#include "TechSetupMapper/TechSetupMapper.h" -#include -#include -#include -#include - -namespace EU4 -{ -class EU4Agreement; -class EU4LocalizationLoader; -class Country; -class CultureLoader; -class ReligionLoader; -} // namespace EU4 -namespace mappers -{ -class CountryMapper; -class CultureMapper; -class ReligionMapper; -} // namespace mappers -namespace V3 -{ -struct Demographic; -class Country; -class SubState; -class PopManager; -class ClayManager; -class LocalizationLoader; -class PoliticalManager -{ - public: - using CulturalSubStates = std::map>>; // culture -> substates - - PoliticalManager() = default; - - void initializeVanillaCountries(const commonItems::ModFilesystem& modFS, const commonItems::ModFilesystem& vanillaFS); - void loadCountryMapper(const std::shared_ptr& theCountryMapper); - void loadPopulationSetupMapperRules(const std::string& filePath); - void loadIdeaEffectMapperRules(const std::string& filePath); - void loadTechSetupMapperRules(const std::string& filePath); - void loadLawMapperRules(const std::string& filePath); - void loadLawDefinitions(const commonItems::ModFilesystem& modFS); - void loadDiplomaticMapperRules(const std::string& filePath); - void loadCharacterTraitMapperRules(const std::string& filePath); - void loadColonialTagMapperRules(const std::string& filePath); - void loadCountryTierMapperRules(const std::string& filePath); - void loadIGIdeologiesMapperRules(const std::string& filePath); - void loadMajorFormables(const std::string& filePath); - void loadAIStrategies(const std::string& filePath); - void loadAISecretGoals(const std::string& filePath); - void importEU4Countries(const std::map>& eu4Countries); - void generateDecentralizedCountries(const ClayManager& clayManager, const PopManager& popManager); - void convertAllCountries(const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader, - const LocalizationLoader& v3LocLoader, - const EU4::EU4LocalizationLoader& eu4LocLoader, - bool downTiers, - bool vn = false) const; - void addCountry(const std::pair>& country) { countries.emplace(country); } - - [[nodiscard]] const auto& getCountries() const { return countries; } - [[nodiscard]] std::shared_ptr getCountry(const std::string& v3Tag) const; - [[nodiscard]] int getWorldPopCount() const; - [[nodiscard]] static int getCountriesPopCount(std::vector> theCountries); - [[nodiscard]] bool isTagDecentralized(const std::string& v3Tag) const; - [[nodiscard]] std::map getLawsMap() const { return lawMapper.getLaws(); } - [[nodiscard]] const auto& getMajorFormables() const { return majorFormablesLoader.getMajorFormables(); } - - void determineAndApplyWesternization(const mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - Configuration::EUROCENTRISM eurocentrism, - Configuration::STARTDATE startDate, - const DatingData& datingData); - void setupTech(); - void setupLaws(); - void setupInstitutions(const std::shared_ptr& country) const; - void convertDiplomacy(const std::vector& agreements); - [[nodiscard]] const auto& getAgreements() const { return agreements; } - void convertRivals(); - void convertTruces(const date& lastEU4Date); - void convertCharacters(const date& conversionDate, - Configuration::STARTDATE startDate, - const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader); - void injectDynamicCulturesIntoFormables(const mappers::CultureMapper& cultureMapper); - void expandReleasablesFootprint(const ClayManager& clayManager); - void alterReleasablesReligion(); - void alterMajorFormables(); - void alterIGIdeologies(const mappers::CultureMapper& cultureMapper, const mappers::ReligionMapper& religionMapper, const ClayManager& clayManager); - void generateAIStrategies(const ClayManager& clayManager); - void generateAISecretGoals(const ClayManager& clayManager); - void attemptColonialTagReplacement(const mappers::ColonialRegionMapper& colonialRegionMapper, const ClayManager& clayManager); - void incorporateStates(const mappers::CultureMapper& cultureMapper, const ClayManager& clayManager); - void designateTreatyPorts(const ClayManager& clayManager); - void distributeColonialClaims(const ClayManager& clayManager); - - // VN specifics - void importVNColonialDiplomacy(const ClayManager& clayManager); - void importVanillaDiplomacy(); - - private: - void generateDecentralizedCountry(const std::string& culture, const std::vector>& subStates); - static CulturalSubStates sortSubStatesByCultures(const ClayManager& clayManager, const PopManager& popManager); - static std::string getDominantDemographic(const std::vector& demographics); - void grantLawFromGroup(const std::string& lawGroup, const std::shared_ptr& country) const; - [[nodiscard]] bool isEU4CountryConvertedAndLanded(const std::string& eu4Tag) const; - [[nodiscard]] bool isVanillaCountryAndLanded(const std::string& tag) const; - [[nodiscard]] bool isValidForColonialReplacement(const std::string& tag) const; - void changeTag(const std::string& replacement, const std::string& tag); - - std::map> countries; - std::vector agreements; - - std::shared_ptr countryMapper; - mappers::PopulationSetupMapper populationSetupMapper; - mappers::IdeaEffectsMapper ideaEffectMapper; - mappers::TechSetupMapper techSetupMapper; - mappers::LawMapper lawMapper; - mappers::DiplomaticMapper diplomaticMapper; - mappers::CharacterTraitMapper characterTraitMapper; - mappers::ColonialTagMapper colonialTagMapper; - mappers::CountryTierMapper countryTierMapper; - mappers::IGIdeologiesMapper igIdeologiesMapper; - mappers::AIStrategyMapper aiStrategyMapper; - mappers::AISecretGoalMapper aiSecretGoalMapper; - VanillaDiplomacyLoader vanillaDiplomacyLoader; - VanillaCountryHistoryLoader vanillaCountryHistoryLoader; - VanillaPopulationHistoryLoader vanillaPopulationHistoryLoader; - VanillaCharacterLoader vanillaCharacterLoader; - VanillaDiplomaticPlayLoader vanillaDiplomaticPlayLoader; - MajorFormablesLoader majorFormablesLoader; -}; -} // namespace V3 -#endif // POLITICAL_MANAGER_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/PoliticalManager/TechValues/TechValues.cpp b/EU5ToVic3/Source/V3World/PoliticalManager/TechValues/TechValues.cpp deleted file mode 100644 index bb0e9ef..0000000 --- a/EU5ToVic3/Source/V3World/PoliticalManager/TechValues/TechValues.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "TechValues.h" -#include "CountryManager/EU4Country.h" -#include "PoliticalManager/Country/Country.h" -#include -#include - -V3::TechValues::TechValues(const std::map>& countries) -{ - gatherScores(countries); - if (productionScores.empty()) - return; // Well crap. Play dead and hope they go away. - calculateOrders(); -} - -void V3::TechValues::gatherScores(const std::map>& countries) -{ - for (const auto& [tag, country]: countries) - { - if (!isValidCountryForTechConversion(*country)) - continue; - auto bonus = 0; - if (country->getProcessedData().westernized && country->getSourceCountry()->isGP()) - bonus = 2.0; - - productionScores.emplace(tag, getCountryProductionTech(*country) + bonus); - militaryScores.emplace(tag, getCountryMilitaryTech(*country) + bonus); - societyScores.emplace(tag, getCountrySocietyTech(*country) + bonus); - } -} - -void V3::TechValues::calculateOrders() -{ - productionOrder = sortMap(productionScores); - militaryOrder = sortMap(militaryScores); - societyOrder = sortMap(societyScores); -} - -std::vector V3::TechValues::sortMap(const std::map& theMap) -{ - std::vector sorted; - - std::vector> pairs; - for (const auto& theElement: theMap) - pairs.emplace_back(theElement); - - std::sort(pairs.begin(), pairs.end(), [=](const std::pair& a, const std::pair& b) { - return a.second < b.second; - }); - - for (const auto& tag: pairs | std::views::keys) - sorted.emplace_back(tag); - - return sorted; -} - -bool V3::TechValues::isValidCountryForTechConversion(const Country& country) -{ - return !country.getSubStates().empty() && country.getSourceCountry(); -} - -double V3::TechValues::getProductionTechPercentile(const std::string& tag) const -{ - if (!productionScores.contains(tag)) - return 0; - - const auto it = std::find(productionOrder.begin(), productionOrder.end(), tag); - const auto index = std::distance(productionOrder.begin(), it); - return (static_cast(index) + 1) / static_cast(productionOrder.size()) * 100; -} - -double V3::TechValues::getMilitaryTechPercentile(const std::string& tag) const -{ - if (!militaryScores.contains(tag)) - return 0; - - const auto it = std::find(militaryOrder.begin(), militaryOrder.end(), tag); - const auto index = std::distance(militaryOrder.begin(), it); - return (static_cast(index) + 1) / static_cast(militaryOrder.size()) * 100; -} - -double V3::TechValues::getSocietyTechPercentile(const std::string& tag) const -{ - if (!societyScores.contains(tag)) - return 0; - - const auto it = std::find(societyOrder.begin(), societyOrder.end(), tag); - const auto index = std::distance(societyOrder.begin(), it); - return (static_cast(index) + 1) / static_cast(societyOrder.size()) * 100; -} - -/* These three functions do heavy tech shaping according to civLevel. However civLevel was a *function* of - * incoming tech and low-tech countries already have low civlevel! - * - * This means a lagging country will be twice penalized for its lack of tech, but an eurocentric-shaped one (eg. - * to 60%) will now have tech score reduced only to that 60%. That means we're in fact *counting on* EU4 importing - * all countries with mostly same levels of tech, and double-penalizing the stragglers. - * - * However, we're only reducing the tech score for purpose of *rank* and median values will still apply, and grant - * everyone properly distributed tech *levels* (it will just heavily favor westernized countries). - */ - -double V3::TechValues::getCountryProductionTech(const Country& country) -{ - auto totalDip = country.getSourceCountry()->getDipTech() + country.getProcessedData().ideaEffect.dip; - totalDip += country.getSourceCountry()->getScore() / 100'000; - return totalDip * country.getProcessedData().civLevel / 100; -} - -double V3::TechValues::getCountryMilitaryTech(const Country& country) -{ - auto totalMil = country.getSourceCountry()->getMilTech() + country.getProcessedData().ideaEffect.mil; - totalMil += country.getSourceCountry()->getScore() / 100'000; - return totalMil * country.getProcessedData().civLevel / 100; -} - -double V3::TechValues::getCountrySocietyTech(const Country& country) -{ - auto totalAdm = country.getSourceCountry()->getAdmTech() + country.getProcessedData().ideaEffect.adm; - totalAdm += country.getSourceCountry()->getScore() / 100'000; - return totalAdm * country.getProcessedData().civLevel / 100; -} diff --git a/EU5ToVic3/Source/V3World/PoliticalManager/TechValues/TechValues.h b/EU5ToVic3/Source/V3World/PoliticalManager/TechValues/TechValues.h deleted file mode 100644 index 626bb77..0000000 --- a/EU5ToVic3/Source/V3World/PoliticalManager/TechValues/TechValues.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef TECH_CONVERSION_HELPERS_H -#define TECH_CONVERSION_HELPERS_H -#include -#include -#include -#include -#include - -namespace V3 -{ -class Country; -class TechValues -{ - public: - explicit TechValues(const std::map>& countries); - - [[nodiscard]] static bool isValidCountryForTechConversion(const Country& country); - [[nodiscard]] double getProductionTechPercentile(const std::string& tag) const; - [[nodiscard]] double getMilitaryTechPercentile(const std::string& tag) const; - [[nodiscard]] double getSocietyTechPercentile(const std::string& tag) const; - - private: - [[nodiscard]] static double getCountryProductionTech(const Country& country); - [[nodiscard]] static double getCountryMilitaryTech(const Country& country); - [[nodiscard]] static double getCountrySocietyTech(const Country& country); - - void gatherScores(const std::map>& countries); - void calculateOrders(); - [[nodiscard]] static std::vector sortMap(const std::map& theMap); - - std::map productionScores; - std::map militaryScores; - std::map societyScores; - std::vector productionOrder; - std::vector militaryOrder; - std::vector societyOrder; -}; -} // namespace V3 - -#endif // TECH_CONVERSION_HELPERS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/PopManager/Demographic.h b/EU5ToVic3/Source/V3World/PopManager/Demographic.h deleted file mode 100644 index 1cdc863..0000000 --- a/EU5ToVic3/Source/V3World/PopManager/Demographic.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef V3_DEMOGRAPHIC_H -#define V3_DEMOGRAPHIC_H -#include - -namespace V3 -{ -struct Demographic -{ - std::string culture; - std::string religion; - double upperRatio = 0.0; - double middleRatio = 0.0; - double lowerRatio = 0.0; -}; -} // namespace V3 - -#endif // V3_DEMOGRAPHIC_H diff --git a/EU5ToVic3/Source/V3World/PopManager/PopManager.cpp b/EU5ToVic3/Source/V3World/PopManager/PopManager.cpp deleted file mode 100644 index 04bfa49..0000000 --- a/EU5ToVic3/Source/V3World/PopManager/PopManager.cpp +++ /dev/null @@ -1,701 +0,0 @@ -#include "PopManager.h" -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/Chunk.h" -#include "ClayManager/State/State.h" -#include "ClayManager/State/SubState.h" -#include "CultureMapper/CultureMapper.h" -#include "Loaders/PopLoader/PopLoader.h" -#include "Loaders/SuperRegionLoader/V3Region.h" -#include "Loaders/SuperRegionLoader/V3SuperRegion.h" -#include "Log.h" -#include "PoliticalManager/Country/Country.h" -#include "PoliticalManager/PoliticalManager.h" -#include "ReligionMapper/ReligionMapper.h" -#include -#include -#include - -void V3::PopManager::initializeVanillaPops(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading Vanilla Pops."; - PopLoader popLoader; - popLoader.loadPops(modFS); - vanillaStatePops = popLoader.getStatePops(); - - const auto total = std::accumulate(vanillaStatePops.begin(), vanillaStatePops.end(), 0, [](int sum, const std::pair& statePop) { - return sum + statePop.second.getPopCount(); - }); - - Log(LogLevel::Info) << "<> Vanilla had " << total << " pops."; -} - -void V3::PopManager::initializeDWPops(const commonItems::ModFilesystem& modFS) -{ - Log(LogLevel::Info) << "-> Loading Decentralized World Pops."; - PopLoader popLoader; - popLoader.loadPops(modFS); - dwStatePops = popLoader.getStatePops(); - - const auto total = std::accumulate(dwStatePops.begin(), dwStatePops.end(), 0, [](int sum, const std::pair& statePop) { - return sum + statePop.second.getPopCount(); - }); - - Log(LogLevel::Info) << "<> Decentralized World had " << total << " pops."; -} - -std::optional V3::PopManager::getVanillaSubStatePops(const std::string& stateName, const std::string& ownerTag) const -{ - if (!vanillaStatePops.contains(stateName)) - return std::nullopt; - const auto& subStatePops = vanillaStatePops.at(stateName).getSubStatePops(); - for (const auto& subStatePop: subStatePops) - if (subStatePop.getTag() == ownerTag) - return subStatePop; - return std::nullopt; -} - -std::optional V3::PopManager::getDWSubStatePops(const std::string& stateName, const std::string& ownerTag) const -{ - if (!dwStatePops.contains(stateName)) - return std::nullopt; - const auto& subStatePops = dwStatePops.at(stateName).getSubStatePops(); - for (const auto& subStatePop: subStatePops) - if (subStatePop.getTag() == ownerTag) - return subStatePop; - return std::nullopt; -} - -void V3::PopManager::convertDemographics(const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader) const -{ - Log(LogLevel::Info) << "-> Converting EU4 demographics."; - - // At this point, all substates we have are owned, and formed from sane chunks. They have incoming popratios, - // and using regional data we can convert them into Vic3 demographics. - - for (const auto& [stateName, state]: clayManager.getStates()) - { - if (state->isSea() || state->isLake()) - continue; - - if (!vanillaStatePops.contains(stateName)) - { - Log(LogLevel::Warning) << "State " << stateName << " is unknown. Not creating pops."; - continue; - } - - for (const auto& subState: state->getSubStates()) - { - // skip imported substates, those already have pops and carry no demographics. - if (subState->isVanillaSubState()) - continue; - subState->convertDemographics(clayManager, cultureMapper, religionMapper, cultureLoader, religionLoader); - } - } -} - -void V3::PopManager::applyHomeLands(const ClayManager& clayManager) const -{ - Log(LogLevel::Info) << "-> Applying Homelands."; - auto counter = 0; - for (const auto& state: clayManager.getStates() | std::views::values) - { - if (state->isSea() || state->isLake()) - continue; - - for (const auto& subState: state->getSubStates()) - { - // skip imported substates, those already have imported homelands into their states. - if (subState->isVanillaSubState()) - continue; - if (const auto& primaryCulture = subState->getPrimaryCulture(); primaryCulture) - { - state->addHomeland(*primaryCulture); - ++counter; - } - } - } - - Log(LogLevel::Info) << "<> Applied " << counter << " homelands."; -} - -std::string V3::PopManager::getDominantVanillaCulture(const std::string& stateName) const -{ - if (!vanillaStatePops.contains(stateName)) - { - Log(LogLevel::Warning) << "PopManager knows nothing about vanilla state " << stateName; - return "noculture"; - } - - const auto best = vanillaStatePops.at(stateName).getDominantCulture(); - if (!best) - { - Log(LogLevel::Warning) << "Vanilla state " << stateName << " is dry!"; - return "noculture"; - } - - return *best; -} - -std::string V3::PopManager::getDominantVanillaReligion(const std::string& stateName) const -{ - if (!vanillaStatePops.contains(stateName)) - { - Log(LogLevel::Warning) << "PopManager knows nothing about vanilla state " << stateName; - return "noreligion"; - } - - const auto best = vanillaStatePops.at(stateName).getDominantReligion(); - if (!best) - { - Log(LogLevel::Warning) << "Vanilla state " << stateName << " is dry!"; - return "noreligion"; - } - - return *best; -} - -std::string V3::PopManager::getDominantDWCulture(const std::string& stateName) const -{ - if (!dwStatePops.contains(stateName)) - { - Log(LogLevel::Warning) << "PopManager knows nothing about DW state " << stateName; - return "noculture"; - } - - const auto best = dwStatePops.at(stateName).getDominantCulture(); - if (!best) - { - Log(LogLevel::Warning) << "DW state " << stateName << " is dry!"; - return "noculture"; - } - - return *best; -} - -std::string V3::PopManager::getDominantDWReligion(const std::string& stateName) const -{ - if (!dwStatePops.contains(stateName)) - { - Log(LogLevel::Warning) << "PopManager knows nothing about DW state " << stateName; - return "noreligion"; - } - - const auto best = dwStatePops.at(stateName).getDominantReligion(); - if (!best) - { - Log(LogLevel::Warning) << "DW state " << stateName << " is dry!"; - return "noreligion"; - } - - return *best; -} - -void V3::PopManager::generatePops(const ClayManager& clayManager, const Configuration::POPSHAPES popShapes, double shapingFactor) -{ - const auto worldTotal = std::accumulate(vanillaStatePops.begin(), vanillaStatePops.end(), 0, [](int sum, const auto& statePops) { - return sum + statePops.second.getPopCount(); - }); - Log(LogLevel::Info) << "-> Generating Pops. Vanilla World was: " << worldTotal << " pops."; - - filterVanillaMinorityStatePops(); - - /* EU4-imported substates have their own weights. These weights stem from chunks and prior from EU4 province development, - * and we need to distribute the statePopCount according to those weights. However. - * - * When looking at a mixed state, the imported and shoved substates won't have a weight, but we still need to account for - * them having - or not having - pops! - * - * FIRST assign *something* to shoved substates, then count existing (imported + shoved) pops, subtract that from total pops, - * and only then distribute the remainder according to weights. Tad involved but no way around it. - */ - - const auto vanillaSuperRegionPopCount = getVanillaSuperRegionalPopCounts(clayManager); // superregion -> total popcount - const auto vanillaSuperRegionWeights = getVanillaSuperRegionalWeights(clayManager); // superregion -> total weight - const auto superRegionProjectedCounts = getSuperRegionPopShapingProjections(clayManager); // superregion -> pre-normalized popshaping projection - - for (const auto& [stateName, state]: clayManager.getStates()) - { - if (state->isSea() || state->isLake()) - continue; - - if (!vanillaStatePops.contains(stateName) || !dwStatePops.contains(stateName)) - continue; - - const auto& superRegion = clayManager.getParentSuperRegion(stateName); - if (!superRegion) - continue; - const auto& superRegionName = superRegion->getName(); - - auto minorityPopCount = 0; - if (vanillaMinorityStatePops.contains(stateName)) - minorityPopCount = vanillaMinorityStatePops.at(stateName).getPopCount(); - auto vanillaStatePopCount = 0; - double stateFactor = 1.0; - - if (popShapes == Configuration::POPSHAPES::Vanilla) - { - vanillaStatePopCount = vanillaStatePops.at(stateName).getPopCount(); - } - else if (popShapes == Configuration::POPSHAPES::Extreme) - { - // Unlike Vic2, we're reshuffling the pops within specific superregions. There are 6 superregions in Vic3 and each of the major ones contains approx - // same amount of pops. We're just reshuffling them internally. - const auto totalStateWeight = state->getTotalSubStateWeight(); - if (vanillaSuperRegionWeights.contains(superRegion->getName()) && vanillaSuperRegionPopCount.contains(superRegion->getName())) - { - const auto totalSuperRegionWeight = vanillaSuperRegionWeights.at(superRegionName); - const auto popModifier = totalStateWeight / totalSuperRegionWeight; - - // Keep in mind - these popcounts are tied to states, not substates. A super-high-weight substate will take most of the pops however, - // so we're ok. - vanillaStatePopCount = static_cast(std::round(vanillaSuperRegionPopCount.at(superRegionName) * popModifier)); - // Normalize by shaping factor - vanillaStatePopCount = static_cast(std::round(vanillaStatePopCount * shapingFactor)) + - static_cast(std::round(vanillaStatePops.at(stateName).getPopCount() * (1.0 - shapingFactor))); - - stateFactor = - (vanillaStatePopCount - vanillaStatePops.at(stateName).getPopCount()) / static_cast(vanillaStatePops.at(stateName).getPopCount()); - } - else - { - Log(LogLevel::Warning) << "State " << stateName << " doesn't have a superregion! Defaulting popcount to vanilla!"; - vanillaStatePopCount = vanillaStatePops.at(stateName).getPopCount(); - } - } - else if (popShapes == Configuration::POPSHAPES::PopShaping) - { - const auto superRegionalNormalizationFactor = vanillaSuperRegionPopCount.at(superRegionName) / superRegionProjectedCounts.at(superRegionName); - const auto stateInvestmentFactor = 1.0 + state->getInvestmentFactor(); - const auto projectedPopCount = static_cast(vanillaStatePops.at(stateName).getPopCount()) * stateInvestmentFactor; - vanillaStatePopCount = static_cast(std::round(projectedPopCount * superRegionalNormalizationFactor)); - // Normalize by shaping factor - vanillaStatePopCount = static_cast(std::round(vanillaStatePopCount * shapingFactor)) + - static_cast(std::round(vanillaStatePops.at(stateName).getPopCount() * (1.0 - shapingFactor))); - stateFactor = - (vanillaStatePopCount - vanillaStatePops.at(stateName).getPopCount()) / static_cast(vanillaStatePops.at(stateName).getPopCount()); - } - - // do not count minorities towards vanilla population as they get added separately. - vanillaStatePopCount -= static_cast(minorityPopCount * stateFactor); - // we're assuming minorities are never slaves. - const auto vanillaStateSlavePopCount = static_cast(vanillaStatePops.at(stateName).getSlavePopCount() * stateFactor); - // dw pops don't have minorities. - const auto dwStatePopCount = dwStatePops.at(stateName).getPopCount(); - const auto startingPopCount = static_cast(state->getStatePopCount() * stateFactor); - - /* Now there's a few things to keep in mind. The substate we're operating on can be any of these: - * - * 1. Normally generated from EU4, carrying its own demographics - * 2. Imported from vanilla map, carrying its own (mostly ?) vanilla pops. - * 3. Shoved from unassigned provinces, carrying nothing whatsoever. - * - * Right now we're concerned only with 3, and after that 1. 2 doesn't need work done. - * */ - - // assigned provinces are provinces in substates that have pops inside. We need to exclude them when building ratios. - auto assignedProvinceCount = std::accumulate(state->getSubStates().begin(), state->getSubStates().end(), 0, [](int sum, const auto& subState) { - if (subState->getSubStatePops().getPopCount() > 0) - sum += static_cast(subState->getProvinces().size()); - return sum; - }); - - // what is our unassigned pop count? (original statePopCount - what's in imported substates already) - // shoved states use dw popcount and pops - we *pretend* we'll be using DW popcount for entire state - auto unassignedDWPopCount = dwStatePopCount - startingPopCount; - if (unassignedDWPopCount < 0) - unassignedDWPopCount = 0; - const auto unassignedProvinceCount = static_cast(state->getProvinces().size()) - assignedProvinceCount; - if (unassignedDWPopCount > 0) - generatePopsForShovedSubStates(state, unassignedDWPopCount, unassignedProvinceCount); - - // now iterate again and distribute that unassigned count according to weights. - // normal/imported states use vanilla popcount and pops (with minorities) - we *pretend* we've been using vanilla popcount from the start. - // cap the popcap at whatever clay isn't already assigned. - assignedProvinceCount = std::accumulate(state->getSubStates().begin(), state->getSubStates().end(), 0, [](int sum, const auto& subState) { - if (subState->getSubStatePops().getPopCount() > 0) - sum += static_cast(subState->getProvinces().size()); - return sum; - }); - - const double unassignedClayRatio = - static_cast(state->getProvinces().size() - assignedProvinceCount) / static_cast(state->getProvinces().size()); - auto unassignedVanillaPopCount = static_cast(std::round(vanillaStatePopCount * unassignedClayRatio)); - if (unassignedVanillaPopCount < 0) - unassignedVanillaPopCount = 0; - auto unassignedVanillaSlavePopCount = static_cast(std::round(vanillaStateSlavePopCount * unassignedClayRatio)); - if (unassignedVanillaSlavePopCount < 0) - unassignedVanillaSlavePopCount = 0; - if (unassignedVanillaPopCount > 0) - generatePopsForNormalSubStates(state, unassignedVanillaPopCount, unassignedVanillaSlavePopCount); - } - - const auto worldSum = std::accumulate(clayManager.getStates().begin(), clayManager.getStates().end(), 0, [](int sum, const auto& state) { - return sum + state.second->getStatePopCount(); - }); - - const auto worldDelta = worldSum - worldTotal; - Log(LogLevel::Info) << "<> World now has " << worldSum << " pops (delta: " << worldDelta << " pops)."; - if (std::abs(static_cast(worldDelta) / static_cast(worldTotal)) > 0.001) - Log(LogLevel::Info) << ">> World delta is over one permille (" << std::abs(static_cast(worldDelta) / static_cast(worldTotal)) - << "). This is troubling, but not unexpected."; - else - Log(LogLevel::Info) << ">> World delta at " << std::abs(static_cast(worldDelta) / static_cast(worldTotal)) << ". Acceptable."; -} - -void V3::PopManager::filterVanillaMinorityStatePops() -{ - Log(LogLevel::Info) << "-> Filtering Vanilla Minority Pops."; - auto counter = 0; - - for (auto& [stateName, statePops]: vanillaStatePops) - { - vanillaMinorityStatePops.emplace(stateName, StatePops()); - for (auto& subStatePops: statePops.getSubStatePops()) - { - SubStatePops newSubStatePops; - newSubStatePops.setTag(subStatePops.getTag()); - for (auto& pop: subStatePops.getPops()) - { - auto newPop = pop; - if (minorityPopMapper.blankMajorityFromMinority(newPop)) - { - newSubStatePops.addPop(newPop); - ++counter; - } - } - vanillaMinorityStatePops.at(stateName).addSubStatePops(newSubStatePops); - } - } - Log(LogLevel::Info) << "<> Fished out " << counter << " minority pops."; -} - -void V3::PopManager::generatePopsForNormalSubStates(const std::shared_ptr& state, const int unassignedPopCount, const int unassignedSlavePopCount) const -{ - const auto& stateName = state->getName(); - - for (const auto& subState: state->getSubStates()) - { - if (subState->getSubStatePops().getPopCount() > 0) - continue; - - if (!subState->getWeight()) - { - std::string warnString = "Substate "; - if (subState->getOwnerTag()) - { - warnString += *subState->getOwnerTag(); - } - else - { - warnString += "(shoved)"; - } - warnString += " in " + stateName + " (provinces"; - for (const auto& pid: subState->getProvinceIDs()) - { - warnString += " " + pid; - } - warnString += ") has NO WEIGHT! It's supposed to be imported from EU4! Not generating pops!"; - Log(LogLevel::Warning) << warnString; - continue; - } - - const auto generatedPopCount = generatePopCountForNormalSubState(subState, unassignedPopCount); - const auto generatedSlavePopCount = generatePopCountForNormalSubState(subState, unassignedSlavePopCount); - const auto vanillaPopCount = generatePopCountForNormalSubState(subState, vanillaStatePops.at(stateName).getPopCount()); - subState->generatePops(generatedPopCount, generatedSlavePopCount); - subState->setStageForMinorities(true); - subState->setVanillaPopCount(vanillaPopCount); - } - - if (!vanillaMinorityStatePops.contains(stateName) || vanillaMinorityStatePops.at(stateName).getPopCount() == 0) - { - for (const auto& subState: state->getSubStates()) - subState->setStageForMinorities(false); - return; - } - - for (const auto& subState: state->getSubStates()) - { - if (!subState->isStagedForMinorities()) - continue; - const auto generatedPopCount = generatePopCountForNormalSubState(subState, unassignedPopCount); - // if we assigned 10k out of 80k unassigned pops to this substate, then multiply vanilla minority popcount by 1/8, and get that many pops. - const double minorityPopSizeTotal = std::round(static_cast(vanillaMinorityStatePops.at(stateName).getPopCount()) * - static_cast(generatedPopCount) / static_cast(unassignedPopCount)); - auto minorityPops = generateMinorityPops(stateName, - minorityPopSizeTotal, - subState->getSubStatePops().getDominantCulture(), - subState->getSubStatePops().getDominantReligion()); - subState->addPops(minorityPops); - subState->setStageForMinorities(false); - } -} - -void V3::PopManager::generatePopsForShovedSubStates(const std::shared_ptr& state, int unassignedPopCount, int unassignedProvinceCount) const -{ - const auto& stateName = state->getName(); - for (const auto& subState: state->getSubStates()) - { - if (subState->getSubStatePops().getPopCount() > 0) - continue; - - if (subState->getDemographics().empty()) - { - const auto generatedPopCount = generatePopCountForShovedSubState(subState, unassignedPopCount, unassignedProvinceCount); - // We have no demographics! Use best guess. Also default religion to culture default. - auto pop = Pop(getDominantDWCulture(stateName), "", "", generatedPopCount); - subState->addPop(pop); - // and we're done with this one. - } - } -} - -std::vector V3::PopManager::generateMinorityPops(const std::string& stateName, - double neededPopSizeTotal, - const std::optional& dominantCulture, - const std::optional& dominantReligion) const -{ - std::vector toReturn; - if (!vanillaMinorityStatePops.contains(stateName) || vanillaMinorityStatePops.at(stateName).getPopCount() == 0) - return toReturn; - - const auto vanillaPopSizeTotal = static_cast(vanillaMinorityStatePops.at(stateName).getPopCount()); - for (const auto& subStatePops: vanillaMinorityStatePops.at(stateName).getSubStatePops()) - { - for (const auto& pop: subStatePops.getPops()) - { - auto newPop = pop; - const double ratio = neededPopSizeTotal / vanillaPopSizeTotal; - const double newSize = std::round(ratio * pop.getSize()); - newPop.setSize(static_cast(newSize)); - if (newPop.getCulture().empty()) - { - if (dominantCulture) - newPop.setCulture(*dominantCulture); - else - continue; - } - if (newPop.getReligion().empty()) - { - if (dominantReligion) - newPop.setReligion(*dominantReligion); - else - continue; - } - toReturn.emplace_back(newPop); - } - } - return toReturn; -} - -int V3::PopManager::generatePopCountForNormalSubState(const std::shared_ptr& subState, int unassignedPopCount) const -{ - const auto& state = subState->getHomeState(); - const double subStateWeightRatio = *subState->getWeight() / state->getTotalSubStateWeight(); - - // Size doesn't matter, only weight does. If our weight is 100 (from combined dev etc), and entire state had 1000 weight, we get 10% pops - // regardles of how big the substate is. - - return static_cast(round(subStateWeightRatio * static_cast(unassignedPopCount))); -} - -int V3::PopManager::generatePopCountForShovedSubState(const std::shared_ptr& subState, int unassignedPopCount, int unassignedProvinces) const -{ - // TODO: Use a better method. Any method is better than this: - - const double subStateRatio = static_cast(subState->getProvinces().size()) / static_cast(unassignedProvinces); - return static_cast(round(subStateRatio * static_cast(unassignedPopCount))); -} - -void V3::PopManager::loadMinorityPopRules(const std::string& filePath) -{ - minorityPopMapper.loadMappingRules(filePath); -} - -void V3::PopManager::injectReligionsIntoVanillaPops(const std::map& cultureDefs) -{ - Log(LogLevel::Info) << "-> Injecting Religion into Vanilla Pops."; - vanillaStatePops = injectReligionsIntoPops(cultureDefs, vanillaStatePops); - Log(LogLevel::Info) << "<> Updated vanilla pops."; -} - -void V3::PopManager::injectReligionsIntoDWPops(const std::map& cultureDefs) -{ - Log(LogLevel::Info) << "-> Injecting Religion into Decentralized World Pops."; - dwStatePops = injectReligionsIntoPops(cultureDefs, dwStatePops); - Log(LogLevel::Info) << "<> Updated decentralized world pops."; -} - -std::map V3::PopManager::injectReligionsIntoPops(const std::map& cultureDefs, - const std::map& pops) -{ - std::map newVanillaPops; - for (const auto& [stateName, statePops]: pops) - { - StatePops newStatePops; - newStatePops.setStateName(stateName); - for (const auto& subStatePops: statePops.getSubStatePops()) - { - SubStatePops newSubStatePops; - newSubStatePops.setTag(subStatePops.getTag()); - for (const auto& pop: subStatePops.getPops()) - { - auto newPop = pop; - if (pop.getReligion().empty() && cultureDefs.contains(pop.getCulture())) - newPop.setReligion(cultureDefs.at(pop.getCulture()).religion); - - newSubStatePops.addPop(newPop); - } - newStatePops.addSubStatePops(newSubStatePops); - } - newVanillaPops.emplace(stateName, newStatePops); - } - return newVanillaPops; -} - -void V3::PopManager::loadSlaveCultureRules(const std::string& filePath) -{ - slaveCultureMapper.loadMappingRules(filePath); -} - -void V3::PopManager::liberateSlaves(const PoliticalManager& politicalManager) const -{ - Log(LogLevel::Info) << "-> Liberating slaves where it is banned."; - auto counter = 0; - - for (const auto& country: politicalManager.getCountries() | std::views::values) - { - if (!country->hasLaw("law_slavery_banned")) - continue; - for (const auto& subState: country->getSubStates()) - { - if (subState->getSubStatePops().getSlavePopCount() == 0) - continue; - auto newSubStatePops = subState->getSubStatePops(); - std::vector newPops; - for (const auto& pop: subState->getSubStatePops().getPops()) - { - if (pop.getType() == "slaves") - { - Pop newPop = pop; - newPop.setType(""); - newPops.emplace_back(newPop); - ++counter; - } - else - { - newPops.emplace_back(pop); - } - } - newSubStatePops.setPops(newPops); - subState->setSubStatePops(newSubStatePops); - } - } - Log(LogLevel::Info) << "<> Liberated " << counter << " Slave Pops."; -} - -void V3::PopManager::alterSlaveCultures(const PoliticalManager& politicalManager, - const ClayManager& clayManager, - const std::map& cultureDefs) const -{ - Log(LogLevel::Info) << "-> Updating Slave Pop Cultures."; - auto counter = 0; - - for (const auto& country: politicalManager.getCountries() | std::views::values) - { - std::set cultureTraits; - for (const auto& culture: country->getProcessedData().cultures) - { - if (!cultureDefs.contains(culture)) - continue; - const auto& traits = cultureDefs.at(culture).traits; - cultureTraits.insert(traits.begin(), traits.end()); - } - std::optional newSlaveCulture; - for (const auto& trait: cultureTraits) - if (slaveCultureMapper.getSlaveCulture(trait)) - { - newSlaveCulture = *slaveCultureMapper.getSlaveCulture(trait); - break; - } - if (!newSlaveCulture) - continue; - - for (const auto& subState: country->getSubStates()) - { - if (subState->getSubStatePops().getSlavePopCount() == 0) - continue; - const auto& stateName = subState->getHomeStateName(); - if (!clayManager.stateIsInRegion(stateName, "north_america_strategic_regions") && - !clayManager.stateIsInRegion(stateName, "south_america_strategic_regions")) - continue; - - auto newSubStatePops = subState->getSubStatePops(); - std::vector newPops; - for (const auto& pop: subState->getSubStatePops().getPops()) - { - if (pop.getType() == "slaves") - { - Pop newPop = pop; - newPop.setCulture(*newSlaveCulture); - newPops.emplace_back(newPop); - ++counter; - } - else - { - newPops.emplace_back(pop); - } - } - newSubStatePops.setPops(newPops); - subState->setSubStatePops(newSubStatePops); - } - } - Log(LogLevel::Info) << "<> Updated " << counter << " Slave Pops."; -} - -std::map V3::PopManager::getVanillaSuperRegionalPopCounts(const ClayManager& clayManager) const -{ - std::map toReturn; - - for (const auto& [superRegionName, superRegion]: clayManager.getSuperRegions()) - for (const auto& region: superRegion->getRegions() | std::views::values) - for (const auto& stateName: region->getStates() | std::views::keys) - if (vanillaStatePops.contains(stateName)) - toReturn[superRegionName] += vanillaStatePops.at(stateName).getPopCount(); - - return toReturn; -} - -std::map V3::PopManager::getVanillaSuperRegionalWeights(const ClayManager& clayManager) -{ - std::map toReturn; - - for (const auto& [superRegionName, superRegion]: clayManager.getSuperRegions()) - toReturn[superRegionName] = superRegion->getTotalSubStateWeight(); - - return toReturn; -} - -std::map V3::PopManager::getSuperRegionPopShapingProjections(const ClayManager& clayManager) const -{ - std::map toReturn; - for (const auto& [stateName, state]: clayManager.getStates()) - { - if (state->isSea() || state->isLake()) - continue; - const auto& superRegion = clayManager.getParentSuperRegion(stateName); - if (!superRegion) - continue; - if (!vanillaStatePops.contains(stateName)) - continue; - - const auto stateInvestmentFactor = 1.0 + state->getInvestmentFactor(); - const auto projectedPopCount = static_cast(static_cast(vanillaStatePops.at(stateName).getPopCount()) * stateInvestmentFactor); - toReturn[superRegion->getName()] += projectedPopCount; - } - return toReturn; -} diff --git a/EU5ToVic3/Source/V3World/PopManager/PopManager.h b/EU5ToVic3/Source/V3World/PopManager/PopManager.h deleted file mode 100644 index a396ad9..0000000 --- a/EU5ToVic3/Source/V3World/PopManager/PopManager.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef POP_MANAGER_H -#define POP_MANAGER_H -#include "Configuration.h" -#include "MinorityPopMapper/MinorityPopMapper.h" -#include "ModLoader/ModFilesystem.h" -#include "Pops/StatePops.h" -#include "SlaveCultureMapper/SlaveCultureMapper.h" -#include -#include -#include - -namespace EU4 -{ -class CultureLoader; -class ReligionLoader; -} // namespace EU4 -namespace mappers -{ -class CultureMapper; -class ReligionMapper; -struct CultureDef; -} // namespace mappers -namespace V3 -{ -class ClayManager; -class SubState; -class State; -class PoliticalManager; -class PopManager -{ - public: - PopManager() = default; - - void initializeVanillaPops(const commonItems::ModFilesystem& modFS); - void initializeDWPops(const commonItems::ModFilesystem& modFS); - void convertDemographics(const ClayManager& clayManager, - mappers::CultureMapper& cultureMapper, - const mappers::ReligionMapper& religionMapper, - const EU4::CultureLoader& cultureLoader, - const EU4::ReligionLoader& religionLoader) const; - void generatePops(const ClayManager& clayManager, Configuration::POPSHAPES popShapes, double shapingFactor); - void applyHomeLands(const ClayManager& clayManager) const; - void loadMinorityPopRules(const std::string& filePath); - void loadSlaveCultureRules(const std::string& filePath); - void injectReligionsIntoVanillaPops(const std::map& cultureDefs); - void injectReligionsIntoDWPops(const std::map& cultureDefs); - void liberateSlaves(const PoliticalManager& politicalManager) const; - void alterSlaveCultures(const PoliticalManager& politicalManager, - const ClayManager& clayManager, - const std::map& cultureDefs) const; - - [[nodiscard]] std::string getDominantVanillaCulture(const std::string& stateName) const; - [[nodiscard]] std::string getDominantVanillaReligion(const std::string& stateName) const; - [[nodiscard]] std::string getDominantDWCulture(const std::string& stateName) const; - [[nodiscard]] std::string getDominantDWReligion(const std::string& stateName) const; - [[nodiscard]] std::optional getVanillaSubStatePops(const std::string& stateName, const std::string& ownerTag) const; - [[nodiscard]] std::optional getDWSubStatePops(const std::string& stateName, const std::string& ownerTag) const; - - private: - void generatePopsForShovedSubStates(const std::shared_ptr& state, int unassignedPopCount, int unassignedProvinceCount) const; - void generatePopsForNormalSubStates(const std::shared_ptr& state, int unassignedPopCount, int unassignedSlavePopCount) const; - [[nodiscard]] int generatePopCountForShovedSubState(const std::shared_ptr& subState, int unassignedPopCount, int unassignedProvinces) const; - [[nodiscard]] int generatePopCountForNormalSubState(const std::shared_ptr& subState, int unassignedPopCount) const; - void filterVanillaMinorityStatePops(); - [[nodiscard]] std::vector generateMinorityPops(const std::string& stateName, - double neededPopSizeTotal, - const std::optional& dominantCulture, - const std::optional& dominantReligion) const; - [[nodiscard]] static std::map injectReligionsIntoPops(const std::map& cultureDefs, - const std::map& pops); - [[nodiscard]] std::map getVanillaSuperRegionalPopCounts(const ClayManager& clayManager) const; - [[nodiscard]] static std::map getVanillaSuperRegionalWeights(const ClayManager& clayManager); - [[nodiscard]] std::map getSuperRegionPopShapingProjections(const ClayManager& clayManager) const; - - std::map vanillaStatePops; // state, StatePops - std::map vanillaMinorityStatePops; // state, StatePops - std::map dwStatePops; // decentralized world - used for shoved and imported states only! - - mappers::MinorityPopMapper minorityPopMapper; - mappers::SlaveCultureMapper slaveCultureMapper; -}; -} // namespace V3 -#endif // POP_MANAGER_H diff --git a/EU5ToVic3/Source/V3World/PopManager/PopPoints.h b/EU5ToVic3/Source/V3World/PopManager/PopPoints.h deleted file mode 100644 index 4af68fb..0000000 --- a/EU5ToVic3/Source/V3World/PopManager/PopPoints.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef V3_POP_POINTS_H -#define V3_POP_POINTS_H - -namespace V3 -{ -struct PopPoints -{ - double academics = 0; - double aristocrats = 0; - double bureaucrats = 0; - double capitalists = 0; - double clergymen = 0; - double clerks = 0; - double engineers = 0; - // no farmers. They are default. - double laborers = 0; - double machinists = 0; - double officers = 0; - double peasants = 0; - double shopkeepers = 0; - double slaves = 0; - double soldiers = 0; -}; -} // namespace V3 - -#endif // V3_POP_POINTS_H diff --git a/EU5ToVic3/Source/V3World/PopManager/Pops/Pop.h b/EU5ToVic3/Source/V3World/PopManager/Pops/Pop.h deleted file mode 100644 index e84c8dd..0000000 --- a/EU5ToVic3/Source/V3World/PopManager/Pops/Pop.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef POP_H -#define POP_H -#include - -namespace V3 -{ -class Pop -{ - public: - Pop() = default; - Pop(std::string culture, std::string religion, std::string type, int size): - culture(std::move(culture)), religion(std::move(religion)), type(std::move(type)), size(size) - { - } - bool operator==(const Pop& rhs) const { return culture == rhs.culture && religion == rhs.religion && type == rhs.type; } - - [[nodiscard]] const auto& getCulture() const { return culture; } - [[nodiscard]] const auto& getReligion() const { return religion; } - [[nodiscard]] const auto& getType() const { return type; } - [[nodiscard]] auto getSize() const { return size; } - [[nodiscard]] auto isMinority() const { return minority; } - - void setCulture(const std::string& theCulture) { culture = theCulture; } - void setReligion(const std::string& theReligion) { religion = theReligion; } - void setType(const std::string& theType) { type = theType; } - void setSize(int theSize) { size = theSize; } - void blankReligion() { religion.clear(); } - void blankCulture() { culture.clear(); } - void setMinority() { minority = true; } - - private: - std::string culture; - std::string religion; - std::string type; - int size = 0; - bool minority = false; // Minorities tend to persist unaltered. -}; -} // namespace V3 -#endif // POP_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/PopManager/Pops/StatePops.cpp b/EU5ToVic3/Source/V3World/PopManager/Pops/StatePops.cpp deleted file mode 100644 index 2e5e4d7..0000000 --- a/EU5ToVic3/Source/V3World/PopManager/Pops/StatePops.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "StatePops.h" -#include -#include -#include - -int V3::StatePops::getPopCount() const -{ - return std::accumulate(subStatePops.begin(), subStatePops.end(), 0, [](int sum, const auto& subStatePop) { - return sum + subStatePop.getPopCount(); - }); -} - -int V3::StatePops::getSlavePopCount() const -{ - return std::accumulate(subStatePops.begin(), subStatePops.end(), 0, [](int sum, const auto& subStatePop) { - return sum + subStatePop.getSlavePopCount(); - }); -} - -std::optional V3::StatePops::getDominantCulture() const -{ - std::map cultureCounts; - - for (const auto& subStatePop: subStatePops) - for (const auto& pop: subStatePop.getPops()) - { - if (pop.getCulture().empty()) - continue; - if (cultureCounts.contains(pop.getCulture())) - cultureCounts.at(pop.getCulture()) += pop.getSize(); - else - cultureCounts.emplace(pop.getCulture(), pop.getSize()); - } - - if (cultureCounts.empty()) - return std::nullopt; - - const auto highest = std::max_element(std::begin(cultureCounts), std::end(cultureCounts), [](const auto& p1, const auto& p2) { - return p1.second < p2.second; - }); - - return highest->first; -} - -std::optional V3::StatePops::getDominantReligion() const -{ - std::map religionCounts; - - for (const auto& subStatePop: subStatePops) - for (const auto& pop: subStatePop.getPops()) - { - if (pop.getReligion().empty()) - continue; - if (religionCounts.contains(pop.getReligion())) - religionCounts.at(pop.getReligion()) += pop.getSize(); - else - religionCounts.emplace(pop.getReligion(), pop.getSize()); - } - - if (religionCounts.empty()) - return std::nullopt; - - const auto highest = std::max_element(std::begin(religionCounts), std::end(religionCounts), [](const auto& p1, const auto& p2) { - return p1.second < p2.second; - }); - - return highest->first; -} diff --git a/EU5ToVic3/Source/V3World/PopManager/Pops/StatePops.h b/EU5ToVic3/Source/V3World/PopManager/Pops/StatePops.h deleted file mode 100644 index be91f26..0000000 --- a/EU5ToVic3/Source/V3World/PopManager/Pops/StatePops.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef STATE_POPS_H -#define STATE_POPS_H -#include "SubStatePops.h" -#include -#include -#include - -namespace V3 -{ -class StatePops -{ - public: - StatePops() = default; - - void setSubStatePops(const std::vector& thePops) { subStatePops = thePops; } - void addSubStatePops(const SubStatePops& thePops) { subStatePops.emplace_back(thePops); } - void setStateName(const std::string& theName) { stateName = theName; } - - [[nodiscard]] int getPopCount() const; - [[nodiscard]] int getSlavePopCount() const; - [[nodiscard]] const auto& getSubStatePops() const { return subStatePops; } - [[nodiscard]] const auto& getStateName() const { return stateName; } - - [[nodiscard]] std::optional getDominantCulture() const; - [[nodiscard]] std::optional getDominantReligion() const; - - private: - std::string stateName; - std::vector subStatePops; -}; -} // namespace V3 -#endif // STATE_POPS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/PopManager/Pops/SubStatePops.cpp b/EU5ToVic3/Source/V3World/PopManager/Pops/SubStatePops.cpp deleted file mode 100644 index 1204f65..0000000 --- a/EU5ToVic3/Source/V3World/PopManager/Pops/SubStatePops.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "SubStatePops.h" -#include -#include -#include -#include - -int V3::SubStatePops::getPopCount() const -{ - return std::accumulate(pops.begin(), pops.end(), 0, [](int sum, const auto& pop) { - return sum + pop.getSize(); - }); -} - -int V3::SubStatePops::getSlavePopCount() const -{ - return std::accumulate(pops.begin(), pops.end(), 0, [](int sum, const auto& pop) { - if (pop.getType() == "slaves") - return sum + pop.getSize(); - else - return sum; - }); -} - -std::optional V3::SubStatePops::getDominantCulture() const -{ - std::map cultureCounts; - - for (const auto& pop: pops) - { - if (pop.getCulture().empty()) - continue; - if (cultureCounts.contains(pop.getCulture())) - cultureCounts.at(pop.getCulture()) += pop.getSize(); - else - cultureCounts.emplace(pop.getCulture(), pop.getSize()); - } - - if (cultureCounts.empty()) - return std::nullopt; - - const auto highest = std::max_element(std::begin(cultureCounts), std::end(cultureCounts), [](const auto& p1, const auto& p2) { - return p1.second < p2.second; - }); - - return highest->first; -} - -std::optional V3::SubStatePops::getDominantReligion() const -{ - std::map religionCounts; - - for (const auto& pop: pops) - { - if (pop.getReligion().empty()) - continue; - if (religionCounts.contains(pop.getReligion())) - religionCounts.at(pop.getReligion()) += pop.getSize(); - else - religionCounts.emplace(pop.getReligion(), pop.getSize()); - } - - if (religionCounts.empty()) - return std::nullopt; - - const auto highest = std::max_element(std::begin(religionCounts), std::end(religionCounts), [](const auto& p1, const auto& p2) { - return p1.second < p2.second; - }); - - return highest->first; -} - -void V3::SubStatePops::multiplyPops(double factor) -{ - std::vector replacementPops; - for (const auto& pop: pops) - { - auto newPop = pop; - newPop.setSize(static_cast(std::round(pop.getSize() * factor))); - replacementPops.push_back(newPop); - } - pops.swap(replacementPops); -} diff --git a/EU5ToVic3/Source/V3World/PopManager/Pops/SubStatePops.h b/EU5ToVic3/Source/V3World/PopManager/Pops/SubStatePops.h deleted file mode 100644 index 3e39246..0000000 --- a/EU5ToVic3/Source/V3World/PopManager/Pops/SubStatePops.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef SUB_STATE_POPS_H -#define SUB_STATE_POPS_H -#include "Pop.h" -#include -#include -#include - -namespace V3 -{ -class SubStatePops -{ - public: - SubStatePops() = default; - - void setPops(const std::vector& thePops) { pops = thePops; } - void addPop(const Pop& pop) { pops.push_back(pop); } - void addPops(const std::vector& thePops) { pops.insert(pops.end(), thePops.begin(), thePops.end()); } - void setTag(const std::string& theTag) { tag = theTag; } - void multiplyPops(double factor); - - [[nodiscard]] int getPopCount() const; - [[nodiscard]] int getSlavePopCount() const; - [[nodiscard]] const auto& getPops() const { return pops; } - [[nodiscard]] const auto& getTag() const { return tag; } - - [[nodiscard]] std::optional getDominantCulture() const; - [[nodiscard]] std::optional getDominantReligion() const; - - private: - std::string tag; - std::vector pops; -}; -} // namespace V3 -#endif // SUB_STATE_POPS_H \ No newline at end of file diff --git a/EU5ToVic3/Source/V3World/V3World.cpp b/EU5ToVic3/Source/V3World/V3World.cpp index 64b1da1..2396d4e 100644 --- a/EU5ToVic3/Source/V3World/V3World.cpp +++ b/EU5ToVic3/Source/V3World/V3World.cpp @@ -2,13 +2,12 @@ #include "EU5World/World.h" #include "Log.h" -V3::World::World(const Configuration& configuration, const EU4::World& sourceWorld): +V3::World::World(const Configuration& configuration, const EU5::World& sourceWorld): V3Path(configuration.getVic3Path()), configBlock(configuration.configBlock), datingData(sourceWorld.getDatingData()) { Mods overrideMods; // We use decentralized world mod to fill out wasteland and out-of-scope clay with decentralized tribes. - if (!configuration.configBlock.vn) - overrideMods.emplace_back(Mod{"Decentralized World", "configurables/decentralized_world/"}); + overrideMods.emplace_back(Mod{"Decentralized World", "configurables/decentralized_world/"}); const auto vanillaFS = commonItems::ModFilesystem(V3Path, {}); const auto dwFS = commonItems::ModFilesystem(V3Path, overrideMods); overrideMods.emplace_back(Mod{"Blankmod", "blankMod/output/"}); @@ -19,190 +18,64 @@ V3::World::World(const Configuration& configuration, const EU4::World& sourceWor Log(LogLevel::Progress) << "45 %"; Log(LogLevel::Info) << "* Soaking up the shine *"; - clayManager.loadAdjacencies("configurables/province_adjacencies.txt"); - clayManager.initializeVanillaStates(dwFS); - clayManager.loadTerrainsIntoProvinces(dwFS); - clayManager.initializeSuperRegions(dwFS); - clayManager.loadStatesIntoSuperRegions(); - if (configuration.configBlock.vn) - { - provinceMapper.loadProvinceMappings("configurables/vn_province_mappings.txt"); - clayManager.loadVNColonialRules("configurables/vn_colonial.txt"); - } - else - { - provinceMapper.loadProvinceMappings("configurables/province_mappings.txt"); - } - countryMapper = std::make_shared(); - countryMapper->loadMappingRules("configurables/country_mappings.txt"); - religionMapper.loadMappingRules("configurables/religion_map.txt"); - religionMapper.expandReligionMappings(sourceWorld.getReligionLoader().getAllReligions()); - religionMapper.generateReligionDefinitions(allFS, - "configurables/religion_group_map.txt", - sourceWorld.getReligionLoader().getAllReligions(), - sourceWorld.getEU4Localizations()); - cultureMapper.loadMappingRules("configurables/culture_map.txt"); - cultureMapper.loadColonialRules("configurables/colonial_regions.txt"); - cultureMapper.loadWesternizationRules("configurables/westernization.txt"); - politicalManager.loadPopulationSetupMapperRules("configurables/population_setup.txt"); - politicalManager.loadIdeaEffectMapperRules("configurables/idea_effects.txt"); - politicalManager.loadTechSetupMapperRules("configurables/tech_setup.txt"); - politicalManager.loadLawMapperRules("configurables/law_map.txt"); - politicalManager.loadLawDefinitions(dwFS); - politicalManager.loadDiplomaticMapperRules("configurables/diplomatic_map.txt"); - politicalManager.loadCharacterTraitMapperRules("configurables/character_traits.txt"); - politicalManager.loadColonialTagMapperRules("configurables/colonial_tags.txt"); - politicalManager.loadCountryTierMapperRules("configurables/country_tiers.txt"); - politicalManager.loadMajorFormables("blankMod/output/common/country_formation/00_major_formables.txt"); - politicalManager.loadIGIdeologiesMapperRules("configurables/ig_ideologies.txt"); - politicalManager.loadAIStrategies("configurables/ai_strategy_map.txt"); - politicalManager.loadAISecretGoals("configurables/ai_secret_goal_map.txt"); - popManager.loadMinorityPopRules("configurables/minority_pops.txt"); - popManager.loadSlaveCultureRules("configurables/slave_culture_map.txt"); - cultureMapper.expandCulturalMappings(clayManager, sourceWorld.getCultureLoader(), sourceWorld.getReligionLoader()); - localizationLoader.scrapeLocalizations(dwFS); - vanillaLocalizationLoader.scrapeLocalizations(blankModFS); - cultureMapper.loadCultureDefinitions(allFS); - cultureMapper.loadTraitDefinitions(allFS); - economyManager.loadMappersAndConfigs(allFS); Log(LogLevel::Info) << "*** Hello Vicky 3, creating world. ***"; Log(LogLevel::Progress) << "46 %"; // chunks and substate generation - clayManager.generateChunks(provinceMapper, sourceWorld.getProvinceManager()); - clayManager.unDisputeChunkOwnership(sourceWorld.getCountryManager().getCountries()); - clayManager.splitChunksIntoSubStates(); Log(LogLevel::Progress) << "47 %"; // initializing countries from eu4 and vanilla - politicalManager.initializeVanillaCountries(dwFS, vanillaFS); - politicalManager.loadCountryMapper(countryMapper); - politicalManager.importEU4Countries(sourceWorld.getCountryManager().getCountries()); Log(LogLevel::Progress) << "48 %"; // assigning clay to countries - clayManager.assignSubStateOwnership(politicalManager.getCountries(), *countryMapper); Log(LogLevel::Progress) << "49 %"; // soaking up vanilla pops - popManager.initializeVanillaPops(vanillaFS); - popManager.initializeDWPops(dwFS); - popManager.injectReligionsIntoVanillaPops(cultureMapper.getV3CultureDefinitions()); - popManager.injectReligionsIntoDWPops(cultureMapper.getV3CultureDefinitions()); // inject vanilla substates into map holes. - clayManager.injectVanillaSubStates(dwFS, politicalManager, popManager, configBlock.vn); Log(LogLevel::Progress) << "50 %"; // handling demographics - popManager.convertDemographics(clayManager, cultureMapper, religionMapper, sourceWorld.getCultureLoader(), sourceWorld.getReligionLoader()); Log(LogLevel::Progress) << "51 %"; // generating decentralized countries - clayManager.shoveRemainingProvincesIntoSubStates(); - politicalManager.generateDecentralizedCountries(clayManager, popManager); Log(LogLevel::Progress) << "52 %"; // converting all 3 types of countries - generated decentralized, extinct/extant-VN vanilla-only, and EU4 imports. - politicalManager.convertAllCountries(clayManager, - cultureMapper, - religionMapper, - sourceWorld.getCultureLoader(), - sourceWorld.getReligionLoader(), - localizationLoader, - sourceWorld.getEU4Localizations(), - configBlock.downTiers, - configBlock.vn); Log(LogLevel::Progress) << "53 %"; - politicalManager.attemptColonialTagReplacement(cultureMapper.getColonialRegionMapper(), clayManager); Log(LogLevel::Progress) << "54 %"; - popManager.generatePops(clayManager, configBlock.popShaping, configBlock.shapingFactor); - popManager.applyHomeLands(clayManager); Log(LogLevel::Progress) << "55 %"; - cultureMapper.generateCultureDefinitions("configurables/name_lists.txt", - "configurables/name_list_map.txt", - "configurables/culture_trait_map.txt", - clayManager, - sourceWorld.getCultureLoader(), - sourceWorld.getReligionLoader(), - sourceWorld.getEU4Localizations()); Log(LogLevel::Progress) << "56 %"; - politicalManager.determineAndApplyWesternization(cultureMapper, religionMapper, configBlock.euroCentric, configBlock.startDate, datingData); Log(LogLevel::Progress) << "57 %"; - politicalManager.setupTech(); Log(LogLevel::Progress) << "58 %"; - politicalManager.setupLaws(); - politicalManager.convertDiplomacy(sourceWorld.getDiplomacy().getAgreements()); - politicalManager.convertRivals(); - politicalManager.convertTruces(datingData.lastEU4Date); - if (configuration.configBlock.vn) - { - politicalManager.importVNColonialDiplomacy(clayManager); - politicalManager.importVanillaDiplomacy(); - } Log(LogLevel::Progress) << "59 %"; - clayManager.squashAllSubStates(politicalManager); Log(LogLevel::Progress) << "60 %"; - clayManager.redistributeResourcesAndLandshares(); Log(LogLevel::Progress) << "61 %"; - cultureMapper.injectReligionsIntoCultureDefs(clayManager); Log(LogLevel::Progress) << "62 %"; - politicalManager.convertCharacters(datingData.lastEU4Date, - configBlock.startDate, - clayManager, - cultureMapper, - religionMapper, - sourceWorld.getCultureLoader(), - sourceWorld.getReligionLoader()); Log(LogLevel::Progress) << "63 %"; - flagCrafter.loadCustomColors(configuration.getEU4Path() + "/common/custom_country_colors/00_custom_country_colors.txt"); - flagCrafter.loadAvailableFlags("blankMod/output/common/coat_of_arms/coat_of_arms/", V3Path + "/common/flag_definitions/"); Log(LogLevel::Progress) << "64 %"; - flagCrafter.distributeAvailableFlags(politicalManager.getCountries(), *countryMapper, sourceWorld.getEU4ModFS()); Log(LogLevel::Progress) << "65 %"; - politicalManager.injectDynamicCulturesIntoFormables(cultureMapper); Log(LogLevel::Progress) << "66 %"; - politicalManager.expandReleasablesFootprint(clayManager); - politicalManager.alterReleasablesReligion(); Log(LogLevel::Progress) << "67 %"; - politicalManager.alterMajorFormables(); Log(LogLevel::Progress) << "68 %"; - clayManager.filterInvalidClaims(politicalManager); Log(LogLevel::Progress) << "69 %"; - politicalManager.alterIGIdeologies(cultureMapper, religionMapper, clayManager); - politicalManager.generateAIStrategies(clayManager); - politicalManager.generateAISecretGoals(clayManager); Log(LogLevel::Progress) << "70 %"; - popManager.liberateSlaves(politicalManager); - popManager.alterSlaveCultures(politicalManager, clayManager, cultureMapper.getV3CultureDefinitions()); - - politicalManager.incorporateStates(cultureMapper, clayManager); - politicalManager.designateTreatyPorts(clayManager); - politicalManager.distributeColonialClaims(clayManager); // Place starting buildings for all centralized countries Log(LogLevel::Progress) << "71 %"; - economyManager.loadCentralizedStates(politicalManager.getCountries()); Log(LogLevel::Progress) << "72 %"; - economyManager.establishBureaucracy(politicalManager); Log(LogLevel::Progress) << "73 %"; - economyManager.hardcodePorts(); Log(LogLevel::Progress) << "74 %"; - economyManager.assignCountryCPBudgets(configBlock.economy, configBlock.startDate, datingData, politicalManager, configBlock.vn); - economyManager.balanceNationalBudgets(); Log(LogLevel::Progress) << "75 %"; - economyManager.assignSubStateCPBudgets(configBlock.economy); Log(LogLevel::Progress) << "76 %"; - economyManager.buildBuildings(politicalManager.getLawsMap()); - economyManager.setPMs(); Log(LogLevel::Info) << "*** Goodbye, Vicky 3, and godspeed. ***"; } diff --git a/EU5ToVic3/Source/V3World/V3World.h b/EU5ToVic3/Source/V3World/V3World.h index c8a5241..51288fb 100644 --- a/EU5ToVic3/Source/V3World/V3World.h +++ b/EU5ToVic3/Source/V3World/V3World.h @@ -1,18 +1,9 @@ #ifndef V3_WORLD_H #define V3_WORLD_H -#include "ClayManager/ClayManager.h" #include "Configuration.h" -#include "CountryMapper/CountryMapper.h" -#include "CultureMapper/CultureMapper.h" -#include "EconomyManager/EconomyManager.h" -#include "FlagCrafter/FlagCrafter.h" -#include "Loaders/LocLoader/LocalizationLoader.h" -#include "PoliticalManager/PoliticalManager.h" -#include "PopManager/PopManager.h" -#include "ProvinceMapper/ProvinceMapper.h" -#include "ReligionMapper/ReligionMapper.h" +#include "DatingData.h" -namespace EU4 +namespace EU5 { class World; } @@ -22,32 +13,15 @@ namespace V3 class World { public: - World(const Configuration& configuration, const EU4::World& sourceWorld); + World(const Configuration& configuration, const EU5::World& sourceWorld); - [[nodiscard]] const auto& getClayManager() const { return clayManager; } - [[nodiscard]] const auto& getPoliticalManager() const { return politicalManager; } - [[nodiscard]] const auto& getCultureMapper() const { return cultureMapper; } - [[nodiscard]] const auto& getReligionMapper() const { return religionMapper; } - [[nodiscard]] const auto& getDatingData() const { return datingData; } - [[nodiscard]] const auto& getVanillaLocalizations() const { return vanillaLocalizationLoader; } + [[nodiscard]] const auto& getDatingData() const { return datingData; } private: std::string V3Path; Configuration::ConfigBlock configBlock; DatingData datingData; - ClayManager clayManager; - PoliticalManager politicalManager; - PopManager popManager; - EconomyManager economyManager; - LocalizationLoader localizationLoader; - LocalizationLoader vanillaLocalizationLoader; - - mappers::ProvinceMapper provinceMapper; - mappers::ReligionMapper religionMapper; - mappers::CultureMapper cultureMapper; - std::shared_ptr countryMapper; - FlagCrafter flagCrafter; }; } // namespace V3 diff --git a/EU5ToVic3Tests/ConfigurationTests/ConfigurationTests.cpp b/EU5ToVic3Tests/ConfigurationTests/ConfigurationTests.cpp index 2411abb..28d9446 100644 --- a/EU5ToVic3Tests/ConfigurationTests/ConfigurationTests.cpp +++ b/EU5ToVic3Tests/ConfigurationTests/ConfigurationTests.cpp @@ -4,7 +4,7 @@ TEST(ConfigurationTests, BrokenEU4PathThrowsException) { std::stringstream configurationInput; - configurationInput << "EU4directory = \"TestFiles/eu4installationBROKE\"\n"; + configurationInput << "EU5directory = \"TestFiles/eu5installationBROKE\"\n"; configurationInput << "Vic3directory = \"TestFiles/vic3installation\"\n"; const commonItems::ConverterVersion converterVersion; @@ -14,7 +14,7 @@ TEST(ConfigurationTests, BrokenEU4PathThrowsException) TEST(ConfigurationTests, BrokenVic3PathThrowsException) { std::stringstream configurationInput; - configurationInput << "EU4directory = \"TestFiles/eu4installation\"\n"; + configurationInput << "EU5directory = \"TestFiles/eu5installation\"\n"; configurationInput << "Vic3directory = \"TestFiles/vic3installationBROKE\"\n"; const commonItems::ConverterVersion converterVersion; @@ -24,35 +24,35 @@ TEST(ConfigurationTests, BrokenVic3PathThrowsException) TEST(ConfigurationTests, InstallationPathsCanBeUpdatedRetrieved) { std::stringstream configurationInput; - configurationInput << "EU4directory = \"TestFiles/eu4installation\"\n"; + configurationInput << "EU5directory = \"TestFiles/eu5installation\"\n"; configurationInput << "Vic3directory = \"TestFiles/vic3installation\"\n"; // updated with "/game/" const commonItems::ConverterVersion converterVersion; const auto configuration = Configuration(configurationInput, converterVersion); - EXPECT_EQ("TestFiles/eu4installation", configuration.getEU4Path()); + EXPECT_EQ("TestFiles/eu5installation", configuration.getEU5Path()); EXPECT_EQ("TestFiles/vic3installation/game/", configuration.getVic3Path()); } TEST(ConfigurationTests, SaveAndDocumentsPathCanBeRetrieved) { std::stringstream configurationInput; - configurationInput << "EU4directory = \"TestFiles/eu4installation\"\n"; + configurationInput << "EU5directory = \"TestFiles/eu5installation\"\n"; configurationInput << "Vic3directory = \"TestFiles/vic3installation\"\n"; - configurationInput << "EU4DocumentsDirectory = \"TestFiles\"\n"; - configurationInput << "SaveGame = \"C:\\autosave.eu4\"\n"; + configurationInput << "EU5DocumentsDirectory = \"TestFiles\"\n"; + configurationInput << "SaveGame = \"C:\\autosave.eu5\"\n"; const commonItems::ConverterVersion converterVersion; const auto configuration = Configuration(configurationInput, converterVersion); - EXPECT_EQ("TestFiles", configuration.getEU4DocumentsPath()); - EXPECT_EQ("C:\\autosave.eu4", configuration.getEU4SaveGamePath()); + EXPECT_EQ("TestFiles", configuration.getEU5DocumentsPath()); + EXPECT_EQ("C:\\autosave.eu5", configuration.getEU5SaveGamePath()); } TEST(ConfigurationTests, OutputNameNormalizesSetsFromSavegameName) { std::stringstream configurationInput; - configurationInput << "EU4directory = \"TestFiles/eu4installation\"\n"; + configurationInput << "EU5directory = \"TestFiles/eu5installation\"\n"; configurationInput << "Vic3directory = \"TestFiles/vic3installation\"\n"; - configurationInput << "SaveGame = \"C:\\autosave.eu4\"\n"; + configurationInput << "SaveGame = \"C:\\autosave.eu5\"\n"; const commonItems::ConverterVersion converterVersion; const auto configuration = Configuration(configurationInput, converterVersion); @@ -62,9 +62,9 @@ TEST(ConfigurationTests, OutputNameNormalizesSetsFromSavegameName) TEST(ConfigurationTests, OutputNameNormalizesItselfFromSavegameName) { std::stringstream configurationInput; - configurationInput << "EU4directory = \"TestFiles/eu4installation\"\n"; + configurationInput << "EU5directory = \"TestFiles/eu5installation\"\n"; configurationInput << "Vic3directory = \"TestFiles/vic3installation\"\n"; - configurationInput << "SaveGame = \"C:\\autosave - something.eu4\"\n"; + configurationInput << "SaveGame = \"C:\\autosave - something.eu5\"\n"; const commonItems::ConverterVersion converterVersion; const auto configuration = Configuration(configurationInput, converterVersion); @@ -74,9 +74,9 @@ TEST(ConfigurationTests, OutputNameNormalizesItselfFromSavegameName) TEST(ConfigurationTests, OutputNameSetsFromOverrideName) { std::stringstream configurationInput; - configurationInput << "EU4directory = \"TestFiles/eu4installation\"\n"; + configurationInput << "EU5directory = \"TestFiles/eu5installation\"\n"; configurationInput << "Vic3directory = \"TestFiles/vic3installation\"\n"; - configurationInput << "SaveGame = \"C:\\autosave.eu4\"\n"; + configurationInput << "SaveGame = \"C:\\autosave.eu5\"\n"; configurationInput << "output_name = \"ddd\"\n"; const commonItems::ConverterVersion converterVersion; const auto configuration = Configuration(configurationInput, converterVersion); @@ -87,9 +87,9 @@ TEST(ConfigurationTests, OutputNameSetsFromOverrideName) TEST(ConfigurationTests, OutputNameNormalizesItselfFromOverrideName) { std::stringstream configurationInput; - configurationInput << "EU4directory = \"TestFiles/eu4installation\"\n"; + configurationInput << "EU5directory = \"TestFiles/eu5installation\"\n"; configurationInput << "Vic3directory = \"TestFiles/vic3installation\"\n"; - configurationInput << "SaveGame = \"C:\\autosave - something.eu4\"\n"; + configurationInput << "SaveGame = \"C:\\autosave - something.eu5\"\n"; configurationInput << "output_name = \"ddd - something\"\n"; const commonItems::ConverterVersion converterVersion; const auto configuration = Configuration(configurationInput, converterVersion); diff --git a/EU5ToVic3Tests/EU5ToVic3Tests.vcxproj b/EU5ToVic3Tests/EU5ToVic3Tests.vcxproj index ed67ae6..01d49c9 100644 --- a/EU5ToVic3Tests/EU5ToVic3Tests.vcxproj +++ b/EU5ToVic3Tests/EU5ToVic3Tests.vcxproj @@ -72,216 +72,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Document - $(OutDir)/TestFiles/eu4installation - - - - - $(OutDir)/TestFiles/eu4installation/common/countries - - - $(OutDir)/TestFiles/eu4installation/common/countries - - - - - $(OutDir)/TestFiles/eu4installation/common/country_tags - - - - - $(OutDir)/TestFiles/eu4installation/map - @@ -305,12 +96,6 @@ $(OutDir)/TestFiles/vic3installation/binaries - - - Document - $(OutDir)/TestFiles/eu4installation - - Document @@ -367,29 +152,6 @@ $(OutDir)/TestFiles/configurables - - - Document - $(OutDir)/TestFiles/eu4installation/map - - - - - Document - $(OutDir)/TestFiles/eu4installation/map - - - - - $(OutDir)/TestFiles/eu4installation/map - - - $(OutDir)/TestFiles/eu4installation/map - - - $(OutDir)/TestFiles/eu4installation/map - - $(OutDir)/TestFiles/vic3installation/game/map_data/state_regions @@ -411,11 +173,6 @@ $(OutDir)/TestFiles/configurables - - - $(OutDir)/TestFiles/eu4installation/common/religions - - $(OutDir)/TestFiles/mod/themod/common/religions @@ -442,11 +199,6 @@ $(OutDir)/TestFiles/configurables - - - $(OutDir)/TestFiles/eu4installation/common/cultures - - Document @@ -550,11 +302,6 @@ $(OutDir)/TestFiles/configurables/blankMod/output/common/coat_of_arms/coat_of_arms - - - $(OutDir)/TestFiles/eu4installation/common/custom_country_colors - - $(OutDir)/TestFiles/vic3installation/game/common/flag_definitions @@ -693,11 +440,6 @@ $(OutDir)/TestFiles/configurables - - - $(OutDir)/TestFiles/eu4installation/common/trade_companies - - $(OutDir)/TestFiles/configurables/economy @@ -721,6 +463,21 @@ $(OutDir)/TestFiles/vic3installation/game/common/discrimination_traits/ + + + Document + $(OutDir)/TestFiles/eu5installation + + + Document + $(OutDir)/TestFiles/eu5installation + + + + + $(OutDir)/TestFiles/eu5installation/map + + diff --git a/EU5ToVic3Tests/EU5ToVic3Tests.vcxproj.filters b/EU5ToVic3Tests/EU5ToVic3Tests.vcxproj.filters index 5021c1c..24496dc 100644 --- a/EU5ToVic3Tests/EU5ToVic3Tests.vcxproj.filters +++ b/EU5ToVic3Tests/EU5ToVic3Tests.vcxproj.filters @@ -1,569 +1,14 @@  - - EU5WorldTests\RegionManagerTests - - - EU5WorldTests\RegionManagerTests - - - EU5WorldTests\RegionManagerTests - - - EU5WorldTests\RegionManagerTests - - - EU5WorldTests\ProvinceManagerTests - - - EU5WorldTests\ProvinceManagerTests - - - EU5WorldTests\ProvinceManagerTests - - - EU5WorldTests\ProvinceManagerTests - - - EU5WorldTests\ProvinceManagerTests - - - EU5WorldTests\ProvinceManagerTests - - - MapperTests\SuperGroupMapperTests - - - MapperTests\SuperGroupMapperTests - - - MapperTests\SuperGroupMapperTests - - - EU5WorldTests\LoaderTests\BuildingCostLoaderTests - - - EU5WorldTests\LoaderTests\BuildingCostLoaderTests - - - EU5WorldTests\LoaderTests\CultureLoaderTests - - - EU5WorldTests\LoaderTests\CultureLoaderTests - - - EU5WorldTests\LoaderTests\CultureLoaderTests - - - EU5WorldTests\LoaderTests\DefaultMapParserTests - - - EU5WorldTests\LoaderTests\DefinitionScraperTests - - - EU5WorldTests\LoaderTests\ModLoaderTests - - - EU5WorldTests\LoaderTests\ReligionLoaderTests - - - EU5WorldTests\LoaderTests\ReligionLoaderTests - - - EU5WorldTests\LoaderTests\UnitTypeLoaderTests - - - EU5WorldTests\LoaderTests\UnitTypeLoaderTests - - - EU5WorldTests\CountryManagerTests\CountryArmyTests - - - EU5WorldTests\CountryManagerTests\CountryArmyTests - - - EU5WorldTests\CountryManagerTests\CountryGovernmentTests - - - EU5WorldTests\CountryManagerTests\CountryGovernmentTests - - - EU5WorldTests\CountryManagerTests\CountryLeaderTests - - - EU5WorldTests\CountryManagerTests\CountryLeaderTests - - - EU5WorldTests\CountryManagerTests\CountryHistoryTests - - - EU5WorldTests\CountryManagerTests\CountryHistoryTests - - - EU5WorldTests\CountryManagerTests\CountryRelationsTests - - - EU5WorldTests\CountryManagerTests\CountryRelationsTests - - - EU5WorldTests\CountryManagerTests\NationalSymbolTests - - - EU5WorldTests\CountryManagerTests\NationalSymbolTests - - - EU5WorldTests\CountryManagerTests - - - EU5WorldTests\CountryManagerTests - - - EU5WorldTests\CountryManagerTests - - - EU5WorldTests\CountryManagerTests - - - EU5WorldTests\CountryManagerTests - - - EU5WorldTests\CountryManagerTests - - - EU5WorldTests\CountryManagerTests - - - EU5WorldTests\EmpireParserTests - - - MapperTests\NationMergeMapperTests - - - MapperTests\NationMergeMapperTests - - - EU5WorldTests\DiplomacyParserTests - - - EU5WorldTests\DiplomacyParserTests - - - EU5WorldTests\WarParserTests - - - EU5WorldTests\WarParserTests - - - EU5WorldTests\LoaderTests\LocalizationLoaderTests - - - EU5WorldTests\LoaderTests\CommonCountryLoaderTests - ConfigurationTests - - EU5WorldTests\LoaderTests\ColonialRegionLoaderTests - - - EU5WorldTests\LoaderTests\ColonialRegionLoaderTests - - - V3WorldTests\ClayManagerTests - - - MapperTests\ProvinceMapperTests - - - MapperTests\ProvinceMapperTests - - - MapperTests\ProvinceMapperTests - - - V3WorldTests\PoliticalManagerTests - - - MapperTests\CountryMapperTests - - - MapperTests\CountryMapperTests - - - MapperTests\ReligionMapperTests - - - MapperTests\ReligionMapperTests - - - MapperTests\CultureMapperTests - - - MapperTests\CultureMapperTests - - - V3WorldTests\PopManagerTests - - - V3WorldTests\LoaderTests\LocalizationLoaderTests - - - V3WorldTests\ClayManagerTests\StateTests - - - V3WorldTests\ClayManagerTests\StateTests - - - V3WorldTests\LoaderTests\CountryDefinitionLoaderTests - - - V3WorldTests\LoaderTests\PopLoaderTests - - - V3WorldTests\LoaderTests\PopLoaderTests - - - V3WorldTests\LoaderTests\PopLoaderTests - - - V3WorldTests\LoaderTests\PopLoaderTests - - - V3WorldTests\LoaderTests\PopLoaderTests - - - V3WorldTests\LoaderTests\StateLoaderTests - - - V3WorldTests\LoaderTests\SuperRegionLoaderTests - - - V3WorldTests\LoaderTests\SuperRegionLoaderTests - - - V3WorldTests\LoaderTests\SuperRegionLoaderTests - - - V3WorldTests\LoaderTests\TerrainLoaderTests - - - V3WorldTests\PoliticalManagerTests\CountryTests - - - V3WorldTests\LoaderTests\BuildingLoaderTests - - - V3WorldTests\ClayManagerTests\StateTests - - - V3WorldTests\LoaderTests\VanillaStateLoaderTests - - - V3WorldTests\LoaderTests\VanillaStateLoaderTests - - - V3WorldTests\LoaderTests\VanillaStateLoaderTests - - - V3WorldTests\LoaderTests\VanillaStateLoaderTests - - - MapperTests\ReligionMapperTests\ReligionDefinitionLoaderTests - - - MapperTests\ReligionMapperTests\ReligionDefinitionLoaderTests - - - MapperTests\ReligionMapperTests\ReligionGroupMapperTests - - - MapperTests\ReligionMapperTests\ReligionGroupMapperTests - - - EU5WorldTests\LoaderTests\ReligionLoaderTests - - - V3WorldTests\LoaderTests\StateModifierLoaderTests - - - V3WorldTests\ClayManagerTests\StateTests - - - MapperTests\CultureMapperTests\NameListLoaderTests - - - MapperTests\CultureMapperTests\NameListLoaderTests - - - MapperTests\CultureMapperTests\CultureTraitMapperTests - - - MapperTests\CultureMapperTests\CultureTraitMapperTests - - - MapperTests\CultureMapperTests\NameListMapperTests - - - MapperTests\CultureMapperTests\NameListMapperTests - - - MapperTests\CultureMapperTests\CultureDefinitionLoaderTests - - - MapperTests\CultureMapperTests\CultureDefinitionLoaderTests - - - MapperTests\CultureMapperTests\WesternizationMapperTests - - - MapperTests\CultureMapperTests\WesternizationMapperTests - - - MapperTests\PopulationSetupMapperTests - - - MapperTests\PopulationSetupMapperTests - - - MapperTests\IdeaEffectsMapperTests - - - MapperTests\IdeaEffectsMapperTests - - - MapperTests\TechSetupMapperTests - - - MapperTests\TechSetupMapperTests - - - V3WorldTests\PoliticalManagerTests\TechValuesTests - - - V3WorldTests\LoaderTests\LawLoaderTests - - - V3WorldTests\LoaderTests\LawLoaderTests - - - MapperTests\LawMapperTests - - - MapperTests\LawMapperTests - - - MapperTests\LawMapperTests - - - MapperTests\ColonialRegionMapperTests - - - MapperTests\ColonialRegionMapperTests - - - MapperTests\DiplomaticMapperTests - - - MapperTests\CharacterTraitMapperTests - - - MapperTests\CharacterTraitMapperTests - - - MapperTests\CharacterTraitMapperTests - - - V3WorldTests\FlagCrafterTests\FlagNameLoaderTests - - - V3WorldTests\FlagCrafterTests - - - V3WorldTests\FlagCrafterTests\FlagColorLoaderTests - - - MapperTests\ColonialTagMapperTests - - - MapperTests\ColonialTagMapperTests - - - MapperTests\VNColonialMapperTests - - - MapperTests\VNColonialMapperTests - - - V3WorldTests\EconomyManagerTests - - - V3WorldTests\LoaderTests\TerrainLoaderTests - - - V3WorldTests\LoaderTests\DefinesLoaderTests - - - V3WorldTests\LoaderTests\BuildingLoaderTests - - - V3WorldTests\LoaderTests\BuildingLoaderTests - - - V3WorldTests\LoaderTests\BuildingLoaderTests - - - MapperTests\BuildingMapperTests - - - MapperTests\BuildingMapperTests - - - V3WorldTests\LoaderTests\NationalBudgetLoaderTests - - - V3WorldTests\LoaderTests\NationalBudgetLoaderTests - - - V3WorldTests\LoaderTests\NationalBudgetLoaderTests - - - V3WorldTests\EconomyManagerTests\NationalBudgetTests - - - V3WorldTests\EconomyManagerTests\BuildingTests - - - V3WorldTests\EconomyManagerTests\BuildingTests - - - V3WorldTests\EconomyManagerTests\BuildingTests - - - V3WorldTests\EconomyManagerTests\BuildingTests - - - V3WorldTests\LoaderTests\DefinesLoaderTests - - - V3WorldTests\LoaderTests\VanillaDiplomacyLoaderTests - - - V3WorldTests\LoaderTests\VanillaDiplomacyLoaderTests - - - V3WorldTests\LoaderTests\VanillaDiplomacyLoaderTests - - - V3WorldTests\LoaderTests\VanillaDiplomacyLoaderTests - - - V3WorldTests\LoaderTests\VanillaDiplomacyLoaderTests - - - V3WorldTests\LoaderTests\VanillaCountryHistoryLoaderTests - - - V3WorldTests\LoaderTests\VanillaCountryHistoryLoaderTests - - - V3WorldTests\LoaderTests\VanillaPopulationHistoryLoaderTests - - - V3WorldTests\LoaderTests\VanillaCharacterLoaderTests - - - V3WorldTests\LoaderTests\VanillaCharacterLoaderTests - - - V3WorldTests\LoaderTests\VanillaDiplomaticPlayLoaderTests - - - V3WorldTests\LoaderTests\VanillaDiplomaticPlayLoaderTests - - - V3WorldTests\LoaderTests\VanillaBuildingLoaderTests - - - V3WorldTests\LoaderTests\VanillaBuildingLoaderTests - - - MapperTests\CountryTierMapperTests - - - MapperTests\CountryTierMapperTests - - - V3WorldTests\LoaderTests\TechLoaderTests - - - V3WorldTests\LoaderTests\TechLoaderTests - - - V3WorldTests\LoaderTests\MajorFormablesLoaderTests - - - V3WorldTests\LoaderTests\MajorFormablesLoaderTests - - - MapperTests\IGIdeologiesMapperTests - - - MapperTests\IGIdeologiesMapperTests - - - MapperTests\MinorityPopMapperTests - - - MapperTests\MinorityPopMapperTests - - - MapperTests\SlaveCultureMapperTests - - - MapperTests\SlaveCultureMapperTests - - - MapperTests\CoastalMapperTests - - - MapperTests\ExcludedTradeCompaniesMapperTests - - - EU5WorldTests\LoaderTests\TradeCompanyLoaderTests - - - EU5WorldTests\LoaderTests\TradeCompanyLoaderTests - - - MapperTests\BuildingMapperTests - - - MapperTests\BuildingMapperTests - - - MapperTests\BuildingMapperTests - - - MapperTests\AIStrategyMapperTests - - - MapperTests\AIStrategyMapperTests - - - MapperTests\AISecretGoalMapperTests - - - MapperTests\AISecretGoalMapperTests - - - MapperTests\CultureMapperTests\TraitDefinitionLoaderTests - - - MapperTests\CultureMapperTests\TraitDefinitionLoaderTests + + EU5WorldTests\LoaderTests\ModLoaderTests @@ -573,102 +18,15 @@ {464b88af-654c-465b-a04b-5006c936bb45} - - {b4ef8576-4f81-4ffc-a2b5-2afaea3e0d98} - - - {6729bfb3-9ccc-4d2b-9dd1-2ca60d761bae} - - - {242c6565-90c8-4fea-896f-39de1f94e472} - - - {e6614708-9f21-47fd-b83c-772981f22fab} - - - {d78cdf3c-cda5-4d88-8e64-7f8794decb43} - - - {ad1c1d81-0387-41de-bfbc-0a900b10e2c4} - - - {f10878dd-ecf1-4f00-bd00-1f3f79ccd6f1} - - - {77e0394e-6b89-45e2-8992-50ae44257995} - - - {33b784fc-849c-4e54-a475-4449583fdf6e} - - - {81696546-f8ff-4cb3-8b4a-dade3b161800} - - - {88ec5ced-4f6b-437b-8ba5-097fd08b83e7} - - - {a0fbaa4d-4231-4999-b8a4-a3f4762e8222} - - - {8b495883-ddce-4b0c-9276-beb8b14ef7cf} - - - {1f24f4d6-c79c-4217-83b5-88ce7ad8f1d6} - - - {7741bcaa-0e32-4bd4-8bef-9348a49dacd9} - - - {75059f4c-7715-4d4f-92d9-786435acfe63} - - - {35ce10ec-508a-4a1a-a16b-7c686094d171} - - - {ab8bc148-8d8a-4e32-a0b2-80f39c3e87a5} - - - {b7d39fad-36a0-4b04-827b-3a0ffb9ce5a1} - - - {d2d43417-0fba-42ad-b26c-72a68efc520b} - - - {5aa77b72-9dc5-464d-aa4d-b762adddfea0} - - - {f540ef76-9842-4bcc-a545-3b8c0460c928} - - - {fe7c01cf-8669-406a-925e-b22b3b2b6b05} - - - {ab8ad006-20d7-4b40-b012-83f3a3a7f27b} - {785958ab-fd05-476a-9f5d-5813b158fd3a} - - {f936c043-6d57-4c1b-9ec2-116b88631119} - {812ac39e-e238-4c36-9fb2-804a0399ddf9} {b8c74649-7210-4df2-869a-199e28c95862} - - {443b4434-80be-487c-995d-2a8243bc1feb} - - - {6f09c0bd-9e77-4e72-a9a3-d3502ad28b46} - - - {1baeed56-3eb0-46af-9163-33db7c129553} - - - {826e227a-3c44-4f98-8599-9251c402a8c9} - {837641fe-c3ce-417f-a374-831e6127b64d} @@ -687,9 +45,6 @@ {78e10c95-9667-48a4-9ed5-2143ad121ebe} - - {82c0c817-7c7d-4a3b-8fba-dff1e4e059b6} - {28d5aea0-8b7d-4c2c-9496-2a2ed268bda1} @@ -702,9 +57,6 @@ {33a9c988-04ed-4cc2-a2ad-344454122c07} - - {602e8f77-1022-4025-bde9-406b90a08b71} - {93fd21b3-3260-4334-81be-2b151b9d706d} @@ -714,147 +66,39 @@ {ae049f6c-3e57-486e-aea0-d1ba0ecac49e} - - {582ceffa-683f-4fcd-a3a3-8c123ae4184c} - {c6468281-ce5e-4d89-b7f7-b9568d1bc471} {271da9b9-e451-4e20-8585-a9f9e2f1c32c} - - {54e2ee93-f0c0-4ecb-b201-660c1194efad} - - - {b30a64ec-33c3-4c1a-918c-9548abe3d542} - - - {4065a709-074f-42cf-bf7f-171b3f0847ce} - {4c847025-db73-4418-b1fd-9d3e65c6b0ab} - - {fec254af-2009-4951-8c05-8832e3787c84} - - - {c281e033-efcf-441e-89bd-8b35fec9c2b4} - - - {c93c185d-07d1-4d30-a03a-4bb4a5bcff2d} - {60ef75d2-0ec5-49dc-951c-145d679db359} {cfcab57a-62a5-4b91-ad41-791d3145d89e} - - {52d3e42d-aaf6-4ebd-853a-a5481e8bfa9b} - - - {9058f76b-f8b7-4b40-aa15-3b580c78f0ed} - - - {2638dab7-045c-489a-a157-4531b90a7e66} - - - {a0a27003-7b84-4321-a951-de605c2177c5} - - - {11dec3f7-d020-469c-9c0e-2be28ac8872b} - - - {21acbe62-6e4d-474f-bbf6-ebdac4f6a33c} - - - {81f53b5b-3592-4c62-a916-5ab049205363} - - - {73825d87-91ac-43bb-ac76-8ed227aad884} - - - {475425c1-7aa3-4657-8c22-8ba591a8cc9d} - - - {8f2c6daa-0d7b-446b-9f4a-cf6d26bb1429} - - - {f10838b2-8c07-41e8-85f4-1a5dda945e80} - {bf10684e-caf1-401b-9205-852794559d16} - - {19564662-8a85-4edf-8e09-ca4fe0b12c5f} - {29f81f0d-78da-49cc-ae54-0e3eac5e9c76} - - {87f15707-3493-4208-9e43-c7e226e27a9c} - {3c3d4aee-21e1-49f5-a9ea-863aaad8b597} - - {e201b8c7-b1e1-4498-9fbf-50032992f731} - - - {af850810-628e-4ace-ac58-38924939f4a3} - {a95577b4-b6c0-4618-ac4d-ca756857202a} - - {c7493d57-5ee6-4c3a-85f4-486d68fccbba} - - - {36c00db3-ffb7-4050-903e-f497f916532d} - - - {98ff957a-ddc0-40ab-9567-cab8fe827811} - {f2c8d09d-5524-46d5-9129-2d3d492ddc58} - - {a744e1a6-8ff7-4c81-88ed-22636480642d} - - - {6899b28e-03e3-4aac-bfdb-b74391b1ca7f} - - - {d7923070-5f3a-4368-a595-3a1c684711eb} - - - {691c173e-87a9-4006-8760-f61e6943d19c} - - - {61d8cf98-685e-44da-8341-e87430d6bbfb} - - - {8879c215-cdd5-4594-bcd1-ec17813d49c4} - - - {980c8272-a098-4b81-907d-1ba71e5f4164} - {048cd0ed-4de5-4734-921f-b9851cf25945} - - {7c725354-1c7b-4a8a-b652-72e4adbce720} - - - {28e5c0b1-22e4-406e-a7e8-583101adf313} - - - {a4ec3f65-92bf-43a1-a289-c8cee0dfe4ac} - - - {ad7579fe-9dee-4071-b28a-384906519c1e} - {e8d58524-6ec0-40bf-a727-b0e2de3f46c6} @@ -870,33 +114,12 @@ {4b4c2400-3a2a-4c3e-a080-f8df04882169} - - {543463dd-1472-4ddb-9865-7cd9f37e05c0} - - - {5c89c2c0-61bf-498c-95c6-e9202155ea3d} - - - {cf42fc18-95b8-4b45-954e-b6323671b27b} - - - {341d0772-4aa5-4366-a7ee-7e5e47a5af60} - {ca85255b-b270-4a84-9a99-f95e64bdddc0} - - {534a3502-8b86-4538-b3d1-392ee938a0a9} - - - {573f1048-5d39-401f-9411-bd6e9d713877} - {e1a42b52-c0b9-413f-a3d2-8ec836d9de8c} - - {dc05326d-e032-410e-8e85-c9f2cce282ff} - {b835f81d-26c5-4778-844d-b7ab55ea7d83} @@ -906,66 +129,27 @@ {e63ab612-b774-48b0-83c0-a31e3e5457fd} - - {290c5f66-efe4-4d46-ae0d-66fd3d9aebbb} - - - {7b43a39e-89ad-4ba7-84de-8acfcc33160a} - - - {d57f2e0b-e86b-4bd5-aa6e-e4147d15f0dd} - - - {65a5f619-227d-48ad-bcf4-a2dd8d5ceec5} - {87780099-ea20-452f-a003-b29afc7a4b78} - - {c65c49b1-cacd-457b-881a-443e87d6ba6f} - {d1c6fca6-23c7-445a-8f39-7fca399d8b2b} - - {d61d3d22-6b07-4b60-9ece-1b8e11e15683} - {8a70b679-271d-4eb5-b0a5-85232bc58ab3} - - {8d708777-127b-4cf5-8c13-35c2b6f74450} - {9add5a71-a373-4cb3-8079-a4f7660ddd7b} - - {fe90b092-7996-4fc1-b005-a94a6bddc729} - {7f1be867-bd5f-4955-ba34-08cc845bf5f0} - - {f881fc37-9e16-4e90-9372-55285982516f} - {e9f0af77-fd48-421a-98fa-f24330627fad} - - {bc3f7edc-2685-4952-976d-a2649bf7db6e} - {ffad5bfd-de20-4289-9336-d034d4d13fa2} - - {c966864f-7cc6-41e4-8378-c2718d674406} - - - {915497d0-8091-40ed-b17f-73c31d97b30f} - - - {91baf2ed-9328-49d5-8e36-1cfb17af0ce1} - {f0567553-07b5-48dc-83ff-371eba4bad00} @@ -975,59 +159,23 @@ {37062f10-3781-4b51-8f35-db9a56c5f65e} - - {7dcdd744-0f8b-4922-b814-79a6ce5fdd75} - - - {781aac3f-b769-4971-986d-58e518b4494e} - - - {f5ab94ff-af5b-4562-a4d0-8085a1f20269} - - - {81d64d41-8073-4105-a2e6-15107884eb19} - - - {e36d27e5-770a-4604-bfd5-142d936796aa} - - - {25c5e07d-dd91-46ca-a560-f71c314c05d2} - - - {03649701-95eb-43da-b032-c7dd9d197ed1} - - - {48e56511-bcd7-4793-814a-8724b09dec96} + + {d5634f2d-b7bd-4607-86b3-a9ae06cbeba5} - - {bf9eba21-5f26-441a-95db-ac35d9f3539e} + + {f936c043-6d57-4c1b-9ec2-116b88631119} - - {9fb0dd77-e303-421a-9b2a-e03ea8441c9f} + + {dcb39a2d-1c45-4f7c-8aa3-f5a71ddfe1bd} - - {93a6f166-a1e6-4c6b-92db-9c2d5cbd8633} + + {410554a5-ba4a-44f3-a3c1-268eae345bec} - - {d5634f2d-b7bd-4607-86b3-a9ae06cbeba5} + + {24bb5fa9-535b-4b7f-84e5-430c3f6e687d} - - TestFiles\eu4installation - - - TestFiles\eu4installation\common\countries - - - TestFiles\eu4installation\common\countries - - - TestFiles\eu4installation\common\country_tags - - - TestFiles\eu4installation\map - TestFiles\mod @@ -1040,9 +188,6 @@ TestFiles\vic3installation\binaries - - TestFiles\eu4installation - TestFiles\vic3installation\launcher @@ -1076,21 +221,6 @@ TestFiles\configurables - - TestFiles\eu4installation\map - - - TestFiles\eu4installation\map - - - TestFiles\eu4installation\map - - - TestFiles\eu4installation\map - - - TestFiles\eu4installation\map - TestFiles\vic3installation\game\map_data\state_regions @@ -1103,9 +233,6 @@ TestFiles\configurables - - TestFiles\eu4installation\common\religions - TestFiles\mod\themod\common\religions @@ -1124,9 +251,6 @@ TestFiles\configurables - - TestFiles\eu4installation\common\cultures - TestFiles\vic3installation\game\common\history\pops @@ -1193,9 +317,6 @@ TestFiles\configurables\blankMod\output\common\coat_of_arms\coat_of_arms - - TestFiles\eu4installation\common\custom_country_colors - TestFiles\vic3installation\game\common\flag_definitions @@ -1298,9 +419,6 @@ TestFiles\configurables - - TestFiles\eu4installation\common\trade_companies - TestFiles\configurables\economy @@ -1316,5 +434,14 @@ TestFiles\vic3installation\game\common\discrimination_traits + + TestFiles\eu5installation + + + TestFiles\eu5installation + + + TestFiles\eu5installation\map + \ No newline at end of file diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryArmyTests/EU4ArmyTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryArmyTests/EU4ArmyTests.cpp deleted file mode 100644 index b15ccee..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryArmyTests/EU4ArmyTests.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include "CountryManager/CountryArmy/EU4Army.h" -#include "UnitTypeLoader/UnitTypeLoader.h" -#include "gtest/gtest.h" - -TEST(EU4World_EU4ArmyTests, primitivesDefaultToBlank) -{ - std::stringstream input; - const auto army = EU4::EU4Army(input, "army"); - - EXPECT_TRUE(army.getName().empty()); - EXPECT_FALSE(army.getArmyFloats()); - EXPECT_EQ(0, army.getLocation()); - EXPECT_TRUE(army.getRegiments().empty()); -} - -TEST(EU4World_EU4ArmyTests, primitivesCanBeLoaded) -{ - std::stringstream input; - input << "name = \"1st Army\"\n"; - input << "location = 971\n"; - input << "regiment = {name = \"Penobscott's 1st Regiment\" home = 971 type = \"native_indian_archer\"}\n"; - input << "regiment = {name = \"Penobscott's 2st Regiment\" home = 971 type = \"native_indian_archer\"}\n"; - const auto army = EU4::EU4Army(input, "army"); - - EXPECT_EQ("1st Army", army.getName()); - EXPECT_FALSE(army.getArmyFloats()); - EXPECT_EQ(971, army.getLocation()); - EXPECT_EQ(2, army.getRegiments().size()); -} - -TEST(EU4World_EU4ArmyTests, regimentsCanBeUpdated) -{ - EU4::UnitTypeLoader unitTypeLoader; - std::stringstream unitInput; - unitInput << "type = infantry\nmaneuver = 2\n"; - unitTypeLoader.loadUnitType("native_indian_archer", unitInput); - std::stringstream unitInput2; - unitInput2 << "type = cavalry\nmaneuver = 4\n"; - unitTypeLoader.loadUnitType("native_indian_horseperson", unitInput2); - - std::stringstream input; - input << "name = \"1st Army\"\n"; - input << "location = 971\n"; - input << "regiment = {name = \"Penobscott's 1st Regiment\" home = 971 type = \"native_indian_archer\"}\n"; - input << "regiment = {name = \"Penobscott's 3st Regiment\" home = 971 type = \"native_indian_archer\"}\n"; - input << "regiment = {name = \"Penobscott's 2st Regiment\" home = 971 type = \"native_indian_horseperson\"}\n"; - auto army = EU4::EU4Army(input, "army"); - - army.updateRegimentTypes(unitTypeLoader); - - EXPECT_EQ(4, army.getTotalTypeStrength("infantry")); // two inf regiments worth 2 each - EXPECT_EQ(4, army.getTotalTypeStrength("cavalry")); // one cav regiment worth 4 -} - -TEST(EU4World_EU4ArmyTests, shipsCanBeResolved) -{ - EU4::UnitTypeLoader unitTypeLoader; - std::stringstream unitInput; - unitInput << "type = heavy_ship\nmaneuver = 60\n"; - unitTypeLoader.loadUnitType("the-manowar", unitInput); - std::stringstream unitInput2; - unitInput2 << "type = transport\nmaneuver = 4\n"; - unitTypeLoader.loadUnitType("the-transport", unitInput2); - - std::stringstream input; - input << "name = \"1st Fleet\"\n"; - input << "location = 11\n"; - input << "ship = {name = \"Dulecha\" home = 1211 type = \"the-manowar\"}\n"; - input << "ship = {name = \"Koneba\" home = 1211 type = \"the-manowar\"}\n"; - input << "ship = {name = \"Dallol\" home = 1211 type = \"the-transport\"}\n"; - auto navy = EU4::EU4Army(input, "navy"); - - navy.updateRegimentTypes(unitTypeLoader); - - EXPECT_EQ(120, navy.getTotalTypeStrength("heavy_ship")); // two heavy ships worth 60 each - EXPECT_EQ(4, navy.getTotalTypeStrength("transport")); // one transport worth 4. -} - -TEST(EU4World_EU4ArmyTests, resolvingUnknownUnitTypesReplacesShipTypesWithSillytons) -{ - const EU4::UnitTypeLoader unitTypeLoader; // not loading anything. - - std::stringstream input; - input << "name = \"1st Fleet\"\n"; - input << "location = 11\n"; - input << "ship = {name = \"Dulecha\" home = 1211 type = \"the-manowar\"}\n"; - input << "ship = {name = \"Koneba\" home = 1211 type = \"the-manowar\"}\n"; - input << "ship = {name = \"Dallol\" home = 1211 type = \"the-transport\"}\n"; - auto navy = EU4::EU4Army(input, "navy"); - - navy.updateRegimentTypes(unitTypeLoader); - - EXPECT_EQ(3, navy.getTotalTypeStrength("transport")); // 3 transports worth 1 each. -} - -TEST(EU4World_EU4ArmyTests, resolvingUnknownUnitTypesReplacesLandTypesWithSillytons) -{ - const EU4::UnitTypeLoader unitTypeLoader; // not loading anything. - - std::stringstream input; - input << "name = \"1st Army\"\n"; - input << "location = 971\n"; - input << "regiment = {name = \"Penobscott's 1st Regiment\" home = 971 type = \"native_indian_archer\"}\n"; - input << "regiment = {name = \"Penobscott's 3st Regiment\" home = 971 type = \"native_indian_archer\"}\n"; - input << "regiment = {name = \"Penobscott's 2st Regiment\" home = 971 type = \"native_indian_horseperson\"}\n"; - auto army = EU4::EU4Army(input, "army"); - - army.updateRegimentTypes(unitTypeLoader); - - EXPECT_EQ(3, army.getTotalTypeStrength("infantry")); // 3 infantry worth 1 each. -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryArmyTests/EU4RegimentTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryArmyTests/EU4RegimentTests.cpp deleted file mode 100644 index 82e239f..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryArmyTests/EU4RegimentTests.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "CountryManager/CountryArmy/EU4Regiment.h" -#include "gtest/gtest.h" - -TEST(EU4World_EU4RegimentTests, primitivesDefaultToBlank) -{ - std::stringstream input; - const EU4::EU4Regiment regiment(input); - - EXPECT_TRUE(regiment.getType().empty()); - EXPECT_TRUE(regiment.getName().empty()); - EXPECT_EQ(0, regiment.getHome()); - EXPECT_EQ(0, regiment.getStrength()); -} - -TEST(EU4World_EU4RegimentTests, primitivesCanBeLoaded) -{ - std::stringstream input; - input << "name=\"Penobscott's 1st Regiment\"\n"; - input << "home=971\n"; - input << "type=\"native_indian_archer\"\n"; - const EU4::EU4Regiment regiment(input); - - EXPECT_EQ("native_indian_archer", regiment.getType()); - EXPECT_EQ("Penobscott's 1st Regiment", regiment.getName()); - EXPECT_EQ(971, regiment.getHome()); - EXPECT_EQ(0, regiment.getStrength()); // Strengths are assigned by Army after loading. -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryGovernmentTests/EU4GovernmentSectionTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryGovernmentTests/EU4GovernmentSectionTests.cpp deleted file mode 100644 index d99b818..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryGovernmentTests/EU4GovernmentSectionTests.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "CountryManager/CountryGovernment/EU4GovernmentSection.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_EU4GovernmentSectionTests, primitivesDefaultToBlank) -{ - std::stringstream input; - const EU4::GovernmentSection government(input); - - EXPECT_TRUE(government.getGovernment().empty()); - EXPECT_TRUE(government.getGovernmentReforms().empty()); -} - -TEST(EU4World_EU4GovernmentSectionTests, reformsCanBeLoaded) -{ - std::stringstream input; - input << "government = the_government\n"; - input << "reform_stack = {\n"; - input << "\treforms = {\n"; - input << "\t\ta_reform the_reform the_the_reform\n"; - input << "\t}\n"; - input << "}\n"; - const EU4::GovernmentSection government(input); - - EXPECT_EQ("the_government", government.getGovernment()); - EXPECT_THAT(government.getGovernmentReforms(), UnorderedElementsAre("a_reform", "the_reform", "the_the_reform")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryGovernmentTests/EU4ReformStackSectionTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryGovernmentTests/EU4ReformStackSectionTests.cpp deleted file mode 100644 index 5f2da96..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryGovernmentTests/EU4ReformStackSectionTests.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "CountryManager/CountryGovernment/EU4ReformStackSection.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_EU4ReformStackSectionTests, primitivesDefaultToBlank) -{ - std::stringstream input; - const EU4::ReformStackSection reforms(input); - - EXPECT_TRUE(reforms.getReforms().empty()); -} - -TEST(EU4World_EU4ReformStackSectionTests, reformsCanBeLoaded) -{ - std::stringstream input; - input << "reforms = {\n"; - input << "\ta_reform the_reform the_the_reform\n"; - input << "}\n"; - const EU4::ReformStackSection reforms(input); - - EXPECT_THAT(reforms.getReforms(), UnorderedElementsAre("a_reform", "the_reform", "the_the_reform")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryHistoryTests/CountryHistoryDateTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryHistoryTests/CountryHistoryDateTests.cpp deleted file mode 100644 index 331213a..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryHistoryTests/CountryHistoryDateTests.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "CountryManager/CountryHistory/CountryHistoryDate.h" -#include "gtest/gtest.h" - -TEST(EU4World_CountryHistoryDateTests, primitivesDefaultToBlank) -{ - std::stringstream input; - const EU4::CountryHistoryDate historyDate(input); - - EXPECT_TRUE(historyDate.getCharacters().empty()); -} - -TEST(EU4World_CountryHistoryDateTests, simpleLeadersCanBeLoaded) -{ - std::stringstream input; - input << "leader = {\n"; - input << "\tname=Boby\n"; - input << "}\n"; - input << "leader = {\n"; - input << "\tname=Carol\n"; - input << "}\n"; - const EU4::CountryHistoryDate historyDate(input); - - ASSERT_EQ(2, historyDate.getCharacters().size()); - const auto& leader1 = historyDate.getCharacters()[0]; - const auto& leader2 = historyDate.getCharacters()[1]; - - EXPECT_EQ("Boby", leader1.leaderName); - EXPECT_EQ("Carol", leader2.leaderName); -} - -TEST(EU4World_CountryHistoryDateTests, monarchLeaderAndDynastyCanBeLoaded) -{ - std::stringstream input; - input << "monarch = {\n"; - input << "\tname = Boby\n"; - input << "\tdynasty = Bobbypants\n"; - input << "\tleader = {\n"; - input << "\t\tname=\"Boby 1st of Bobbypants\"\n"; - input << "\t}\n"; - input << "}\n"; - const EU4::CountryHistoryDate historyDate(input); - - ASSERT_EQ(1, historyDate.getCharacters().size()); - const auto& leader = historyDate.getCharacters()[0]; - - EXPECT_EQ("Boby", leader.name); - EXPECT_EQ("Bobbypants", leader.dynasty); - EXPECT_EQ("Boby 1st of Bobbypants", leader.leaderName); - EXPECT_TRUE(leader.ruler); -} - -TEST(EU4World_CountryHistoryDateTests, heirAndQueenCanBeLoaded) -{ - std::stringstream input; - input << "queen = {\n"; - input << "\tname = Boby\n"; - input << "\tdynasty = Bobbypants\n"; - input << "\tleader = {\n"; - input << "\t\tname=\"Queen 1st of Bobbypants\"\n"; - input << "\t}\n"; - input << "}\n"; - input << "heir = {\n"; - input << "\tname = Boby\n"; - input << "\tdynasty = Bobbypants\n"; - input << "\tleader = {\n"; - input << "\t\tname=\"Heir 2nd of Bobbypants\"\n"; - input << "\t}\n"; - input << "}\n"; - const EU4::CountryHistoryDate historyDate(input); - - ASSERT_EQ(2, historyDate.getCharacters().size()); - const auto& leader1 = historyDate.getCharacters()[0]; - const auto& leader2 = historyDate.getCharacters()[1]; - - EXPECT_EQ("Queen 1st of Bobbypants", leader1.leaderName); - EXPECT_EQ("Bobbypants", leader1.dynasty); - EXPECT_TRUE(leader1.consort); - EXPECT_EQ("Heir 2nd of Bobbypants", leader2.leaderName); - EXPECT_EQ("Bobbypants", leader2.dynasty); - EXPECT_TRUE(leader2.heir); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryHistoryTests/CountryHistoryTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryHistoryTests/CountryHistoryTests.cpp deleted file mode 100644 index 4183e2a..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryHistoryTests/CountryHistoryTests.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "CountryManager/CountryHistory/CountryHistory.h" -#include "gtest/gtest.h" - -TEST(EU4World_CountryHistoryTests, primitivesDefaultToBlank) -{ - std::stringstream input; - const EU4::CountryHistory history(input); - - EXPECT_TRUE(history.getReligion().empty()); - EXPECT_TRUE(history.getPrimaryCulture().empty()); -} - -TEST(EU4World_CountryHistoryTests, cultureAndReligionCanBeLoaded) -{ - std::stringstream input; - input << "religion = atheist\n"; - input << "primary_culture = cosmopolitan\n"; - const EU4::CountryHistory history(input); - - EXPECT_EQ("atheist", history.getReligion()); - EXPECT_EQ("cosmopolitan", history.getPrimaryCulture()); -} - -TEST(EU4World_CountryHistoryTests, datesCanBeParsedForLeaders) -{ - std::stringstream input; - input << "2.2.2 = {\n"; - input << "\tleader = {\n"; - input << "\t\tname = TheGeneral\n"; - input << "\t}"; - input << "}"; - input << "4.4.4 = {\n"; - input << "\tleader = {\n"; - input << "\t\tname = TheAdmiral\n"; - input << "\t}"; - input << "\tleader = {\n"; - input << "\t\tname = TheExplorer\n"; - input << "\t}"; - input << "}"; - - const EU4::CountryHistory history(input); - const auto& leader1 = history.getCharacters()[0]; - const auto& leader2 = history.getCharacters()[1]; - const auto& leader3 = history.getCharacters()[2]; - - EXPECT_EQ(3, history.getCharacters().size()); - EXPECT_EQ("TheGeneral", leader1.leaderName); - EXPECT_EQ("TheAdmiral", leader2.leaderName); - EXPECT_EQ("TheExplorer", leader3.leaderName); -} - -TEST(EU4World_CountryHistoryTests, datesCanBeParsedForRulerLeaders) -{ - std::stringstream input; - input << "2.2.2 = {\n"; - input << "\tmonarch = {\n"; - input << "\t\tname = Boby\n"; - input << "\t\tdynasty = Bobbypants\n"; - input << "\t\tleader = {\n"; - input << "\t\t\tname=\"Boby 1st of Bobbypants\"\n"; - input << "\t\t}\n"; - input << "\t}\n"; - input << "}\n"; - - input << "3.3.3 = {\n"; - input << "\tqueen = {\n"; - input << "\t\tname = Boby\n"; - input << "\t\tdynasty = Bobbypantaloon\n"; - input << "\t\tleader = {\n"; - input << "\t\t\tname=\"Boby 2nd of Bobbypants\"\n"; - input << "\t\t}\n"; - input << "\t}\n"; - input << "\their = {\n"; - input << "\t\tname = Boby\n"; - input << "\t\tdynasty = Bobbypantaloon\n"; - input << "\t\tleader = {\n"; - input << "\t\t\tname=\"Boby 3rd of Bobbypants\"\n"; - input << "\t\t}\n"; - input << "\t}\n"; - input << "}\n"; - - const EU4::CountryHistory history(input); - const auto& leader1 = history.getCharacters()[0]; - const auto& leader2 = history.getCharacters()[1]; - const auto& leader3 = history.getCharacters()[2]; - - EXPECT_EQ("Boby 1st of Bobbypants", leader1.leaderName); - EXPECT_EQ("Boby 2nd of Bobbypants", leader2.leaderName); - EXPECT_EQ("Boby 3rd of Bobbypants", leader3.leaderName); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryLeaderTests/EU4LeaderIDTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryLeaderTests/EU4LeaderIDTests.cpp deleted file mode 100644 index 47dede8..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryLeaderTests/EU4LeaderIDTests.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "CountryManager/CountryLeader/EU4LeaderID.h" -#include "gtest/gtest.h" - -TEST(EU4World_EU4LeaderIDTests, primitivesDefaultToZero) -{ - std::stringstream input; - const EU4::LeaderID id(input); - - EXPECT_EQ(0, id.getIDNum()); -} - -TEST(EU4World_EU4LeaderIDTests, idCanBeSet) -{ - std::stringstream input; - input << "id = 1\n"; - const EU4::LeaderID id(input); - - EXPECT_EQ(1, id.getIDNum()); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryLeaderTests/EU4LeaderTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryLeaderTests/EU4LeaderTests.cpp deleted file mode 100644 index a977d13..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryLeaderTests/EU4LeaderTests.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include "CountryManager/CountryLeader/EU4Leader.h" -#include "gtest/gtest.h" -#include - -TEST(EU4World_EU4LeaderTests, primitivesDefaultToDefaultValues) -{ - const EU4::Leader leaderParser; - const auto& leader = leaderParser.getCharacter(); - - EXPECT_TRUE(leader.leaderName.empty()); - EXPECT_FALSE(leader.female); - EXPECT_FALSE(leader.activationDate.isSet()); - EXPECT_EQ(0, leader.fire); - EXPECT_EQ(0, leader.shock); - EXPECT_EQ(0, leader.maneuver); - EXPECT_EQ(0, leader.shock); - EXPECT_EQ(0, leader.leaderID); -} - -TEST(EU4World_EU4LeaderTests, primitiveLeaderCanBeLoaded) -{ - std::stringstream input; - input << "name=Boby\n"; - input << "type=admiral\n"; - input << "female=true\n"; - input << "manuever=3\n"; - input << "fire=1\n"; - input << "shock=2\n"; - input << "siege=9\n"; - input << "activation=6.6.6\n"; - input << "personality=aggressive\n"; - input << "id={\n"; - input << "\tid=32\n"; - input << "}\n"; - EU4::Leader leaderParser; - leaderParser.parseLeader(input); - const auto& leader = leaderParser.getCharacter(); - - EXPECT_EQ("Boby", leader.leaderName); - EXPECT_TRUE(leader.female); - EXPECT_EQ(date("6.6.6"), leader.activationDate); - EXPECT_EQ(1, leader.fire); - EXPECT_EQ(2, leader.shock); - EXPECT_EQ(3, leader.maneuver); - EXPECT_EQ(9, leader.siege); - EXPECT_EQ(32, leader.leaderID); - EXPECT_EQ("aggressive", leader.leaderTrait); -} - -TEST(EU4World_EU4LeaderTests, simpleCharacterCanBeLoaded) -{ - std::stringstream input; - input << "id={\n"; - input << " id=3052\n"; - input << " type=48\n"; - input << "}\n"; - input << "name=\"Marie\"\n"; - input << "country=\"FRA\"\n"; - input << "DIP=4\n"; - input << "ADM=4\n"; - input << "MIL=4\n"; - input << "female=yes\n"; - input << "culture=occitain\n"; - input << "religion=catholic\n"; - input << "personalities={\n"; - input << " zealot_personality=yes\n"; - input << "}\n"; - input << "dynasty=\"d'Anjou\"\n"; - input << "birth_date=1404.10.14\n"; - input << "country_of_origin=PRO\n"; - - EU4::Leader leaderParser; - leaderParser.parseRuler(input); - const auto& character = leaderParser.getCharacter(); - - EXPECT_EQ(3052, character.monarchID); - EXPECT_EQ("Marie", character.name); - EXPECT_EQ("FRA", character.country); - EXPECT_EQ(4, character.adm); - EXPECT_EQ(4, character.mil); - EXPECT_EQ(4, character.dip); - EXPECT_EQ(true, character.female); - EXPECT_EQ("occitain", character.culture); - EXPECT_EQ("catholic", character.religion); - EXPECT_THAT(character.traits, testing::UnorderedElementsAre("zealot_personality")); - EXPECT_EQ("d'Anjou", character.dynasty); - EXPECT_EQ(date("1404.10.14"), character.birthDate); - EXPECT_EQ("PRO", character.countryOfOrigin); -} - -TEST(EU4World_EU4LeaderTests, complexCharacterCanBeLoaded) -{ - std::stringstream input; - input << "id={\n"; - input << " id=3052\n"; - input << " type=48\n"; - input << "}\n"; - input << "name=\"Marie\"\n"; - input << "country=\"FRA\"\n"; - input << "DIP=4\n"; - input << "ADM=4\n"; - input << "MIL=4\n"; - input << "female=yes\n"; - input << "culture=occitain\n"; - input << "religion=catholic\n"; - input << "personalities={\n"; - input << " zealot_personality=yes\n"; - input << "}\n"; - input << "leader = {\n"; - input << " name=Boby\n"; - input << " type=admiral\n"; - input << " female=true\n"; - input << " manuever=3\n"; - input << " fire=1\n"; - input << " shock=2\n"; - input << " siege=9\n"; - input << " activation=6.6.6\n"; - input << " personality=aggressive\n"; - input << " id={\n"; - input << " id=32\n"; - input << " }\n"; - input << "}\n"; - input << "dynasty=\"d'Anjou\"\n"; - input << "birth_date=1404.10.14\n"; - input << "country_of_origin=PRO\n"; - - EU4::Leader leaderParser; - leaderParser.parseRuler(input); - const auto& character = leaderParser.getCharacter(); - - EXPECT_EQ(32, character.leaderID); - EXPECT_EQ(3052, character.monarchID); - EXPECT_EQ("Marie", character.name); - EXPECT_EQ("FRA", character.country); - EXPECT_EQ(4, character.adm); - EXPECT_EQ(4, character.mil); - EXPECT_EQ(4, character.dip); - EXPECT_EQ(true, character.female); - EXPECT_EQ("occitain", character.culture); - EXPECT_EQ("catholic", character.religion); - EXPECT_THAT(character.traits, testing::UnorderedElementsAre("zealot_personality")); - EXPECT_EQ("d'Anjou", character.dynasty); - EXPECT_EQ(date("1404.10.14"), character.birthDate); - EXPECT_EQ("PRO", character.countryOfOrigin); - EXPECT_EQ("Boby", character.leaderName); - EXPECT_EQ(date("6.6.6"), character.activationDate); - EXPECT_EQ(1, character.fire); - EXPECT_EQ(2, character.shock); - EXPECT_EQ(3, character.maneuver); - EXPECT_EQ(9, character.siege); - EXPECT_EQ("aggressive", character.leaderTrait); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryRelationsTests/EU4RelationDetailsTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryRelationsTests/EU4RelationDetailsTests.cpp deleted file mode 100644 index fb6a2b0..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryRelationsTests/EU4RelationDetailsTests.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "CountryManager/CountryRelations/EU4RelationDetails.h" -#include "gtest/gtest.h" - -TEST(EU4World_RelationDetailsTests, primitivesDefaultToDefaults) -{ - std::stringstream input; - const EU4::EU4RelationDetails details(input); - - EXPECT_EQ("attitude_neutral", details.getAttitude()); - EXPECT_EQ(0, details.getRelations()); - EXPECT_FALSE(details.hasMilitaryAccess()); - EXPECT_FALSE(details.getTruceExpiry()); -} - -TEST(EU4World_RelationDetailsTests, primitivesCanBeLoaded) -{ - std::stringstream input; - input << "attitude = attitude_rival\n"; - input << "cached_sum = -137\n"; - input << "military_access = irrelevant\n"; - const EU4::EU4RelationDetails details(input); - - EXPECT_EQ("attitude_rival", details.getAttitude()); - EXPECT_EQ(-137, details.getRelations()); - EXPECT_TRUE(details.hasMilitaryAccess()); - EXPECT_FALSE(details.getTruceExpiry()); -} - -TEST(EU4World_RelationDetailsTests, truceExpiryCanBeCalculated) -{ - std::stringstream input; - input << "last_war = \"1000.1.1\"\n"; - input << "last_warscore = 100\n"; - input << "truce = yes\n"; - const EU4::EU4RelationDetails details(input); - - ASSERT_TRUE(details.getTruceExpiry()); - EXPECT_EQ(date("1015.1.1"), *details.getTruceExpiry()); -} - -TEST(EU4World_RelationDetailsTests, truceExpiryLastsFiveYearsForDiplobreak) -{ - std::stringstream input; - input << "last_war = \"1000.1.1\"\n"; - input << "truce = yes\n"; - const EU4::EU4RelationDetails details(input); - - ASSERT_TRUE(details.getTruceExpiry()); - EXPECT_EQ(date("1005.1.1"), *details.getTruceExpiry()); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryRelationsTests/EU4RelationsTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryRelationsTests/EU4RelationsTests.cpp deleted file mode 100644 index 61aeb0c..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/CountryRelationsTests/EU4RelationsTests.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "CountryManager/CountryRelations/EU4Relations.h" -#include "gtest/gtest.h" - -TEST(EU4World_RelationsTests, relationsDefaultToEmpty) -{ - std::stringstream input; - const EU4::EU4Relations relations(input); - - EXPECT_TRUE(relations.getRelations().empty()); -} - -TEST(EU4World_RelationsTests, relationsCanBeLoaded) -{ - std::stringstream input; - input << "HAB = {\n"; - input << "\tcached_sum = -137\n"; - input << "\tmilitary_access = irrelevant\n"; - input << "}\n"; - input << "BOH = {\n"; - input << "\tattitude = attitude_rival\n"; - input << "}\n"; - const EU4::EU4Relations relations(input); - - const auto habRelation = relations.getRelations().at("HAB"); - const auto bohRelation = relations.getRelations().at("BOH"); - - EXPECT_EQ("attitude_neutral", habRelation.getAttitude()); - EXPECT_EQ(-137, habRelation.getRelations()); - EXPECT_TRUE(habRelation.hasMilitaryAccess()); - - EXPECT_EQ("attitude_rival", bohRelation.getAttitude()); - EXPECT_EQ(0, bohRelation.getRelations()); - EXPECT_FALSE(bohRelation.hasMilitaryAccess()); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4ActiveIdeasTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4ActiveIdeasTests.cpp deleted file mode 100644 index 231430f..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4ActiveIdeasTests.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "CountryManager/EU4ActiveIdeas.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_EU4ActiveIdeasTests, primitivesDefaultToBlank) -{ - std::stringstream input; - const EU4::EU4ActiveIdeas ideas(input); - - EXPECT_TRUE(ideas.getActiveIdeas().empty()); -} - -TEST(EU4World_EU4ActiveIdeasTests, ideasDevelopedTo7OrMoreAreLoaded) -{ - std::stringstream input; - input << "idea1 = 4\n"; - input << "idea2 = 7\n"; - input << "idea3 = 14\n"; // mods? - const EU4::EU4ActiveIdeas ideas(input); - - EXPECT_THAT(ideas.getActiveIdeas(), UnorderedElementsAre("idea2", "idea3")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4ActivePolicyTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4ActivePolicyTests.cpp deleted file mode 100644 index 17c3473..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4ActivePolicyTests.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "CountryManager/EU4ActivePolicy.h" -#include "gtest/gtest.h" - -TEST(EU4World_EU4ActivePolicyTests, policyDefaultsToEmpty) -{ - std::stringstream input; - const EU4::EU4ActivePolicy thePolicy(input); - - EXPECT_TRUE(thePolicy.getPolicy().empty()); -} - -TEST(EU4World_EU4ActivePolicyTests, policyCanBeImported) -{ - std::stringstream input; - input << "policy=\"agricultural_cultivations\""; - const EU4::EU4ActivePolicy thePolicy(input); - - EXPECT_EQ(thePolicy.getPolicy(), "agricultural_cultivations"); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryFlagsTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryFlagsTests.cpp deleted file mode 100644 index 495d938..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryFlagsTests.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "CountryManager/EU4CountryFlags.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_EU4CountryFlagsTests, primitivesDefaultToBlank) -{ - std::stringstream input; - const EU4::EU4CountryFlags flags(input); - - EXPECT_TRUE(flags.getFlags().empty()); -} - -TEST(EU4World_EU4CountryFlagsTests, flagsCanBeLoaded) -{ - std::stringstream input; - input << "flag1 = 11.11.11\n"; - input << "flag2 = color3\n"; - input << "flag3 = {14 34}\n"; - const EU4::EU4CountryFlags flags(input); - - EXPECT_THAT(flags.getFlags(), UnorderedElementsAre("flag1", "flag2", "flag3")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryManagerTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryManagerTests.cpp deleted file mode 100644 index b356cf1..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryManagerTests.cpp +++ /dev/null @@ -1,406 +0,0 @@ -#include "CommonFunctions.h" -#include "CountryManager/EU4CountryManager.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_CountryManagerTests, primitivesDefaultToBlank) -{ - const EU4::CountryManager manager; - - EXPECT_TRUE(manager.getCountries().empty()); -} - -TEST(EU4World_CountryManagerTests, countriesCanBeLoaded) -{ - std::stringstream input; - input << "AAA = {}\n"; - input << "BBB = {}\n"; - EU4::CountryManager manager; - manager.loadCountries(input); - - EXPECT_EQ(2, manager.getCountries().size()); - EXPECT_TRUE(manager.getCountries().contains("AAA")); - EXPECT_TRUE(manager.getCountries().contains("BBB")); -} - -TEST(EU4World_CountryManagerTests, SpecialCountriesAreIgnored) -{ - std::stringstream input; - input << "--- = {}\n"; - input << "REB = {}\n"; - input << "PIR = {}\n"; - input << "NAT = {}\n"; - input << "AAA = {}\n"; - input << "BBB = {}\n"; - EU4::CountryManager manager; - manager.loadCountries(input); - - EXPECT_EQ(2, manager.getCountries().size()); - EXPECT_TRUE(manager.getCountries().contains("AAA")); - EXPECT_TRUE(manager.getCountries().contains("BBB")); -} - -TEST(EU4World_CountryManagerTests, CountriesCanBeRetrieved) -{ - std::stringstream input; - input << "AAA = {}\n"; - input << "BBB = {}\n"; - EU4::CountryManager manager; - manager.loadCountries(input); - - EXPECT_EQ("AAA", manager.getCountry("AAA")->getTag()); - EXPECT_EQ("BBB", manager.getCountry("BBB")->getTag()); -} - -TEST(EU4World_CountryManagerTests, CountryMismatchReturnsNullptr) -{ - std::stringstream input; - EU4::CountryManager manager; - manager.loadCountries(input); - - EXPECT_EQ(nullptr, manager.getCountry("AAA")); -} - -TEST(EU4World_CountryManagerTests, LinkingProvincesToOwnersWorks) -{ - std::stringstream provincesInput; - provincesInput << "-1 = { owner=TAG }\n"; - provincesInput << "-2 = { owner=TAG }\n"; - provincesInput << "-3 = { owner=GAT }\n"; - provincesInput << "-4 = { }\n"; // unowned - provincesInput << "-5 = { owner=BLA }\n"; // nonsense - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provincesInput); - - std::stringstream countryManagerInput; - countryManagerInput << "TAG = { capital = 2 }\n"; - countryManagerInput << "GAT = { capital = 3 }\n"; - EU4::CountryManager manager; - manager.loadCountries(countryManagerInput); - - manager.linkProvincesToCountries(provinceManager); - - const auto& tag = manager.getCountry("TAG"); - const auto& gat = manager.getCountry("GAT"); - - EXPECT_EQ(2, tag->getProvinces().size()); - EXPECT_EQ(1, tag->getProvinces().at(1)->getID()); - EXPECT_TRUE(tag->getProvinces().at(1)->getCapitals().empty()); - EXPECT_EQ(2, tag->getProvinces().at(2)->getID()); - EXPECT_THAT(tag->getProvinces().at(2)->getCapitals(), testing::UnorderedElementsAre("TAG")); - - EXPECT_EQ(1, gat->getProvinces().size()); - EXPECT_EQ(3, gat->getProvinces().at(3)->getID()); - EXPECT_THAT(gat->getProvinces().at(3)->getCapitals(), testing::UnorderedElementsAre("GAT")); -} - -TEST(EU4World_CountryManagerTests, LinkingProvincesToCoreOwnersWorks) -{ - std::stringstream provincesInput; - provincesInput << "-1 = { cores = { TAG GAT } }\n"; - provincesInput << "-2 = { cores = { TAG } }\n"; - provincesInput << "-3 = { cores = { GAT } }\n"; - provincesInput << "-4 = { }\n"; // no cores - provincesInput << "-5 = { cores = { BLA } }\n"; // nonsense - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provincesInput); - - std::stringstream countryManagerInput; - countryManagerInput << "TAG = {}\n"; - countryManagerInput << "GAT = {}\n"; - EU4::CountryManager manager; - manager.loadCountries(countryManagerInput); - - manager.linkProvincesToCountries(provinceManager); - - const auto& tag = manager.getCountry("TAG"); - const auto& gat = manager.getCountry("GAT"); - - EXPECT_EQ(2, tag->getCores().size()); - EXPECT_EQ(1, tag->getCores().at(1)->getID()); - EXPECT_EQ(2, tag->getCores().at(2)->getID()); - - EXPECT_EQ(2, gat->getCores().size()); - EXPECT_EQ(1, gat->getCores().at(1)->getID()); - EXPECT_EQ(3, gat->getCores().at(3)->getID()); -} - -TEST(EU4World_CountryManagerTests, HREStatusInheritedFromCapitalProvince) -{ - std::stringstream provincesInput; - provincesInput << "-1 = { hre = yes } }\n"; - provincesInput << "-2 = { }\n"; - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provincesInput); - - std::stringstream countryManagerInput; - countryManagerInput << "TAG = { capital = 1 }\n"; - countryManagerInput << "GAT = { capital = 2 }\n"; - EU4::CountryManager manager; - manager.loadCountries(countryManagerInput); - - manager.setHREAndEmperors("", "", provinceManager); - - const auto& tag = manager.getCountry("TAG"); - const auto& gat = manager.getCountry("GAT"); - - EXPECT_TRUE(tag->isInHRE()); - EXPECT_FALSE(gat->isInHRE()); -} - -TEST(EU4World_CountryManagerTests, EmperorshipsAreForwardedToCountries) -{ - const EU4::ProvinceManager provinceManager; - - std::stringstream countryManagerInput; - countryManagerInput << "TAG = { }\n"; - countryManagerInput << "GAT = { }\n"; - countryManagerInput << "AAA = { }\n"; - EU4::CountryManager manager; - manager.loadCountries(countryManagerInput); - - manager.setHREAndEmperors("TAG", "GAT", provinceManager); - - const auto& tag = manager.getCountry("TAG"); - const auto& gat = manager.getCountry("GAT"); - const auto& aaa = manager.getCountry("AAA"); - - EXPECT_TRUE(tag->isHREmperor()); - EXPECT_FALSE(tag->isCelestialEmperor()); - EXPECT_FALSE(gat->isHREmperor()); - EXPECT_TRUE(gat->isCelestialEmperor()); - EXPECT_FALSE(aaa->isHREmperor()); - EXPECT_FALSE(aaa->isCelestialEmperor()); -} - -TEST(EU4World_CountryManagerTests, RevolutionaryIsForwardedToCountries) -{ - std::stringstream countryManagerInput; - countryManagerInput << "TAG = { }\n"; - countryManagerInput << "GAT = { }\n"; - countryManagerInput << "AAA = { }\n"; - EU4::CountryManager manager; - manager.loadCountries(countryManagerInput); - - manager.setRevolutionTarget("GAT"); - - const auto& tag = manager.getCountry("TAG"); - const auto& gat = manager.getCountry("GAT"); - const auto& aaa = manager.getCountry("AAA"); - - EXPECT_FALSE(tag->isRevolutionary()); - EXPECT_TRUE(gat->isRevolutionary()); - EXPECT_FALSE(aaa->isRevolutionary()); -} - -TEST(EU4World_CountryManagerTests, JapanCanBeUnited) -{ - std::stringstream provincesInput; - provincesInput << "-1 = { owner = AAA cores={ AAA } }\n"; - provincesInput << "-2 = { owner = BBB cores={ BBB } }\n"; - provincesInput << "-3 = { owner = CCC cores={ CCC } }\n"; - provincesInput << "-4 = { owner = DDD cores={ DDD } }\n"; - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provincesInput); - - std::stringstream nationMergeInput; - nationMergeInput << "merge_daimyos = yes"; - mappers::NationMergeMapper mapper; - mapper.loadNationMerge(nationMergeInput); - - std::stringstream countryManagerInput; - countryManagerInput << "AAA = { government = { reform_stack={ reforms={ daimyo } } } }\n"; - countryManagerInput << "BBB = { government = { reform_stack={ reforms={ indep_daimyo } } } }\n"; - countryManagerInput << "CCC = { government = { reform_stack={ reforms={ shogunate } } } }\n"; - countryManagerInput << "DDD = { government = { reform_stack={ reforms={ plutocracy } } } }\n"; // control group. - EU4::CountryManager manager; - manager.loadCountries(countryManagerInput); - manager.linkProvincesToCountries(provinceManager); - manager.loadNationMergeMapper(mapper); - manager.mergeNations(); - - EXPECT_THAT(provinceManager.getProvince(1)->getCores(), UnorderedElementsAre("CCC")); - EXPECT_THAT(provinceManager.getProvince(2)->getCores(), UnorderedElementsAre("CCC")); - EXPECT_THAT(provinceManager.getProvince(3)->getCores(), UnorderedElementsAre("CCC")); - EXPECT_THAT(provinceManager.getProvince(4)->getCores(), UnorderedElementsAre("DDD")); - EXPECT_EQ("CCC", provinceManager.getProvince(1)->getOwnerTag()); - EXPECT_EQ("CCC", provinceManager.getProvince(2)->getOwnerTag()); - EXPECT_EQ("CCC", provinceManager.getProvince(3)->getOwnerTag()); - EXPECT_EQ("DDD", provinceManager.getProvince(4)->getOwnerTag()); -} - -TEST(EU4World_CountryManagerTests, NationsCanBeMerged) -{ - std::stringstream provincesInput; - provincesInput << "-1 = { owner = AAA cores={ AAA } }\n"; - provincesInput << "-2 = { owner = BBB cores={ BBB } }\n"; - provincesInput << "-3 = { owner = CCC cores={ CCC } }\n"; - provincesInput << "-4 = { owner = DDD cores={ DDD } }\n"; - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provincesInput); - - std::stringstream nationMergeInput; - nationMergeInput << "test = {\n"; - nationMergeInput << " merge = yes\n"; - nationMergeInput << " master = BBB\n"; - nationMergeInput << " slave = AAA\n"; - nationMergeInput << " slave = DDD\n"; - nationMergeInput << "}\n"; - mappers::NationMergeMapper mapper; - mapper.loadNationMerge(nationMergeInput); - - std::stringstream countryManagerInput; - countryManagerInput << "AAA = { }\n"; - countryManagerInput << "BBB = { }\n"; - countryManagerInput << "CCC = { }\n"; // control group. - countryManagerInput << "DDD = { }\n"; - EU4::CountryManager manager; - manager.loadCountries(countryManagerInput); - manager.linkProvincesToCountries(provinceManager); - manager.loadNationMergeMapper(mapper); - manager.mergeNations(); - - EXPECT_THAT(provinceManager.getProvince(1)->getCores(), UnorderedElementsAre("BBB")); - EXPECT_THAT(provinceManager.getProvince(2)->getCores(), UnorderedElementsAre("BBB")); - EXPECT_THAT(provinceManager.getProvince(3)->getCores(), UnorderedElementsAre("CCC")); - EXPECT_THAT(provinceManager.getProvince(4)->getCores(), UnorderedElementsAre("BBB")); - EXPECT_EQ("BBB", provinceManager.getProvince(1)->getOwnerTag()); - EXPECT_EQ("BBB", provinceManager.getProvince(2)->getOwnerTag()); - EXPECT_EQ("CCC", provinceManager.getProvince(3)->getOwnerTag()); - EXPECT_EQ("BBB", provinceManager.getProvince(4)->getOwnerTag()); -} - -TEST(EU4World_CountryManagerTests, LocalizationsCanBeInjected) -{ - std::stringstream input; - input << commonItems::utf8BOM << "l_english:\n"; - input << " AAA: \"aloc\" # comment\n"; - input << " BBB: \"bloc\"\n"; - input << " AAA_ADJ: \"aloc adj\" # comment\n"; - input << " BBB_ADJ: \"bloc adj\"\n"; - std::stringstream input2; - input2 << commonItems::utf8BOM << "l_french:\n"; - input2 << " AAA: \"alocee\"\n"; - input2 << " BBB: \"blocee\"\n"; - input2 << " AAA_ADJ: \"alocee adj\"\n"; - input2 << " BBB_ADJ: \"blocee adj\"\n"; - EU4::EU4LocalizationLoader locs; - locs.loadLocalizations(input); - locs.loadLocalizations(input2); - - std::stringstream countryManagerInput; - countryManagerInput << "AAA = { name = \"le default a\" adjective = \"le default a adj\" }\n"; - countryManagerInput << "BBB = { name = \"le default b\" adjective = \"le default b adj\" }\n"; - countryManagerInput << "CCC = { name = \"le default c\" adjective = \"le default c adj\" }\n"; // control group. - EU4::CountryManager manager; - manager.loadCountries(countryManagerInput); - manager.loadLocalizations(locs); - manager.injectLocalizations(); - - EXPECT_EQ("aloc", manager.getCountry("AAA")->getName("english")); - EXPECT_EQ("alocee", manager.getCountry("AAA")->getName("french")); - EXPECT_EQ("aloc", manager.getCountry("AAA")->getName("nonsense")); - EXPECT_EQ("aloc adj", manager.getCountry("AAA")->getAdjective("english")); - EXPECT_EQ("alocee adj", manager.getCountry("AAA")->getAdjective("french")); - EXPECT_EQ("aloc adj", manager.getCountry("AAA")->getAdjective("nonsense")); - - EXPECT_EQ("bloc", manager.getCountry("BBB")->getName("english")); - EXPECT_EQ("blocee", manager.getCountry("BBB")->getName("french")); - EXPECT_EQ("bloc", manager.getCountry("BBB")->getName("nonsense")); - EXPECT_EQ("bloc adj", manager.getCountry("BBB")->getAdjective("english")); - EXPECT_EQ("blocee adj", manager.getCountry("BBB")->getAdjective("french")); - EXPECT_EQ("bloc adj", manager.getCountry("BBB")->getAdjective("nonsense")); - - EXPECT_EQ("le default c", manager.getCountry("CCC")->getName("english")); - EXPECT_EQ("le default c", manager.getCountry("CCC")->getName("french")); - EXPECT_EQ("le default c", manager.getCountry("CCC")->getName("nonsense")); - EXPECT_EQ("le default c adj", manager.getCountry("CCC")->getAdjective("english")); - EXPECT_EQ("le default c adj", manager.getCountry("CCC")->getAdjective("french")); - EXPECT_EQ("le default c adj", manager.getCountry("CCC")->getAdjective("nonsense")); -} - -TEST(EU4World_CountryManagerTests, EmptyNationsAreDeleted) -{ - std::stringstream provincesInput; - provincesInput << "-1 = { owner = AAA cores={ AAA } }\n"; - provincesInput << "-2 = { owner = AAA cores={ BBB } }\n"; - provincesInput << "-3 = { owner = CCC cores={ CCC } }\n"; - provincesInput << "-4 = { owner = AAA cores={ BBB } }\n"; - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provincesInput); - - std::stringstream countryManagerInput; - countryManagerInput << "AAA = { }\n"; - countryManagerInput << "BBB = { }\n"; - countryManagerInput << "CCC = { }\n"; - countryManagerInput << "DDD = { }\n"; // no provinces, no cores, to be deleted. - EU4::CountryManager manager; - manager.loadCountries(countryManagerInput); - manager.linkProvincesToCountries(provinceManager); - - manager.filterDeadNations(Configuration::DEADCORES::LeaveAll); - - EXPECT_TRUE(manager.getCountry("AAA")); - EXPECT_TRUE(manager.getCountry("BBB")); - EXPECT_TRUE(manager.getCountry("CCC")); - EXPECT_FALSE(manager.getCountry("DDD")); -} - -TEST(EU4World_CountryManagerTests, ProvinceLessNationsCanBeDeleted) -{ - std::stringstream provincesInput; - provincesInput << "-1 = { owner = AAA cores={ AAA } }\n"; - provincesInput << "-2 = { owner = AAA cores={ BBB } }\n"; - provincesInput << "-3 = { owner = CCC cores={ CCC } }\n"; - provincesInput << "-4 = { owner = AAA cores={ BBB } }\n"; - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provincesInput); - - std::stringstream countryManagerInput; - countryManagerInput << "AAA = { }\n"; - countryManagerInput << "BBB = { }\n"; // no provinces, to be deleted. - countryManagerInput << "CCC = { }\n"; - countryManagerInput << "DDD = { }\n"; // no provinces, no cores, deleted automatically. - EU4::CountryManager manager; - manager.loadCountries(countryManagerInput); - manager.linkProvincesToCountries(provinceManager); - - manager.filterDeadNations(Configuration::DEADCORES::AllCores); - - EXPECT_TRUE(manager.getCountry("AAA")); - EXPECT_FALSE(manager.getCountry("BBB")); - EXPECT_TRUE(manager.getCountry("CCC")); - EXPECT_FALSE(manager.getCountry("DDD")); -} - -TEST(EU4World_CountryManagerTests, CultureLessNationsCanBeDeleted) -{ - std::stringstream provincesInput; - provincesInput << "-1 = { owner = AAA cores={ AAA } culture = livingCulture religion = irrelevant }\n"; - provincesInput << "-2 = { owner = AAA cores={ BBB } culture = livingCulture religion = irrelevant }\n"; - provincesInput << "-3 = { owner = AAA cores={ CCC } culture = livingCulture religion = irrelevant }\n"; - provincesInput << "-4 = { owner = AAA cores={ BBB } culture = livingCulture religion = irrelevant }\n"; - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provincesInput); - - DatingData datingData; - datingData.startEU4Date = date("1444.11.11"); - provinceManager.buildPopRatios(datingData, false); - - std::stringstream countryManagerInput; - countryManagerInput << "AAA = { primary_culture=foreignCulture }\n"; - countryManagerInput << "BBB = { primary_culture=livingCulture }\n"; // culture survives in province 2, country survives. - countryManagerInput << "CCC = { primary_culture=deadCulture }\n"; // culture does not survive in province 3, country is deleted. - countryManagerInput << "DDD = { primary_culture=deadCulture }\n"; // no provinces, no cores, deleted automatically. - EU4::CountryManager manager; - manager.loadCountries(countryManagerInput); - manager.linkProvincesToCountries(provinceManager); - - manager.filterDeadNations(Configuration::DEADCORES::DeadCores); - - EXPECT_TRUE(manager.getCountry("AAA")); - EXPECT_TRUE(manager.getCountry("BBB")); - EXPECT_FALSE(manager.getCountry("CCC")); - EXPECT_FALSE(manager.getCountry("DDD")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryModifierTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryModifierTests.cpp deleted file mode 100644 index 20c8152..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryModifierTests.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "CountryManager/EU4CountryModifier.h" -#include "gtest/gtest.h" - -TEST(EU4World_EU4CountryModifierTests, primitivesDefaultToBlank) -{ - std::stringstream input; - const EU4::EU4CountryModifier modifier(input); - - EXPECT_TRUE(modifier.getModifier().empty()); -} - -TEST(EU4World_Country_EU4CountryModifierTests, modifierCanBeLoaded) -{ - std::stringstream input; - input << "modifier = a_modifier\n"; - const EU4::EU4CountryModifier modifier(input); - - EXPECT_EQ("a_modifier", modifier.getModifier()); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryTests.cpp deleted file mode 100644 index e74f4a3..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4CountryTests.cpp +++ /dev/null @@ -1,878 +0,0 @@ -#include "CountryManager/EU4Country.h" -#include "CountryManager/EU4CountryManager.h" -#include "ProvinceManager/ProvinceManager.h" -#include "gtest/gtest.h" -#include -using testing::ElementsAre; -using testing::UnorderedElementsAre; -#include "UnitTypeLoader/UnitTypeLoader.h" - -TEST(EU4World_EU4CountryTests, countryTagIsStored) -{ - std::stringstream input; - const EU4::Country country("TAG", input); - - EXPECT_EQ("TAG", country.getTag()); -} - -TEST(EU4World_EU4CountryTests, ProvincesAndCoresCanBeStoredAndRetrieved) -{ - std::stringstream input; - EU4::Country country("TAG", input); - - std::stringstream provinceStream; - provinceStream << "-1={}\n"; - provinceStream << "-2={}\n"; - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provinceStream); - - const auto& province1 = provinceManager.getProvince(1); - const auto& province2 = provinceManager.getProvince(2); - - EXPECT_TRUE(country.getProvinces().empty()); - country.addProvince(province1); - country.addProvince(province2); - EXPECT_EQ(2, country.getProvinces().size()); - - EXPECT_TRUE(country.getCores().empty()); - country.addCore(province1); - country.addCore(province2); - EXPECT_EQ(2, country.getCores().size()); -} - -TEST(EU4World_EU4CountryTests, StatusesCanBeToggled) -{ - std::stringstream input; - EU4::Country country("TAG", input); - - EXPECT_FALSE(country.isInHRE()); - EXPECT_FALSE(country.isHREmperor()); - EXPECT_FALSE(country.isCelestialEmperor()); - EXPECT_FALSE(country.isRevolutionary()); - - country.setInHRE(true); - country.setEmperor(true); - country.setCelestialEmperor(true); - country.setRevolutionary(true); - - EXPECT_TRUE(country.isInHRE()); - EXPECT_TRUE(country.isHREmperor()); - EXPECT_TRUE(country.isCelestialEmperor()); - EXPECT_TRUE(country.isRevolutionary()); -} - -TEST(EU4World_EU4CountryTests, capitalScoreAndTechCanBeRead) -{ - std::stringstream deadInput; - const EU4::Country deadCountry("GAT", deadInput); - - EXPECT_EQ(0, deadCountry.getCapital()); - EXPECT_EQ(0, deadCountry.getScore()); - EXPECT_EQ(0, deadCountry.getAdmTech()); - EXPECT_EQ(0, deadCountry.getDipTech()); - EXPECT_EQ(0, deadCountry.getMilTech()); - EXPECT_TRUE(deadCountry.getTechGroup().empty()); - - std::stringstream input; - input << "capital=9\n"; - input << "age_score={1 2 3 4}\n"; - input << "technology = {\n"; - input << " adm_tech=1\n"; - input << " dip_tech=2\n"; - input << " mil_tech=3\n"; - input << "}\n"; - input << "technology_group=western\n"; - const EU4::Country country("TAG", input); - - EXPECT_EQ(9, country.getCapital()); - EXPECT_EQ(10, country.getScore()); - EXPECT_EQ(1, country.getAdmTech()); - EXPECT_EQ(2, country.getDipTech()); - EXPECT_EQ(3, country.getMilTech()); - EXPECT_EQ("western", country.getTechGroup()); -} - -TEST(EU4World_EU4CountryTests, RivalsCanBeRead) -{ - std::stringstream input; - input << "rival = {\n"; - input << " country = TA1\n"; - input << "}\n"; - input << "rival = {\n"; - input << " country = TA2\n"; - input << "}\n"; - const EU4::Country country("TAG", input); - - EXPECT_THAT(country.getRivals(), UnorderedElementsAre("TA1", "TA2")); -} - -TEST(EU4World_EU4CountryTests, cultureAndReligionCanBeRead) -{ - std::stringstream deadInput; - const EU4::Country deadCountry("GAT", deadInput); - - EXPECT_TRUE(deadCountry.getPrimaryCulture().empty()); - EXPECT_TRUE(deadCountry.getReligion().empty()); - - std::stringstream input; - input << "primary_culture=theCulture\n"; - input << "religion=theReligion\n"; - const EU4::Country country("TAG", input); - - EXPECT_EQ("theCulture", country.getPrimaryCulture()); - EXPECT_EQ("theReligion", country.getReligion()); -} - -TEST(EU4World_EU4CountryTests, cultureAndReligionCanBeReadFromHistoryIfLacking) -{ - std::stringstream input; - input << "history={\n"; - input << " primary_culture=theCulture\n"; - input << " religion=theReligion\n"; - input << "}\n"; - const EU4::Country country("TAG", input); - - EXPECT_EQ("theCulture", country.getPrimaryCulture()); - EXPECT_EQ("theReligion", country.getReligion()); -} - -TEST(EU4World_EU4CountryTests, cultureAndReligionSupercedeHistory) -{ - std::stringstream input; - input << "primary_culture=theCulture\n"; - input << "religion=theReligion\n"; - input << "history={\n"; - input << " primary_culture=theCulture2\n"; - input << " religion=theReligion2\n"; - input << "}\n"; - const EU4::Country country("TAG", input); - - EXPECT_EQ("theCulture", country.getPrimaryCulture()); - EXPECT_EQ("theReligion", country.getReligion()); -} - -TEST(EU4World_EU4CountryTests, JapaneseAffairsCanBeSet) -{ - std::stringstream daimyoInput; - daimyoInput << "isolationism=4\n"; - daimyoInput << "government={\n"; - daimyoInput << " reform_stack={\n"; - daimyoInput << " reforms={ daimyo }\n"; - daimyoInput << " }\n"; - daimyoInput << "}\n"; - const EU4::Country daimyo("TAG", daimyoInput); - - EXPECT_EQ(4, daimyo.getIsolationism()); - EXPECT_TRUE(daimyo.isPossibleDaimyo()); - EXPECT_FALSE(daimyo.isPossibleShogun()); - - std::stringstream indepDaimyoInput; - indepDaimyoInput << "government={\n"; - indepDaimyoInput << " reform_stack={\n"; - indepDaimyoInput << " reforms={ indep_daimyo }\n"; - indepDaimyoInput << " }\n"; - indepDaimyoInput << "}\n"; - const EU4::Country indepDaimyo("TAG2", indepDaimyoInput); - - EXPECT_TRUE(indepDaimyo.isPossibleDaimyo()); - EXPECT_FALSE(indepDaimyo.isPossibleShogun()); - - std::stringstream shogunInput; - shogunInput << "government={\n"; - shogunInput << " reform_stack={\n"; - shogunInput << " reforms={ shogunate }\n"; - shogunInput << " }\n"; - shogunInput << "}\n"; - const EU4::Country shogun("TAG3", shogunInput); - - EXPECT_FALSE(shogun.isPossibleDaimyo()); - EXPECT_TRUE(shogun.isPossibleShogun()); -} - -TEST(EU4World_EU4CountryTests, FlagsAndModifiersCanBeSetAndPoked) -{ - std::stringstream input; - input << "flags={\n"; - input << " flag1=blah\n"; - input << " flag2=blah\n"; - input << "}\n"; - input << "hidden_flags={\n"; - input << " flag3=blah\n"; - input << " flag4=blah\n"; - input << "}\n"; - input << "variables={\n"; - input << " flag5=blah\n"; - input << " flag6=blah\n"; - input << "}\n"; - input << "modifier={\n"; - input << " modifier=mod1\n"; - input << "}\n"; - input << "modifier={\n"; - input << " modifier=mod2\n"; - input << "}\n"; - const EU4::Country country("TAG", input); - - EXPECT_THAT(country.getFlags(), UnorderedElementsAre("flag1", "flag2", "flag3", "flag4", "flag5", "flag6")); - EXPECT_TRUE(country.hasFlag("flag1")); - EXPECT_THAT(country.getModifiers(), UnorderedElementsAre("mod1", "mod2")); - EXPECT_TRUE(country.hasModifier("mod1")); -} - -TEST(EU4World_EU4CountryTests, LeadersCanBeReadAndProcessed) -{ - std::stringstream input; - input << "history={\n"; - input << " 1265.1.1={\n"; - input << " leader={\n"; - input << " name=\"Sir. Long Dead\"\n"; - input << " id={\n"; - input << " id=1\n"; - input << " }\n"; - input << " }\n"; - input << " }\n"; - input << " 1765.1.1={\n"; - input << " leader={\n"; - input << " name=\"Sir. Still Alive\"\n"; - input << " type=admiral\n"; - input << " manuever=6\n"; - input << " id={\n"; - input << " id=2\n"; - input << " }\n"; - input << " }\n"; - input << " }\n"; - input << " 1768.1.1={\n"; - input << " monarch={\n"; - input << " leader={\n"; - input << " name=\"His Majesty Still Kicking\"\n"; - input << " type=general\n"; - input << " fire=4\n"; - input << " id={\n"; - input << " id=3\n"; - input << " }\n"; - input << " }\n"; - input << " }\n"; - input << " }\n"; - input << "}\n"; - input << "leader={\n"; - input << " id=2\n"; - input << "}\n"; - input << "leader={\n"; - input << " id=3\n"; - input << "}\n"; - - const EU4::Country country("TAG", input); - const auto& leaders = country.getCharacters(); - - ASSERT_EQ(2, leaders.size()); - - const auto& leader1 = leaders[0]; - const auto& leader2 = leaders[1]; - - EXPECT_EQ("His Majesty Still Kicking", leader1.leaderName); - EXPECT_TRUE(leader1.ruler); - EXPECT_EQ(4, leader1.fire); - - EXPECT_EQ("Sir. Still Alive", leader2.leaderName); - EXPECT_EQ(6, leader2.maneuver); -} - -TEST(EU4World_EU4CountryTests, DuplicateLeadersAreDitched) -{ - std::stringstream input; - input << "history={\n"; - input << " 1751.1.1={\n"; - input << " heir={\n"; - input << " name=\"I was heir\"\n"; - input << " id={\n"; - input << " id=1\n"; - input << " }\n"; - input << " monarch_name=\"I'll be monarch\"\n"; - input << " }\n"; - input << " }\n"; - input << " 1768.1.1={\n"; - input << " monarch_heir={\n"; - input << " name=\"Now I'm monarch\"\n"; - input << " id={\n"; - input << " id=1\n"; - input << " }\n"; - input << " }\n"; - input << " }\n"; - input << "}\n"; - input << "monarch={\n"; - input << " id=1\n"; - input << "}\n"; - - const EU4::Country country("TAG", input); - const auto& leaders = country.getCharacters(); - - ASSERT_EQ(1, leaders.size()); - - const auto& leader = leaders[0]; - - EXPECT_EQ("Now I'm monarch", leader.name); - EXPECT_TRUE(leader.ruler); -} - -TEST(EU4World_EU4CountryTests, ArmiesCanBeLoaded) -{ - std::stringstream input; - input << "army={\n"; - input << " name = \"Armee royale\"\n"; - input << " location = 183\n"; - input << " regiment = {\n"; - input << " name=\"Reims's 1st Regiment\"\n"; - input << " home = 180\n"; - input << " type = \"chevauchee\"\n"; - input << " }\n"; - input << "}\n"; - - const EU4::Country country("TAG", input); - - ASSERT_EQ(1, country.getArmies().size()); - const auto& army = country.getArmies()[0]; - - EXPECT_EQ("Armee royale", army.getName()); - EXPECT_FALSE(army.getArmyFloats()); - EXPECT_EQ(183, army.getLocation()); - - ASSERT_EQ(1, army.getRegiments().size()); - const auto& regiment = army.getRegiments()[0]; - - EXPECT_EQ("Reims's 1st Regiment", regiment.getName()); - EXPECT_EQ(180, regiment.getHome()); - EXPECT_EQ("chevauchee", regiment.getType()); -} - -TEST(EU4World_EU4CountryTests, RelationsCanBeLoaded) -{ - std::stringstream input; - input << "active_relations={\n"; - input << " C01={\n"; - input << " cached_sum = -45\n"; - input << " attitude = hostile\n"; - input << " }\n"; - input << " C02={\n"; - input << " military_access=something\n"; - input << " attitude = neutral\n"; - input << " }\n"; - input << "}\n"; - - const EU4::Country country("TAG", input); - - ASSERT_EQ(2, country.getRelations().size()); - const auto& C01relation = country.getRelations().at("C01"); - const auto& C02relation = country.getRelations().at("C02"); - - EXPECT_FALSE(C01relation.hasMilitaryAccess()); - EXPECT_EQ(-45, C01relation.getRelations()); - EXPECT_EQ("hostile", C01relation.getAttitude()); - - EXPECT_TRUE(C02relation.hasMilitaryAccess()); - EXPECT_EQ(0, C02relation.getRelations()); - EXPECT_EQ("neutral", C02relation.getAttitude()); -} - -TEST(EU4World_EU4CountryTests, CountryStatsCanBeLoaded) -{ - std::stringstream input; - input << "legitimacy=48\n"; - input << "stability=2\n"; - input << "average_autonomy=0.13\n"; - input << "absolutism=98\n"; - input << "army_tradition=45.2\n"; - input << "navy_tradition=15.2\n"; - input << "army_professionalism=75.4\n"; - - const EU4::Country country("TAG", input); - - EXPECT_NEAR(48, country.getLegitimacy(), 0.0001); - EXPECT_NEAR(2, country.getStability(), 0.0001); - EXPECT_NEAR(0.13, country.getAverageAutonomy(), 0.0001); - EXPECT_NEAR(98, country.getAbsolutism(), 0.0001); - EXPECT_NEAR(45.2, country.getArmyTradition(), 0.0001); - EXPECT_NEAR(15.2, country.getNavyTradition(), 0.0001); - EXPECT_NEAR(75.4, country.getArmyProfessionalism(), 0.0001); -} - -TEST(EU4World_EU4CountryTests, StabilityDefaultsTo0) -{ - std::stringstream input; - const EU4::Country country("TAG", input); - - EXPECT_EQ(0, country.getStability()); -} - -TEST(EU4World_EU4CountryTests, LegitimacyDefaultsTo100) -{ - std::stringstream input; - const EU4::Country country("TAG", input); - - EXPECT_NEAR(100, country.getLegitimacy(), 0.0001); -} - -TEST(EU4World_EU4CountryTests, ColonyDefaultsToFalse) -{ - std::stringstream input; - const EU4::Country country("TAG", input); - - EXPECT_FALSE(country.isColony()); -} - -TEST(EU4World_EU4CountryTests, ColonyCanBeSet) -{ - std::stringstream input; - input << "colonial_parent=SWE\n"; - const EU4::Country country("TAG", input); - - EXPECT_TRUE(country.isColony()); -} - -TEST(EU4World_EU4CountryTests, DependentStuffDefaultsToEmptyZero) -{ - std::stringstream input; - const EU4::Country country("TAG", input); - - EXPECT_TRUE(country.getOverLord().empty()); - EXPECT_EQ(0, country.getLibertyDesire()); -} - -TEST(EU4World_EU4CountryTests, DependentStuffCanBeSet) -{ - std::stringstream input; - input << "overlord=SWE\n"; - input << "liberty_desire=6.600\n"; - const EU4::Country country("TAG", input); - - EXPECT_EQ("SWE", country.getOverLord()); - EXPECT_NEAR(6.6, country.getLibertyDesire(), 0.0001); -} - -TEST(EU4World_EU4CountryTests, GovernmentAndReformsCanBeSetAndPinged) -{ - std::stringstream input; - input << "government_rank = 2\n"; - input << "government = {\n"; - input << " government = monarchy\n"; - input << " reform_stack={\n"; - input << " reforms = { \"monarchy_mechanic\" \"plutocratic_reform\" \"enforce_privileges_reform\" }\n"; - input << " }\n"; - input << "}\n"; - const EU4::Country country("TAG", input); - - EXPECT_EQ(2, country.getGovernmentRank()); - EXPECT_EQ("monarchy", country.getGovernment()); - EXPECT_THAT(country.getReforms(), UnorderedElementsAre("monarchy_mechanic", "plutocratic_reform", "enforce_privileges_reform")); - EXPECT_TRUE(country.hasReform("plutocratic_reform")); - EXPECT_FALSE(country.hasReform("nonsense")); -} - -TEST(EU4World_EU4CountryTests, PoliciesCanBeLoaded) -{ - std::stringstream input; - input << "active_policy = {\n"; - input << " policy = pol1\n"; - input << "}\n"; - input << "active_policy = {\n"; - input << " policy = pol2\n"; - input << "}\n"; - const EU4::Country country("TAG", input); - - EXPECT_THAT(country.getPolicies(), UnorderedElementsAre("pol1", "pol2")); -} - -TEST(EU4World_EU4CountryTests, InstitutionsCanBeLoadedAndPinged) -{ - std::stringstream input; - input << "institutions = {\n"; - input << " 0 1 1 0 0 0 0\n"; - input << "}\n"; - const EU4::Country country("TAG", input); - - EXPECT_THAT(country.getEmbracedInstitutions(), ElementsAre(false, true, true, false, false, false, false)); - EXPECT_EQ(2, country.getNumEmbracedInstitutions()); -} - -TEST(EU4World_EU4CountryTests, IdeasCanBeLoadedAndPinged) -{ - std::stringstream input; - input << "active_idea_groups = {\n"; - input << " religious_ideas = 7\n"; - input << " offensive_ideas = 7\n"; - input << " defensive_ideas = 3\n"; // <- dropped - input << " trade_ideas = 1\n"; // <- dropped - input << "}\n"; - const EU4::Country country("TAG", input); - - EXPECT_THAT(country.getNationalIdeas(), UnorderedElementsAre("religious_ideas", "offensive_ideas")); - EXPECT_TRUE(country.hasNationalIdea("religious_ideas")); - EXPECT_TRUE(country.hasNationalIdea("offensive_ideas")); - EXPECT_FALSE(country.hasNationalIdea("defensive_ideas")); - EXPECT_FALSE(country.hasNationalIdea("trade_ideas")); -} - -TEST(EU4World_EU4CountryTests, ManufactoriesCanBeTallied) -{ - std::stringstream provinceInput; - provinceInput << "buildings={\n"; - provinceInput << " weapons=yes\n"; // We're simulating a province with 2 manufactories. In reality there should be just 1 per province. - provinceInput << " furnace=yes\n"; // this one counts as 3 - provinceInput << "}\n"; - auto province = std::make_shared("-1", provinceInput); - - std::stringstream countryManagerInput; - countryManagerInput << "TAG = {}\n"; - EU4::CountryManager countryManager; - countryManager.loadCountries(countryManagerInput); - - const auto& country = countryManager.getCountry("TAG"); - country->addProvince(province); - country->buildManufactoryCount(countryManager.getCountries()); // it needs all countries for manufactory power transfer to overlord. Lee later tests. - - EXPECT_EQ(4, country->getManufactoryCount()); - EXPECT_EQ(4, country->getManufactoryDensity()); // 4 manufactories per 1 province. -} - -TEST(EU4World_EU4CountryTests, ManufactoriesCanBeTransferredToOverlord) -{ - std::stringstream provinceInput; // we'll be sharing this province among both countries - provinceInput << "buildings={\n"; - provinceInput << " weapons=yes\n"; // We're simulating a province with 2 manufactories. In reality there should be just 1 per province. - provinceInput << " furnace=yes\n"; // this one counts as 3 - provinceInput << "}\n"; - auto province = std::make_shared("-1", provinceInput); - - std::stringstream countryManagerInput; - countryManagerInput << "TAG = { overlord = TA2 }\n"; - countryManagerInput << "TA2 = {}\n"; - EU4::CountryManager countryManager; - countryManager.loadCountries(countryManagerInput); - - const auto& underling = countryManager.getCountry("TAG"); - const auto& overlord = countryManager.getCountry("TA2"); - underling->addProvince(province); - overlord->addProvince(province); - underling->buildManufactoryCount(countryManager.getCountries()); - overlord->buildManufactoryCount(countryManager.getCountries()); - - EXPECT_EQ(2, underling->getManufactoryCount()); // sent half to overlord - EXPECT_EQ(4, underling->getManufactoryDensity()); // density is unaffected as they are physically in underling's borders - EXPECT_EQ(6, overlord->getManufactoryCount()); // got half from underling - EXPECT_EQ(4, overlord->getManufactoryDensity()); // density is unaffected. -} - -TEST(EU4World_EU4CountryTests, NamesAndAdjectivesCanBeLoadedAndPoked) -{ - std::stringstream input; - input << "name = \"the name\"\n"; - input << "adjective = \"the adjective\"\n"; - EU4::Country country("TAG", input); - - country.setLocalizationName("french", "le country"); - country.setLocalizationName("english", "the country"); - country.setLocalizationAdjective("french", "le country's"); - country.setLocalizationAdjective("english", "the country's"); - - EXPECT_EQ("le country", country.getName("french")); - EXPECT_EQ("the country", country.getName("english")); - EXPECT_EQ("le country's", country.getAdjective("french")); - EXPECT_EQ("the country's", country.getAdjective("english")); -} - -TEST(EU4World_EU4CountryTests, NamesAndAdjectivesUseEnglishForFallback) -{ - std::stringstream input; - input << "name = \"the name\"\n"; - input << "adjective = \"the adjective\"\n"; - EU4::Country country("TAG", input); - - country.setLocalizationName("french", "le country"); - country.setLocalizationName("english", "the country"); - country.setLocalizationAdjective("french", "le country's"); - country.setLocalizationAdjective("english", "the country's"); - - EXPECT_EQ("the country", country.getName("german")); - EXPECT_EQ("the country's", country.getAdjective("portugese")); -} - -TEST(EU4World_EU4CountryTests, NamesAndAdjectivesUseBaseGameForFallbackForEnglishForFallback) -{ - std::stringstream input; - input << "name = \"the name\"\n"; - input << "adjective = \"the adjective\"\n"; - EU4::Country country("TAG", input); - - country.setLocalizationName("french", "le country"); - country.setLocalizationAdjective("french", "le country's"); - - // these 2 are set - EXPECT_EQ("le country", country.getName("french")); - EXPECT_EQ("le country's", country.getAdjective("french")); - - // these lack english locs for fallback and aren't set. - EXPECT_EQ("the name", country.getName("english")); - EXPECT_EQ("the adjective", country.getAdjective("russian")); - EXPECT_EQ("the name", country.getName("german")); - EXPECT_EQ("the adjective", country.getAdjective("portugese")); -} - -TEST(EU4World_EU4CountryTests, NationalColorsCanBeLoadedInTheirFullGlory) -{ - std::stringstream input; - input << "colors={\n"; - input << " map_color = { 1 2 3 }\n"; - input << " revolutionary_colors = { 4 5 6 }\n"; - input << " custom_colors = {\n"; - input << " flag = 7\n"; - input << " color = 23\n"; - input << " symbol_index = 34\n"; - input << " flag_colors = {12 34 56}\n"; - input << " }\n"; - input << "}\n"; - const EU4::Country country("TAG", input); - - const auto& symbol = country.getNationalColors(); - - EXPECT_EQ("= rgb { 1 2 3 }", symbol.getMapColor()->outputRgb()); - EXPECT_EQ("= rgb { 4 5 6 }", symbol.getRevolutionaryColor()->outputRgb()); - EXPECT_EQ(8, symbol.getCustomColors()->flagIndex); - EXPECT_EQ(24, symbol.getCustomColors()->colorIndex); - EXPECT_EQ(35, symbol.getCustomColors()->symbolIndex); - EXPECT_EQ("= rgb { 12 34 56 }", symbol.getCustomColors()->flagColors->outputRgb()); -} - -TEST(EU4World_EU4CountryTests, CultureInCoresCanBePingedForCoresUnderForeignRule) -{ - std::stringstream provinceInput; // this province belongs to TAG, but it's a core of GAT and has their primary culture. - provinceInput << "culture = cul\n"; - provinceInput << "religion = rel\n"; - provinceInput << "owner = TAG\n"; - auto province = std::make_shared("-1", provinceInput); - - std::stringstream countryManagerInput; - countryManagerInput << "TAG = { primary_culture = cul2 }\n"; // they don't share the culture with the province - countryManagerInput << "GAT = { primary_culture = cul }\n"; - EU4::CountryManager countryManager; - countryManager.loadCountries(countryManagerInput); - - const auto& tag = countryManager.getCountry("TAG"); - const auto& gat = countryManager.getCountry("GAT"); - tag->addProvince(province); - gat->addCore(province); - - DatingData datingData; - datingData.startEU4Date = date("1444.11.11"); - province->buildPopRatios(datingData); - - EXPECT_TRUE(gat->cultureSurvivesInCores(countryManager.getCountries())); -} - -TEST(EU4World_EU4CountryTests, CultureInCoresCanBePingedForCoresUnderSameCultureRule) -{ - std::stringstream provinceInput; // this province belongs to TAG, but it's a core of GAT and has their primary culture. - provinceInput << "culture = cul\n"; - provinceInput << "religion = rel\n"; - provinceInput << "owner = TAG\n"; - auto province = std::make_shared("-1", provinceInput); - - std::stringstream countryManagerInput; - countryManagerInput << "TAG = { primary_culture = cul }\n"; // they share the culture with Gat's province so it belongs to them, actually. - countryManagerInput << "GAT = { primary_culture = cul }\n"; - EU4::CountryManager countryManager; - countryManager.loadCountries(countryManagerInput); - - const auto& tag = countryManager.getCountry("TAG"); - const auto& gat = countryManager.getCountry("GAT"); - tag->addProvince(province); - gat->addCore(province); - - DatingData datingData; - datingData.startEU4Date = date("1444.11.11"); - province->buildPopRatios(datingData); - - EXPECT_FALSE(gat->cultureSurvivesInCores(countryManager.getCountries())); -} - -TEST(EU4World_EU4CountryTests, CountryWeightSumsProvinceWeight) -{ - std::stringstream province1Input; - province1Input << "owner = TAG\n"; - province1Input << "base_tax = 3\n"; - province1Input << "base_production = 4\n"; - province1Input << "base_manpower = 5\n"; - auto province1 = std::make_shared("-1", province1Input); - - std::stringstream province2Input; - province2Input << "owner = TAG\n"; - province2Input << "base_tax = 13\n"; - province2Input << "base_production = 14\n"; - province2Input << "base_manpower = 15\n"; - auto province2 = std::make_shared("-2", province2Input); - - const EU4::BuildingCostLoader buildings; - - province1->determineProvinceWeight(buildings); - province2->determineProvinceWeight(buildings); - - std::stringstream input; - EU4::Country country("TAG", input); - - country.addProvince(province1); - country.addProvince(province2); - - EXPECT_NEAR(12, province1->getProvinceWeight(), 0.0001); - EXPECT_NEAR(42, province2->getProvinceWeight(), 0.0001); - EXPECT_NEAR(54, country.getCountryWeight(), 0.0001); -} - -TEST(EU4World_EU4CountryTests, CountryReturnsAverageProvinceDevelopment) -{ - std::stringstream province1Input; - province1Input << "owner = TAG\n"; - province1Input << "base_tax = 3\n"; - province1Input << "base_production = 4\n"; - province1Input << "base_manpower = 5\n"; - auto province1 = std::make_shared("-1", province1Input); - - std::stringstream province2Input; - province2Input << "owner = TAG\n"; - province2Input << "base_tax = 13\n"; - province2Input << "base_production = 14\n"; - province2Input << "base_manpower = 15\n"; - auto province2 = std::make_shared("-2", province2Input); - - std::stringstream input; - EU4::Country country("TAG", input); - - country.addProvince(province1); - country.addProvince(province2); - - EXPECT_NEAR(27, country.getAverageDevelopment(), 0.0001); // 12 + 42 = 54, 54 / 2 = 27 -} - -TEST(EU4World_EU4CountryTests, AverageProvinceDevelopmentForNoProvincesIsZero) -{ - std::stringstream input; - EU4::Country country("TAG", input); - - EXPECT_DOUBLE_EQ(0, country.getAverageDevelopment()); -} - -TEST(EU4World_EU4CountryTests, UpdateRegimentTypesUpdatesallArmies) -{ - EU4::UnitTypeLoader unitTypeLoader; - std::stringstream unitInput; - unitInput << "type = heavy_ship maneuver = 60\n"; - unitTypeLoader.loadUnitType("the-manowar", unitInput); - std::stringstream unitInput2; - unitInput2 << "type = transport maneuver = 4\n"; - unitTypeLoader.loadUnitType("the-transport", unitInput2); - std::stringstream unitInput3; - unitInput3 << "type = infantry maneuver = 2\n"; - unitTypeLoader.loadUnitType("native_indian_archer", unitInput3); - std::stringstream unitInput4; - unitInput4 << "type = cavalry maneuver = 4\n"; - unitTypeLoader.loadUnitType("native_indian_horseperson", unitInput4); - - std::stringstream input; - input << "navy={\n"; - input << " name = \"1st Fleet\"\n"; - input << " location = 11\n"; - input << " ship = {name = \"Dulecha\" home = 1211 type = \"the-manowar\"}\n"; - input << " ship = {name = \"Koneba\" home = 1211 type = \"the-manowar\"}\n"; - input << " ship = {name = \"Dallol\" home = 1211 type = \"the-transport\"}\n"; - input << "}\n"; - input << "army={\n"; - input << " name = \"1st Army\"\n"; - input << " location = 971\n"; - input << " regiment = {name = \"Penobscott's 1st Regiment\" home = 971 type = \"native_indian_archer\"}\n"; - input << " regiment = {name = \"Penobscott's 3st Regiment\" home = 971 type = \"native_indian_archer\"}\n"; - input << " regiment = {name = \"Penobscott's 2st Regiment\" home = 971 type = \"native_indian_horseperson\"}\n"; - input << "}\n"; - - EU4::Country country("TAG", input); - - country.updateRegimentTypes(unitTypeLoader); - - const auto& navy = country.getArmies()[0]; - const auto& army = country.getArmies()[1]; - - EXPECT_EQ(120, navy.getTotalTypeStrength("heavy_ship")); // two heavy ships worth 60 each - EXPECT_EQ(4, navy.getTotalTypeStrength("transport")); // one transport worth 4. - EXPECT_EQ(4, army.getTotalTypeStrength("infantry")); // two inf regiments worth 2 each - EXPECT_EQ(4, army.getTotalTypeStrength("cavalry")); // one cav regiment worth 4 -} - -TEST(EU4World_EU4CountryTests, EatCountryWontEatItself) -{ - std::stringstream input; - auto country = std::make_shared("TAG", input); - - std::stringstream province1Input; - const auto province1 = std::make_shared("-1", province1Input); - - country->addProvince(province1); - country->eatCountry(country); - - EXPECT_FALSE(country->getProvinces().empty()); // province is still inside. -} - -TEST(EU4World_EU4CountryTests, EatCountryFullExample) -{ - std::stringstream provincesInput; - provincesInput << "-1 = { cores={EAT} }\n"; // to eater - provincesInput << "-2 = { cores={EAT} }\n"; // to eater - provincesInput << "-3 = { cores={TGT} }\n"; // to target - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provincesInput); - - std::stringstream countryManagerInput; - countryManagerInput << "TGT = { army={} }\n"; // target, tech 0 for simplicity, 1 army, 0 score - countryManagerInput << "EAT = { navy={} \n"; // eater, tech 10, 1 navy, 10 score - countryManagerInput << " technology = { adm_tech = 10 dip_tech = 10 mil_tech = 10}\n"; - countryManagerInput << " age_score = { 10 }\n"; - countryManagerInput << "}\n"; - EU4::CountryManager countryManager; - countryManager.loadCountries(countryManagerInput); - - const auto& target = countryManager.getCountry("TGT"); - const auto& eater = countryManager.getCountry("EAT"); - - // weight ratio will be 2:1 - target->addCore(provinceManager.getProvince(1)); - target->addProvince(provinceManager.getProvince(1)); - eater->addCore(provinceManager.getProvince(2)); - eater->addProvince(provinceManager.getProvince(2)); - eater->addCore(provinceManager.getProvince(3)); - eater->addProvince(provinceManager.getProvince(3)); - - // yum - eater->eatCountry(target); - - // eater's score has been lowered by 2:1 from 10 to 6.66 since target was at 0 - EXPECT_NEAR(6.6666, eater->getScore(), 0.0001); - // techs have been lowered by same ratio. - EXPECT_NEAR(6.6666, eater->getAdmTech(), 0.0001); - EXPECT_NEAR(6.6666, eater->getDipTech(), 0.0001); - EXPECT_NEAR(6.6666, eater->getMilTech(), 0.0001); - - // eaten province contains a single core - of the eater - EXPECT_THAT(provinceManager.getProvince(1)->getCores(), UnorderedElementsAre("EAT")); - - // eaten province has been added to the cores and provinces of eater - EXPECT_EQ(1, eater->getCores().at(1)->getID()); - EXPECT_EQ(1, eater->getProvinces().at(1)->getID()); - EXPECT_EQ(3, eater->getCores().size()); - EXPECT_EQ(3, eater->getProvinces().size()); - - // target has no cores or provinces. - EXPECT_TRUE(target->getCores().empty()); - EXPECT_TRUE(target->getProvinces().empty()); - - // eater has both armies - EXPECT_EQ(2, eater->getArmies().size()); - EXPECT_TRUE(eater->getArmies()[0].getArmyFloats()); - EXPECT_FALSE(eater->getArmies()[1].getArmyFloats()); // eaten land army - - // target has no armies - EXPECT_TRUE(target->getArmies().empty()); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4TechnologyTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4TechnologyTests.cpp deleted file mode 100644 index 359dfd7..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/EU4TechnologyTests.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "CountryManager/EU4Technology.h" -#include "gtest/gtest.h" - -TEST(EU4World_EU4TechnologyTests, primitivesDefaultToZero) -{ - std::stringstream input; - const EU4::EU4Technology technology(input); - - EXPECT_EQ(0, technology.getAdm()); - EXPECT_EQ(0, technology.getDip()); - EXPECT_EQ(0, technology.getMil()); -} - -TEST(EU4World_EU4TechnologyTests, technologyLevelsCanBeLoaded) -{ - std::stringstream input; - input << "adm_tech = 1\n"; - input << "dip_tech = 2\n"; - input << "mil_tech = 3\n"; - const EU4::EU4Technology technology(input); - - EXPECT_EQ(1, technology.getAdm()); - EXPECT_EQ(2, technology.getDip()); - EXPECT_EQ(3, technology.getMil()); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/NationalSymbolTests/EU4CustomColorsTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/NationalSymbolTests/EU4CustomColorsTests.cpp deleted file mode 100644 index be4f2cb..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/NationalSymbolTests/EU4CustomColorsTests.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "CountryManager/NationalSymbol/EU4CustomColors.h" -#include "gtest/gtest.h" - -TEST(EU4World_EU4CustomColorsTests, primitivesDefaultToBlank) -{ - std::stringstream input; - const EU4::CustomColors colors(input); - - const auto& customColorBlock = colors.getCustomColorsBlock(); - - EXPECT_EQ(0, customColorBlock.colorIndex); - EXPECT_EQ(0, customColorBlock.symbolIndex); - EXPECT_EQ(0, customColorBlock.flagIndex); - EXPECT_FALSE(customColorBlock.flagColors); -} - -TEST(EU4World_EU4CustomColorsTests, primitivesCanBeLoadedAndIndexIsIncreased) -{ - std::stringstream input; - input << "flag = 7\n"; - input << "color = 23\n"; - input << "symbol_index = 34\n"; - input << "flag_colors = {12 34 56}\n"; - const EU4::CustomColors colors(input); - const auto& customColorBlock = colors.getCustomColorsBlock(); - - EXPECT_EQ(8, customColorBlock.flagIndex); - EXPECT_EQ(24, customColorBlock.colorIndex); - EXPECT_EQ(35, customColorBlock.symbolIndex); - EXPECT_TRUE(customColorBlock.flagColors); -} - -TEST(EU4World_EU4CustomColorsTests, negativeFlagIndexIsSetTo1) -{ - std::stringstream input; - input << "flag = -2\n"; - const EU4::CustomColors colors(input); - - EXPECT_EQ(1, colors.getCustomColorsBlock().flagIndex); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/NationalSymbolTests/EU4NationalSymbolTests.cpp b/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/NationalSymbolTests/EU4NationalSymbolTests.cpp deleted file mode 100644 index cf0c4c3..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/CountryManagerTests/NationalSymbolTests/EU4NationalSymbolTests.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "CountryManager/NationalSymbol/EU4NationalSymbol.h" -#include "gtest/gtest.h" - -TEST(EU4World_EU4NationalSymbolTests, primitivesDefaultToFalse) -{ - std::stringstream input; - const EU4::NationalSymbol symbol(input); - - EXPECT_FALSE(symbol.getCustomColors()); - EXPECT_FALSE(symbol.getMapColor()); - EXPECT_FALSE(symbol.getRevolutionaryColor()); -} - -TEST(EU4World_EU4NationalSymbolTests, colorsCanBeLoaded) -{ - std::stringstream input; - input << "map_color = { 1 2 3 }\n"; - input << "revolutionary_colors = { 4 5 6 }\n"; - input << "custom_colors = {\n"; - input << "\tflag = 10\n"; - input << "}\n"; - const EU4::NationalSymbol symbol(input); - - EXPECT_EQ("= rgb { 1 2 3 }", symbol.getMapColor()->outputRgb()); - EXPECT_EQ("= rgb { 4 5 6 }", symbol.getRevolutionaryColor()->outputRgb()); - EXPECT_EQ(11, symbol.getCustomColors()->flagIndex); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/DiplomacyParserTests/DiplomacyParserTests.cpp b/EU5ToVic3Tests/EU5WorldTests/DiplomacyParserTests/DiplomacyParserTests.cpp deleted file mode 100644 index e503cea..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/DiplomacyParserTests/DiplomacyParserTests.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "DiplomacyParser/DiplomacyParser.h" -#include "gtest/gtest.h" - -TEST(EU4World_DiplomacyTests, primitivesDefaultToEmpty) -{ - const EU4::DiplomacyParser diplomacy; - - EXPECT_TRUE(diplomacy.getAgreements().empty()); -} - -TEST(EU4World_DiplomacyTests, dependencyAgreementsAreLoadedDirectly) -{ - std::stringstream input; - input << "dependency = {\n"; - input << " type=tributary\n"; - input << " first=BYZ\n"; - input << " second=TUR\n"; - input << " start_date=1444.11.11\n"; - input << "}\n"; - input << "dependency = {\n"; - input << " type=vassal\n"; - input << " first=BYZ\n"; - input << " second=TUR\n"; - input << " start_date=1445.11.11\n"; - input << "}\n"; - EU4::DiplomacyParser diplomacy; - diplomacy.loadDiplomacy(input); - - ASSERT_EQ(2, diplomacy.getAgreements().size()); - const auto& agreement1 = diplomacy.getAgreements()[0]; - const auto& agreement2 = diplomacy.getAgreements()[1]; - - EXPECT_EQ("tributary", agreement1.getAgreementType()); - EXPECT_EQ("BYZ", agreement1.getOriginTag()); - EXPECT_EQ("TUR", agreement1.getTargetTag()); - EXPECT_EQ(date("1444.11.11"), agreement1.getStartDate()); - EXPECT_EQ("vassal", agreement2.getAgreementType()); - EXPECT_EQ("BYZ", agreement2.getOriginTag()); - EXPECT_EQ("TUR", agreement2.getTargetTag()); - EXPECT_EQ(date("1445.11.11"), agreement2.getStartDate()); -} - -TEST(EU4World_DiplomacyTests, nonDependencyAgreementsHaveTypeOverridden) -{ - std::stringstream input; - input << "royal_marriage = {\n"; - input << " type=irrelevant\n"; - input << "}\n"; - input << "guarantee = {\n"; - input << " type=irrelevant\n"; - input << "}\n"; - input << "alliance = {\n"; - input << " type=irrelevant\n"; - input << "}\n"; - input << "transfer_trade_power = {\n"; - input << " type=irrelevant\n"; - input << "}\n"; - input << "steer_trade = {\n"; - input << " type=irrelevant\n"; - input << "}\n"; - EU4::DiplomacyParser diplomacy; - diplomacy.loadDiplomacy(input); - - ASSERT_EQ(5, diplomacy.getAgreements().size()); - const auto& agreement1 = diplomacy.getAgreements()[0]; - const auto& agreement2 = diplomacy.getAgreements()[1]; - const auto& agreement3 = diplomacy.getAgreements()[2]; - const auto& agreement4 = diplomacy.getAgreements()[3]; - const auto& agreement5 = diplomacy.getAgreements()[4]; - - EXPECT_EQ("royal_marriage", agreement1.getAgreementType()); - EXPECT_EQ("guarantee", agreement2.getAgreementType()); - EXPECT_EQ("alliance", agreement3.getAgreementType()); - EXPECT_EQ("transfer_trade_power", agreement4.getAgreementType()); - EXPECT_EQ("steer_trade", agreement5.getAgreementType()); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/DiplomacyParserTests/EU4AgreementTests.cpp b/EU5ToVic3Tests/EU5WorldTests/DiplomacyParserTests/EU4AgreementTests.cpp deleted file mode 100644 index 9f04550..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/DiplomacyParserTests/EU4AgreementTests.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "DiplomacyParser/EU4Agreement.h" -#include "gtest/gtest.h" - -TEST(EU4World_EU4AgreementTests, primitivesDefaultToDefaults) -{ - std::stringstream input; - const EU4::EU4Agreement agreement(input); - - EXPECT_TRUE(agreement.getAgreementType().empty()); - EXPECT_TRUE(agreement.getOriginTag().empty()); - EXPECT_TRUE(agreement.getTargetTag().empty()); - EXPECT_EQ(date("1.1.1"), agreement.getStartDate()); - EXPECT_EQ(date("1.1.1"), agreement.getEndDate()); -} - -TEST(EU4World_EU4AgreementTests, primitivesCanBeLoaded) -{ - std::stringstream input; - input << "type=vassal\n"; - input << "first=BYZ\n"; - input << "second=TUR\n"; - input << "start_date=1444.11.11\n"; - input << "end_date=1445.1.1\n"; - const EU4::EU4Agreement agreement(input); - - EXPECT_EQ("vassal", agreement.getAgreementType()); - EXPECT_EQ("BYZ", agreement.getOriginTag()); - EXPECT_EQ("TUR", agreement.getTargetTag()); - EXPECT_EQ(date("1444.11.11"), agreement.getStartDate()); - EXPECT_EQ(date("1445.1.1"), agreement.getEndDate()); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/EmpireParser/EmpireParserTests.cpp b/EU5ToVic3Tests/EU5WorldTests/EmpireParser/EmpireParserTests.cpp deleted file mode 100644 index b4f7678..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/EmpireParser/EmpireParserTests.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "EmpireParser/EmpireParser.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_EmpireParserTests, emperorDefaultsToBlank) -{ - std::stringstream input; - const EU4::EmpireParser empire(input); - - EXPECT_TRUE(empire.getEmperor().empty()); -} - -TEST(EU4World_EmpireParserTests, emperorCanBeLoaded) -{ - std::stringstream input; - input << "emperor = HAB\n"; - const EU4::EmpireParser empire(input); - - EXPECT_EQ("HAB", empire.getEmperor()); -} - -TEST(EU4World_EmpireParserTests, refomsDefaultToBlank) -{ - std::stringstream input; - const EU4::EmpireParser empire(input); - - EXPECT_TRUE(empire.getHREReforms().empty()); -} - -TEST(EU4World_EmpireParserTests, reformsCanBeLoaded) -{ - std::stringstream input; - input << "passed_reform=reform1\n"; - input << "passed_reform=reform2\n"; - const EU4::EmpireParser empire(input); - - EXPECT_THAT(empire.getHREReforms(), UnorderedElementsAre("reform1", "reform2")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/BuildingCostLoaderTests/BuildingCostLoaderTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/BuildingCostLoaderTests/BuildingCostLoaderTests.cpp deleted file mode 100644 index f674774..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/BuildingCostLoaderTests/BuildingCostLoaderTests.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "BuildingCostLoader/BuildingCostLoader.h" -#include "gtest/gtest.h" - -TEST(EU4World_BuildingCostLoaderTests, nonExistentBuildingReturnsNullopt) -{ - std::stringstream input; - EU4::BuildingCostLoader theBuildings; - theBuildings.loadBuildingCosts(input); - - EXPECT_EQ(std::nullopt, theBuildings.getBuildingCost("nonBuilding")); -} - -TEST(EU4World_BuildingCostLoaderTests, buildingIsReturned) -{ - std::stringstream input; - input << "testBuilding = {\n"; - input << "\tcost = 100\n"; - input << "}"; - input << "testBuilding2 = {\n"; - input << "\tcost = 200\n"; - input << "}"; - EU4::BuildingCostLoader theBuildings; - theBuildings.loadBuildingCosts(input); - - EXPECT_NEAR(100, *theBuildings.getBuildingCost("testBuilding"), 0.001); - EXPECT_NEAR(200, *theBuildings.getBuildingCost("testBuilding2"), 0.001); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/BuildingCostLoaderTests/BuildingCostTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/BuildingCostLoaderTests/BuildingCostTests.cpp deleted file mode 100644 index 1fbbf02..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/BuildingCostLoaderTests/BuildingCostTests.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "BuildingCostLoader/BuildingCost.h" -#include "gtest/gtest.h" - -TEST(EU4World_BuildingCostTests, costDefaultsToZero) -{ - std::stringstream input; - const EU4::BuildingCost theBuilding(input); - - EXPECT_EQ(0, theBuilding.getCost()); -} - -TEST(EU4World_BuildingCostTests, costCanBeSet) -{ - std::stringstream input; - input << "cost = 100\n"; - const EU4::BuildingCost theBuilding(input); - - EXPECT_NEAR(100, theBuilding.getCost(), 0.001); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ColonialRegionLoaderTests/ColonialRegionLoaderTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ColonialRegionLoaderTests/ColonialRegionLoaderTests.cpp deleted file mode 100644 index a0a1ae2..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ColonialRegionLoaderTests/ColonialRegionLoaderTests.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "ColonialRegionLoader/ColonialRegionLoader.h" -#include "gtest/gtest.h" - -TEST(EU4World_ColonialRegionLoaderTests, provincesCanBeMatched) -{ - std::stringstream input; - input << "colonial_alaska = {\n"; - input << "\ttax_income = 2\n"; - input << "\tprovinces = {\n"; - input << "\t\t1 2 3\n"; - input << "\t}\n"; - input << "}\n"; - input << "colonial_placeholder = {\n"; - input << "\tcolor = { 200 190 20 }\n "; - input << "}\n"; - EU4::ColonialRegionLoader regions; - regions.loadColonialRegions(input); - - EXPECT_EQ("colonial_alaska", regions.getColonialRegionForProvince(1)); - EXPECT_EQ("colonial_alaska", regions.getColonialRegionForProvince(2)); - EXPECT_EQ("colonial_alaska", regions.getColonialRegionForProvince(3)); -} - -TEST(EU4World_ColonialRegionLoaderTests, provincesCanBeMisMatched) -{ - std::stringstream input; - input << "colonial_alaska = {\n"; - input << "\ttax_income = 2\n"; - input << "\tprovinces = {\n"; - input << "\t\t1 2 3\n"; - input << "\t}\n"; - input << "}\n"; - input << "colonial_placeholder = {\n"; - input << "\tcolor = { 200 190 20 }\n "; - input << "}\n"; - EU4::ColonialRegionLoader regions; - regions.loadColonialRegions(input); - - EXPECT_EQ(std::nullopt, regions.getColonialRegionForProvince(4)); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ColonialRegionLoaderTests/ColonialRegionTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ColonialRegionLoaderTests/ColonialRegionTests.cpp deleted file mode 100644 index 460713f..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ColonialRegionLoaderTests/ColonialRegionTests.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "ColonialRegionLoader/ColonialRegion.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_ColonialRegionTests, provincesDefaultToBlank) -{ - std::stringstream input; - const EU4::ColonialRegion region(input); - - EXPECT_TRUE(region.getProvinces().empty()); -} - -TEST(EU4World_ColonialRegionTests, provincesCanBeLoaded) -{ - std::stringstream input; - input << "provinces={\n"; - input << " 1 2 3\n"; - input << "}\n"; - const EU4::ColonialRegion region(input); - - EXPECT_THAT(region.getProvinces(), UnorderedElementsAre(1, 2, 3)); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CommonCountryLoaderTests/CommonCountryLoaderTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CommonCountryLoaderTests/CommonCountryLoaderTests.cpp deleted file mode 100644 index b631c3c..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CommonCountryLoaderTests/CommonCountryLoaderTests.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "CommonCountryLoader/CommonCountryLoader.h" -#include "Configuration.h" -#include "ConverterVersion.h" -#include "gtest/gtest.h" - -TEST(EU4World_CommonCountryLoaderTests, colorsCanBeLoadedFromCommonCountries) -{ - std::stringstream configurationInput; - configurationInput << "EU4DocumentsDirectory = \"TestFiles\"\n"; - configurationInput << "EU4directory = \"TestFiles/eu4installation\"\n"; - configurationInput << "Vic3directory = \"TestFiles/vic3installation\"\n"; - const commonItems::ConverterVersion converterVersion; - const auto configuration = Configuration(configurationInput, converterVersion); - - Mods mods; - mods.emplace_back(Mod("Some mod", "mod/themod.mod")); - - commonItems::ModLoader modLoader; - modLoader.loadMods(configuration.getEU4DocumentsPath(), mods); - mods = modLoader.getMods(); - - auto modFS = commonItems::ModFilesystem("TestFiles/eu4installation/", mods); - - EU4::CommonCountryLoader loader; - loader.loadCommonCountries(modFS); - - EXPECT_EQ("= rgb { 157 51 167 }", loader.getCommonColor("AAA")->outputRgb()); - EXPECT_EQ("= rgb { 49 115 90 }", loader.getCommonColor("BBB")->outputRgb()); - EXPECT_EQ("= rgb { 18 139 228 }", loader.getCommonColor("CCC")->outputRgb()); - EXPECT_EQ(std::nullopt, loader.getCommonColor("DDD")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CultureLoaderTests/CultureGroupParserTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CultureLoaderTests/CultureGroupParserTests.cpp deleted file mode 100644 index 83b5f4d..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CultureLoaderTests/CultureGroupParserTests.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "CultureLoader/CultureGroupParser.h" -#include "CultureLoader/CultureParser.h" -#include "gtest/gtest.h" -#include -using testing::ElementsAre; - -TEST(EU4World_CultureGroupParserTests, nameCanBeSet) -{ - std::stringstream input; - const EU4::CultureGroupParser group("name", input, {}); - - EXPECT_EQ("name", group.getName()); -} - -TEST(EU4World_CultureGroupParserTests, culturesCanBeLoaded) -{ - std::stringstream input; - input << "someculture = {}\n"; - input << "otherculture = {}\n"; - const EU4::CultureGroupParser group("name", input, {}); - - EXPECT_EQ(2, group.getCultures().size()); - EXPECT_TRUE(group.getCultures().contains("someculture")); - EXPECT_TRUE(group.getCultures().contains("otherculture")); -} - -TEST(EU4World_CultureGroupParserTests, culturesCanBeSkipped) -{ - std::stringstream input; - input << "someculture = {}\n"; - input << "otherculture = {}\n"; - const EU4::CultureGroupParser group("name", input, {"someculture"}); - - EXPECT_EQ(1, group.getCultures().size()); - EXPECT_FALSE(group.getCultures().contains("someculture")); - EXPECT_TRUE(group.getCultures().contains("otherculture")); -} - -TEST(EU4World_CultureGroupParserTests, culturesCanBeMerged) -{ - std::stringstream input; - input << "someculture = {\n"; - input << "\tmale_names = { bob }\n"; - input << "\tfemale_names = { boba }\n"; - input << "\tdynasty_names = { bobby }\n"; - input << "}\n"; - EU4::CultureGroupParser group("name", input, {}); - - std::stringstream input2; - input2 << "male_names = { jon }\n"; - input2 << "female_names = { jona }\n"; - input2 << "dynasty_names = { jonny }\n"; - const auto sameCulture = EU4::CultureParser(input2); - - group.mergeCulture("someculture", sameCulture); - - const auto& someCulture = group.getCultures().at("someculture"); - - EXPECT_THAT(someCulture.getMaleNames(), ElementsAre("bob", "jon")); - EXPECT_THAT(someCulture.getFemaleNames(), ElementsAre("boba", "jona")); - EXPECT_THAT(someCulture.getDynastyNames(), ElementsAre("bobby", "jonny")); -} - -TEST(EU4World_CultureGroupParserTests, unmergeableCulturesAreAddedToGroup) -{ - std::stringstream input; - input << "someculture = {\n"; - input << "\tmale_names = { bob }\n"; - input << "\tfemale_names = { boba }\n"; - input << "\tdynasty_names = { bobby }\n"; - input << "}\n"; - EU4::CultureGroupParser group("name", input, {}); - - std::stringstream input2; - input2 << "male_names = { jon }\n"; - input2 << "female_names = { jona }\n"; - input2 << "dynasty_names = { jonny }\n"; - const auto otherCulture = EU4::CultureParser(input2); - - group.mergeCulture("otherculture", otherCulture); - - EXPECT_EQ(2, group.getCultures().size()); - EXPECT_TRUE(group.getCultures().contains("someculture")); - EXPECT_TRUE(group.getCultures().contains("otherculture")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CultureLoaderTests/CultureLoaderTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CultureLoaderTests/CultureLoaderTests.cpp deleted file mode 100644 index a331cbc..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CultureLoaderTests/CultureLoaderTests.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include "CultureLoader/CultureGroupParser.h" -#include "CultureLoader/CultureLoader.h" -#include "gtest/gtest.h" - -TEST(EU4World_CultureLoaderTests, cultureGroupsCanBeLoaded) -{ - std::stringstream input; - input << "groupA = { cultureA = {} }\n"; - input << "groupB = { cultureB = {} }\n"; - EU4::CultureLoader groups; - groups.loadCultures(input); - - EXPECT_EQ(2, groups.getCultureGroupsMap().size()); - EXPECT_TRUE(groups.getCultureGroupsMap().contains("groupA")); - EXPECT_TRUE(groups.getCultureGroupsMap().contains("groupB")); -} - -TEST(EU4World_CultureLoaderTests, excessCulturesAreSkipped) -{ - std::stringstream input; - input << "groupA = { cultureA = {} }\n"; - input << "groupB = { cultureA = {} }\n"; - EU4::CultureLoader groups; - groups.loadCultures(input); - - EXPECT_EQ(2, groups.getCultureGroupsMap().size()); - EXPECT_TRUE(groups.getCultureGroupsMap().contains("groupA")); - EXPECT_TRUE(groups.getCultureGroupsMap().at("groupA").getCultureNames().contains("cultureA")); - EXPECT_TRUE(groups.getCultureGroupsMap().contains("groupB")); - EXPECT_FALSE(groups.getCultureGroupsMap().at("groupB").getCultureNames().contains("cultureA")); -} - -TEST(EU4World_CultureLoaderTests, GroupNameForCultureCanBeRetrieved) -{ - std::stringstream input; - input << "groupA = { cultureA = {} }\n"; - input << "groupB = { cultureB = {} }\n"; - EU4::CultureLoader groups; - groups.loadCultures(input); - - EXPECT_EQ("groupA", groups.getGroupNameForCulture("cultureA")); - EXPECT_EQ("groupB", groups.getGroupNameForCulture("cultureB")); -} - -TEST(EU4World_CultureLoaderTests, GroupNameForCultureReturnsNulloptForFailure) -{ - std::stringstream input; - input << "groupA = { cultureA = {} }\n"; - input << "groupB = { cultureB = {} }\n"; - EU4::CultureLoader groups; - groups.loadCultures(input); - - EXPECT_EQ(std::nullopt, groups.getGroupNameForCulture("cultureC")); -} - -TEST(EU4World_CultureLoaderTests, GroupForCultureCanBeRetrieved) -{ - std::stringstream input; - input << "groupA = { cultureA = {} }\n"; - input << "groupB = { cultureB = {} }\n"; - EU4::CultureLoader groups; - groups.loadCultures(input); - - EXPECT_EQ("groupA", groups.getGroupForCulture("cultureA")->getName()); - EXPECT_EQ("groupB", groups.getGroupForCulture("cultureB")->getName()); -} - -TEST(EU4World_CultureLoaderTests, GroupForCultureReturnsNulloptForFailure) -{ - std::stringstream input; - input << "groupA = { cultureA = {} }\n"; - input << "groupB = { cultureB = {} }\n"; - EU4::CultureLoader groups; - groups.loadCultures(input); - - EXPECT_EQ(std::nullopt, groups.getGroupForCulture("cultureC")); -} - -TEST(EU4World_CultureLoaderTests, CultureCanBePinged) -{ - std::stringstream input; - input << "groupA = { cultureA = {} }\n"; - input << "groupB = { cultureB = {} }\n"; - EU4::CultureLoader groups; - groups.loadCultures(input); - - EXPECT_TRUE(groups.containsCulture("cultureA")); - EXPECT_TRUE(groups.containsCulture("cultureB")); - EXPECT_FALSE(groups.containsCulture("cultureC")); -} - -TEST(EU4World_CultureLoaderTests, mergableCultureGroupsCanBeMerged) -{ - std::stringstream input; - input << "groupA = { cultureA = {} }\n"; - input << "groupB = { cultureB = {} }\n"; - EU4::CultureLoader groups; - groups.loadCultures(input); - - std::stringstream input2; - input2 << "groupA = { cultureC = {} }\n"; - input2 << "groupB = { cultureD = {} }\n"; - groups.loadCultures(input2); - - EXPECT_EQ(2, groups.getCultureGroupsMap().size()); - EXPECT_TRUE(groups.getCultureGroupsMap().contains("groupA")); - EXPECT_TRUE(groups.getCultureGroupsMap().contains("groupB")); - - const auto& cultureGroupA = groups.getCultureGroupsMap().at("groupA"); - EXPECT_EQ(2, cultureGroupA.getCultures().size()); - EXPECT_TRUE(cultureGroupA.getCultures().contains("cultureA")); - EXPECT_TRUE(cultureGroupA.getCultures().contains("cultureC")); - - const auto& cultureGroupB = groups.getCultureGroupsMap().at("groupB"); - EXPECT_EQ(2, cultureGroupB.getCultures().size()); - EXPECT_TRUE(cultureGroupB.getCultures().contains("cultureB")); - EXPECT_TRUE(cultureGroupB.getCultures().contains("cultureD")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CultureLoaderTests/CultureParserTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CultureLoaderTests/CultureParserTests.cpp deleted file mode 100644 index adda566..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/CultureLoaderTests/CultureParserTests.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "CultureLoader/CultureParser.h" -#include "gtest/gtest.h" -#include -using testing::ElementsAre; - -TEST(EU4World_CultureParserTests, primitivesDefaultToDefaults) -{ - std::stringstream input; - const EU4::CultureParser culture(input); - - EXPECT_TRUE(culture.getMaleNames().empty()); - EXPECT_TRUE(culture.getFemaleNames().empty()); - EXPECT_TRUE(culture.getDynastyNames().empty()); - EXPECT_TRUE(culture.getPrimaryTag().empty()); -} - -TEST(EU4World_CultureParserTests, maleNamesCanBeRetrievedAndAdded) -{ - std::stringstream input; - input << "male_names = { Bob Jon }"; - EU4::CultureParser culture(input); - - EXPECT_THAT(culture.getMaleNames(), ElementsAre("Bob", "Jon")); - - const std::vector moreNames = {"Dod", "Kro"}; - - culture.addMaleNames(moreNames); - - EXPECT_THAT(culture.getMaleNames(), ElementsAre("Bob", "Jon", "Dod", "Kro")); -} - -TEST(EU4World_CultureParserTests, femaleNamesCanBeRetrievedAndAdded) -{ - std::stringstream input; - input << "female_names = { Bob Jon }"; - EU4::CultureParser culture(input); - - EXPECT_THAT(culture.getFemaleNames(), ElementsAre("Bob", "Jon")); - - const std::vector moreNames = {"Dod", "Kro"}; - - culture.addFemaleNames(moreNames); - - EXPECT_THAT(culture.getFemaleNames(), ElementsAre("Bob", "Jon", "Dod", "Kro")); -} - -TEST(EU4World_CultureParserTests, dynastyNamesCanBeRetrievedAndAdded) -{ - std::stringstream input; - input << "dynasty_names = { Bob Jon }"; - EU4::CultureParser culture(input); - - EXPECT_THAT(culture.getDynastyNames(), ElementsAre("Bob", "Jon")); - - const std::vector moreNames = {"Dod", "Kro"}; - - culture.addDynastyNames(moreNames); - - EXPECT_THAT(culture.getDynastyNames(), ElementsAre("Bob", "Jon", "Dod", "Kro")); -} - -TEST(EU4World_CultureParserTests, primaryTagCanBeLoadedAndAdded) -{ - std::stringstream input; - input << "primary = TAG"; - EU4::CultureParser culture(input); - - EXPECT_EQ("TAG", culture.getPrimaryTag()); - - culture.setPrimaryTag("GAT"); - EXPECT_EQ("GAT", culture.getPrimaryTag()); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/DefaultMapParserTests/DefaultMapParserTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/DefaultMapParserTests/DefaultMapParserTests.cpp deleted file mode 100644 index ee4f10a..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/DefaultMapParserTests/DefaultMapParserTests.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "DefaultMapParser/DefaultMapParser.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_DefaultMapParserTests, primitivesDefaultToBlank) -{ - std::stringstream input; - EU4::DefaultMapParser defaults; - defaults.loadDefaultMap(input); - - EXPECT_TRUE(defaults.getSeaIDs().empty()); - EXPECT_TRUE(defaults.getRandomsIDs().empty()); - EXPECT_TRUE(defaults.getLakeIDs().empty()); -} - -TEST(EU4World_DefaultMapParserTests, seasCanBeLoadedandPinged) -{ - std::stringstream input; - input << "sea_starts = { 1 2 3 }"; - EU4::DefaultMapParser defaults; - defaults.loadDefaultMap(input); - - EXPECT_THAT(defaults.getSeaIDs(), UnorderedElementsAre(1, 2, 3)); - EXPECT_TRUE(defaults.isSea(1)); - EXPECT_TRUE(defaults.isSea(2)); - EXPECT_TRUE(defaults.isSea(3)); -} - -TEST(EU4World_DefaultMapParserTests, randomsCanBeLoaded) -{ - std::stringstream input; - input << "only_used_for_random = { 1 2 3 }"; - EU4::DefaultMapParser defaults; - defaults.loadDefaultMap(input); - - EXPECT_THAT(defaults.getRandomsIDs(), UnorderedElementsAre(1, 2, 3)); - EXPECT_TRUE(defaults.isRNW(1)); - EXPECT_TRUE(defaults.isRNW(2)); - EXPECT_TRUE(defaults.isRNW(3)); -} - -TEST(EU4World_DefaultMapParserTests, lakesCanBeLoaded) -{ - std::stringstream input; - input << "lakes = { 1 2 3 }"; - EU4::DefaultMapParser defaults; - defaults.loadDefaultMap(input); - - EXPECT_THAT(defaults.getLakeIDs(), UnorderedElementsAre(1, 2, 3)); - EXPECT_TRUE(defaults.isLake(1)); - EXPECT_TRUE(defaults.isLake(2)); - EXPECT_TRUE(defaults.isLake(3)); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/DefinitionScraperTests/DefinitionScraperTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/DefinitionScraperTests/DefinitionScraperTests.cpp deleted file mode 100644 index 75c5dd5..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/DefinitionScraperTests/DefinitionScraperTests.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "DefinitionScraper/DefinitionScraper.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_DefinitionScraperTests, primitivesDefaultToBlank) -{ - std::stringstream input; - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(input); - - EXPECT_TRUE(definitions.getProvinceIDs().empty()); -} - -TEST(EU4World_DefinitionScraperTests, firstLineIsIgnored) -{ - std::stringstream input; - input << "comment\n"; - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(input); - - EXPECT_TRUE(definitions.getProvinceIDs().empty()); -} - -TEST(EU4World_DefinitionScraperTests, definitionsCanBeLoadedAndPinged) -{ - std::stringstream input; - input << "comment\n"; - input << "1;1;2;3;name1;x;\n"; - input << "2;4;5;6;name2;x;\n"; - input << "3;7;8;9;name3;x;\n"; - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(input); - - EXPECT_THAT(definitions.getProvinceIDs(), UnorderedElementsAre(1, 2, 3)); - EXPECT_TRUE(definitions.isValidID(1)); - EXPECT_TRUE(definitions.isValidID(2)); - EXPECT_TRUE(definitions.isValidID(3)); -} - -TEST(EU4World_DefinitionScraperTests, commentsAndEmptyLinesAreIgnored) -{ - std::stringstream input; - input << "comment\n"; - input << "1;1;2;3;name1;x;\n"; - input << "# comment\n"; - input << "\n"; - input << "2;5;6;7;name2;x; # commentmore\n"; - input << "3;1;3;4;name3;x; # commentmore;x;x;1;2;3;x;x;\n"; - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(input); - - EXPECT_THAT(definitions.getProvinceIDs(), UnorderedElementsAre(1, 2, 3)); -} - -TEST(EU4World_DefinitionScraperTests, incompleteRGBDefinitionsAreIgnored) -{ - std::stringstream input; - input << "comment\n"; - input << "1;1;2;3;name1;x;\n"; - input << "2;4;;6;name2;x;\n"; - input << "3;7;8;;name3;x;\n"; - input << "4;;8;9;name3;x;\n"; - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(input); - - EXPECT_THAT(definitions.getProvinceIDs(), UnorderedElementsAre(1)); - EXPECT_TRUE(definitions.isValidID(1)); - EXPECT_FALSE(definitions.isValidID(2)); - EXPECT_FALSE(definitions.isValidID(3)); - EXPECT_FALSE(definitions.isValidID(4)); -} - -TEST(EU4World_DefinitionScraperTests, randomJunkIsIgnored) -{ - std::stringstream input; - input << "comment\n"; - input << "1;junk;2;3;;x;\n"; - input << "2\n"; - input << "johnnyboy\n"; - input << "3;7;8;9;name3;x;\n"; - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(input); - - EXPECT_THAT(definitions.getProvinceIDs(), UnorderedElementsAre(3)); - EXPECT_FALSE(definitions.isValidID(1)); - EXPECT_FALSE(definitions.isValidID(2)); - EXPECT_TRUE(definitions.isValidID(3)); -} - -TEST(EU4World_DefinitionScraperTests, doubleEntriesAreIgnored) -{ - std::stringstream input; - input << "comment\n"; - input << "3;7;8;9;name3;x;\n"; - input << "3;7;8;9;name3;x;\n"; - input << "3;7;8;9;name3;x;\n"; - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(input); - - EXPECT_THAT(definitions.getProvinceIDs(), UnorderedElementsAre(3)); - EXPECT_FALSE(definitions.isValidID(1)); - EXPECT_FALSE(definitions.isValidID(2)); - EXPECT_TRUE(definitions.isValidID(3)); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/LocalizationLoaderTests/EU4LocalizationTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/LocalizationLoaderTests/EU4LocalizationTests.cpp deleted file mode 100644 index b9466c1..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/LocalizationLoaderTests/EU4LocalizationTests.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "CommonFunctions.h" -#include "LocalizationLoader/EU4LocalizationLoader.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -EU4::EU4LocalizationLoader prepLoader() -{ - std::stringstream input; - input << commonItems::utf8BOM << "l_english:\n"; - input << " key1: \"value 1\" # comment\n"; - input << " key2: \"value \"subquoted\" 2\"\n"; - std::stringstream input2; - input2 << commonItems::utf8BOM << "l_french:\n"; - input2 << " key1: \"valuee 1\"\n"; - input2 << " key2: \"valuee \"subquoted\" 2\"\n"; - std::stringstream input3; - input3 << commonItems::utf8BOM << "l_english:\n"; - input3 << " key1: \"replaced value 1\"\n"; // <- modded overrides - - EU4::EU4LocalizationLoader locs; - locs.loadLocalizations(input3); // mods load first. - locs.loadLocalizations(input); - locs.loadLocalizations(input2); - - return locs; -} - -TEST(EU4World_LocalizationLoaderTests, localizationsReturnsLocMapForKey) -{ - const auto locs = prepLoader(); - - EXPECT_THAT(*locs.getTextInEachLanguage("key1"), - testing::UnorderedElementsAre(testing::Pair("english", "replaced value 1"), testing::Pair("french", "valuee 1"))); - EXPECT_THAT(*locs.getTextInEachLanguage("key2"), - testing::UnorderedElementsAre(testing::Pair("english", "value \"subquoted\" 2"), testing::Pair("french", "valuee \"subquoted\" 2"))); -} - -TEST(EU4World_LocalizationLoaderTests, localizationsReturnsLocValueForKey) -{ - const auto locs = prepLoader(); - - EXPECT_EQ("replaced value 1", locs.getTextForKey("key1", "english")); - EXPECT_EQ("valuee \"subquoted\" 2", locs.getTextForKey("key2", "french")); -} - -TEST(EU4World_LocalizationLoaderTests, localizationsReturnsEnglishWhenStuck) -{ - const auto locs = prepLoader(); - - EXPECT_EQ("replaced value 1", *locs.getTextForKey("key1", "alien")); - EXPECT_EQ("value \"subquoted\" 2", *locs.getTextForKey("key2", "alien")); -} - -TEST(EU4World_LocalizationLoaderTests, localizationsReturnsNulloptMapForMissingKeyMap) -{ - const auto locs = prepLoader(); - - const auto& locMap = locs.getTextInEachLanguage("key3"); - - EXPECT_FALSE(locMap); -} - -TEST(EU4World_LocalizationLoaderTests, localizationsReturnsNulloptMapForMissingKey) -{ - const auto locs = prepLoader(); - - const auto& value = locs.getTextForKey("key3", "english"); - - EXPECT_FALSE(value); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ModLoaderTests/ModNamesTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ModLoaderTests/ModNamesTests.cpp index 7ef354f..3a8ad91 100644 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ModLoaderTests/ModNamesTests.cpp +++ b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ModLoaderTests/ModNamesTests.cpp @@ -4,7 +4,7 @@ TEST(EU4World_ModNamesTests, primitivesDefaultToBlank) { std::stringstream input; - const EU4::ModNames theMod(input); + const EU5::ModNames theMod(input); EXPECT_TRUE(theMod.getName().empty()); EXPECT_TRUE(theMod.getPath().empty()); @@ -16,7 +16,7 @@ TEST(EU4World_ModNamesTests, primitivesCanBeSet) input << "name=\"modName\"\n"; input << "filename=\"mod/modPath.mod\"\n"; - const EU4::ModNames theMod(input); + const EU5::ModNames theMod(input); EXPECT_EQ("modName", theMod.getName()); EXPECT_EQ("mod/modPath.mod", theMod.getPath()); } diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ReligionLoaderTests/ReligionEntryTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ReligionLoaderTests/ReligionEntryTests.cpp deleted file mode 100644 index 00b37da..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ReligionLoaderTests/ReligionEntryTests.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "ReligionLoader/ReligionEntry.h" -#include "gtest/gtest.h" - -TEST(EU4World_ReligionEntryTests, EntryDefaultsToNoColor) -{ - std::stringstream input; - const EU4::ReligionEntry entry(input); - - EXPECT_FALSE(entry.getColor()); -} - -TEST(EU4World_ReligionEntryTests, colorCanBeImported) -{ - std::stringstream input; - input << "color = { 1 2 3 }"; - - const EU4::ReligionEntry entry(input); - ASSERT_TRUE(entry.getColor()); - - EXPECT_EQ(commonItems::Color(std::array{1, 2, 3}), entry.getColor()); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ReligionLoaderTests/ReligionLoaderTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ReligionLoaderTests/ReligionLoaderTests.cpp deleted file mode 100644 index 10a48be..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ReligionLoaderTests/ReligionLoaderTests.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "ReligionLoader/ReligionLoader.h" -#include "ReligionLoader/ReligionParser.h" -#include "gtest/gtest.h" -#include -#include -using testing::UnorderedElementsAre; - -namespace -{ -const auto eu4FS = commonItems::ModFilesystem("TestFiles/eu4installation/", {Mod("Some mod", "TestFiles/mod/themod/")}); -} - -TEST(EU4World_ReligionLoaderTests, religionsDefaultToEmpty) -{ - std::stringstream input; - EU4::ReligionLoader theReligions; - theReligions.loadReligions(input); - - EXPECT_TRUE(theReligions.getAllReligions().empty()); -} - -TEST(EU4World_ReligionLoaderTests, religionNamesCanBeImported) -{ - EU4::ReligionLoader theReligions; - theReligions.loadReligions(eu4FS); - - std::set religionNames; - for (const auto& name: theReligions.getAllReligions() | std::views::keys) - religionNames.emplace(name); - - EXPECT_THAT(religionNames, UnorderedElementsAre("religion_2", "religion_3", "converted_dynamic_faith_107", "converted_dynamic_faith_108", "shamanism")); -} - -TEST(EU4World_ReligionLoaderTests, religionsImportWithCorrectReligiousGroups) -{ - EU4::ReligionLoader theReligions; - theReligions.loadReligions(eu4FS); - - EXPECT_THAT(theReligions.getAllReligions(), - UnorderedElementsAre(std::pair("religion_2", EU4::Religion("religion_2", "mod_group_1")), - std::pair("religion_3", EU4::Religion("religion_3", "mod_group_1")), - std::pair("converted_dynamic_faith_107", EU4::Religion("converted_dynamic_faith_107", "mod_group_2", "shamanism")), - std::pair("converted_dynamic_faith_108", EU4::Religion("converted_dynamic_faith_108", "mod_group_3")), - std::pair("shamanism", EU4::Religion("shamanism", "mod_group_1")))); -} - -TEST(EU4World_ReligionLoaderTests, trappingsAreLoadedForSaneCustomReligions) -{ - EU4::ReligionLoader theReligions; - theReligions.loadReligions(eu4FS); - - const auto& religion107 = theReligions.getAllReligions().at("converted_dynamic_faith_107"); - const auto& religion108 = theReligions.getAllReligions().at("converted_dynamic_faith_108"); - - EXPECT_EQ("shamanism", religion107.trappings); // 99_converted_dynamic_faith_107-from-shamanism.txt - EXPECT_TRUE(religion108.trappings.empty()); // 99_converted_dynamic_faith_108-from-.txt -} - -TEST(EU4World_ReligionLoaderTests, loadingInsaneCustomReligionsThrowsWarnings) -{ - EU4::ReligionLoader theReligions; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - theReligions.loadReligions(eu4FS); - std::cout.rdbuf(cout_buffer); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] ! Religion Mapper: Cannot parse filename for metadata: 99_converted_dynamic_faith_108-from-.txt)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] ! Religion Mapper: Filename for custom religion is broken: 99_converted_dynamic_faith_error-.txt)")); -} - -TEST(EU4World_ReligionLoaderTests, GroupForReligionCanBeRetrieved) -{ - std::stringstream input; - input << "groupA = { religionA = {} }\n"; - input << "groupB = { religionB = {} }\n"; - EU4::ReligionLoader groups; - groups.loadReligions(input); - - EXPECT_EQ("groupA", groups.getGroupForReligion("religionA")); - EXPECT_EQ("groupB", groups.getGroupForReligion("religionB")); -} - -TEST(EU4World_ReligionLoaderTests, GroupForReligionReturnsNulloptForFailure) -{ - std::stringstream input; - input << "groupA = { religionA = {} }\n"; - input << "groupB = { religionB = {} }\n"; - EU4::ReligionLoader groups; - groups.loadReligions(input); - - EXPECT_EQ(std::nullopt, groups.getGroupForReligion("religionC")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ReligionLoaderTests/ReligionParserTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ReligionLoaderTests/ReligionParserTests.cpp deleted file mode 100644 index 2905e1f..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/ReligionLoaderTests/ReligionParserTests.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "ReligionLoader/ReligionParser.h" -#include "gtest/gtest.h" - -TEST(EU4World_ReligionParserTests, religionsDefaultToEmpty) -{ - std::stringstream input; - const EU4::ReligionParser religionGroup(input); - const auto& theReligions = religionGroup.getReligions(); - - EXPECT_TRUE(theReligions.empty()); -} - -TEST(EU4World_ReligionParserTests, religionsCanBeImported) -{ - std::stringstream input; - // These keys is not relevant but all unnecessary named keys must be specifically ignored. - input << "defender_of_faith = yes\n"; - input << "can_form_personal_unions = yes\n"; - input << "center_of_religion = 385 # Mecca\n"; - input << "flags_with_emblem_percentage = 33\n"; - input << "flag_emblem_index_range = { 110 110 }\n"; - input << "ai_will_propagate_through_trade = yes\n"; - input << "religious_schools = { big block of bull }\n"; - input << "zoroastrian = {\n"; // <-- - input << "\tcolor = { 1 2 3 }\n"; // <-- - input << "\trest = irrelevant\n"; - input << "}\n"; - input << "harmonized_modifier = harmonized_zoroastrian_group\n"; // also not relevant. - input << "crusade_name = HOLY_WAR\n"; - - const EU4::ReligionParser religionGroup(input); - ASSERT_EQ(1, religionGroup.getReligions().size()); - - const auto& religion = religionGroup.getReligions()[0]; - - EXPECT_EQ("zoroastrian", religion.name); - EXPECT_EQ(commonItems::Color(std::array{1, 2, 3}), religion.color); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/TradeCompanyLoaderTests/TradeCompanyEntryTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/TradeCompanyLoaderTests/TradeCompanyEntryTests.cpp deleted file mode 100644 index ad58ea2..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/TradeCompanyLoaderTests/TradeCompanyEntryTests.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "TradeCompanyLoader/TradeCompanyEntry.h" -#include "gtest/gtest.h" -#include - -TEST(EU4World_TradeCompanyEntryTests, tradeCompanyDefaultsToEmpty) -{ - const EU4::TradeCompanyEntry entry; - const auto& tc = entry.getTradeCompany(); - - EXPECT_TRUE(tc.name.empty()); - EXPECT_FALSE(tc.color); - EXPECT_TRUE(tc.provinces.empty()); - EXPECT_TRUE(tc.locNameKeys.empty()); -} - -TEST(EU4World_TradeCompanyEntryTests, tradeCompanyCanBeLoaded) -{ - std::stringstream input; - input << "color = { 135 104 85 }\n"; - input << "provinces = { 135 104 }\n"; - input << "names = {\n"; - input << " trigger = { some junk }\n"; // skipping this. - input << " name = \"TRADE_COMPANY_INDIA_British_trade_company_south_india\"\n "; - input << "}\n"; - input << "names = {\n"; - input << " name = \"TRADE_COMPANY_WEST_INDIA_Root_Culture_GetName\"\n "; - input << "}\n"; - input << "names = {\n"; - input << " name = \"TRADE_COMPANY_WEST_INDIA_India_Trade_Company\"\n "; - input << "}\n"; - const EU4::TradeCompanyEntry entry(input); - const auto& tc = entry.getTradeCompany(); - - EXPECT_TRUE(tc.name.empty()); - EXPECT_EQ(commonItems::Color(std::array{135, 104, 85}), tc.color); - EXPECT_THAT(tc.provinces, testing::UnorderedElementsAre(135, 104)); - EXPECT_THAT(tc.locNameKeys, testing::UnorderedElementsAre("TRADE_COMPANY_WEST_INDIA_Root_Culture_GetName", "TRADE_COMPANY_WEST_INDIA_India_Trade_Company")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/TradeCompanyLoaderTests/TradeCompanyLoaderTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/TradeCompanyLoaderTests/TradeCompanyLoaderTests.cpp deleted file mode 100644 index c9685ec..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/TradeCompanyLoaderTests/TradeCompanyLoaderTests.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "TradeCompanyLoader/TradeCompanyLoader.h" -#include "gtest/gtest.h" - -namespace -{ -auto modFS = commonItems::ModFilesystem("TestFiles/eu4installation", {}); -} - -TEST(EU4World_TradeCompanyLoaderTests, TradeCompanyProvincesCanBePinged) -{ - EU4::TradeCompanyLoader loader; - loader.loadTradeCompanies(modFS); - - EXPECT_TRUE(loader.isProvinceInTradeRegion(1164)); - EXPECT_TRUE(loader.isProvinceInTradeRegion(518)); - EXPECT_FALSE(loader.isProvinceInTradeRegion(9999)); -} - -TEST(EU4World_TradeCompanyLoaderTests, TradeCompanyProvincesCanBeExcluded) -{ - EU4::TradeCompanyLoader loader; - loader.loadTradeCompanies(modFS); - - EXPECT_TRUE(loader.isProvinceInTradeRegion(1164)); - EXPECT_TRUE(loader.isProvinceInTradeRegion(518)); - - loader.loadExcludedTradeCompanies("TestFiles/configurables/excluded_trade_companies.txt"); - - EXPECT_FALSE(loader.isProvinceInTradeRegion(1164)); - EXPECT_TRUE(loader.isProvinceInTradeRegion(518)); - EXPECT_FALSE(loader.isProvinceInTradeRegion(9999)); -} - -TEST(EU4World_TradeCompanyLoaderTests, TradeCompaniesCanBeRetrieved) -{ - EU4::TradeCompanyLoader loader; - loader.loadTradeCompanies(modFS); - loader.loadExcludedTradeCompanies("TestFiles/configurables/excluded_trade_companies.txt"); - auto tc1 = loader.getTCForProvince(1164); - auto tc2 = loader.getTCForProvince(518); - auto tc3 = loader.getTCForProvince(9999); - - EXPECT_FALSE(tc1); - EXPECT_TRUE(tc2); - EXPECT_FALSE(tc3); - - EXPECT_EQ("trade_company_west_india", (*tc2).name); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/UnitTypeLoaderTests/UnitTypeLoaderTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/UnitTypeLoaderTests/UnitTypeLoaderTests.cpp deleted file mode 100644 index f64f41a..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/UnitTypeLoaderTests/UnitTypeLoaderTests.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "UnitTypeLoader/UnitTypeLoader.h" -#include "UnitTypeLoader/UnitTypeParser.h" -#include "gtest/gtest.h" - -TEST(EU4World_UnitTypeLoaderTests, UnitTypesCanBeMatched) -{ - EU4::UnitTypeLoader unitTypeLoader; - - std::stringstream input; - input << "type = cavalry\n"; - input << "maneuver = 2\n"; - unitTypeLoader.loadUnitType("some-cavalry", input); - std::stringstream input2; - input2 << "type = infantry\n"; - input2 << "maneuver = 4\n"; - unitTypeLoader.loadUnitType("some-infantry", input2); - - const auto unitType1 = unitTypeLoader.getUnitTypeForRegimentTypeName("some-cavalry"); - EXPECT_EQ("cavalry", unitType1->unitType); - EXPECT_EQ(2, unitType1->strength); - - const auto unitType2 = unitTypeLoader.getUnitTypeForRegimentTypeName("some-infantry"); - EXPECT_EQ("infantry", unitType2->unitType); - EXPECT_EQ(4, unitType2->strength); -} - -TEST(EU4World_UnitTypeLoaderTests, UnitTypeMismatchReturnsNullOpt) -{ - EU4::UnitTypeLoader unitTypeLoader; - - std::stringstream input; - input << "type = cavalry\n"; - input << "maneuver = 2\n"; - unitTypeLoader.loadUnitType("some-cavalry", input); - std::stringstream input2; - input2 << "type = infantry\n"; - input2 << "maneuver = 4\n"; - unitTypeLoader.loadUnitType("some-infantry", input2); - - const auto unitType = unitTypeLoader.getUnitTypeForRegimentTypeName("junk"); - EXPECT_EQ(std::nullopt, unitType); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/UnitTypeLoaderTests/UnitTypeParserTests.cpp b/EU5ToVic3Tests/EU5WorldTests/LoaderTests/UnitTypeLoaderTests/UnitTypeParserTests.cpp deleted file mode 100644 index 886fe0c..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/LoaderTests/UnitTypeLoaderTests/UnitTypeParserTests.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "UnitTypeLoader/UnitTypeParser.h" -#include "gtest/gtest.h" - -TEST(EU4world_UnitTypeParserTests, primitivesDefaultToBlank) -{ - std::stringstream input; - const EU4::UnitTypeParser unitType(input); - - EXPECT_EQ(0, unitType.getUnitType().strength); - EXPECT_TRUE(unitType.getUnitType().unitType.empty()); -} - -TEST(EU4world_UnitTypeParserTests, regimentLoadsPrimitives) -{ - std::stringstream input; - input << "type = cavalry\n"; - input << "unit_type = sub_saharan\n"; // irrelevant - input << "maneuver = 2\n"; - input << "offensive_morale = 3\n"; - input << "defensive_morale = 3\n"; - input << "offensive_fire = 0\n"; - input << "defensive_fire = 0\n"; - input << "offensive_shock = 2\n"; - input << "defensive_shock = 2\n"; - const EU4::UnitTypeParser unitType(input); - - EXPECT_EQ(12, unitType.getUnitType().strength); // Sum of all pips loaded. - EXPECT_EQ("cavalry", unitType.getUnitType().unitType); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/DateItemsTests.cpp b/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/DateItemsTests.cpp deleted file mode 100644 index 8430b3a..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/DateItemsTests.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "ProvinceManager/DateItems.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_DateItemsTests, emptyItemsAreNotImported) -{ - std::stringstream input; - const EU4::DateItems dateItems(input); - - EXPECT_TRUE(dateItems.getDateChanges().empty()); -} - -TEST(EU4World_DateItemsTests, itemsCanBeImported) -{ - std::stringstream input; - input << "owner = SWE\n"; - input << "religion = catholic\n"; - input << "culture = swedish\n"; - - const EU4::DateItems dateItems(input); - - EXPECT_THAT(dateItems.getDateChanges(), - UnorderedElementsAre(EU4::DateChange("owner", "SWE"), EU4::DateChange("religion", "catholic"), EU4::DateChange("culture", "swedish"))); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/EU4ProvinceTests.cpp b/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/EU4ProvinceTests.cpp deleted file mode 100644 index c870dc9..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/EU4ProvinceTests.cpp +++ /dev/null @@ -1,350 +0,0 @@ -#include "BuildingCostLoader/BuildingCostLoader.h" -#include "ProvinceManager/EU4Province.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_ProvinceTests, IDProperlyInterpreted) -{ - std::stringstream input; - const EU4::Province theProvince("-42", input); - - EXPECT_EQ(42, theProvince.getID()); -} - -TEST(EU4World_ProvinceTests, primitivesDefaultToDefaults) -{ - std::stringstream input; - const EU4::Province theProvince("-1", input); - - EXPECT_TRUE(theProvince.getName().empty()); - EXPECT_TRUE(theProvince.getOwnerTag().empty()); - EXPECT_TRUE(theProvince.getControllerTag().empty()); - EXPECT_TRUE(theProvince.getCulture().empty()); - EXPECT_TRUE(theProvince.getReligion().empty()); - - EXPECT_FALSE(theProvince.inHre()); - EXPECT_FALSE(theProvince.isTradeCompany()); - EXPECT_FALSE(theProvince.isTerritorialCore()); - - EXPECT_EQ(0.0, theProvince.getBaseTax()); - EXPECT_EQ(0.0, theProvince.getBaseProduction()); - EXPECT_EQ(0.0, theProvince.getBaseManpower()); - - EXPECT_TRUE(theProvince.getCores().empty()); - EXPECT_TRUE(theProvince.getBuildings().empty()); -} - -TEST(EU4World_ProvinceTests, primitivesCanBeSet) -{ - std::stringstream input; - input << "name = theName\n"; - input << "owner = TAG\n"; - input << "controller = TAG2\n"; - input << "culture = theCulture\n"; - input << "religion = theReligion\n"; - - input << "hre = yes\n"; - input << "active_trade_company = yes\n"; - input << "territorial_core = irrelevant\n"; - - input << "base_tax = 3.000\n"; - input << "base_production = 4.000\n"; - input << "base_manpower = 5.000\n"; - - const EU4::Province theProvince("-1", input); - - EXPECT_EQ("theName", theProvince.getName()); - EXPECT_EQ("TAG", theProvince.getOwnerTag()); - EXPECT_EQ("TAG2", theProvince.getControllerTag()); - EXPECT_EQ("theCulture", theProvince.getCulture()); - EXPECT_EQ("theReligion", theProvince.getReligion()); - - EXPECT_TRUE(theProvince.isTerritorialCore()); - EXPECT_TRUE(theProvince.isTradeCompany()); - EXPECT_TRUE(theProvince.inHre()); - - EXPECT_DOUBLE_EQ(3.0, theProvince.getBaseTax()); - EXPECT_DOUBLE_EQ(4.0, theProvince.getBaseProduction()); - EXPECT_DOUBLE_EQ(5.0, theProvince.getBaseManpower()); -} - -TEST(EU4World_ProvinceTests, provinceWithoutFullHistoryInitializesHistory) -{ - std::stringstream input; - input << "culture = cul\n"; - input << "religion = rel\n"; - const EU4::Province theProvince("-1", input); - - const auto& cultureHistory = theProvince.getProvinceHistory().getCultureHistory(); - const auto& religionHistory = theProvince.getProvinceHistory().getReligionHistory(); - - EXPECT_THAT(cultureHistory, UnorderedElementsAre(std::pair(date("1.1.1"), "cul"))); - EXPECT_THAT(religionHistory, UnorderedElementsAre(std::pair(date("1.1.1"), "rel"))); -} - -TEST(EU4World_ProvinceTests, coresCanBeSet) -{ - std::stringstream input; - input << "cores={\n"; - input << "\t\"TAG\"\n"; - input << "}\n"; - const EU4::Province theProvince("-1", input); - - EXPECT_THAT(theProvince.getCores(), UnorderedElementsAre("TAG")); -} - -TEST(EU4World_ProvinceTests, inHreCanRemainNegative) -{ - std::stringstream input; - input << "hre=no\n"; - const EU4::Province theProvince("-1", input); - - EXPECT_FALSE(theProvince.inHre()); -} - -TEST(EU4World_ProvinceTests, inHreCanBeTrue) -{ - std::stringstream input; - input << "hre=yes\n"; - const EU4::Province theProvince("-1", input); - - EXPECT_TRUE(theProvince.inHre()); -} - -TEST(EU4World_ProvinceTests, hasBuildingDefaultsToFalse) -{ - std::stringstream input; - const EU4::Province theProvince("-1", input); - - EXPECT_FALSE(theProvince.hasBuilding("theBuilding")); -} - -TEST(EU4World_ProvinceTests, hasBuildingCanBeTrue) -{ - std::stringstream input; - input << "buildings={\n"; - input << "\ttheBuilding=yes\n"; - input << "}\n"; - const EU4::Province theProvince("-1", input); - - EXPECT_TRUE(theProvince.hasBuilding("theBuilding")); -} - -TEST(EU4World_ProvinceTests, hasGreatProjectDefaultsToFalse) -{ - std::stringstream input; - const EU4::Province theProvince("-1", input); - - EXPECT_FALSE(theProvince.hasGreatProject("test_canal")); -} - -TEST(EU4World_ProvinceTests, hasGreatProjectFindsProjects) -{ - std::stringstream input; - input << "great_projects={\n"; - input << "\t\"test_canal\"\n"; - input << "}\n"; - const EU4::Province theProvince("-1", input); - - EXPECT_TRUE(theProvince.hasGreatProject("test_canal")); -} - -TEST(EU4World_ProvinceTests, provinceWeightWithoutOwnerIsZero) -{ - std::stringstream input; - input << "base_tax = 3\n"; - input << "base_production = 4\n"; - input << "base_manpower = 5\n"; - EU4::Province theProvince("-1", input); - - const EU4::BuildingCostLoader buildings; - - theProvince.determineProvinceWeight(buildings); - - EXPECT_EQ(0.0, theProvince.getProvinceWeight()); -} - -TEST(EU4World_ProvinceTests, provinceWeightWithoutBuildingsIsCombinedDevelopment) -{ - std::stringstream input; - input << "owner = TST\n"; - input << "base_tax = 3\n"; - input << "base_production = 4\n"; - input << "base_manpower = 5\n"; - EU4::Province theProvince("-1", input); - - const EU4::BuildingCostLoader buildings; - - theProvince.determineProvinceWeight(buildings); - - EXPECT_NEAR(12, theProvince.getProvinceWeight(), 0.001); -} - -TEST(EU4World_ProvinceTests, provinceWeightIncreasesByOnePercentOfBuildingsCost) -{ - std::stringstream input; - input << "owner = TST\n"; - input << "base_tax = 3\n"; - input << "base_production = 4\n"; - input << "base_manpower = 5\n"; - input << "buildings = {\n"; - input << "\tshack = lovely\n"; - input << "\twatermill = nice\n"; - input << "}\n"; - EU4::Province theProvince("-1", input); - - std::stringstream buildingStream; - buildingStream << "shack = { cost = 100 }\n"; - buildingStream << "watermill = { cost = 700 }\n"; // sums to 8 in total - EU4::BuildingCostLoader buildings; - buildings.loadBuildingCosts(buildingStream); - - theProvince.determineProvinceWeight(buildings); - - EXPECT_NEAR(20.0, theProvince.getProvinceWeight(), 0.001); -} - -TEST(EU4World_ProvinceTests, investmentFactorForNoOwnerIsZero) -{ - std::stringstream input; - input << "base_tax = 3\n"; - input << "base_production = 4\n"; - input << "base_manpower = 5\n"; - input << "history = {\n"; - input << "\tbase_tax = 1\n"; - input << "\tbase_production = 2\n"; - input << "\tbase_manpower = 1\n"; - input << "}\n"; - - EU4::Province theProvince("-1", input); - - std::stringstream buildingStream; - EU4::BuildingCostLoader buildings; - buildings.loadBuildingCosts(buildingStream); - - theProvince.determineProvinceWeight(buildings); - - EXPECT_EQ(0.0, theProvince.getInvestmentFactor()); -} - -TEST(EU4World_ProvinceTests, investmentWeightWithoutBuildingsCanBeCalculated) -{ - std::stringstream input; - input << "owner = TST\n"; - input << "base_tax = 1\n"; - input << "base_production = 12\n"; // increased by 10 - input << "base_manpower = 1\n"; - input << "history = {\n"; - input << "\tbase_tax = 1\n"; - input << "\tbase_production = 2\n"; - input << "\tbase_manpower = 1\n"; - input << "}\n"; - - EU4::Province theProvince("-1", input); - - std::stringstream buildingStream; - EU4::BuildingCostLoader buildings; - buildings.loadBuildingCosts(buildingStream); - - // Increasing development by 10 gives us a factor of 0 (log10(10) - 1) * 10 - theProvince.determineProvinceWeight(buildings); - - EXPECT_EQ(10.0, theProvince.getInvestedWeight()); -} - -TEST(EU4World_ProvinceTests, investmentWeightUsesOnePercentBuildingsCostAsDev) -{ - std::stringstream input; - input << "owner = TST\n"; - input << "base_tax = 1\n"; - input << "base_production = 92\n"; // increased by 90 - input << "base_manpower = 1\n"; - input << "history = {\n"; - input << "\tbase_tax = 1\n"; - input << "\tbase_production = 2\n"; - input << "\tbase_manpower = 1\n"; - input << "}\n"; - input << "buildings = {\n"; - input << "\tshack = lovely\n"; - input << "\twatermill = nice\n"; - input << "}\n"; - EU4::Province theProvince("-1", input); - - std::stringstream buildingStream; - buildingStream << "shack = { cost = 300 }\n"; - buildingStream << "watermill = { cost = 700 }\n"; // sums to 10 in total - EU4::BuildingCostLoader buildings; - buildings.loadBuildingCosts(buildingStream); - - // Increasing development by 90 + 10 - theProvince.determineProvinceWeight(buildings); - - EXPECT_NEAR(100.0, theProvince.getInvestedWeight(), 0.001); -} - -TEST(EU4World_ProvinceTests, startingCultureCanBeRetrieved) -{ - std::stringstream input; - input << "culture=TAG1Culture\n"; - input << "history = {\n"; - input << " culture=origCulture\n"; - input << " 1736.1.1={\n"; - input << " culture=TAG1Culture\n"; - input << " }\n"; - input << "}\n"; - EU4::Province province("-1", input); - - EXPECT_EQ("origCulture", province.getStartingCulture()); -} - -TEST(EU4World_ProvinceTests, culturePercentCanBeRetrieved) -{ - DatingData datingData; - datingData.startEU4Date = date("1254.11.11"); - - std::stringstream input; - input << "culture=TAG1Culture\n"; - input << "religion=TAG1Religion\n"; - input << "history = {\n"; - input << " culture=origCulture\n"; - input << " religion=origReligion\n"; - input << " 1736.1.1={\n"; - input << " owner=TAG1\n"; - input << " culture=TAG1Culture\n"; - input << " religion=TAG1Religion\n"; - input << " }\n"; - input << "}\n"; - EU4::Province province("-1", input); - province.setAssimilationFactor(0.0025); - province.buildPopRatios(datingData); - - EXPECT_NEAR(0.7785, province.getCulturePercent("origCulture"), 0.0001); - EXPECT_NEAR(0.2214, province.getCulturePercent("TAG1Culture"), 0.0001); -} - -TEST(EU4World_ProvinceTests, culturePercentAfterPurgingIs100) -{ - DatingData datingData; - datingData.startEU4Date = date("1254.11.11"); - - std::stringstream input; - input << "culture=TAG1Culture\n"; - input << "religion=TAG1Religion\n"; - input << "history = {\n"; - input << " culture=origCulture\n"; - input << " religion=origReligion\n"; - input << " 1736.1.1={\n"; - input << " owner=TAG1\n"; - input << " culture=TAG1Culture\n"; - input << " religion=TAG1Religion\n"; - input << " }\n"; - input << "}\n"; - EU4::Province province("-1", input); - province.purgeHistories(); - province.setAssimilationFactor(0.0025); - province.buildPopRatios(datingData); - - EXPECT_NEAR(0, province.getCulturePercent("origCulture"), 0.0001); - EXPECT_NEAR(1, province.getCulturePercent("TAG1Culture"), 0.0001); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/PopRatioTests.cpp b/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/PopRatioTests.cpp deleted file mode 100644 index 97f62d3..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/PopRatioTests.cpp +++ /dev/null @@ -1,221 +0,0 @@ -#include "ProvinceManager/PopRatio.h" -#include "gtest/gtest.h" - -TEST(EU4World_PopRatioTests, defaultConstructionCorrect) -{ - const EU4::PopRatio theRatio("theCulture", "theReligion"); - - EXPECT_EQ("theCulture", theRatio.getCulture()); - EXPECT_EQ("theReligion", theRatio.getReligion()); - EXPECT_DOUBLE_EQ(1.0, theRatio.getUpperRatio()); - EXPECT_DOUBLE_EQ(1.0, theRatio.getMiddleRatio()); - EXPECT_DOUBLE_EQ(1.0, theRatio.getLowerRatio()); -} - -TEST(EU4World_PopRatioTests, decayByAssimilationValuePerYear) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.decay(1, 0.0025); // default assimilation value "1" is 0.0025 (factor = (1.0 - pow(0.75, value)) / 100;) - - EXPECT_DOUBLE_EQ(0.9975, theRatio.getUpperRatio()); - EXPECT_DOUBLE_EQ(0.9975, theRatio.getMiddleRatio()); - EXPECT_DOUBLE_EQ(0.9975, theRatio.getLowerRatio()); -} - -TEST(EU4World_PopRatioTests, decayForHigherAssimilationValue) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.decay(1, 0.068359375); // assimilation value "4" is 0.06835 (factor = (1.0 - pow(0.75, 4)) / 100;) - - EXPECT_DOUBLE_EQ(0.931640625, theRatio.getUpperRatio()); - EXPECT_DOUBLE_EQ(0.931640625, theRatio.getMiddleRatio()); - EXPECT_DOUBLE_EQ(0.931640625, theRatio.getLowerRatio()); -} - -TEST(EU4World_PopRatioTests, decayByZeroAssimilationDoesNoAffectRatios) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.decay(1, 0); // No assimilation - - EXPECT_DOUBLE_EQ(1, theRatio.getUpperRatio()); - EXPECT_DOUBLE_EQ(1, theRatio.getMiddleRatio()); - EXPECT_DOUBLE_EQ(1, theRatio.getLowerRatio()); -} - -TEST(EU4World_PopRatioTests, increaseByDefaultAssimilationValue) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); // ratios are all at 1, we cannot increase them. - theRatio.convertTo("newCulture", "newReligion"); // halving and zeroing ratios to drive them lower. - theRatio.increase(1, 0.0025); // default assimilation value "1" is 0.0025 (factor = (1.0 - pow(0.75, value)) / 100;) - - EXPECT_DOUBLE_EQ(0.50125, theRatio.getUpperRatio()); - EXPECT_DOUBLE_EQ(0.50125, theRatio.getMiddleRatio()); - EXPECT_NEAR(0.0025, theRatio.getLowerRatio(), 0.001); -} - -TEST(EU4World_PopRatioTests, increaseByHigherAssimilationValue) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); // ratios are all at 1, we cannot increase them. - theRatio.convertTo("newCulture", "newReligion"); // halving and zeroing ratios to drive them lower. - theRatio.increase(1, 0.068359375); // assimilation value "4" is 0.06835 (factor = (1.0 - pow(0.75, 4)) / 100;) - - EXPECT_DOUBLE_EQ(0.5341796875, theRatio.getUpperRatio()); - EXPECT_DOUBLE_EQ(0.5341796875, theRatio.getMiddleRatio()); - EXPECT_DOUBLE_EQ(0.068359375, theRatio.getLowerRatio()); -} - -TEST(EU4World_PopRatioTests, increaseByZeroDoesNotAffectPopRatios) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); // ratios are all at 1, we cannot increase them. - theRatio.convertTo("newCulture", "newReligion"); // halving and zeroing ratios to drive them lower. - theRatio.increase(1, 0); // No assimilation - - EXPECT_DOUBLE_EQ(0.5, theRatio.getUpperRatio()); - EXPECT_DOUBLE_EQ(0.5, theRatio.getMiddleRatio()); - EXPECT_DOUBLE_EQ(0, theRatio.getLowerRatio()); -} - -TEST(EU4World_PopRatioTests, convertingFromDecreasesUpperAndMiddleRatio) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.convertFrom(); - - EXPECT_DOUBLE_EQ(0.5, theRatio.getUpperRatio()); - EXPECT_DOUBLE_EQ(0.5, theRatio.getMiddleRatio()); -} - -TEST(EU4World_PopRatioTests, convertingFromDoesNotDecreaseLowerRatio) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.convertFrom(); - - EXPECT_DOUBLE_EQ(1.0, theRatio.getLowerRatio()); -} - -TEST(EU4World_PopRatioTests, convertingToCultureModifiesCulture) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.convertToCulture("newCulture"); - - EXPECT_EQ("newCulture", theRatio.getCulture()); -} - -TEST(EU4World_PopRatioTests, convertingToCultureHalvesUpperAndMiddleRatio) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.convertToCulture("newCulture"); - - EXPECT_DOUBLE_EQ(0.5, theRatio.getUpperRatio()); - EXPECT_DOUBLE_EQ(0.5, theRatio.getMiddleRatio()); -} - -TEST(EU4World_PopRatioTests, convertingToCultureZeroesLowerRatio) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.convertToCulture("newCulture"); - - EXPECT_EQ(0.0, theRatio.getLowerRatio()); -} - -TEST(EU4World_PopRatioTests, convertingToReligionModifiesReligion) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.convertToReligion("newReligion"); - - EXPECT_EQ("newReligion", theRatio.getReligion()); -} - -TEST(EU4World_PopRatioTests, convertingToReligionHalvesUpperAndMiddleRatio) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.convertToReligion("newReligion"); - - EXPECT_DOUBLE_EQ(0.5, theRatio.getUpperRatio()); - EXPECT_DOUBLE_EQ(0.5, theRatio.getMiddleRatio()); -} - -TEST(EU4World_PopRatioTests, convertingToReligionZeroesLowerRatio) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.convertToReligion("newReligion"); - - EXPECT_EQ(0.0, theRatio.getLowerRatio()); -} - -TEST(EU4World_PopRatioTests, convertingToModifiesReligionAndCulture) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.convertTo("newCulture", "newReligion"); - - EXPECT_EQ("newCulture", theRatio.getCulture()); - EXPECT_EQ("newReligion", theRatio.getReligion()); -} - -TEST(EU4World_PopRatioTests, convertingToHavesUpperAndMiddleRatio) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.convertTo("newCulture", "newReligion"); - - EXPECT_DOUBLE_EQ(0.5, theRatio.getUpperRatio()); - EXPECT_DOUBLE_EQ(0.5, theRatio.getMiddleRatio()); -} - -TEST(EU4World_PopRatioTests, convertingToZeroesLowerRatio) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.convertTo("newCulture", "newReligion"); - - EXPECT_EQ(0.0, theRatio.getLowerRatio()); -} - -TEST(EU4World_PopRatioTests, multiplyByFactor) -{ - std::set input; - - EU4::PopRatio theRatio("theCulture", "theReligion"); - theRatio.multiplyRatios(0.5); - - EXPECT_EQ(0.5, theRatio.getUpperRatio()); - EXPECT_EQ(0.5, theRatio.getMiddleRatio()); - EXPECT_EQ(0.5, theRatio.getLowerRatio()); - - theRatio.multiplyRatios(0.5); - - EXPECT_EQ(0.25, theRatio.getUpperRatio()); - EXPECT_EQ(0.25, theRatio.getMiddleRatio()); - EXPECT_EQ(0.25, theRatio.getLowerRatio()); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/ProvinceBuildingsTests.cpp b/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/ProvinceBuildingsTests.cpp deleted file mode 100644 index 4f84755..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/ProvinceBuildingsTests.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "ProvinceManager/ProvinceBuildings.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_ProvinceBuildingsTests, buildingsDefaultsToEmpty) -{ - std::stringstream input; - const EU4::ProvinceBuildings theBuildings(input); - - EXPECT_TRUE(theBuildings.getBuildings().empty()); -} - -TEST(EU4World_ProvinceBuildingsTests, buildingsCanBeAdded) -{ - std::stringstream input; - input << "theBuilding=yes\n"; - const EU4::ProvinceBuildings theBuildings(input); - - EXPECT_THAT(theBuildings.getBuildings(), UnorderedElementsAre("theBuilding")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/ProvinceHistoryTests.cpp b/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/ProvinceHistoryTests.cpp deleted file mode 100644 index 8a107be..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/ProvinceHistoryTests.cpp +++ /dev/null @@ -1,299 +0,0 @@ -#include "ProvinceManager/ProvinceHistory.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(EU4World_ProvinceHistoryTests, originalDevelopmentIsMarked) -{ - std::stringstream input; - input << "base_tax = 3\n"; - input << "base_production = 2\n"; - input << "base_manpower = 1\n"; - const EU4::ProvinceHistory theHistory(input); - - EXPECT_DOUBLE_EQ(6.0, theHistory.getOriginalDevelopment()); -} - -TEST(EU4World_ProvinceHistoryTests, startingCultureCanBeLoadedAndOverridden) -{ - std::stringstream input; - input << "culture = dummy\n"; - EU4::ProvinceHistory theHistory(input); - - EXPECT_EQ("dummy", theHistory.getStartingCulture()); - - theHistory.setStartingCulture("culture"); - - EXPECT_EQ("culture", theHistory.getStartingCulture()); -} - -TEST(EU4World_ProvinceHistoryTests, startingReligionCanBeLoadedAndOverridden) -{ - std::stringstream input; - input << "religion = dummy\n"; - EU4::ProvinceHistory theHistory(input); - - EXPECT_EQ("dummy", theHistory.getStartingReligion()); - - theHistory.setStartingReligion("religion"); - - EXPECT_EQ("religion", theHistory.getStartingReligion()); -} - -TEST(EU4World_ProvinceHistoryTests, historyIsInitializedForBothCultureAndReligion) -{ - std::stringstream input1; - EU4::ProvinceHistory theHistory1(input1); - std::stringstream input2; - input2 << "culture = dummy_culture\n"; - EU4::ProvinceHistory theHistory2(input2); - std::stringstream input3; - input3 << "religion = dummy_religion\n"; - EU4::ProvinceHistory theHistory3(input3); - std::stringstream input4; - input4 << "culture = dummy_culture\n"; - input4 << "religion = dummy_religion\n"; - EU4::ProvinceHistory theHistory4(input4); - - EXPECT_FALSE(theHistory1.hasInitializedHistory()); - EXPECT_FALSE(theHistory2.hasInitializedHistory()); - EXPECT_FALSE(theHistory3.hasInitializedHistory()); - EXPECT_TRUE(theHistory4.hasInitializedHistory()); -} - -TEST(EU4World_ProvinceHistoryTests, dateItemsStoreEntries) -{ - std::stringstream input; - input << "1.1.1 = { owner = t1 }\n"; - input << "1.1.2 = { culture = c1 }\n"; - input << "1.1.3 = { religion = r1 }\n"; - input << "1.1.4 = { owner = t2 }\n"; - input << "1.1.5 = { culture = c2 }\n"; - input << "1.1.6 = { religion = r2 }\n"; - EU4::ProvinceHistory theHistory(input); - - EXPECT_THAT(theHistory.getOwnershipHistory(), - UnorderedElementsAre(std::pair(date("1.1.1"), "t1"), std::pair(date("1.1.4"), "t2"))); - EXPECT_THAT(theHistory.getCultureHistory(), - UnorderedElementsAre(std::pair(date("1.1.2"), "c1"), std::pair(date("1.1.5"), "c2"))); - EXPECT_THAT(theHistory.getReligionHistory(), - UnorderedElementsAre(std::pair(date("1.1.3"), "r1"), std::pair(date("1.1.6"), "r2"))); -} - -TEST(EU4World_ProvinceHistoryTests, popRatiosForTrivialHistoryAreOne) -{ - DatingData datingData; - datingData.startEU4Date = date("1254.11.11"); - - std::stringstream input; - input << "culture=origCulture\n"; - input << "religion=origReligion\n"; - EU4::ProvinceHistory theHistory(input); - theHistory.buildPopRatios(0.0025, datingData); // using default assimilation factor. - - const auto& popRatios = theHistory.getPopRatios(); - - ASSERT_EQ(1, popRatios.size()); - - // There is a single pop ratio filling entire pie chart - const auto& pop1 = popRatios[0]; - EXPECT_EQ("origCulture", pop1.getCulture()); - EXPECT_EQ("origReligion", pop1.getReligion()); - EXPECT_NEAR(1, pop1.getUpperRatio(), 0.0000001); - EXPECT_NEAR(1, pop1.getMiddleRatio(), 0.0000001); - EXPECT_NEAR(1, pop1.getLowerRatio(), 0.0000001); -} - -TEST(EU4World_ProvinceHistoryTests, popRatiosForColonizationAreCalculated) -{ - DatingData datingData; - datingData.startEU4Date = date("1254.11.11"); - datingData.lastEU4Date = date("1737.1.1"); - - std::stringstream input; - input << "culture=origCulture\n"; - input << "religion=origReligion\n"; - input << "1736.1.1={\n"; // colonized 1 year before end date - input << "\towner=TAG1\n"; - input << "\tculture=TAG1Culture\n"; // converted culture - input << "\treligion=TAG1Religion\n"; // converted religion - input << "}\n"; - EU4::ProvinceHistory theHistory(input); - theHistory.buildPopRatios(0.0025, datingData); // using default assimilation factor. - - const auto& popRatios = theHistory.getPopRatios(); - - EXPECT_EQ(2, popRatios.size()); - - // First ratio is the original one. - const auto& pop1 = popRatios[0]; - EXPECT_EQ("origCulture", pop1.getCulture()); - EXPECT_EQ("origReligion", pop1.getReligion()); - EXPECT_NEAR(0.49875, pop1.getUpperRatio(), 0.0000001); - EXPECT_NEAR(0.49875, pop1.getMiddleRatio(), 0.0000001); - EXPECT_NEAR(0.99750, pop1.getLowerRatio(), 0.0000001); // Majority of peasants are still here, they assimilate very hard. - - const auto& pop2 = popRatios[1]; - EXPECT_EQ("TAG1Culture", pop2.getCulture()); - EXPECT_EQ("TAG1Religion", pop2.getReligion()); - EXPECT_NEAR(0.50125, pop2.getUpperRatio(), 0.0000001); // we converted half, and then decayed by 1 year, which is remaining 50% * 0.0025 - EXPECT_NEAR(0.50125, pop2.getMiddleRatio(), 0.0000001); - EXPECT_NEAR(0.00250, pop2.getLowerRatio(), 0.0000001); // 0.0025 * remaining 100% -} - -TEST(EU4World_ProvinceHistoryTests, provinceHistoryCanBePurgedForSimplePopRatio) -{ - DatingData datingData; - datingData.startEU4Date = date("1254.11.11"); - datingData.lastEU4Date = date("1737.1.1"); - - std::stringstream input; - input << "culture=origCulture\n"; - input << "religion=origReligion\n"; - input << "1736.1.1={\n"; // colonized 1 year before end date - input << "\towner=TAG1\n"; - input << "\tculture=TAG1Culture\n"; // converted culture - input << "\treligion=TAG1Religion\n"; // converted religion - input << "}\n"; - EU4::ProvinceHistory theHistory(input); - - theHistory.purgeHistories(); - - ASSERT_EQ(1, theHistory.getCultureHistory().size()); - const auto& cultureEntry = theHistory.getCultureHistory()[0]; - EXPECT_EQ(date("1.1.1"), cultureEntry.first); - EXPECT_EQ("TAG1Culture", cultureEntry.second); - - ASSERT_EQ(1, theHistory.getReligionHistory().size()); - const auto& religionEntry = theHistory.getReligionHistory()[0]; - EXPECT_EQ(date("1.1.1"), religionEntry.first); - EXPECT_EQ("TAG1Religion", religionEntry.second); - - theHistory.buildPopRatios(0.0025, datingData); // using default assimilation factor. - - const auto& popRatios = theHistory.getPopRatios(); - - ASSERT_EQ(1, popRatios.size()); - - const auto& pop = popRatios[0]; - EXPECT_EQ("TAG1Culture", pop.getCulture()); - EXPECT_EQ("TAG1Religion", pop.getReligion()); - EXPECT_NEAR(1, pop.getUpperRatio(), 0.0000001); - EXPECT_NEAR(1, pop.getMiddleRatio(), 0.0000001); - EXPECT_NEAR(1, pop.getLowerRatio(), 0.0000001); -} - -TEST(EU4World_ProvinceHistoryTests, popRatiosCanBeCombined) -{ - DatingData datingData; - datingData.startEU4Date = date("1254.11.11"); - datingData.lastEU4Date = date("1737.1.1"); - - std::stringstream input; - input << "culture=origCulture\n"; - input << "religion=origReligion\n"; - input << "1736.1.1={\n"; // colonized 1 year before end date - input << "\towner=TAG1\n"; - input << "\tculture=TAG1Culture\n"; // converted culture - input << "\treligion=TAG1Religion\n"; // converted religion - input << "}\n"; - input << "1736.7.1={\n"; // recolonized 1/2 year before end date - input << "\towner=TAG1\n"; - input << "\tculture=TAG1Culture\n"; // converted culture - input << "\treligion=TAG1Religion\n"; // converted religion - input << "}\n"; - EU4::ProvinceHistory theHistory(input); - theHistory.buildPopRatios(0.0025, datingData); // using default assimilation factor. - - const auto& popRatios = theHistory.getPopRatios(); - - ASSERT_EQ(2, popRatios.size()); - - // First ratio is the original one. - const auto& pop1 = popRatios[0]; - EXPECT_EQ("origCulture", pop1.getCulture()); - EXPECT_EQ("origReligion", pop1.getReligion()); - EXPECT_NEAR(0.49875, pop1.getUpperRatio(), 0.0000001); - EXPECT_NEAR(0.49875, pop1.getMiddleRatio(), 0.0000001); - EXPECT_NEAR(0.99750, pop1.getLowerRatio(), 0.0000001); // Majority of peasants are still here, they assimilate very hard. - - const auto& pop2 = popRatios[1]; - EXPECT_EQ("TAG1Culture", pop2.getCulture()); - EXPECT_EQ("TAG1Religion", pop2.getReligion()); - EXPECT_NEAR(0.50125, pop2.getUpperRatio(), 0.0000001); // we converted half, and then decayed by 1 year, which is remaining 50% * 0.0025 - EXPECT_NEAR(0.50125, pop2.getMiddleRatio(), 0.0000001); - EXPECT_NEAR(0.00250, pop2.getLowerRatio(), 0.0000001); // 0.0025 * remaining 100% -} - -TEST(EU4World_ProvinceHistoryTests, popRatiosCanBeConstructed) -{ - DatingData datingData; - datingData.startEU4Date = date("1254.11.11"); - - std::stringstream input; - input << "culture=origCulture\n"; - input << "religion=origReligion\n"; - input << "1600.1.1={\n"; // colonized - input << "\towner=TAG1\n"; - input << "\tculture=TAG1Culture\n"; // converted culture - input << "}\n"; - input << "1600.1.10={\n"; // colonized (EU4 error, this entry will be discarded) - input << "\tculture=TAG1Culture\n"; // converted culture - input << "}\n"; - input << "1600.1.20={\n"; // colonized (EU4 error, this entry will be discarded) - input << "\tculture=TAG1Culture\n"; // converted culture - input << "}\n"; - input << "1602.1.1={\n"; // converted religion - input << "\treligion=TAG1Religion\n"; - input << "}\n"; - input << "1603.1.1={\n"; // conquered - input << "\towner=TAG2\n"; - input << "}\n"; - input << "1605.1.1={\n"; // converted religion and culture on same day. - input << "\tculture=TAG2Culture\n"; - input << "\treligion=TAG2Religion\n"; - input << "}\n"; - EU4::ProvinceHistory theHistory(input); - theHistory.buildPopRatios(0.0025, datingData); // using default assimilation factor. - - const auto& popRatios = theHistory.getPopRatios(); - - ASSERT_EQ(4, popRatios.size()); - - // First ratio is the original one. It has been decayed by 236 years (1836 - 1600). - const auto& pop1 = popRatios[0]; - EXPECT_EQ("origCulture", pop1.getCulture()); - EXPECT_EQ("origReligion", pop1.getReligion()); - EXPECT_NEAR(0.0692397, pop1.getUpperRatio(), 0.0000001); - EXPECT_NEAR(0.0692397, pop1.getMiddleRatio(), 0.0000001); - EXPECT_NEAR(0.5539179, pop1.getLowerRatio(), 0.0000001); // Majority of peasants are still here, they assimilate very hard. - - // Second ratio is the tag1Culture ratio from 1602, decayed by 234 years (1836 - 1602). - const auto& pop2 = popRatios[1]; - EXPECT_EQ("TAG1Culture", pop2.getCulture()); - EXPECT_EQ("origReligion", pop2.getReligion()); - EXPECT_NEAR(0.0699347, pop2.getUpperRatio(), 0.0000001); - EXPECT_NEAR(0.0699347, pop2.getMiddleRatio(), 0.0000001); - EXPECT_NEAR(0.0027800, pop2.getLowerRatio(), 0.0000001); // There aren't all that many peasants that converted in those 2 years. - - // Third ratio is from 1605, for Tag1culture/Tag1Religion, for the few folks that also converted religion, decayed by 231 years (1836 - 1605). - const auto& pop3 = popRatios[2]; - EXPECT_EQ("TAG1Culture", pop3.getCulture()); - EXPECT_EQ("TAG1Religion", pop3.getReligion()); - EXPECT_NEAR(0.1412725, pop3.getUpperRatio(), 0.0000001); - EXPECT_NEAR(0.1412725, pop3.getMiddleRatio(), 0.0000001); - EXPECT_NEAR(0.0041961, pop3.getLowerRatio(), 0.0000001); // Very few people assimilated in 3 years. - - // Final ratio is the current (game end date) ratio (defaults to 1836), for Tag2culture/Tag2Religion, decayed by 0 years (1836 - 1836). - const auto& pop4 = popRatios[3]; - EXPECT_EQ("TAG2Culture", pop4.getCulture()); - EXPECT_EQ("TAG2Religion", pop4.getReligion()); - EXPECT_NEAR(0.7195529, pop4.getUpperRatio(), 0.0000001); // Most of nobility and middle class have assimilated. - EXPECT_NEAR(0.7195529, pop4.getMiddleRatio(), 0.0000001); - EXPECT_NEAR(0.4391058, pop4.getLowerRatio(), 0.0000001); // This is where most of assimilated peasants are. - - // Confirm sums are mostly correct: - EXPECT_NEAR(1, pop1.getUpperRatio() + pop2.getUpperRatio() + pop3.getUpperRatio() + pop4.getUpperRatio(), 0.001); - EXPECT_NEAR(1, pop1.getMiddleRatio() + pop2.getMiddleRatio() + pop3.getMiddleRatio() + pop4.getMiddleRatio(), 0.001); - EXPECT_NEAR(1, pop1.getLowerRatio() + pop2.getLowerRatio() + pop3.getLowerRatio() + pop4.getLowerRatio(), 0.001); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/ProvinceManagerTests.cpp b/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/ProvinceManagerTests.cpp deleted file mode 100644 index e72f9c0..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/ProvinceManagerTests/ProvinceManagerTests.cpp +++ /dev/null @@ -1,215 +0,0 @@ -#include "ProvinceManager/ProvinceManager.h" -#include "gtest/gtest.h" -#include - -TEST(EU4World_ProvinceManagerTests, defaultProvinceManagerIsEmpty) -{ - std::stringstream input; - EU4::ProvinceManager theProvinceManager; - theProvinceManager.loadProvinces(input); - - EXPECT_TRUE(theProvinceManager.getAllProvinces().empty()); -} - -TEST(EU4World_ProvinceManagerTests, ProvinceManagerCanBeInput) -{ - std::stringstream input; - input << "-1={}"; - EU4::ProvinceManager theProvinceManager; - theProvinceManager.loadProvinces(input); - - EXPECT_TRUE(theProvinceManager.getAllProvinces().contains(1)); -} - -TEST(EU4World_ProvinceManagerTests, gettingNonExistentProvinceReturnsNullptr) -{ - std::stringstream input; - input << "-1={}"; - EU4::ProvinceManager theProvinceManager; - theProvinceManager.loadProvinces(input); - - EXPECT_EQ(nullptr, theProvinceManager.getProvince(42)); -} - -TEST(EU4World_ProvinceManagerTests, provinceCanBeRetrieved) -{ - std::stringstream input; - input << "-1={}"; - EU4::ProvinceManager theProvinceManager; - theProvinceManager.loadProvinces(input); - - EXPECT_EQ(1, theProvinceManager.getProvince(1)->getID()); -} - -TEST(EU4World_ProvinceManagerTests, provincesCanBeClassified) -{ - std::stringstream defaultMap; - defaultMap << "sea_starts = { 1 }\n"; - defaultMap << "only_used_for_random = { 2 }\n"; - defaultMap << "lakes = { 3 }\n"; - EU4::DefaultMapParser defaults; - defaults.loadDefaultMap(defaultMap); - - std::stringstream definitionsCsv; - definitionsCsv << "comment\n"; - definitionsCsv << "1;1;1;1;name1;x;\n"; // <- sea - definitionsCsv << "2;2;2;2;name2;x;\n"; // <- rnw - definitionsCsv << "3;3;3;3;name3;x;\n"; // <- lake - definitionsCsv << "4;4;4;4;name4;x;\n"; // <- land - definitionsCsv << "5;5;5;5;name5;x;\n"; // <- wasteland - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(definitionsCsv); - - EU4::RegionManager regionMapper; - std::stringstream areaStream; - areaStream << "land_area = { 4 } \n"; - areaStream << "sea_area = { 1 } "; - std::stringstream regionStream; - regionStream << "land_region = { areas = { land_area } }"; - regionStream << "sea_region = { areas = { sea_area } }\n"; - std::stringstream superRegionStream; - superRegionStream << "land_superregion = { land_region }\n"; - superRegionStream << "sea_superregion = { sea_region }"; - regionMapper.loadRegions(areaStream, regionStream, superRegionStream); - - std::stringstream provinceStream; - provinceStream << "-1={}\n"; - provinceStream << "-2={}\n"; - provinceStream << "-3={}\n"; - provinceStream << "-4={}\n"; - provinceStream << "-5={}\n"; - EU4::ProvinceManager theProvinceManager; - theProvinceManager.loadProvinces(provinceStream); - - theProvinceManager.loadDefaultMapParser(defaults); - theProvinceManager.loadDefinitionScraper(definitions); - theProvinceManager.classifyProvinces(regionMapper); - - EXPECT_TRUE(theProvinceManager.getProvince(1)->isSea()); - EXPECT_EQ(nullptr, theProvinceManager.getProvince(2)); // discarded provinces can't be retrieved - EXPECT_EQ(nullptr, theProvinceManager.getProvince(3)); // discarded provinces can't be retrieved - EXPECT_FALSE(theProvinceManager.getProvince(4)->isSea()); - EXPECT_FALSE(theProvinceManager.getProvince(5)->isSea()); - - EXPECT_FALSE(theProvinceManager.isProvinceDiscarded(1)); - EXPECT_TRUE(theProvinceManager.isProvinceDiscarded(2)); - EXPECT_TRUE(theProvinceManager.isProvinceDiscarded(3)); - EXPECT_FALSE(theProvinceManager.isProvinceDiscarded(4)); - EXPECT_FALSE(theProvinceManager.isProvinceDiscarded(5)); - - EXPECT_FALSE(theProvinceManager.isProvinceWasteland(1)); - EXPECT_FALSE(theProvinceManager.isProvinceWasteland(2)); - EXPECT_FALSE(theProvinceManager.isProvinceWasteland(3)); - EXPECT_FALSE(theProvinceManager.isProvinceWasteland(4)); - EXPECT_TRUE(theProvinceManager.isProvinceWasteland(5)); -} - -TEST(EU4World_ProvinceManagerTests, provincesCanBeDiscardedAndWarnedWhenAccessing) -{ - std::stringstream defaultMap; - defaultMap << "sea_starts = { 1 }\n"; - defaultMap << "only_used_for_random = { 2 }\n"; - defaultMap << "lakes = { 3 }\n"; - EU4::DefaultMapParser defaults; - defaults.loadDefaultMap(defaultMap); - - std::stringstream definitionsCsv; - definitionsCsv << "comment\n"; - definitionsCsv << "1;1;1;1;name1;x;\n"; // <- sea - definitionsCsv << "2;2;2;2;name2;x;\n"; // <- rnw, to be discarded - definitionsCsv << "3;3;3;3;name3;x;\n"; // <- lake, to be discarded - definitionsCsv << "4;4;4;4;name4;x;\n"; // <- land - definitionsCsv << "5;5;5;5;name5;x;\n"; // <- wasteland - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(definitionsCsv); - - EU4::RegionManager regionMapper; - std::stringstream areaStream; - areaStream << "land_area = { 4 } \n"; - areaStream << "sea_area = { 1 } "; - std::stringstream regionStream; - regionStream << "land_region = { areas = { land_area } }"; - regionStream << "sea_region = { areas = { sea_area } }\n"; - std::stringstream superRegionStream; - superRegionStream << "land_superregion = { land_region }\n"; - superRegionStream << "sea_superregion = { sea_region }"; - regionMapper.loadRegions(areaStream, regionStream, superRegionStream); - - std::stringstream provinceStream; - provinceStream << "-1={}\n"; - provinceStream << "-2={}\n"; - provinceStream << "-3={}\n"; - provinceStream << "-4={}\n"; - provinceStream << "-5={}\n"; - EU4::ProvinceManager theProvinceManager; - theProvinceManager.loadProvinces(provinceStream); - - theProvinceManager.loadDefaultMapParser(defaults); - theProvinceManager.loadDefinitionScraper(definitions); - theProvinceManager.classifyProvinces(regionMapper); - - EXPECT_FALSE(theProvinceManager.isProvinceDiscarded(1)); - EXPECT_TRUE(theProvinceManager.isProvinceDiscarded(2)); // We're discarding provinces outside political ownership sphere unless wastelands. - EXPECT_TRUE(theProvinceManager.isProvinceDiscarded(3)); // We're discarding provinces outside political ownership sphere unless wastelands. - EXPECT_FALSE(theProvinceManager.isProvinceDiscarded(4)); - EXPECT_FALSE(theProvinceManager.isProvinceDiscarded(5)); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - const auto& prov2 = theProvinceManager.getProvince(2); - const auto& prov3 = theProvinceManager.getProvince(3); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Accessing EU4 province 2 that does not exist (Save/EU4 version mismatch?))")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Accessing EU4 province 3 that does not exist (Save/EU4 version mismatch?))")); - EXPECT_EQ(nullptr, prov2); - EXPECT_EQ(nullptr, prov3); - - std::cout.rdbuf(cout_buffer); -} - -TEST(EU4World_ProvinceManagerTests, provincesClassificationThrowsForDefinitionMismatch) -{ - std::stringstream defaultMap; - defaultMap << "sea_starts = { 1 }\n"; - defaultMap << "only_used_for_random = { 2 }\n"; - defaultMap << "lakes = { 3 }\n"; - EU4::DefaultMapParser defaults; - defaults.loadDefaultMap(defaultMap); - - std::stringstream definitionsCsv; - definitionsCsv << "comment\n"; - definitionsCsv << "1;1;1;1;name1;x;\n"; // <- sea - definitionsCsv << "2;2;2;2;name2;x;\n"; // <- rnw - definitionsCsv << "3;3;3;3;name3;x;\n"; // <- lake - definitionsCsv << "4;4;4;4;name4;x;\n"; // <- land - definitionsCsv << "5;5;5;5;name5;x;\n"; // <- wasteland - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(definitionsCsv); - - EU4::RegionManager regionMapper; - std::stringstream areaStream; - areaStream << "land_area = { 4 } \n"; - areaStream << "sea_area = { 1 } "; - std::stringstream regionStream; - regionStream << "land_region = { areas = { land_area } }"; - regionStream << "sea_region = { areas = { sea_area } }\n"; - std::stringstream superRegionStream; - superRegionStream << "land_superregion = { land_region }\n"; - superRegionStream << "sea_superregion = { sea_region }"; - regionMapper.loadRegions(areaStream, regionStream, superRegionStream); - - std::stringstream provinceStream; - provinceStream << "-1={}\n"; - provinceStream << "-2={}\n"; - provinceStream << "-3={}\n"; - provinceStream << "-4={}\n"; - provinceStream << "-5={}\n"; - provinceStream << "-6={}\n"; // <- rogue province - EU4::ProvinceManager theProvinceManager; - theProvinceManager.loadProvinces(provinceStream); - - theProvinceManager.loadDefaultMapParser(defaults); - theProvinceManager.loadDefinitionScraper(definitions); - EXPECT_THROW(theProvinceManager.classifyProvinces(regionMapper), std::runtime_error); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/AreaTests.cpp b/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/AreaTests.cpp deleted file mode 100644 index 5c4acc9..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/AreaTests.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "RegionManager/Area.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_AreaTests, blankAreasLoadForNoProvinces) -{ - std::stringstream input; - const EU4::Area newArea(input); - - EXPECT_TRUE(newArea.getProvinces().empty()); -} - -TEST(Mappers_AreaTests, provincesCanBeLoaded) -{ - std::stringstream input; - input << "{ 1 2 3 }"; - const EU4::Area newArea(input); - - EXPECT_THAT(newArea.getProvinces(), testing::UnorderedElementsAre(1, 2, 3)); -} - -TEST(Mappers_AreaTests, provincesCanBeFound) -{ - std::stringstream input; - input << "{ 1 2 3 }"; - const EU4::Area newArea(input); - - EXPECT_TRUE(newArea.areaContainsProvince(1)); - EXPECT_TRUE(newArea.areaContainsProvince(2)); - EXPECT_TRUE(newArea.areaContainsProvince(3)); -} - -TEST(Mappers_AreaTests, provinceMismatchReturnsFalse) -{ - std::stringstream input; - input << "{ 1 2 3 }"; - const EU4::Area newArea(input); - - EXPECT_FALSE(newArea.areaContainsProvince(4)); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/RegionManagerTests.cpp b/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/RegionManagerTests.cpp deleted file mode 100644 index f021982..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/RegionManagerTests.cpp +++ /dev/null @@ -1,455 +0,0 @@ -#include "ProvinceManager/ProvinceManager.h" -#include "RegionManager/RegionManager.h" -#include "gtest/gtest.h" - -// This is a collective mapper test for Area, Region, SuperRegion and RegionManager. - -TEST(Mappers_RegionMapperTests, regionMapperCanBeEnabled) -{ - // We start humble, it's a machine. - EU4::RegionManager theMapper; - std::stringstream areaStream; - std::stringstream regionStream; - std::stringstream superRegionStream; - - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - EXPECT_FALSE(theMapper.provinceIsInRegion(1, "test")); - EXPECT_FALSE(theMapper.regionNameIsValid("test")); - EXPECT_FALSE(theMapper.getParentAreaName(1)); - EXPECT_FALSE(theMapper.getParentRegionName(1)); - EXPECT_FALSE(theMapper.getParentSuperRegionName(1)); -} - -TEST(Mappers_RegionMapperTests, loadingBrokenAreaWillThrowException) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "broken_area = { 1 2 3 } "; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }"; - try - { - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - FAIL(); - } - catch (const std::runtime_error& e) - { - EXPECT_STREQ("Region's test_region area test_area does not exist!", e.what()); - } -} - -TEST(Mappers_RegionMapperTests, loadingBrokenRegionWillThrowException) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 2 3 } "; - std::stringstream regionStream; - regionStream << "broken_region = { areas = { test_area } }"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }"; - try - { - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - FAIL(); - } - catch (const std::runtime_error& e) - { - EXPECT_STREQ("Superregion's test_superregion region test_region does not exist!", e.what()); - } -} - -TEST(Mappers_RegionMapperTests, locationServicesWork) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 2 3 } "; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }"; - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - - EXPECT_TRUE(theMapper.provinceIsInRegion(3, "test_area")); - EXPECT_TRUE(theMapper.provinceIsInRegion(2, "test_region")); - EXPECT_TRUE(theMapper.provinceIsInRegion(1, "test_superregion")); - - EXPECT_TRUE(theMapper.provinceIsValid(1)); - EXPECT_TRUE(theMapper.provinceIsValid(2)); - EXPECT_TRUE(theMapper.provinceIsValid(3)); -} - -TEST(Mappers_RegionMapperTests, locationServicesCorrectlyFail) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 2 3 } \n"; - areaStream << "test_area2 = { 4 5 6 } "; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - regionStream << "test_region2 = { areas = { test_area2 } }\n"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }\n"; - superRegionStream << "test_superregion2 = { test_region2 }"; - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - - EXPECT_FALSE(theMapper.provinceIsInRegion(4, "test_area")); - EXPECT_FALSE(theMapper.provinceIsInRegion(5, "test_region")); - EXPECT_FALSE(theMapper.provinceIsInRegion(6, "test_superregion")); -} - -TEST(Mappers_RegionMapperTests, locationServicesFailForNonsense) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 2 3 } \n"; - areaStream << "test_area2 = { 4 5 6 } "; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - regionStream << "test_region2 = { areas = { test_area2 } }\n"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }\n"; - superRegionStream << "test_superregion2 = { test_region2 }"; - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - - EXPECT_FALSE(theMapper.provinceIsInRegion(1, "nonsense")); - EXPECT_FALSE(theMapper.provinceIsInRegion(9, "test_area")); - - EXPECT_FALSE(theMapper.provinceIsValid(9)); -} - -TEST(Mappers_RegionMapperTests, correctParentLocationsReported) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 2 3 } \n"; - areaStream << "test_area2 = { 4 5 6 } "; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - regionStream << "test_region2 = { areas = { test_area2 } }\n"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }\n"; - superRegionStream << "test_superregion2 = { test_region2 }"; - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - - EXPECT_EQ("test_area", *theMapper.getParentAreaName(1)); - EXPECT_EQ("test_region", *theMapper.getParentRegionName(1)); - EXPECT_EQ("test_superregion", *theMapper.getParentSuperRegionName(1)); - EXPECT_EQ("test_area2", *theMapper.getParentAreaName(5)); - EXPECT_EQ("test_region2", *theMapper.getParentRegionName(5)); - EXPECT_EQ("test_superregion2", *theMapper.getParentSuperRegionName(5)); -} - -TEST(Mappers_RegionMapperTests, wrongParentLocationsReturnNullopt) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 2 3 } \n"; - areaStream << "test_area2 = { 4 5 6 } "; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - regionStream << "test_region2 = { areas = { test_area2 } }\n"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }\n"; - superRegionStream << "test_superregion2 = { test_region2 }"; - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - - EXPECT_FALSE(theMapper.getParentAreaName(7)); - EXPECT_FALSE(theMapper.getParentRegionName(7)); - EXPECT_FALSE(theMapper.getParentSuperRegionName(7)); -} - -TEST(Mappers_RegionMapperTests, locationNameValidationWorks) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 2 3 } \n"; - areaStream << "test_area2 = { 4 5 6 } "; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - regionStream << "test_region2 = { areas = { test_area2 } }\n"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }\n"; - superRegionStream << "test_superregion2 = { test_region2 }"; - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - - EXPECT_TRUE(theMapper.regionNameIsValid("test_area")); - EXPECT_TRUE(theMapper.regionNameIsValid("test_region2")); - EXPECT_TRUE(theMapper.regionNameIsValid("test_superregion2")); - EXPECT_FALSE(theMapper.regionNameIsValid("nonsense")); -} - -TEST(Mappers_RegionMapperTests, assimilationCanBeAssignedAndPinged) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 }"; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }\n"; - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - - std::stringstream superGroupStream; - superGroupStream << "test_supergroup = { test_superregion = {assimilation = 2}}\n"; - mappers::SuperGroupMapper superGroupMapper; - superGroupMapper.loadSuperGroups(superGroupStream); - - theMapper.loadSuperGroups(superGroupMapper); - theMapper.applySuperGroups(); - - EXPECT_NEAR(0.004375, *theMapper.getAssimilationFactor(1), 0.0001); -} - -TEST(Mappers_RegionMapperTests, assimilationMismatchReturnsNullopt) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 }"; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }\n"; - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - - std::stringstream superGroupStream; - superGroupStream << "test_supergroup = { test_superregion = {assimilation = 2}}\n"; - mappers::SuperGroupMapper superGroupMapper; - superGroupMapper.loadSuperGroups(superGroupStream); - - theMapper.loadSuperGroups(superGroupMapper); - theMapper.applySuperGroups(); - - EXPECT_EQ(std::nullopt, theMapper.getAssimilationFactor(99)); -} - -TEST(Mappers_RegionMapperTests, superGroupsCanBeAssignedAndPinged) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 }"; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }\n"; - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - - std::stringstream superGroupStream; - superGroupStream << "test_supergroup = { test_superregion = {assimilation = 2}}\n"; - mappers::SuperGroupMapper superGroupMapper; - superGroupMapper.loadSuperGroups(superGroupStream); - - theMapper.loadSuperGroups(superGroupMapper); - theMapper.applySuperGroups(); - - EXPECT_EQ("test_supergroup", theMapper.getParentSuperGroupName(1)); -} - -TEST(Mappers_RegionMapperTests, supergroupMismatchReturnsNullopt) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 }"; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }\n"; - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - - std::stringstream superGroupStream; - superGroupStream << "test_supergroup = { test_superregion = {assimilation = 2}}\n"; - mappers::SuperGroupMapper superGroupMapper; - superGroupMapper.loadSuperGroups(superGroupStream); - - theMapper.loadSuperGroups(superGroupMapper); - theMapper.applySuperGroups(); - - EXPECT_EQ(std::nullopt, theMapper.getParentSuperGroupName(99)); -} - -TEST(Mappers_RegionMapperTests, brokenSupergroupDefaultsToOldWorld) -{ - EU4::RegionManager theMapper; - std::stringstream areaStream; - areaStream << "test_area = { 1 }"; - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion = { test_region }\n"; - theMapper.loadRegions(areaStream, regionStream, superRegionStream); - - std::stringstream superGroupStream; - superGroupStream << "test_supergroup = { test_superregionBROKE = {assimilation = 2}}\n"; - mappers::SuperGroupMapper superGroupMapper; - superGroupMapper.loadSuperGroups(superGroupStream); - - theMapper.loadSuperGroups(superGroupMapper); - theMapper.applySuperGroups(); - - EXPECT_EQ("old_world", theMapper.getParentSuperGroupName(1)); -} - -TEST(Mappers_RegionMapperTests, colonialRegionForProvinceCanBeRetrieved) -{ - std::stringstream colonialInput; - colonialInput << "colonial_alaska = {\n"; - colonialInput << " provinces = {\n"; - colonialInput << " 1 2 3\n"; - colonialInput << " }\n"; - colonialInput << "}\n"; - EU4::ColonialRegionLoader regions; - regions.loadColonialRegions(colonialInput); - - EU4::RegionManager mapper; - mapper.loadColonialRegions(regions); - - EXPECT_EQ("colonial_alaska", mapper.getColonialRegionForProvince(1)); - EXPECT_EQ("colonial_alaska", mapper.getColonialRegionForProvince(2)); - EXPECT_EQ("colonial_alaska", mapper.getColonialRegionForProvince(3)); - EXPECT_EQ(std::nullopt, mapper.getColonialRegionForProvince(4)); -} - -TEST(Mappers_RegionMapperTests, nativeCulturesCanBeCataloguedAndBrowsed) -{ - std::stringstream worldInput; - worldInput << "old_world = { test_superregion3 = {assimilation = 2} }\n"; - worldInput << "new_world = { test_superregion1 = {assimilation = 2} test_superregion2 = {assimilation = 2} }\n"; - mappers::SuperGroupMapper superGroupMapper; - superGroupMapper.loadSuperGroups(worldInput); - - std::stringstream colonialInput; - colonialInput << "colonial_alaska = {\n"; - colonialInput << " provinces = {\n"; - colonialInput << " 1\n"; - colonialInput << " }\n"; - colonialInput << "}\n"; - EU4::ColonialRegionLoader regions; - regions.loadColonialRegions(colonialInput); - - EU4::RegionManager mapper; - mapper.loadColonialRegions(regions); - - EXPECT_EQ("colonial_alaska", mapper.getColonialRegionForProvince(1)); - EXPECT_EQ(std::nullopt, mapper.getColonialRegionForProvince(2)); - - std::stringstream areaStream; - areaStream << "test_area = { 1 } \n"; // <- in colonial region - areaStream << "test_area2 = { 2 } "; // <- not colonial but same continent/superregion/supergroup - areaStream << "test_area3 = { 3 } "; // old world - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - regionStream << "test_region2 = { areas = { test_area2 } }\n"; - regionStream << "test_region3 = { areas = { test_area3 } }\n"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion1 = { test_region }\n"; // <- colonial superregion, new world - superRegionStream << "test_superregion2 = { test_region2 }"; // new world - superRegionStream << "test_superregion3 = { test_region3 }"; // old world - mapper.loadRegions(areaStream, regionStream, superRegionStream); - mapper.loadSuperGroups(superGroupMapper); - mapper.applySuperGroups(); - - std::stringstream provincesInput; - provincesInput << "-1={ history = { culture = nativeCulture } }\n"; - provincesInput << "-2={ history = { culture = otherNativeCulture } }\n}"; - provincesInput << "-3={ history = { culture = invasiveCulture } }\n"; - EU4::ProvinceManager theProvinceManager; - theProvinceManager.loadProvinces(provincesInput); - - EXPECT_EQ("nativeCulture", theProvinceManager.getProvince(1)->getStartingCulture()); - EXPECT_EQ("otherNativeCulture", theProvinceManager.getProvince(2)->getStartingCulture()); - EXPECT_EQ("invasiveCulture", theProvinceManager.getProvince(3)->getStartingCulture()); - - mapper.catalogueNativeCultures(theProvinceManager); - - EXPECT_FALSE(mapper.doesProvinceRequireNeoCulture(1, "nativeCulture")); // false because it's native to the region - EXPECT_FALSE(mapper.doesProvinceRequireNeoCulture(1, "otherNativeCulture")); // false because it's native to the new world - EXPECT_TRUE(mapper.doesProvinceRequireNeoCulture(1, "invasiveCulture")); // true as not native and province is colonial - - EXPECT_FALSE(mapper.doesProvinceRequireNeoCulture(2, "nativeCulture")); // false because not colonial - EXPECT_FALSE(mapper.doesProvinceRequireNeoCulture(2, "otherNativeCulture")); // false because not colonial - EXPECT_FALSE(mapper.doesProvinceRequireNeoCulture(2, "invasiveCulture")); // false because not colonial - - EXPECT_FALSE(mapper.doesProvinceRequireNeoCulture(3, "nativeCulture")); // false because not colonial - EXPECT_FALSE(mapper.doesProvinceRequireNeoCulture(3, "otherNativeCulture")); // false because not colonial - EXPECT_FALSE(mapper.doesProvinceRequireNeoCulture(3, "invasiveCulture")); // false because not colonial -} - -TEST(Mappers_RegionMapperTests, invasiveCulturesCanBeFlagged) -{ - std::stringstream worldInput; - worldInput << "old_world = { test_superregion3 = {assimilation = 2} }\n"; - worldInput << "new_world = { test_superregion1 = {assimilation = 2} test_superregion2 = {assimilation = 2} }\n"; - mappers::SuperGroupMapper superGroupMapper; - superGroupMapper.loadSuperGroups(worldInput); - - std::stringstream colonialInput; - colonialInput << "colonial_alaska = {\n"; - colonialInput << " provinces = {\n"; - colonialInput << " 1\n"; - colonialInput << " }\n"; - colonialInput << "}\n"; - EU4::ColonialRegionLoader regions; - regions.loadColonialRegions(colonialInput); - - EU4::RegionManager mapper; - mapper.loadColonialRegions(regions); - - EXPECT_EQ("colonial_alaska", mapper.getColonialRegionForProvince(1)); - EXPECT_EQ(std::nullopt, mapper.getColonialRegionForProvince(2)); - - std::stringstream areaStream; - areaStream << "test_area = { 1 } \n"; // <- in colonial region - areaStream << "test_area2 = { 2 } "; // <- not colonial but same continent/superregion/supergroup - areaStream << "test_area3 = { 3 } "; // old world - std::stringstream regionStream; - regionStream << "test_region = { areas = { test_area } }"; - regionStream << "test_region2 = { areas = { test_area2 } }\n"; - regionStream << "test_region3 = { areas = { test_area3 } }\n"; - std::stringstream superRegionStream; - superRegionStream << "test_superregion1 = { test_region }\n"; // <- colonial superregion, new world - superRegionStream << "test_superregion2 = { test_region2 }"; // new world - superRegionStream << "test_superregion3 = { test_region3 }"; // old world - mapper.loadRegions(areaStream, regionStream, superRegionStream); - mapper.loadSuperGroups(superGroupMapper); - mapper.applySuperGroups(); - - std::stringstream provincesInput; - provincesInput << "-1={ history = { culture = nativeCulture religion = rel } }\n"; - provincesInput << "-2={ history = { culture = otherNativeCulture religion = rel } }\n}"; - provincesInput << "-3={ history = { culture = invasiveCulture religion = rel } }\n"; - EU4::ProvinceManager theProvinceManager; - theProvinceManager.loadProvinces(provincesInput); - - EXPECT_EQ("nativeCulture", theProvinceManager.getProvince(1)->getStartingCulture()); - EXPECT_EQ("otherNativeCulture", theProvinceManager.getProvince(2)->getStartingCulture()); - EXPECT_EQ("invasiveCulture", theProvinceManager.getProvince(3)->getStartingCulture()); - - mapper.catalogueNativeCultures(theProvinceManager); - - // let's put all cultures in province 1 which generates neocultures. - const auto& prov1 = theProvinceManager.getProvince(1); - prov1->buildPopRatios(DatingData()); // build native ratio - auto history = prov1->getProvinceHistory(); - // first ratio is there: - EXPECT_EQ(1, history.getPopRatios().size()); - history.addPopRatio(EU4::PopRatio("otherNativeCulture", "")); // add the other 2. - history.addPopRatio(EU4::PopRatio("invasiveCulture", "")); - prov1->setProvinceHistory(history); - - mapper.flagNeoCultures(theProvinceManager); - - // now grab all 3 popratios. - const auto& pop1 = prov1->getProvinceHistory().getPopRatios()[0]; - const auto& pop2 = prov1->getProvinceHistory().getPopRatios()[1]; - const auto& pop3 = prov1->getProvinceHistory().getPopRatios()[2]; - - EXPECT_EQ("nativeCulture", pop1.getCulture()); - EXPECT_FALSE(pop1.isNeoCulture()); - - EXPECT_EQ("otherNativeCulture", pop2.getCulture()); - EXPECT_FALSE(pop2.isNeoCulture()); - - EXPECT_EQ("invasiveCulture", pop3.getCulture()); - EXPECT_TRUE(pop3.isNeoCulture()); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/RegionTests.cpp b/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/RegionTests.cpp deleted file mode 100644 index 368237d..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/RegionTests.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "RegionManager/Area.h" -#include "RegionManager/Region.h" -#include "gtest/gtest.h" - -TEST(Mappers_RegionTests, blankRegionLoadsWithNoAreas) -{ - std::stringstream input; - const EU4::Region region(input); - - EXPECT_TRUE(region.getAreas().empty()); -} - -TEST(Mappers_RegionTests, areaCanBeLoaded) -{ - std::stringstream input; - input << "areas = { test_area } \n"; - const EU4::Region region(input); - - EXPECT_TRUE(region.getAreas().contains("test_area")); -} - -TEST(Mappers_RegionTests, multipleAreasCanBeLoaded) -{ - std::stringstream input; - input << "areas = { test_area area2 area3 } \n"; - const EU4::Region region(input); - - EXPECT_EQ(3, region.getAreas().size()); -} - -TEST(Mappers_RegionTests, regionCanBeLinkedToArea) -{ - std::stringstream input; - input << "areas = { test_area area2 area3 } \n"; - EU4::Region region(input); - - std::stringstream input2; - input << "{ 3 4 5 6 } \n"; - auto area2 = std::make_shared(input); - - EXPECT_FALSE(region.getAreas().at("area2")); - region.linkArea(std::pair("area2", area2)); - EXPECT_TRUE(region.getAreas().at("area2")); -} - -TEST(Mappers_RegionTests, LinkedRegionCanLocateProvince) -{ - std::stringstream input; - input << "areas = { area2 } \n"; - EU4::Region region(input); - - std::stringstream input2; - input2 << "{ 3 4 5 6 } \n"; - auto area2 = std::make_shared(input2); - - region.linkArea(std::pair("area2", area2)); - - EXPECT_TRUE(region.regionContainsProvince(5)); -} - -TEST(Mappers_RegionTests, LinkedRegionReturnsFalseForProvinceMismatch) -{ - std::stringstream input; - input << "areas = { area2 } \n"; - EU4::Region region(input); - - std::stringstream input2; - input << "{ 3 4 5 6 } \n"; - auto area2 = std::make_shared(input); - - region.linkArea(std::pair("area2", area2)); - - EXPECT_FALSE(region.regionContainsProvince(9)); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/SuperRegionTests.cpp b/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/SuperRegionTests.cpp deleted file mode 100644 index bdb5749..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/RegionManagerTests/SuperRegionTests.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "RegionManager/Area.h" -#include "RegionManager/Region.h" -#include "RegionManager/SuperRegion.h" -#include "gtest/gtest.h" - -TEST(Mappers_SuperRegionTests, blankSuperRegionLoadsWithNoRegions) -{ - const std::vector input; - const EU4::SuperRegion superRegion(input); - - EXPECT_TRUE(superRegion.getRegions().empty()); -} - -TEST(Mappers_SuperRegionTests, RegionsCanBeLoaded) -{ - const std::vector input = {"region1", "region2"}; - const EU4::SuperRegion superRegion(input); - - EXPECT_TRUE(superRegion.getRegions().contains("region1")); - EXPECT_TRUE(superRegion.getRegions().contains("region2")); -} - -TEST(Mappers_SuperRegionTests, superRegionCanBeLinkedToRegion) -{ - std::stringstream input; - input << "areas = { test_area area2 area3 } \n"; - auto theRegion = std::make_shared(input); - - const std::vector input2 = {"region1"}; - EU4::SuperRegion superRegion(input2); - - EXPECT_FALSE(superRegion.getRegions().at("region1")); - superRegion.linkRegion(std::pair("region1", theRegion)); - EXPECT_TRUE(superRegion.getRegions().at("region1")); -} - -TEST(Mappers_SuperRegionTests, LinkedRegionCanLocateProvince) -{ - std::stringstream input2; - input2 << "{ 3 4 5 6 } \n"; - auto area2 = std::make_shared(input2); - - std::stringstream input; - input << "areas = { area2 } \n"; - auto theRegion = std::make_shared(input); - theRegion->linkArea(std::pair("area2", area2)); - - const std::vector input3 = {"region1"}; - EU4::SuperRegion superRegion(input3); - superRegion.linkRegion(std::pair("region1", theRegion)); - - EXPECT_TRUE(superRegion.superRegionContainsProvince(5)); -} - -TEST(Mappers_SuperRegionTests, LinkedRegionReturnsFalseOnProvinceMismatch) -{ - std::stringstream input2; - input2 << "{ 3 4 5 6 } \n"; - auto area2 = std::make_shared(input2); - - std::stringstream input; - input << "areas = { area2 } \n"; - auto theRegion = std::make_shared(input); - theRegion->linkArea(std::pair("area2", area2)); - - const std::vector input3 = {"region1"}; - EU4::SuperRegion superRegion(input3); - superRegion.linkRegion(std::pair("region1", theRegion)); - - EXPECT_FALSE(superRegion.superRegionContainsProvince(9)); -} - -TEST(Mappers_SuperRegionTests, NativeCultureCanBeRegisteredAndRetrieved) -{ - const std::vector input = {"region"}; - EU4::SuperRegion superRegion(input); - - superRegion.registerNativeCulture("culture"); - - EXPECT_TRUE(superRegion.superRegionContainsNativeCulture("culture")); - EXPECT_FALSE(superRegion.superRegionContainsNativeCulture("dummy")); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/WarParserTests/WarDetailsTests.cpp b/EU5ToVic3Tests/EU5WorldTests/WarParserTests/WarDetailsTests.cpp deleted file mode 100644 index b75a98b..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/WarParserTests/WarDetailsTests.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "WarParser/WarDetails.h" -#include "gtest/gtest.h" - -TEST(EU4World_WarDetailsTests, primitivesDefaultToDefaults) -{ - const EU4::WarDetails details; - - EXPECT_EQ(0, details.targetProvinceID); - EXPECT_TRUE(details.warGoalType.empty()); - EXPECT_TRUE(details.targetTag.empty()); - EXPECT_TRUE(details.warGoalClass.empty()); - EXPECT_FALSE(details.startDate.isSet()); -} - -TEST(EU4World_WarDetailsTests, detailsCanBeAddedMultipleTimes) -{ - EU4::WarDetails details; - std::stringstream input; - input << "type = serious_war\n"; - input << "province = 14\n"; - details.addDetails(input); - - std::stringstream input2; - input2 << "tag = FRA\n"; - details.addDetails(input2); - - EXPECT_EQ(14, details.targetProvinceID); - EXPECT_EQ("serious_war", details.warGoalType); - EXPECT_EQ("FRA", details.targetTag); -} - -TEST(EU4World_WarDetailsTests, startDateCatchesOnlyFirstDate) -{ - EU4::WarDetails details; - std::stringstream input; - input << "7.7.7 = { something happened }\n"; - input << "8.8.8 = { someone bailed }\n"; - input << "9.9.9 = { further developments }\n"; - details.addDetails(input); - - EXPECT_EQ(date("7.7.7"), details.startDate); -} diff --git a/EU5ToVic3Tests/EU5WorldTests/WarParserTests/WarParserTests.cpp b/EU5ToVic3Tests/EU5WorldTests/WarParserTests/WarParserTests.cpp deleted file mode 100644 index b6204a4..0000000 --- a/EU5ToVic3Tests/EU5WorldTests/WarParserTests/WarParserTests.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "WarParser/WarParser.h" -#include "gtest/gtest.h" -#include -using testing::ElementsAre; - -TEST(EU4World_WarParserTests, primitivesDefaultToDefaults) -{ - std::stringstream input; - const EU4::WarParser war(input); - - EXPECT_TRUE(war.getAttackers().empty()); - EXPECT_TRUE(war.getDefenders().empty()); - EXPECT_TRUE(war.getName().empty()); - EXPECT_FALSE(war.getDetails().startDate.isSet()); - EXPECT_EQ(0, war.getDetails().targetProvinceID); - EXPECT_TRUE(war.getDetails().targetTag.empty()); - EXPECT_TRUE(war.getDetails().warGoalClass.empty()); - EXPECT_TRUE(war.getDetails().warGoalType.empty()); -} - -TEST(EU4World_WarParserTests, warCanBeLoaded) -{ - std::stringstream input; - input << "name = \"Silly War\""; - input << "history = {\n"; - input << " 9.9.9 = { it begins }\n"; - input << " 10.10.10 = { it doesn't end }\n"; - input << "}\n"; - input << "attackers = { ULM C01 }\n"; - input << "defenders = { FRA TUR HAB }\n"; - input << "take_province = {\n"; - input << " province = 13\n"; - input << " type = conquest\n"; - input << " tag = FRA\n"; - input << "}\n"; - const EU4::WarParser war(input); - - EXPECT_THAT(war.getAttackers(), ElementsAre("ULM", "C01")); - EXPECT_THAT(war.getDefenders(), ElementsAre("FRA", "TUR", "HAB")); - EXPECT_EQ("Silly War", war.getName()); - EXPECT_EQ(date("9.9.9"), war.getDetails().startDate); - EXPECT_EQ(13, war.getDetails().targetProvinceID); - EXPECT_EQ("FRA", war.getDetails().targetTag); - EXPECT_EQ("take_province", war.getDetails().warGoalClass); - EXPECT_EQ("conquest", war.getDetails().warGoalType); -} diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/map/positions.txt b/EU5ToVic3Tests/MapperTests/.dummy similarity index 100% rename from EU5ToVic3Tests/TestFiles/eu4installation/map/positions.txt rename to EU5ToVic3Tests/MapperTests/.dummy diff --git a/EU5ToVic3Tests/MapperTests/AISecretGoalMapperTests/AISecretGoalMapperTests.cpp b/EU5ToVic3Tests/MapperTests/AISecretGoalMapperTests/AISecretGoalMapperTests.cpp deleted file mode 100644 index b0e5bfb..0000000 --- a/EU5ToVic3Tests/MapperTests/AISecretGoalMapperTests/AISecretGoalMapperTests.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "AISecretGoalMapper/AISecretGoalMapper.h" -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/SubState.h" -#include "CountryManager/EU4Country.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" -#include - -namespace -{ -std::pair, std::shared_ptr> prepCountries() -{ - auto newCountry = std::make_shared(); - V3::ProcessedData data; - data.laws.emplace("law_presidential_republic"); - data.capitalStateName = "STATE_TEST_LAND1"; - data.tier = "city_state"; - data.rivals.emplace("GAT"); - data.rivals.emplace("TAT"); - newCountry->setProcessedData(data); - const auto srcCountry = std::make_shared(); - srcCountry->setGP(); - newCountry->setSourceCountry(srcCountry); - newCountry->setTag("TAG"); - - auto newCountry2 = std::make_shared(); - V3::ProcessedData data2; - data2.laws.emplace("law_theocracy"); - data2.capitalStateName = "STATE_TEST_LAND2"; - data2.tier = "hegemony"; - data2.overlordTag = "TAG"; - newCountry2->setProcessedData(data2); - const auto srcCountry2 = std::make_shared(); - newCountry2->setSourceCountry(srcCountry2); - newCountry2->setTag("GAT"); - - const auto subState = std::make_shared(); - subState->addClaim("TAG"); - subState->addClaim("TAT"); - newCountry2->addSubState(subState); - - return std::pair{newCountry, newCountry2}; -} - -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); - -V3::ClayManager prepClayManager() -{ - - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - return clayManager; -} -} // namespace - - -TEST(Mappers_AISecretGoalMapperTests, EmptyMapperReturnsNothing) -{ - const mappers::AISecretGoalMapper mapper; - const auto& [country, target] = prepCountries(); - const auto clayManager = prepClayManager(); - - EXPECT_FALSE(mapper.matchSecretGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMapperTests, SecretGoalCanBeGenerated) -{ - mappers::AISecretGoalMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/ai_secret_goal_map.txt"); - const auto& [country, target] = prepCountries(); - const auto clayManager = prepClayManager(); - - const auto goal = mapper.matchSecretGoal(*country, *target, clayManager); - - ASSERT_TRUE(goal); - EXPECT_EQ("conquer", *goal); -} diff --git a/EU5ToVic3Tests/MapperTests/AISecretGoalMapperTests/AISecretGoalMappingTests.cpp b/EU5ToVic3Tests/MapperTests/AISecretGoalMapperTests/AISecretGoalMappingTests.cpp deleted file mode 100644 index abdeb7b..0000000 --- a/EU5ToVic3Tests/MapperTests/AISecretGoalMapperTests/AISecretGoalMappingTests.cpp +++ /dev/null @@ -1,405 +0,0 @@ -#include "AISecretGoalMapper/AISecretGoalMapping.h" -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/SubState.h" -#include "CountryManager/EU4Country.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" -#include - -namespace -{ -std::pair, std::shared_ptr> prepCountries() -{ - auto newCountry = std::make_shared(); - V3::ProcessedData data; - data.laws.emplace("law_presidential_republic"); - data.capitalStateName = "STATE_TEST_LAND1"; - data.tier = "city_state"; - data.rivals.emplace("GAT"); - data.rivals.emplace("TAT"); - newCountry->setProcessedData(data); - const auto srcCountry = std::make_shared(); - srcCountry->setGP(); - newCountry->setSourceCountry(srcCountry); - newCountry->setTag("TAG"); - - auto newCountry2 = std::make_shared(); - V3::ProcessedData data2; - data2.laws.emplace("law_theocracy"); - data2.capitalStateName = "STATE_TEST_LAND2"; - data2.tier = "hegemony"; - data2.overlordTag = "TAG"; - newCountry2->setProcessedData(data2); - const auto srcCountry2 = std::make_shared(); - newCountry2->setSourceCountry(srcCountry2); - newCountry2->setTag("GAT"); - - const auto subState = std::make_shared(); - subState->addClaim("TAG"); - subState->addClaim("TAT"); - newCountry2->addSubState(subState); - - return std::pair{newCountry, newCountry2}; -} - -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); - -V3::ClayManager prepClayManager() -{ - - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - return clayManager; -} -} // namespace - -TEST(Mappers_AISecretGoalMappingTests, blankMappingReturnsTrue) -{ - const mappers::AISecretGoalMapping mapping; - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnCapital) -{ - std::stringstream input; - input << "capital = STATE_TEST_LAND1"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnCapital) -{ - std::stringstream input; - input << "capital = STATE_TEST_LAND2"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnTargetCapital) -{ - std::stringstream input; - input << "target_capital = STATE_TEST_LAND2"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnTargetCapital) -{ - std::stringstream input; - input << "target_capital = STATE_TEST_LAND1"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnCapitalDifferentRegions) -{ - std::stringstream input; - input << "target_capital_diff_region = no"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnCapitalDifferentRegions) -{ - std::stringstream input; - input << "target_capital_diff_region = yes"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnTargetRankLEQ) -{ - std::stringstream input; - input << "target_rank_leq = 5"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnTargetRankLEQ) -{ - std::stringstream input; - input << "target_rank_leq = 0"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnTargetRankGEQ) -{ - std::stringstream input; - input << "target_rank_geq = 0"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnTargetRankGEQ) -{ - std::stringstream input; - input << "target_rank_geq = 6"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnSubject) -{ - std::stringstream input; - input << "target_subject = yes"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnSubject) -{ - std::stringstream input; - input << "target_subject = no"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnOverlord) -{ - std::stringstream input; - input << "target_overlord = yes"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*target, *country, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnOverlord) -{ - std::stringstream input; - input << "target_overlord = no"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*target, *country, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnRival) -{ - std::stringstream input; - input << "target_is_rival = yes"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnRival) -{ - std::stringstream input; - input << "target_is_rival = no"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnTargetGP) -{ - std::stringstream input; - input << "target_gp = no"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnTargetGP) -{ - std::stringstream input; - input << "target_gp = yes"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnGP) -{ - std::stringstream input; - input << "gp = yes"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnGP) -{ - std::stringstream input; - input << "gp = no"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnClaim) -{ - std::stringstream input; - input << "target_is_claimed = yes"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnClaim) -{ - std::stringstream input; - input << "target_is_claimed = no"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnRivalClaim) -{ - std::stringstream input; - input << "target_is_claimed_by_rival = yes"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnRivalClaim) -{ - std::stringstream input; - input << "target_is_claimed_by_rival = no"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, matchOnGovernmentFormDifferent) -{ - std::stringstream input; - input << "gov_form_diff = yes"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_TRUE(mapping.matchGoal(*country, *target, clayManager)); -} - -TEST(Mappers_AISecretGoalMappingTests, failOnGovernmentFormDifferent) -{ - std::stringstream input; - input << "gov_form_diff = no"; - const mappers::AISecretGoalMapping mapping(input); - - - const auto& [country, target] = prepCountries(); - const auto& clayManager = prepClayManager(); - - EXPECT_FALSE(mapping.matchGoal(*country, *target, clayManager)); -} diff --git a/EU5ToVic3Tests/MapperTests/AIStrategyMapperTests/AIStrategyMapperTests.cpp b/EU5ToVic3Tests/MapperTests/AIStrategyMapperTests/AIStrategyMapperTests.cpp deleted file mode 100644 index 72dc908..0000000 --- a/EU5ToVic3Tests/MapperTests/AIStrategyMapperTests/AIStrategyMapperTests.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "AIStrategyMapper/AIStrategyMapper.h" -#include "ClayManager/ClayManager.h" -#include "CountryManager/EU4Country.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" -#include - -namespace -{ -std::shared_ptr prepCountry() -{ - auto newCountry = std::make_shared(); - V3::ProcessedData data; - data.laws.emplace("law_slavery_banned"); - data.laws.emplace("law_presidential_republic"); - data.laws.emplace("law_national_supremacy"); - data.laws.emplace("law_serfdom_banned"); - data.laws.emplace("law_hereditary_bureaucrats"); - data.capitalStateName = "STATE_TEST_LAND1"; - newCountry->setProcessedData(data); - - const auto srcCountry = std::make_shared(); - srcCountry->setCelestialEmperor(true); - srcCountry->setEmperor(true); - - newCountry->setSourceCountry(srcCountry); - - return newCountry; -} - -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); - -V3::ClayManager prepClayManager() -{ - - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - return clayManager; -} -} // namespace - -TEST(Mappers_AIStrategyMapperTests, EmptyMapperReturnsNothing) -{ - const mappers::AIStrategyMapper mapper; - const auto country = prepCountry(); - const auto clayManager = prepClayManager(); - - EXPECT_TRUE(mapper.getAdmStrategies(*country, clayManager).empty()); - EXPECT_TRUE(mapper.getDipStrategies(*country, clayManager).empty()); - EXPECT_TRUE(mapper.getPolStrategies(*country, clayManager).empty()); -} - -TEST(Mappers_AIStrategyMapperTests, StrategiesCanBeMatchedAndOverridden) -{ - mappers::AIStrategyMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/ai_strategy_map.txt"); - const auto country = prepCountry(); - const auto clayManager = prepClayManager(); - - const auto adm = mapper.getAdmStrategies(*country, clayManager); - const auto dip = mapper.getDipStrategies(*country, clayManager); - const auto pol = mapper.getPolStrategies(*country, clayManager); - - - // law_serfdom_banned -> ai_strategy_industrial_expansion=50 - // law_slavery_banned -> ai_strategy_resource_expansion=25 - EXPECT_THAT(adm, testing::UnorderedElementsAre(std::pair("ai_strategy_industrial_expansion", 50), std::pair("ai_strategy_resource_expansion", 25))); - - // hremperor -> ai_strategy_maintain_power_balance=100 - // not_gp -> ai_strategy_maintain_power_balance=50 - // law_national_supremacy -> ai_strategy_territorial_expansion=0 - EXPECT_THAT(dip, testing::UnorderedElementsAre(std::pair("ai_strategy_maintain_power_balance", 150), std::pair("ai_strategy_territorial_expansion", 25))); - - // cemperor -> ai_strategy_maintain_mandate_of_heaven=50 OVERRIDE - // law_hereditary_bureaucrats -> ai_strategy_conservative_agenda=25 overridden - // law_presidential_republic -> ai_strategy_progressive_agenda=25 overridden - EXPECT_THAT(pol, testing::UnorderedElementsAre(std::pair("ai_strategy_maintain_mandate_of_heaven", 0))); -} - -TEST(Mappers_AIStrategyMapperTests, StrategiesCanDefault) -{ - mappers::AIStrategyMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/ai_strategy_map.txt"); - const auto country = std::make_shared(); // no data inside. - const auto clayManager = prepClayManager(); - - const auto adm = mapper.getAdmStrategies(*country, clayManager); - const auto dip = mapper.getDipStrategies(*country, clayManager); - const auto pol = mapper.getPolStrategies(*country, clayManager); - - EXPECT_THAT(adm, testing::UnorderedElementsAre(std::pair("ai_strategy_resource_expansion", 0))); - EXPECT_THAT(dip, testing::UnorderedElementsAre(std::pair("ai_strategy_maintain_power_balance", 0))); - EXPECT_THAT(pol, testing::UnorderedElementsAre(std::pair("ai_strategy_conservative_agenda", 0))); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/MapperTests/AIStrategyMapperTests/AIStrategyMappingTests.cpp b/EU5ToVic3Tests/MapperTests/AIStrategyMapperTests/AIStrategyMappingTests.cpp deleted file mode 100644 index 21d233e..0000000 --- a/EU5ToVic3Tests/MapperTests/AIStrategyMapperTests/AIStrategyMappingTests.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "AIStrategyMapper/AIStrategyMapping.h" -#include "ClayManager/ClayManager.h" -#include "CountryManager/EU4Country.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" -#include - -namespace -{ -std::shared_ptr prepCountry() -{ - auto newCountry = std::make_shared(); - V3::ProcessedData data; - data.laws.emplace("law_slavery_banned"); - data.laws.emplace("law_presidential_republic"); - data.capitalStateName = "STATE_TEST_LAND1"; - newCountry->setProcessedData(data); - - const auto srcCountry = std::make_shared(); - srcCountry->setCelestialEmperor(true); - srcCountry->setEmperor(true); - - newCountry->setSourceCountry(srcCountry); - - return newCountry; -} - -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); - -V3::ClayManager prepClayManager() -{ - - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - return clayManager; -} -} // namespace - -TEST(Mappers_AIStrategyMappingTests, DefaultsDefaultToDefault) -{ - const mappers::AIStrategyMapping mapping; - - EXPECT_FALSE(mapping.isOverride()); -} - -TEST(Mappers_AIStrategyMappingTests, EmptyMappingReturnsZero) -{ - const mappers::AIStrategyMapping mapping; - - const auto clayManager = V3::ClayManager(); - const auto country = prepCountry(); - - EXPECT_EQ(0, mapping.matchStrategy(*country, clayManager)); -} - -TEST(Mappers_AIStrategyMappingTests, LawsAddValueToStrategy) -{ - std::stringstream input; - input << "laws = { law_slavery_banned = 25 law_presidential_republic = 10 }"; // matches both. - const mappers::AIStrategyMapping mapping(input); - const auto clayManager = V3::ClayManager(); - const auto country = prepCountry(); - - EXPECT_EQ(35, mapping.matchStrategy(*country, clayManager)); -} - - -TEST(Mappers_AIStrategyMappingTests, CapitalAddsValueToStrategy) -{ - std::stringstream input; - input << "capital = { STATE_TEST_LAND1 = 25 STATE_TEST_LAND2 = 10 }"; // matches STATE_TEST_LAND1 - const mappers::AIStrategyMapping mapping(input); - const auto clayManager = prepClayManager(); - const auto country = prepCountry(); - - EXPECT_EQ(25, mapping.matchStrategy(*country, clayManager)); -} - -TEST(Mappers_AIStrategyMappingTests, StatusesAddValueToStrategy) -{ - std::stringstream input; - input << "hremperor = 100 cemperor = 50 gp = 25 not_gp = 10"; // does NOT match gp, matches rest. - const mappers::AIStrategyMapping mapping(input); - const auto clayManager = prepClayManager(); - const auto country = prepCountry(); - - EXPECT_EQ(160, mapping.matchStrategy(*country, clayManager)); -} - -TEST(Mappers_AIStrategyMappingTests, OverrideCanBeSet) -{ - std::stringstream input; - input << "override = yes"; - const mappers::AIStrategyMapping mapping(input); - - EXPECT_TRUE(mapping.isOverride()); -} diff --git a/EU5ToVic3Tests/MapperTests/BuildingMapperTests/BuildingMapperTests.cpp b/EU5ToVic3Tests/MapperTests/BuildingMapperTests/BuildingMapperTests.cpp deleted file mode 100644 index bc13f0a..0000000 --- a/EU5ToVic3Tests/MapperTests/BuildingMapperTests/BuildingMapperTests.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "BuildingMapper/BuildingMapper.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_BuildingMapperTests, RulesCanBeLoaded) -{ - mappers::BuildingMapper mapper; - - EXPECT_TRUE(mapper.getVic3Buildings("wharf").empty()); - - mapper.loadBuildingMappings("TestFiles/configurables/economy/buildings_map.txt"); - - EXPECT_THAT(mapper.getVic3Buildings("wharf"), testing::UnorderedElementsAre("building_fishing_wharf")); - EXPECT_THAT(mapper.getVic3Buildings("mills"), testing::UnorderedElementsAre("building_glassworks", "building_paper_mills", "building_logging_camp")); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/MapperTests/BuildingMapperTests/BuildingMappingTests.cpp b/EU5ToVic3Tests/MapperTests/BuildingMapperTests/BuildingMappingTests.cpp deleted file mode 100644 index 9e4971c..0000000 --- a/EU5ToVic3Tests/MapperTests/BuildingMapperTests/BuildingMappingTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "BuildingMapper/BuildingMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_BuildingMappingTests, EmptyInputCreatesEmptyDefault) -{ - - std::stringstream input; - input << ""; - const mappers::BuildingMapping buildingMapping(input); - - EXPECT_TRUE(buildingMapping.getVic3Buildings().empty()); - EXPECT_TRUE(buildingMapping.getEU4Building().empty()); -} - -TEST(Mappers_BuildingMappingTests, RulesCanBeLoaded) -{ - - std::stringstream input; - input << "eu4 = building_1 vic3 = { building_1 building_2 }\n"; - - const mappers::BuildingMapping buildingMapping(input); - - EXPECT_THAT(buildingMapping.getVic3Buildings(), testing::UnorderedElementsAre("building_1", "building_2")); - EXPECT_EQ("building_1", buildingMapping.getEU4Building()); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/MapperTests/BuildingMapperTests/ProductionMethodEntryTests.cpp b/EU5ToVic3Tests/MapperTests/BuildingMapperTests/ProductionMethodEntryTests.cpp deleted file mode 100644 index 04755c1..0000000 --- a/EU5ToVic3Tests/MapperTests/BuildingMapperTests/ProductionMethodEntryTests.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "Mappers/BuildingMapper/ProductionMethodMapper/ProductionMethodEntry.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_ProductionMethodEntryTests, DefaultsDefaultToDefaults) -{ - const mappers::ProductionMethodEntry entry; - const auto& rule = entry.getRule(); - - EXPECT_TRUE(rule.pm.empty()); - EXPECT_DOUBLE_EQ(1, rule.percent); -} - -TEST(V3World_ProductionMethodEntryTests, PMCanBeLoaded) -{ - std::stringstream input; - input << "name = pm_hardwood\n "; - input << "percent = 0.33\n "; - const mappers::ProductionMethodEntry entry(input); - const auto& rule = entry.getRule(); - - EXPECT_EQ("pm_hardwood", rule.pm); - EXPECT_DOUBLE_EQ(0.33, rule.percent); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/MapperTests/BuildingMapperTests/ProductionMethodMapperTests.cpp b/EU5ToVic3Tests/MapperTests/BuildingMapperTests/ProductionMethodMapperTests.cpp deleted file mode 100644 index ac02557..0000000 --- a/EU5ToVic3Tests/MapperTests/BuildingMapperTests/ProductionMethodMapperTests.cpp +++ /dev/null @@ -1,194 +0,0 @@ -#include "BuildingMapper/ProductionMethodMapper/ProductionMethodMapper.h" -#include "ClayManager/State/SubState.h" -#include "EconomyManager/Building/Building.h" -#include "Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodGroupLoader.h" -#include "Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodLoader.h" -#include "ModLoader/ModFilesystem.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" -#include -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -std::pair, std::map> prepPMData() -{ - V3::ProductionMethodLoader PMLoader; - PMLoader.loadPMs(modFS); - - V3::ProductionMethodGroupLoader PMGroupLoader; - PMGroupLoader.loadPMGroups(modFS); - - return {PMLoader.getPMs(), PMGroupLoader.getPMGroups()}; -} - -// Tests for specific PMs -auto sumSawmills = [](const int sum, const std::shared_ptr s) { - if (s->getBuildings()[0]->getPMs().contains("pm_saw_mills")) - return sum + s->getBuildings()[0]->getLevel(); // Only built logging camps - return sum; -}; - -auto sumHardwoods = [](const int sum, const std::shared_ptr s) { - if (s->getBuildings()[0]->getPMs().contains("pm_hardwood")) - return sum + s->getBuildings()[0]->getLevel(); // Only built logging camps - return sum; -}; - -auto sumForestry = [](const int sum, const std::shared_ptr s) { - if (s->getBuildings()[0]->getPMs().contains("pm_simple_forestry")) - return sum + s->getBuildings()[0]->getLevel(); // Only built logging camps - return sum; -}; - -// Building pmgs -const std::set lumberPmgs = {"pmg_base_building_logging_camp", - "pmg_hardwood", - "pmg_equipment", - "pmg_transportation_building_logging_camp", - "pmg_ownership_capital_building_logging_camp"}; -} // namespace - -TEST(Mappers_ProductionMethodMapperTests, RulesCanBeLoaded) -{ - mappers::ProductionMethodMapper mapper; - - EXPECT_TRUE(mapper.getRules().empty()); - - mapper.loadRules("TestFiles/configurables/economy/production_method_rules.txt"); - - EXPECT_FALSE(mapper.getRules().contains("building_government_administration")); - EXPECT_THAT(mapper.getRules().at("building_logging_camp"), - testing::UnorderedElementsAre(mappers::PMRule{"pm_saw_mills"}, mappers::PMRule{"pm_hardwood", 0.65})); -} -TEST(Mappers_ProductionMethodMapperTests, ApplyRules) -{ - mappers::ProductionMethodMapper mapper; - mapper.loadRules("TestFiles/configurables/economy/production_method_rules.txt"); - - // Set up a country with many subStates with lumber camps - V3::Country country; - country.addTech("steelworking"); // Allows sawmills - country.addTech("electrical_generation"); // Allows PMs after sawmills - - for (const int lvl: {3, 12, 14, 2, 7, 8, 9, 7, 5, 3, 5, 7, 1, 4, 6, 8, 4, 2, 1, 15}) // TN: 79 - { - auto subState = std::make_shared(); - auto lumberCamp = std::make_shared(); - lumberCamp->setName("building_logging_camp"); - lumberCamp->setPMGroups(lumberPmgs); - lumberCamp->setLevel(lvl); - subState->addBuilding(lumberCamp); - country.addSubState(subState); - } - - // Load in PM and PMGroup definitions - const auto [PMs, PMGroups] = prepPMData(); - mapper.applyRules(country, PMs, PMGroups); - - EXPECT_EQ(123, std::accumulate(country.getSubStates().begin(), country.getSubStates().end(), 0, sumSawmills)); - EXPECT_EQ(79, std::accumulate(country.getSubStates().begin(), country.getSubStates().end(), 0, sumHardwoods)); -} -TEST(Mappers_ProductionMethodMapperTests, ApplyRulesInexactOverClosest) -{ - mappers::ProductionMethodMapper mapper; - mapper.loadRules("TestFiles/configurables/economy/production_method_rules.txt"); - - // Set up a country with many subStates with lumber camps - V3::Country country; - - for (const int lvl: {22, 22, 18, 22}) // TN: 54, U: 44, O: 62, Over is closer. - { - auto subState = std::make_shared(); - auto lumberCamp = std::make_shared(); - lumberCamp->setName("building_logging_camp"); - lumberCamp->setPMGroups(lumberPmgs); - lumberCamp->setLevel(lvl); - subState->addBuilding(lumberCamp); - country.addSubState(subState); - } - - // Load in PM and PMGroup definitions - const auto [PMs, PMGroups] = prepPMData(); - mapper.applyRules(country, PMs, PMGroups); - - EXPECT_EQ(62, std::accumulate(country.getSubStates().begin(), country.getSubStates().end(), 0, sumHardwoods)); -} -TEST(Mappers_ProductionMethodMapperTests, ApplyRulesInexactUnderClosest) -{ - mappers::ProductionMethodMapper mapper; - mapper.loadRules("TestFiles/configurables/economy/production_method_rules.txt"); - - // Set up a country with many subStates with lumber camps - V3::Country country; - - for (const int lvl: {15, 3, 15, 15}) // TN: 31, U: 30, O: 33. Under is closer. - { - auto subState = std::make_shared(); - auto lumberCamp = std::make_shared(); - lumberCamp->setName("building_logging_camp"); - lumberCamp->setPMGroups(lumberPmgs); - lumberCamp->setLevel(lvl); - subState->addBuilding(lumberCamp); - country.addSubState(subState); - } - - // Load in PM and PMGroup definitions - const auto [PMs, PMGroups] = prepPMData(); - mapper.applyRules(country, PMs, PMGroups); - - EXPECT_EQ(30, std::accumulate(country.getSubStates().begin(), country.getSubStates().end(), 0, sumHardwoods)); -} -TEST(Mappers_ProductionMethodMapperTests, ApplyRulesSmallestLargeBuildingIsClosest) -{ - mappers::ProductionMethodMapper mapper; - mapper.loadRules("TestFiles/configurables/economy/production_method_rules.txt"); - - // Set up a country with many subStates with lumber camps - V3::Country country; - - for (const int lvl: {9, 91}) // TN: 65, 91 is closer to 65 than 9, singe buildings larger than the TN are special cases. - { - auto subState = std::make_shared(); - auto lumberCamp = std::make_shared(); - lumberCamp->setName("building_logging_camp"); - lumberCamp->setPMGroups(lumberPmgs); - lumberCamp->setLevel(lvl); - subState->addBuilding(lumberCamp); - country.addSubState(subState); - } - - // Load in PM and PMGroup definitions - const auto [PMs, PMGroups] = prepPMData(); - mapper.applyRules(country, PMs, PMGroups); - - EXPECT_EQ(91, std::accumulate(country.getSubStates().begin(), country.getSubStates().end(), 0, sumHardwoods)); -} -TEST(Mappers_ProductionMethodMapperTests, ApplyRulesUnderTeched) -{ - mappers::ProductionMethodMapper mapper; - mapper.loadRules("TestFiles/configurables/economy/production_method_rules.txt"); - - // Set up a country with many subStates with lumber camps - V3::Country country; - - for (const int lvl: {3, 12, 14, 2, 7, 8, 9, 7, 5, 3, 5, 7, 1, 4, 6, 8, 4, 2, 1, 15}) - { - auto subState = std::make_shared(); - auto lumberCamp = std::make_shared(); - lumberCamp->setName("building_logging_camp"); - lumberCamp->setPMGroups(lumberPmgs); - lumberCamp->setLevel(lvl); - subState->addBuilding(lumberCamp); - country.addSubState(subState); - } - - // Load in PM and PMGroup definitions - const auto [PMs, PMGroups] = prepPMData(); - mapper.applyRules(country, PMs, PMGroups); - - // No tech for sawmills - EXPECT_EQ(0, std::accumulate(country.getSubStates().begin(), country.getSubStates().end(), 0, sumSawmills)); - EXPECT_EQ(123, std::accumulate(country.getSubStates().begin(), country.getSubStates().end(), 0, sumForestry)); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/MapperTests/BuildingMapperTests/ProductionMethodMappingTests.cpp b/EU5ToVic3Tests/MapperTests/BuildingMapperTests/ProductionMethodMappingTests.cpp deleted file mode 100644 index 85ecf91..0000000 --- a/EU5ToVic3Tests/MapperTests/BuildingMapperTests/ProductionMethodMappingTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "BuildingMapper/ProductionMethodMapper/ProductionMethodMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_ProductionMethodMappingTests, EmptyInputCreatesEmptyDefault) -{ - - std::stringstream input; - mappers::ProductionMethodMapping rules; - rules.loadRules(input); - - EXPECT_TRUE(rules.getRules().empty()); -} - -TEST(Mappers_ProductionMethodMappingTests, RulesCanBeLoaded) -{ - - std::stringstream input; - input << "pm = { name = pm_hardwood percent = 0.33 }\n"; - input << "pm = { name = pm_sawmill }\n"; - - mappers::ProductionMethodMapping rules; - rules.loadRules(input); - - EXPECT_THAT(rules.getRules(), testing::UnorderedElementsAre(mappers::PMRule{"pm_hardwood", 0.33}, mappers::PMRule{"pm_sawmill"})); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/MapperTests/CharacterTraitMapperTests/AssignmentMappingTests.cpp b/EU5ToVic3Tests/MapperTests/CharacterTraitMapperTests/AssignmentMappingTests.cpp deleted file mode 100644 index 70cdda7..0000000 --- a/EU5ToVic3Tests/MapperTests/CharacterTraitMapperTests/AssignmentMappingTests.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "CharacterTraitMapper/AssignmentMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_AssignmentMappingTests, DefaultsDefaultToDefaults) -{ - - std::stringstream input; - const mappers::AssignmentMapping mapping(input); - - EXPECT_TRUE(mapping.getAssignments().empty()); -} - -TEST(Mappers_AssignmentMappingTests, AssignmentsCanBeLoaded) -{ - std::stringstream input; - input << "a = a1\n"; - input << "b = b2\n"; - const mappers::AssignmentMapping mapping(input); - - EXPECT_THAT(mapping.getAssignments(), testing::UnorderedElementsAre(std::pair("a", "a1"), std::pair("b", "b2"))); -} diff --git a/EU5ToVic3Tests/MapperTests/CharacterTraitMapperTests/CharacterTraitMapperTests.cpp b/EU5ToVic3Tests/MapperTests/CharacterTraitMapperTests/CharacterTraitMapperTests.cpp deleted file mode 100644 index bf2fb5d..0000000 --- a/EU5ToVic3Tests/MapperTests/CharacterTraitMapperTests/CharacterTraitMapperTests.cpp +++ /dev/null @@ -1,169 +0,0 @@ -#include "CharacterTraitMapper/CharacterTraitMapper.h" -#include "CountryManager/CountryLeader/EU4Character.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_CharacterTraitMapperTests, personalitiesCanBeMatched) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EXPECT_EQ("ambitious", *mapper.getPersonality("glory_seeker_personality")); -} - -TEST(Mappers_CharacterTraitMapperTests, personalitiesWillFailForNonsense) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EXPECT_FALSE(mapper.getPersonality("nonsense")); -} - -TEST(Mappers_CharacterTraitMapperTests, skillTraitsGrabsGlobalsForExplorersAndConquistadors) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EU4::Character character1; - character1.leaderType = "explorer"; - EU4::Character character2; - character2.leaderType = "conquistador"; - - EXPECT_THAT(mapper.getSkillTraits(character1), testing::UnorderedElementsAre("explorer")); - EXPECT_THAT(mapper.getSkillTraits(character2), testing::UnorderedElementsAre("surveyor")); -} - -TEST(Mappers_CharacterTraitMapperTests, skillTraitsMatchesActualSkillsForGeneralsAndAdmirals) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EU4::Character character1; - character1.leaderType = "general"; - character1.fire = 6; - character1.shock = 5; - character1.maneuver = 5; - character1.siege = 5; - EU4::Character character2; - character2.fire = 5; - character2.shock = 5; - character2.maneuver = 6; - character2.siege = 5; - character2.leaderType = "admiral"; - - EXPECT_THAT(mapper.getSkillTraits(character1), testing::UnorderedElementsAre("expert_defensive_strategist")); - EXPECT_THAT(mapper.getSkillTraits(character2), testing::UnorderedElementsAre("expert_convoy_raider")); -} - -TEST(Mappers_CharacterTraitMapperTests, skillTraitsReturnsEmptyForJunkLeadersWithNoMatches) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EU4::Character character1; - character1.leaderType = "general"; - character1.fire = 1; - character1.shock = 0; - character1.maneuver = 0; - character1.siege = 0; - EU4::Character character2; - character2.fire = 0; - character2.shock = 0; - character2.maneuver = 0; - character2.siege = 1; - character2.leaderType = "admiral"; - - EXPECT_TRUE(mapper.getSkillTraits(character1).empty()); - EXPECT_TRUE(mapper.getSkillTraits(character2).empty()); -} - -TEST(Mappers_CharacterTraitMapperTests, skillTraitsMatchesActualSkillsForRulers) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EU4::Character character1; - character1.ruler = true; - character1.adm = 6; - character1.dip = 5; - character1.mil = 5; - - EXPECT_THAT(mapper.getSkillTraits(character1), testing::UnorderedElementsAre("expert_colonial_administrator")); -} - -TEST(Mappers_CharacterTraitMapperTests, skillTraitsReturnsEmptyForJunkRulersWithNoMatches) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EU4::Character character1; - character1.ruler = true; - character1.adm = 1; - character1.dip = 0; - character1.mil = 0; - - EXPECT_TRUE(mapper.getSkillTraits(character1).empty()); -} - -TEST(Mappers_CharacterTraitMapperTests, skillTraitsCombinesRulerAndLeaderTraits) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EU4::Character character1; - character1.leaderType = "general"; - character1.fire = 6; - character1.shock = 5; - character1.maneuver = 5; - character1.siege = 5; - character1.ruler = true; - character1.adm = 6; - character1.dip = 5; - character1.mil = 5; - - EXPECT_THAT(mapper.getSkillTraits(character1), testing::UnorderedElementsAre("expert_colonial_administrator", "expert_defensive_strategist")); -} - -TEST(Mappers_CharacterTraitMapperTests, gratisIncompetenciesCanBeReturned) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EXPECT_EQ("alcoholic", mapper.getGratisIncompetency(-76)); - EXPECT_EQ("alcoholic", mapper.getGratisIncompetency(0)); - EXPECT_EQ("opium_addiction", mapper.getGratisIncompetency(3)); - EXPECT_EQ("alcoholic", mapper.getGratisIncompetency(4988)); -} - -TEST(Mappers_CharacterTraitMapperTests, gratisVeterancyCanBeReturned) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EXPECT_EQ("beetle_ear", mapper.getGratisVeterancy(-76)); - EXPECT_EQ("beetle_ear", mapper.getGratisVeterancy(0)); - EXPECT_EQ("beetle_ear", mapper.getGratisVeterancy(3)); - EXPECT_EQ("wounded", mapper.getGratisVeterancy(4988)); -} - -TEST(Mappers_CharacterTraitMapperTests, gratisAgeismCanBeReturned) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EXPECT_EQ("cancer", mapper.getGratisAgeism(-76)); - EXPECT_EQ("cancer", mapper.getGratisAgeism(0)); - EXPECT_EQ("cancer", mapper.getGratisAgeism(3)); - EXPECT_EQ("senile", mapper.getGratisAgeism(4988)); -} - -TEST(Mappers_CharacterTraitMapperTests, gratisDisordersCanBeReturned) -{ - mappers::CharacterTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/character_traits.txt"); - - EXPECT_EQ("expensive_tastes", mapper.getGratisDisorder(-76)); - EXPECT_EQ("expensive_tastes", mapper.getGratisDisorder(0)); - EXPECT_EQ("syphilis", mapper.getGratisDisorder(3)); - EXPECT_EQ("expensive_tastes", mapper.getGratisDisorder(4988)); -} diff --git a/EU5ToVic3Tests/MapperTests/CharacterTraitMapperTests/SkillMappingTests.cpp b/EU5ToVic3Tests/MapperTests/CharacterTraitMapperTests/SkillMappingTests.cpp deleted file mode 100644 index 9d42cc5..0000000 --- a/EU5ToVic3Tests/MapperTests/CharacterTraitMapperTests/SkillMappingTests.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "CharacterTraitMapper/SkillMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_SkillMappingTests, RulerTraitCanBeMatchedByPrimary) -{ - - std::stringstream input; - input << "sum = 10 prim = adm trait = theTrait"; - const mappers::SkillMapping mapping(input); - - const auto& match = mapping.matchTrait({5, 3, 3}); // sum 11, passes adm primary. - - ASSERT_TRUE(match); - EXPECT_EQ("theTrait", *match); -} - -TEST(Mappers_SkillMappingTests, RulerTraitWillFailForWrongPrimary) -{ - - std::stringstream input; - input << "sum = 10 prim = adm trait = theTrait"; - const mappers::SkillMapping mapping(input); - - const auto& match = mapping.matchTrait({3, 3, 5}); // sum 11, fails adm primary. - - EXPECT_FALSE(match); -} - -TEST(Mappers_SkillMappingTests, RulerTraitWillFailForSubCount) -{ - - std::stringstream input; - input << "sum = 10 prim = adm trait = theTrait"; - const mappers::SkillMapping mapping(input); - - const auto& match = mapping.matchTrait({2, 1, 1}); // sum 4, fails sum. - - EXPECT_FALSE(match); -} - -TEST(Mappers_SkillMappingTests, RulerTraitCanBeMatchedGenerallyBySum) -{ - - std::stringstream input; - input << "sum = 10 trait = theTrait"; - const mappers::SkillMapping mapping(input); - - const auto& match = mapping.matchTrait({5, 3, 3}); // sum 11, passes sum. - - ASSERT_TRUE(match); - EXPECT_EQ("theTrait", *match); -} - -TEST(Mappers_SkillMappingTests, RulerTraitWillFailForGeneralSubCount) -{ - - std::stringstream input; - input << "sum = 10 trait = theTrait"; - const mappers::SkillMapping mapping(input); - - const auto& match = mapping.matchTrait({1, 1, 2}); // sum 4, fails sum. - - EXPECT_FALSE(match); -} diff --git a/EU5ToVic3Tests/MapperTests/CoastalMapperTests/CoastalMapperTests.cpp b/EU5ToVic3Tests/MapperTests/CoastalMapperTests/CoastalMapperTests.cpp deleted file mode 100644 index f953007..0000000 --- a/EU5ToVic3Tests/MapperTests/CoastalMapperTests/CoastalMapperTests.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "CoastalMapper/CoastalMapper.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_CoastalMapperTests, MismatchReturnsEmpty) -{ - mappers::CoastalMapper mapper; - mapper.loadAdjacencies("TestFiles/configurables/province_adjacencies.txt"); - - EXPECT_TRUE(mapper.getAdjacencies("mismatch").empty()); -} - -TEST(Mappers_CoastalMapperTests, AdjacenciesCanBeRetrieved) -{ - mappers::CoastalMapper mapper; - mapper.loadAdjacencies("TestFiles/configurables/province_adjacencies.txt"); - - EXPECT_THAT(mapper.getAdjacencies("x00004B"), testing::UnorderedElementsAre("x005ED2", "x184708", "x371070")); - EXPECT_THAT(mapper.getAdjacencies("x000090"), testing::UnorderedElementsAre("x638C4B", "xAD371C", "xBF2D59")); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/MapperTests/ColonialRegionMapperTests/ColonialRegionMapperTests.cpp b/EU5ToVic3Tests/MapperTests/ColonialRegionMapperTests/ColonialRegionMapperTests.cpp deleted file mode 100644 index e24b5df..0000000 --- a/EU5ToVic3Tests/MapperTests/ColonialRegionMapperTests/ColonialRegionMapperTests.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "ColonialRegionMapper/ColonialRegionMapper.h" -#include "gtest/gtest.h" - -namespace -{ -std::tuple prepMappers() -{ - const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - mappers::ColonialRegionMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/colonial_regions.txt"); - - return {clayManager, mapper}; -} -} // namespace - -TEST(Mappers_ColonialRegionMapperTests, rulesCanBeLoadedInOrder) -{ - mappers::ColonialRegionMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/colonial_regions.txt"); - - ASSERT_EQ(2, mapper.getColonialRegions().size()); - EXPECT_TRUE(mapper.getColonialRegions().contains("usa_north_colony")); - EXPECT_TRUE(mapper.getColonialRegions().contains("usa_south_colony")); -} - -TEST(Mappers_ColonialRegionMapperTests, coloniesCanBeMatchedViaDirectState) -{ - auto [clayMapper, mapper] = prepMappers(); - - const auto& match1 = mapper.getColonyNameForState("STATE_TEST_4", clayMapper); - const auto& match2 = mapper.getColonyForState("STATE_TEST_4", clayMapper); - ASSERT_TRUE(match1); - ASSERT_TRUE(match2); - EXPECT_EQ("usa_south_colony", *match1); - EXPECT_EQ("Floridian", match2->getAloneName()); -} - -TEST(Mappers_ColonialRegionMapperTests, coloniesCanBeMatchedViaRegion) -{ - auto [clayMapper, mapper] = prepMappers(); - - const auto& match1 = mapper.getColonyNameForState("STATE_TEST_1", clayMapper); - const auto& match2 = mapper.getColonyForState("STATE_TEST_1", clayMapper); - ASSERT_TRUE(match1); - ASSERT_TRUE(match2); - EXPECT_EQ("usa_north_colony", *match1); - EXPECT_EQ("Appalachian", match2->getAloneName()); -} - -TEST(Mappers_ColonialRegionMapperTests, mismapReturnsNullopt) -{ - auto [clayMapper, mapper] = prepMappers(); - - const auto& match1 = mapper.getColonyNameForState("non", clayMapper); - const auto& match2 = mapper.getColonyForState("non", clayMapper); - ASSERT_FALSE(match1); - ASSERT_FALSE(match2); -} diff --git a/EU5ToVic3Tests/MapperTests/ColonialRegionMapperTests/ColonialRegionMappingTests.cpp b/EU5ToVic3Tests/MapperTests/ColonialRegionMapperTests/ColonialRegionMappingTests.cpp deleted file mode 100644 index 9ed8a1e..0000000 --- a/EU5ToVic3Tests/MapperTests/ColonialRegionMapperTests/ColonialRegionMappingTests.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "ColonialRegionMapper/ColonialRegionMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_ColonialRegionMappingTests, DefaultsDefaultToDefaults) -{ - - std::stringstream input; - const mappers::ColonialRegionMapping colonialRegionMapping(input); - - EXPECT_TRUE(colonialRegionMapping.getRegions().empty()); - EXPECT_TRUE(colonialRegionMapping.getAloneName().empty()); - EXPECT_TRUE(colonialRegionMapping.getSplitName().empty()); -} - -TEST(Mappers_ColonialRegionMappingTests, RulesCanBeLoaded) -{ - std::stringstream input; - input << R"(region = region_new_england region = STATE_CALIFORNIA region = STATE_WASHINGTON alone_name = "Appalachian" split_name = "$PARENT$ - American")"; - const mappers::ColonialRegionMapping colonialRegionMapping(input); - - EXPECT_THAT(colonialRegionMapping.getRegions(), testing::UnorderedElementsAre("region_new_england", "STATE_CALIFORNIA", "STATE_WASHINGTON")); - EXPECT_EQ("Appalachian", colonialRegionMapping.getAloneName()); - EXPECT_EQ("$PARENT$ - American", colonialRegionMapping.getSplitName()); -} diff --git a/EU5ToVic3Tests/MapperTests/ColonialTagMapperTests/ColonialTagMapperTests.cpp b/EU5ToVic3Tests/MapperTests/ColonialTagMapperTests/ColonialTagMapperTests.cpp deleted file mode 100644 index 5588a3b..0000000 --- a/EU5ToVic3Tests/MapperTests/ColonialTagMapperTests/ColonialTagMapperTests.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/SubState.h" -#include "ColonialRegionMapper/ColonialRegionMapper.h" -#include "ColonialTagMapper/ColonialTagMapper.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" - -TEST(Mappers_ColonialTagMapperTests, rulesCanBeLoadedAndMatched) -{ - mappers::ColonialTagMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/colonial_tags.txt"); - - const auto country = std::make_shared(); - const auto subState = std::make_shared(); - country->addSubState(subState); - V3::ProcessedData data; - data.capitalStateName = "STATE_BRITISH_COLUMBIA"; - country->setProcessedData(data); - - const auto& match = mapper.matchColonialTag(*country, {}, {}); - - ASSERT_TRUE(match); - EXPECT_EQ("COL", *match); -} - -TEST(Mappers_ColonialTagMapperTests, MatchWillFailForExistingColonialTag) -{ - mappers::ColonialTagMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/colonial_tags.txt"); - - const auto country = std::make_shared(); - country->setTag("COL"); - const auto subState = std::make_shared(); - country->addSubState(subState); - V3::ProcessedData data; - data.capitalStateName = "STATE_BRITISH_COLUMBIA"; - country->setProcessedData(data); - - const auto& match = mapper.matchColonialTag(*country, {}, {}); - - EXPECT_FALSE(match); -} - -TEST(Mappers_ColonialTagMapperTests, MatchWillFailForNoMatches) -{ - mappers::ColonialTagMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/colonial_tags.txt"); - - const auto country = std::make_shared(); - const auto subState = std::make_shared(); - country->addSubState(subState); - V3::ProcessedData data; - data.capitalStateName = "STATE_WRONG_COLUMBIA"; - country->setProcessedData(data); - - const auto& match = mapper.matchColonialTag(*country, {}, {}); - - EXPECT_FALSE(match); -} diff --git a/EU5ToVic3Tests/MapperTests/ColonialTagMapperTests/ColonialTagMappingTests.cpp b/EU5ToVic3Tests/MapperTests/ColonialTagMapperTests/ColonialTagMappingTests.cpp deleted file mode 100644 index a7467bf..0000000 --- a/EU5ToVic3Tests/MapperTests/ColonialTagMapperTests/ColonialTagMappingTests.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/SubState.h" -#include "ColonialRegionMapper/ColonialRegionMapper.h" -#include "ColonialTagMapper/ColonialTagMapping.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_ColonialTagMappingTests, MatchFailsForNoSubStates) -{ - - std::stringstream input; - input << "region = STATE_BRITISH_COLUMBIA tag = COL"; - const mappers::ColonialTagMapping mapping(input); - - const auto country = std::make_shared(); - - const auto& match = mapping.matchColonialTag(*country, {}, {}); - - EXPECT_FALSE(match); -} - -TEST(Mappers_ColonialTagMappingTests, MatchFailsForNoCapital) -{ - - std::stringstream input; - input << "region = STATE_BRITISH_COLUMBIA tag = COL"; - const mappers::ColonialTagMapping mapping(input); - - const auto country = std::make_shared(); - const auto subState = std::make_shared(); - country->addSubState(subState); - - const auto& match = mapping.matchColonialTag(*country, {}, {}); - - EXPECT_FALSE(match); -} - -TEST(Mappers_ColonialTagMappingTests, MatchPassesForCorrectCapital) -{ - - std::stringstream input; - input << "region = STATE_BRITISH_COLUMBIA tag = COL"; - const mappers::ColonialTagMapping mapping(input); - - const auto country = std::make_shared(); - const auto subState = std::make_shared(); - country->addSubState(subState); - V3::ProcessedData data; - data.capitalStateName = "STATE_BRITISH_COLUMBIA"; - country->setProcessedData(data); - - const auto& match = mapping.matchColonialTag(*country, {}, {}); - - ASSERT_TRUE(match); - EXPECT_EQ("COL", *match); -} diff --git a/EU5ToVic3Tests/MapperTests/CountryMapperTests/CountryMapperTests.cpp b/EU5ToVic3Tests/MapperTests/CountryMapperTests/CountryMapperTests.cpp deleted file mode 100644 index 86dbff8..0000000 --- a/EU5ToVic3Tests/MapperTests/CountryMapperTests/CountryMapperTests.cpp +++ /dev/null @@ -1,283 +0,0 @@ -#include "CountryManager/EU4Country.h" -#include "CountryMapper/CountryMapper.h" -#include "gtest/gtest.h" - -TEST(Mappers_CountryMapperTests, rulesCanBeLoadedInOrder) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - - EXPECT_EQ(13, mapper.getMappingRules().size()); - const auto& rule1 = mapper.getMappingRules()[0]; - EXPECT_EQ("TA1", *rule1.getEU4Tag()); - EXPECT_EQ("GA1", *rule1.getV3Tag()); - const auto& rule12 = mapper.getMappingRules()[11]; - EXPECT_EQ("GA9", *rule12.getV3Tag()); - EXPECT_EQ("Name10", *rule12.getName()); -} - -TEST(Mappers_CountryMapperTests, TrivialMappingsWork) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { eu4 = TA1 vic3 = GA1 } - - const auto country = std::make_shared(); - country->setTag("TA1"); - - const auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("GA1", v3Tag); -} - -TEST(Mappers_CountryMapperTests, NameMappingsWork) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { eu4 = TA2 name = "Name2" vic3 = GA2 } - - const auto country = std::make_shared(); - country->setTag("D99"); // this is invalid/unknown TAG. - country->setLocalizationName("english", "Name2"); - - const auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("GA2", v3Tag); -} - -TEST(Mappers_CountryMapperTests, SoloNameMappingsWork) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { name = "Name3" vic3 = GA3 } - - const auto country = std::make_shared(); - country->setTag("D99"); // this is invalid/unknown TAG. - country->setLocalizationName("english", "Name3"); - - const auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("GA3", v3Tag); -} - -TEST(Mappers_CountryMapperTests, SoloFlagMappingsWork) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { flag = flag1 vic3 = GA4 } - - const auto country = std::make_shared(); - country->setTag("D99"); // this is invalid/unknown TAG. - country->addFlag("flag1"); - - const auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("GA4", v3Tag); -} - -TEST(Mappers_CountryMapperTests, MultipleFlagMatchingMappingsWork) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { flag = flag1 flag = flag2 vic3 = GA4 } - - const auto country = std::make_shared(); - country->setTag("D99"); // this is invalid/unknown TAG. - country->addFlag("flag2"); // flag1 missing - - const auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("GA4", v3Tag); -} - -TEST(Mappers_CountryMapperTests, SoloReformMappingsWork) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { reform = reform1 vic3 = GA5 } - - const auto country = std::make_shared(); - country->setTag("D99"); // this is invalid/unknown TAG. - country->addReform("reform1"); - - const auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("GA5", v3Tag); -} - -TEST(Mappers_CountryMapperTests, MultipleReformMatchingMappingsWork) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { reform = reform1 reform = reform2 vic3 = GA5 } - - const auto country = std::make_shared(); - country->setTag("D99"); // this is invalid/unknown TAG. - country->addReform("reform2"); // reform1 missing - - const auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("GA5", v3Tag); -} - -TEST(Mappers_CountryMapperTests, MixAndMatchFlagsAndReformsMappingsWork) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { flag = flag1 reform = reform1 vic3 = GA6 } - - const auto country = std::make_shared(); - country->setTag("D99"); // this is invalid/unknown TAG. - country->addFlag("flag1"); // will trip on GA4 example if places after GA4 line. This is normal. - country->addReform("reform1"); // will trip on GA5 example if placed after GA5 line. This is normal. - - const auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("GA6", v3Tag); -} - -TEST(Mappers_CountryMapperTests, NameFlagCodeRecordMappingsWork) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { name = "Name7" flag_code = fc7 } - - const auto country = std::make_shared(); - country->setTag("D99"); // this is invalid/unknown TAG. - country->setLocalizationName("english", "Name7"); - - const auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("X00", v3Tag); - EXPECT_EQ("fc7", *mapper.getFlagCode("X00")); -} - -TEST(Mappers_CountryMapperTests, SourceTagFlagCodeRecordMappingsWork) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { eu4 = TA8 flag_code = fc8 } - - const auto country = std::make_shared(); - country->setTag("TA8"); - - const auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("X00", v3Tag); - EXPECT_EQ("fc8", *mapper.getFlagCode("X00")); -} - -TEST(Mappers_CountryMapperTests, ZeroMatchesAssignsTag) -{ - mappers::CountryMapper mapper; - - const auto country = std::make_shared(); - country->setTag("D99"); // this is invalid/unknown TAG. - const auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("X00", v3Tag); -} - -TEST(Mappers_CountryMapperTests, CountryWillGetSameTagIfReprocessed) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { eu4 = TA1 vic3 = GA1 } - - const auto country = std::make_shared(); - country->setTag("TA1"); - auto v3Tag = mapper.assignV3TagToEU4Country(country); - - EXPECT_EQ("GA1", v3Tag); - - v3Tag = mapper.assignV3TagToEU4Country(country); - EXPECT_EQ("GA1", v3Tag); -} - -TEST(Mappers_CountryMapperTests, TwoCountriesWontGetSameTag) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { eu4 = TA9 vic3 = GA9 } - // link = { name = "Name10" vic3 = GA9 } - - const auto country1 = std::make_shared(); - country1->setTag("TA9"); - const auto country2 = std::make_shared(); - country2->setLocalizationName("english", "Name10"); - const auto v3Tag1 = mapper.assignV3TagToEU4Country(country1); - const auto v3Tag2 = mapper.assignV3TagToEU4Country(country2); // assigned X00 since GA9 is taken. - - EXPECT_EQ("GA9", v3Tag1); - EXPECT_EQ("X00", v3Tag2); -} - -TEST(Mappers_CountryMapperTests, CountryWontGetReservedTag) -{ - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - // link = { eu4 = TA9 vic3 = GA9 } - // link = { name = "Name10" vic3 = GA9 } <- should get X00 but won't. - mapper.registerKnownVanillaV3Tag("X00"); // we do this when importing vanilla and modded V3 tags - - const auto country1 = std::make_shared(); - country1->setTag("TA9"); - const auto country2 = std::make_shared(); - country2->setLocalizationName("english", "Name10"); - const auto v3Tag1 = mapper.assignV3TagToEU4Country(country1); - const auto v3Tag2 = mapper.assignV3TagToEU4Country(country2); // assigned X00 since GA9 is taken. - - EXPECT_EQ("GA9", v3Tag1); - EXPECT_EQ("X01", v3Tag2); // gets the next free tag. -} - -TEST(Mappers_CountryMapperTests, tagIsDynamicWorksAsAdvertised) -{ - const mappers::CountryMapper mapper; - EXPECT_TRUE(mapper.tagIsDynamic("C01")); - EXPECT_FALSE(mapper.tagIsDynamic("CC1")); - EXPECT_FALSE(mapper.tagIsDynamic("CCC")); - EXPECT_FALSE(mapper.tagIsDynamic("0C0")); - EXPECT_FALSE(mapper.tagIsDynamic("0CC")); - EXPECT_FALSE(mapper.tagIsDynamic("00C")); -} - -TEST(Mappers_CountryMapperTests, tagIsNonCanonWorksAsAdvertised) -{ - const mappers::CountryMapper mapper; - EXPECT_TRUE(mapper.tagIsNonCanon("C01")); - EXPECT_TRUE(mapper.tagIsNonCanon("C0C")); - EXPECT_FALSE(mapper.tagIsNonCanon("CC1")); - EXPECT_FALSE(mapper.tagIsNonCanon("CCC")); - EXPECT_FALSE(mapper.tagIsNonCanon("0C0")); - EXPECT_FALSE(mapper.tagIsNonCanon("0CC")); - EXPECT_FALSE(mapper.tagIsNonCanon("00C")); -} - -TEST(Mappers_CountryMapperTests, newTagCanBeRequested) -{ - mappers::CountryMapper mapper; - - auto tag = mapper.requestNewV3Tag(); - EXPECT_EQ("X00", tag); - tag = mapper.requestNewV3Tag(); - EXPECT_EQ("X01", tag); - tag = mapper.requestNewV3Tag(); - EXPECT_EQ("X02", tag); -} - -TEST(Mappers_CountryMapperTests, tagGeneratorWillSkipCollisions) -{ - const auto country1 = std::make_shared(); - country1->setTag("Y00"); // will map to X01 - - mappers::CountryMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_mappings.txt"); - auto tag = mapper.assignV3TagToEU4Country(country1); - EXPECT_EQ("X01", tag); - - tag = mapper.requestNewV3Tag(); - EXPECT_EQ("X00", tag); - tag = mapper.requestNewV3Tag(); - EXPECT_EQ("X02", tag); -} diff --git a/EU5ToVic3Tests/MapperTests/CountryMapperTests/CountryMappingTests.cpp b/EU5ToVic3Tests/MapperTests/CountryMapperTests/CountryMappingTests.cpp deleted file mode 100644 index 244ef5a..0000000 --- a/EU5ToVic3Tests/MapperTests/CountryMapperTests/CountryMappingTests.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "CountryMapper/CountryMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_CountryMappingTests, DefaultsDefaultToDefaults) -{ - const mappers::CountryMapping countryMapping; - - EXPECT_FALSE(countryMapping.getEU4Tag()); - EXPECT_FALSE(countryMapping.getV3Tag()); - EXPECT_FALSE(countryMapping.getName()); - EXPECT_FALSE(countryMapping.getFlagCode()); - EXPECT_TRUE(countryMapping.getFlags().empty()); - EXPECT_TRUE(countryMapping.getReforms().empty()); -} - -TEST(Mappers_CountryMappingTests, RulesCanBeLoaded) -{ - std::stringstream input; - input << "eu4 = TAG vic3 = GAT name = \"The Name\" flag_code = flagCode flag = flag1 flag = flag2 flag = flag2 reform = ref1 reform = ref2 reform = ref2"; - const mappers::CountryMapping countryMapping(input); - - EXPECT_EQ("TAG", *countryMapping.getEU4Tag()); - EXPECT_EQ("GAT", *countryMapping.getV3Tag()); - EXPECT_EQ("The Name", *countryMapping.getName()); - EXPECT_EQ("flagCode", *countryMapping.getFlagCode()); - EXPECT_EQ(2, countryMapping.getFlags().size()); - EXPECT_THAT(countryMapping.getFlags(), testing::UnorderedElementsAre("flag1", "flag2")); - EXPECT_EQ(2, countryMapping.getReforms().size()); - EXPECT_THAT(countryMapping.getReforms(), testing::UnorderedElementsAre("ref1", "ref2")); -} diff --git a/EU5ToVic3Tests/MapperTests/CountryTierMapperTests/CountryTierMapperTests.cpp b/EU5ToVic3Tests/MapperTests/CountryTierMapperTests/CountryTierMapperTests.cpp deleted file mode 100644 index 8759e79..0000000 --- a/EU5ToVic3Tests/MapperTests/CountryTierMapperTests/CountryTierMapperTests.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "CountryTierMapper/CountryTierMapper.h" -#include "gtest/gtest.h" - -TEST(Mappers_CountryTierMapperTests, RanksCanBeMatchedForVanilla) -{ - mappers::CountryTierMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_tiers.txt"); - - EXPECT_FALSE(mapper.matchCountryTier(9, 0)); - EXPECT_TRUE(mapper.matchCountryTier(2, 4)); - EXPECT_EQ("kingdom", mapper.matchCountryTier(2, 4)); -} - -TEST(Mappers_CountryTierMapperTests, RanksCanBeMatchedForVN) -{ - mappers::CountryTierMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/country_tiers.txt"); - - EXPECT_FALSE(mapper.matchCountryTier(9, 0, true)); - EXPECT_TRUE(mapper.matchCountryTier(2, 4, true)); - EXPECT_EQ("grand_principality", *mapper.matchCountryTier(2, 4, true)); -} diff --git a/EU5ToVic3Tests/MapperTests/CountryTierMapperTests/CountryTierMappingTests.cpp b/EU5ToVic3Tests/MapperTests/CountryTierMapperTests/CountryTierMappingTests.cpp deleted file mode 100644 index 9142778..0000000 --- a/EU5ToVic3Tests/MapperTests/CountryTierMapperTests/CountryTierMappingTests.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "CountryTierMapper/CountryTierMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_CountryTierMappingTests, NoMatchReturnNull) -{ - const mappers::CountryTierMapping mapping; - - EXPECT_FALSE(mapping.matchTier(1, 1)); -} - -TEST(Mappers_CountryTierMappingTests, MatchSucceedsOnRank) -{ - std::stringstream input; - input << "rank = 4"; - const mappers::CountryTierMapping mapping(input, "theRank"); - - EXPECT_FALSE(mapping.matchTier(5, 0)); - - ASSERT_TRUE(mapping.matchTier(4, 0)); - EXPECT_EQ("theRank", *mapping.matchTier(4, 0)); -} - -TEST(Mappers_CountryTierMappingTests, MatchSucceedsOnRankAndSize) -{ - std::stringstream input; - input << "rank = 4 size = 5"; - const mappers::CountryTierMapping mapping(input, "theRank"); - - EXPECT_FALSE(mapping.matchTier(4, 10)); - - ASSERT_TRUE(mapping.matchTier(4, 5)); - ASSERT_TRUE(mapping.matchTier(4, 2)); - EXPECT_EQ("theRank", *mapping.matchTier(4, 5)); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureDefinitionLoaderTests/CultureDefinitionEntryTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureDefinitionLoaderTests/CultureDefinitionEntryTests.cpp deleted file mode 100644 index 0d012a7..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureDefinitionLoaderTests/CultureDefinitionEntryTests.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "CultureMapper/CultureDefinitionLoader/CultureDefinitionEntry.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_CultureDefinitionEntryTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - const mappers::CultureDefinitionEntry entry(input, false, false); - - EXPECT_TRUE(entry.getCultureDef().name.empty()); - EXPECT_FALSE(entry.getCultureDef().color); - EXPECT_TRUE(entry.getCultureDef().religion.empty()); - EXPECT_TRUE(entry.getCultureDef().traits.empty()); - EXPECT_TRUE(entry.getCultureDef().maleCommonFirstNames.empty()); - EXPECT_TRUE(entry.getCultureDef().femaleCommonFirstNames.empty()); - EXPECT_TRUE(entry.getCultureDef().nobleLastNames.empty()); - EXPECT_TRUE(entry.getCultureDef().commonLastNames.empty()); - EXPECT_TRUE(entry.getCultureDef().maleRegalFirstNames.empty()); - EXPECT_TRUE(entry.getCultureDef().femaleRegalFirstNames.empty()); - EXPECT_TRUE(entry.getCultureDef().regalLastNames.empty()); - EXPECT_TRUE(entry.getCultureDef().ethnicities.empty()); - EXPECT_TRUE(entry.getCultureDef().graphics.empty()); - EXPECT_FALSE(entry.getCultureDef().skipProcessing); - EXPECT_FALSE(entry.getCultureDef().skipExport); -} - -TEST(Mappers_CultureDefinitionEntryTests, EntryCanBeLoaded) -{ - std::stringstream input; - input << "color = rgb{ 1 2 3 }\n"; - input << "religion = religion_1\n"; - input << "traits = { testtrait1 }\n"; - input << "male_common_first_names= { mcfn1 mcfn2 }\n"; - input << "female_common_first_names = { fcfn1 fcfn2 }\n"; - input << "noble_last_names = { nln1 nln2 }\n"; - input << "common_last_names={ cln1 cln2 }\n"; - input << "male_regal_first_names = { mrfn1 mrfn2 }\n"; - input << "female_regal_first_names = { frfn1 frfn2 }\n"; - input << "regal_last_names = { rln1 rln2 }\n"; - input << "ethnicities = {\n"; - input << " 1 = ethnotest\n"; - input << "}\n"; - input << "graphics = graphtest\n"; - const mappers::CultureDefinitionEntry entry(input, true, true); - - EXPECT_TRUE(entry.getCultureDef().name.empty()); - EXPECT_EQ(commonItems::Color(std::array{1, 2, 3}), *entry.getCultureDef().color); - EXPECT_THAT(entry.getCultureDef().traits, testing::UnorderedElementsAre("testtrait1")); - EXPECT_THAT(entry.getCultureDef().maleCommonFirstNames, testing::UnorderedElementsAre("mcfn1", "mcfn2")); - EXPECT_THAT(entry.getCultureDef().femaleCommonFirstNames, testing::UnorderedElementsAre("fcfn1", "fcfn2")); - EXPECT_THAT(entry.getCultureDef().nobleLastNames, testing::UnorderedElementsAre("nln1", "nln2")); - EXPECT_THAT(entry.getCultureDef().commonLastNames, testing::UnorderedElementsAre("cln1", "cln2")); - EXPECT_THAT(entry.getCultureDef().maleRegalFirstNames, testing::UnorderedElementsAre("mrfn1", "mrfn2")); - EXPECT_THAT(entry.getCultureDef().femaleRegalFirstNames, testing::UnorderedElementsAre("frfn1", "frfn2")); - EXPECT_THAT(entry.getCultureDef().regalLastNames, testing::UnorderedElementsAre("rln1", "rln2")); - EXPECT_THAT(entry.getCultureDef().ethnicities, testing::UnorderedElementsAre("ethnotest")); - EXPECT_EQ("graphtest", entry.getCultureDef().graphics); - EXPECT_TRUE(entry.getCultureDef().skipProcessing); - EXPECT_TRUE(entry.getCultureDef().skipExport); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureDefinitionLoaderTests/CultureDefinitionLoaderTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureDefinitionLoaderTests/CultureDefinitionLoaderTests.cpp deleted file mode 100644 index bfc0ee1..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureDefinitionLoaderTests/CultureDefinitionLoaderTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "CultureMapper/CultureDefinitionLoader/CultureDefinitionLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(Mappers_CultureDefinitionLoaderTests, LoaderDefaultsToDry) -{ - const mappers::CultureDefinitionLoader loader; - ASSERT_TRUE(loader.getDefinitions().empty()); -} - -TEST(Mappers_CultureDefinitionLoaderTests, CulturesCanBeRetrieved) -{ - mappers::CultureDefinitionLoader loader; - loader.loadDefinitions(modFS); - - ASSERT_TRUE(loader.getDefinitions().contains("vculture2")); - const auto& vculture2 = loader.getDefinitions().at("vculture2"); - - EXPECT_EQ("vculture2", vculture2.name); - EXPECT_THAT(vculture2.ethnicities, testing::UnorderedElementsAre("ethnotest2")); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureMapperTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureMapperTests.cpp deleted file mode 100644 index 6e81513..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureMapperTests.cpp +++ /dev/null @@ -1,341 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "CommonFunctions.h" -#include "CultureLoader/CultureLoader.h" -#include "CultureMapper/CultureMapper.h" -#include "LocalizationLoader/EU4LocalizationLoader.h" -#include "ReligionLoader/ReligionLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -const auto eu4FS = commonItems::ModFilesystem("TestFiles/eu4installation/", {Mod("Some mod", "TestFiles/mod/themod/")}); - -std::tuple prepMappers() -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - religionLoader.loadReligions(eu4FS); - EU4::CultureLoader cultureLoader; - cultureLoader.loadCultures(eu4FS); - - mappers::CultureMapper culMapper; - culMapper.loadMappingRules("TestFiles/configurables/culture_map.txt"); - culMapper.loadWesternizationRules("TestFiles/configurables/westernization.txt"); - return std::tuple{culMapper, clayManager, cultureLoader, religionLoader}; -} -} // namespace - -TEST(Mappers_CultureMapperTests, noMatchesMatchesRequestRecordsAndWarnsOnce) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - const auto& match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "nonsense", "", "SOMESTATE", ""); - std::cout.rdbuf(cout_buffer); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] ! CultureMapper - Attempting to match culture nonsense in state SOMESTATE failed.)")); - EXPECT_EQ("nonsense", *match); - EXPECT_TRUE(culMapper.getUnMappedCultures().contains("nonsense")); -} - -TEST(Mappers_CultureMapperTests, simpleMatchMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "somereligion", "SOMESTATE", "TAG"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture1", *match); -} - -TEST(Mappers_CultureMapperTests, simpleMatchMatchesBetweenMultipleCultures) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture3", "somereligion", "SOMESTATE", "TAG"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture2", *match); -} - -TEST(Mappers_CultureMapperTests, religionOwnerMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture4", "religion_2", "SOMESTATE", "TAG"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture4", *match); -} - -TEST(Mappers_CultureMapperTests, religionMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture4", "religion_2", "SOMESTATE", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture5", *match); -} - -TEST(Mappers_CultureMapperTests, cultureFallbackMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture4", "religion_3", "SOMESTATE", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture6", *match); -} - -TEST(Mappers_CultureMapperTests, superRegionMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture5", "somereligion", "STATE_TEST_4", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture7", *match); -} - -TEST(Mappers_CultureMapperTests, regionMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture5", "somereligion", "STATE_TEST_3", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture8", *match); -} - -TEST(Mappers_CultureMapperTests, stateMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture5", "somereligion", "STATE_TEST_1", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture9", *match); -} - -TEST(Mappers_CultureMapperTests, regionReligionMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture5", "religion_3", "STATE_TEST_2", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture10", *match); -} - -TEST(Mappers_CultureMapperTests, regionNonReligionMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture5", "religion_1", "STATE_TEST_2", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture11", *match); -} - -TEST(Mappers_CultureMapperTests, cultureGroupRegionReligionMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture6", "religion_2", "STATE_TEST_2", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture12", *match); -} - -TEST(Mappers_CultureMapperTests, cultureGroupReligionMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture6", "religion_2", "STATE_TEST_3", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture13", *match); -} - -TEST(Mappers_CultureMapperTests, cultureGroupRegionMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture6", "religion_1", "STATE_TEST_2", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture14", *match); -} - -TEST(Mappers_CultureMapperTests, cultureGroupMatches) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture6", "religion_1", "STATE_TEST_3", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("culture6", *match); // this remains a dynamic name as there's no direct cultural group mapping for culture6. -} - -TEST(Mappers_CultureMapperTests, macrosAreLoaded1) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture8", "religion_1", "STATE_TEST_2", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture16", *match); -} - -TEST(Mappers_CultureMapperTests, macrosAreLoaded2) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture8", "religion_1", "STATE_TEST_1", "GAT"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture17", *match); -} - -TEST(Mappers_CultureMapperTests, rulesCanBeExpandedWithUnmappedCultures) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - EXPECT_FALSE(culMapper.getUnMappedCultures().contains("unmapped_culture")); - - // now expand - culMapper.expandCulturalMappings(clayManager, cultureLoader, religionLoader); - - EXPECT_TRUE(culMapper.getUnMappedCultures().contains("unmapped_culture")); - - auto match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "unmapped_culture", "", "SOMESTATE", ""); - ASSERT_TRUE(match); - EXPECT_EQ("unmapped_culture", *match); -} - -TEST(Mappers_CultureMapperTests, cultureDefsCanBeGenerated) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - culMapper.expandCulturalMappings(clayManager, cultureLoader, religionLoader); - - EXPECT_TRUE(culMapper.getV3CultureDefinitions().empty()); - - std::stringstream input; - input << commonItems::utf8BOM << "l_english:\n"; - input << " unmapped_culture: \"Unmapped\"\n"; - input << " culture5: \"Culture 5\"\n"; - EU4::EU4LocalizationLoader eu4LocLoader; - eu4LocLoader.loadLocalizations(input); - - culMapper.loadCultureDefinitions(modFS); - culMapper.generateCultureDefinitions("TestFiles/configurables/name_lists.txt", - "TestFiles/configurables/name_list_map.txt", - "TestFiles/configurables/culture_trait_map.txt", - clayManager, - cultureLoader, - religionLoader, - eu4LocLoader); - - // eu4 cultures.txt defines cultures1-10 + unmapped_culture - // culture_map.txt maps everything except culture5 and unmapped_culture - // Those two will have defs generated as all the others are EXPECTED to have preset defs in vanilla + blankmod. - // (in reality they don't but that's not relevant). - // - // In addition, inside are vanilla defs for vculture1 and vculture2 which are not interesting. - - ASSERT_EQ(10, culMapper.getV3CultureDefinitions().size()); - EXPECT_TRUE(culMapper.getV3CultureDefinitions().contains("vculture1")); - EXPECT_TRUE(culMapper.getV3CultureDefinitions().contains("vculture2")); - const auto& def1 = culMapper.getV3CultureDefinitions().at("culture5"); - const auto& def2 = culMapper.getV3CultureDefinitions().at("unmapped_culture"); - - // culture 5 maps via: - // link = { eu4group = culture_group trait = testtrait2 ethnicity = testable2 graphics = gr2 } - // link = { eu4group = culture_group name_pool = name_list_test2 } - EXPECT_EQ("culture5", def1.name); - ASSERT_TRUE(def1.color); - EXPECT_EQ("= rgb { 112 254 237 }", (*def1.color).outputRgb()); - EXPECT_THAT(def1.traits, testing::UnorderedElementsAre("testtrait2")); - EXPECT_THAT(def1.maleCommonFirstNames, testing::UnorderedElementsAre("male3", "male4")); - EXPECT_THAT(def1.femaleCommonFirstNames, testing::UnorderedElementsAre("female3", "female4")); - EXPECT_THAT(def1.nobleLastNames, testing::UnorderedElementsAre("dyn3", "dyn4")); - EXPECT_THAT(def1.commonLastNames, testing::UnorderedElementsAre("dyn3", "dyn4")); - EXPECT_THAT(def1.maleRegalFirstNames, testing::UnorderedElementsAre("male3", "male4")); - EXPECT_THAT(def1.femaleRegalFirstNames, testing::UnorderedElementsAre("female3", "female4")); - EXPECT_TRUE(def1.regalLastNames.empty()); // we don't map these atm. - EXPECT_THAT(def1.ethnicities, testing::UnorderedElementsAre("testable2")); - EXPECT_EQ("gr2", def1.graphics); - EXPECT_EQ("Culture 5", def1.locBlock.at("english")); - EXPECT_EQ(10, culMapper.getWesternizationScoreForCulture("culture5")); - EXPECT_EQ(5, culMapper.getLiteracyScoreForCulture("culture5")); - EXPECT_EQ(5, culMapper.getIndustryScoreForCulture("culture5")); - - // unmapped_culture has no mapping links whatsoever and is scraping defaults - EXPECT_EQ("unmapped_culture", def2.name); - ASSERT_TRUE(def2.color); - EXPECT_EQ("= rgb { 254 61 136 }", (*def2.color).outputRgb()); - EXPECT_TRUE(def2.traits.empty()); - EXPECT_TRUE(def2.maleCommonFirstNames.empty()); - EXPECT_TRUE(def2.femaleCommonFirstNames.empty()); - EXPECT_TRUE(def2.nobleLastNames.empty()); - EXPECT_TRUE(def2.commonLastNames.empty()); - EXPECT_TRUE(def2.maleRegalFirstNames.empty()); - EXPECT_TRUE(def2.femaleRegalFirstNames.empty()); - EXPECT_TRUE(def2.regalLastNames.empty()); // we don't map these atm. - EXPECT_THAT(def2.ethnicities, testing::UnorderedElementsAre("neutral")); // fallback default - EXPECT_EQ("generic", def2.graphics); // generic fallback for everyone. - EXPECT_EQ("Unmapped", def2.locBlock.at("english")); - EXPECT_EQ(0, culMapper.getWesternizationScoreForCulture("unmapped_culture")); - EXPECT_EQ(0, culMapper.getLiteracyScoreForCulture("unmapped_culture")); - EXPECT_EQ(0, culMapper.getIndustryScoreForCulture("unmapped_culture")); -} - -TEST(Mappers_CultureMapperTests, cultureDefsLinksDynamicsToRelatedCultures) -{ - auto [culMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - culMapper.expandCulturalMappings(clayManager, cultureLoader, religionLoader); - - std::stringstream input; - input << commonItems::utf8BOM << "l_english:\n"; - input << " unmapped_culture: \"Unmapped\"\n"; - input << " culture5: \"Culture 5\"\n"; - EU4::EU4LocalizationLoader eu4LocLoader; - eu4LocLoader.loadLocalizations(input); - - const auto& match = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "dynamic-culture1-culture7-culture-num1", "", "", ""); - ASSERT_TRUE(match); - EXPECT_EQ("dynamic-culture1-culture7-culture-num1", *match); // this remains a dynamic culture. - const auto& match2 = culMapper.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "", ""); - ASSERT_TRUE(match2); - EXPECT_EQ("vculture1", *match2); // dynamic-culture1-culture7-culture-num1 should be related to vculture1. - - culMapper.loadCultureDefinitions(modFS); - culMapper.generateCultureDefinitions("TestFiles/configurables/name_lists.txt", - "TestFiles/configurables/name_list_map.txt", - "TestFiles/configurables/culture_trait_map.txt", - clayManager, - cultureLoader, - religionLoader, - eu4LocLoader); - - const auto& related = culMapper.getRelatedCultures(); - - ASSERT_TRUE(related.contains("vculture1")); - EXPECT_THAT(related.at("vculture1"), testing::UnorderedElementsAre("dynamic-culture1-culture7-culture-num1")); - ASSERT_TRUE(related.contains("vculture17")); - EXPECT_THAT(related.at("vculture17"), testing::UnorderedElementsAre("dynamic-culture8-culture-num1")); -} - -TEST(Mappers_CultureMapperTests, cultureMapperCanCompareCulturalTraits) -{ - mappers::CultureMapper culMapper; - culMapper.loadCultureDefinitions(modFS); - culMapper.loadTraitDefinitions(modFS); - - ASSERT_TRUE(culMapper.doCulturesShareHeritageTrait("vculture1", "vculture2")); - EXPECT_FALSE(*culMapper.doCulturesShareHeritageTrait("vculture1", "vculture2")); - ASSERT_TRUE(culMapper.doCulturesShareNonHeritageTrait("vculture1", "vculture2")); - EXPECT_TRUE(*culMapper.doCulturesShareNonHeritageTrait("vculture1", "vculture2")); -} - -TEST(Mappers_CultureMapperTests, cultureMapperDoesNotCompareBrokenCulturalTraits) -{ - mappers::CultureMapper culMapper; - culMapper.loadCultureDefinitions(modFS); - culMapper.loadTraitDefinitions(modFS); - - EXPECT_EQ(std::nullopt, culMapper.doCulturesShareHeritageTrait("vculture1", "nonsense")); - EXPECT_EQ(std::nullopt, culMapper.doCulturesShareNonHeritageTrait("vculture1", "nonsense")); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureMappingRuleTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureMappingRuleTests.cpp deleted file mode 100644 index ad8562e..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureMappingRuleTests.cpp +++ /dev/null @@ -1,449 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "CultureLoader/CultureLoader.h" -#include "CultureMapper/CultureMappingRule.h" -#include "ReligionLoader/ReligionLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(Mappers_CultureMappingRuleTests, primitivesDefaultsToBlank) -{ - const mappers::CultureMappingRule mapping; - - EXPECT_TRUE(mapping.getRequestedMacros().empty()); - EXPECT_TRUE(mapping.getCultures().empty()); - EXPECT_TRUE(mapping.getCultureGroups().empty()); - EXPECT_TRUE(mapping.getReligions().empty()); - EXPECT_TRUE(mapping.getReligionGroups().empty()); - EXPECT_TRUE(mapping.getRegions().empty()); - EXPECT_TRUE(mapping.getReligionGroups().empty()); - EXPECT_TRUE(mapping.getV3Culture().empty()); -} - -TEST(Mappers_CultureMappingRuleTests, primitivesCanBeLoaded) -{ - std::stringstream input; - input << "vic3 = vic3Culture eu4 = culture1 eu4 = culture2 eu4group = cgroup1 eu4group = cgroup2"; - input << " religion = religion1 religion = religion2 religion_group = rgroup1 religion_group = rgroup2"; - input << " @macro1 @macro2 @macro3 "; - input << " region = region1 region = region2 owner = TAG1 owner = TAG2 }"; - - mappers::CultureMappingRule mapping; - mapping.loadMappingRules(input); - - EXPECT_EQ("vic3Culture", mapping.getV3Culture()); - EXPECT_THAT(mapping.getCultures(), testing::UnorderedElementsAre("culture1", "culture2")); - EXPECT_THAT(mapping.getCultureGroups(), testing::UnorderedElementsAre("cgroup1", "cgroup2")); - EXPECT_THAT(mapping.getReligions(), testing::UnorderedElementsAre("religion1", "religion2")); - EXPECT_THAT(mapping.getReligionGroups(), testing::UnorderedElementsAre("rgroup1", "rgroup2")); - EXPECT_THAT(mapping.getRegions(), testing::UnorderedElementsAre("region1", "region2")); - EXPECT_THAT(mapping.getOwners(), testing::UnorderedElementsAre("TAG1", "TAG2")); - EXPECT_THAT(mapping.getRequestedMacros(), testing::UnorderedElementsAre("@macro1", "@macro2", "@macro3")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnSimpleCulture) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1"); - - EXPECT_EQ("vculture1", *theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnSimpleCultureFailsForWrongCulture) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture2", "", "", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnSimpleCultureGroup) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - std::stringstream input; - input << "cgroup1 = { culture1 = {}}"; - cultureLoader.loadCultures(input); - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4group = cgroup1"); - - EXPECT_EQ("vculture1", *theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnSimpleCultureFailsForWrongCultureGroup) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - std::stringstream input; - input << "cgroup1 = { culture1 = {}}"; - cultureLoader.loadCultures(input); - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4group = cgroup1"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture2", "", "", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnReligion) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - std::stringstream input; - input << "rgroup1 = { religion1 = {}}"; - religionLoader.loadReligions(input); - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 religion = religion1"); - - const auto match = theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "religion1", "", ""); - ASSERT_TRUE(match); - EXPECT_EQ("vculture1", *match); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnReligionFailsForNoReligion) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - std::stringstream input; - input << "rgroup1 = { religion1 = {}}"; - religionLoader.loadReligions(input); - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 religion = religion1"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnReligionFailsForWrongReligion) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - std::stringstream input; - input << "rgroup1 = { religion1 = {}}"; - religionLoader.loadReligions(input); - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 religion = religion1"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "religion2", "", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnReligionGroup) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - std::stringstream input; - input << "rgroup1 = { religion1 = {}}"; - religionLoader.loadReligions(input); - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 religion_group = rgroup1"); - - const auto match = theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "religion1", "", ""); - ASSERT_TRUE(match); - EXPECT_EQ("vculture1", *match); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnReligionFailsForNoReligionGroup) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - std::stringstream input; - input << "rgroup1 = { religion1 = {}}"; - religionLoader.loadReligions(input); - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 religion_group = rgroup1"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnReligionFailsForWrongReligionGroup) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - std::stringstream input; - input << "rgroup2 = { religion1 = {}}"; - religionLoader.loadReligions(input); - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 religion_group = rgroup1"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "religion1", "", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnOwner) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 owner = TAG"); - - const auto match = theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "", "TAG"); - ASSERT_TRUE(match); - EXPECT_EQ("vculture1", *match); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnOwnerFailsForWrongOwner) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 owner = TAG"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "", "GAT")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnOwnerFailsForNoOwner) -{ - V3::ClayManager clayManager; - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 owner = TAG"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnState) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 region = STATE_TEST_1"); - - const auto match = theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "STATE_TEST_1", ""); - ASSERT_TRUE(match); - EXPECT_EQ("vculture1", *match); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnRegion) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 region = region_a"); - - const auto match = theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "STATE_TEST_1", ""); - ASSERT_TRUE(match); - EXPECT_EQ("vculture1", *match); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnSuperRegion) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 region = test_1_strategic_regions"); - - const auto match = theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "STATE_TEST_1", ""); - ASSERT_TRUE(match); - EXPECT_EQ("vculture1", *match); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnRegionFailsForWrongState) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 region = STATE_TEST_2"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "STATE_TEST_1", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnRegionFailsForWrongRegion) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 region = region_b"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "STATE_TEST_1", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnRegionFailsForWrongSuperRegion) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 region = test_2_strategic_regions"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "STATE_TEST_1", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regularMatchOnRegionFailsForNoRegion) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 region = test_2_strategic_regions"); - - EXPECT_FALSE(theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "", "")); -} - -TEST(Mappers_CultureMappingRuleTests, regionalMatchOnRegion) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 region = test_1_strategic_regions"); - - const auto match = theMapping.cultureMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "STATE_TEST_1", ""); - ASSERT_TRUE(match); - EXPECT_EQ("vculture1", *match); -} - -TEST(Mappers_CultureMappingRuleTests, regionalMatchOnFailsForNoLoadedRegions) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1"); - - EXPECT_FALSE(theMapping.cultureRegionalMatch(clayManager, cultureLoader, religionLoader, "culture1", "", "STATE_TEST_1", "")); -} - -TEST(Mappers_CultureMappingRuleTests, nonRegionalNonReligionsMatch) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - std::stringstream input; - input << "rgroup2 = { religion1 = {}}"; - religionLoader.loadReligions(input); - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1"); - - const auto match = theMapping.cultureNonRegionalNonReligiousMatch(clayManager, cultureLoader, religionLoader, "culture1", "religion1", "STATE_TEST_1", ""); - ASSERT_TRUE(match); - EXPECT_EQ("vculture1", *match); -} - -TEST(Mappers_CultureMappingRuleTests, nonRegionalNonReligionsMatchOnFailsForLoadedRegions) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - std::stringstream input; - input << "rgroup2 = { religion1 = {}}"; - religionLoader.loadReligions(input); - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 region = STATE_TEST_1"); - - EXPECT_FALSE(theMapping.cultureNonRegionalNonReligiousMatch(clayManager, cultureLoader, religionLoader, "culture1", "religion1", "STATE_TEST_1", "")); -} - -TEST(Mappers_CultureMappingRuleTests, nonRegionalNonReligionsMatchOnFailsForLoadedReligions) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - std::stringstream input; - input << "rgroup2 = { religion1 = {}}"; - religionLoader.loadReligions(input); - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 religion = religion1"); - - EXPECT_FALSE(theMapping.cultureNonRegionalNonReligiousMatch(clayManager, cultureLoader, religionLoader, "culture1", "religion1", "STATE_TEST_1", "")); -} - -TEST(Mappers_CultureMappingRuleTests, nonRegionalNonReligionsMatchOnFailsForLoadedReligionGroups) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - EU4::ReligionLoader religionLoader; - std::stringstream input; - input << "rgroup2 = { religion1 = {}}"; - religionLoader.loadReligions(input); - EU4::CultureLoader cultureLoader; - - mappers::CultureMappingRule theMapping; - theMapping.loadMappingRules("vic3 = vculture1 eu4 = culture1 religion_group = rgroup2"); - - EXPECT_FALSE(theMapping.cultureNonRegionalNonReligiousMatch(clayManager, cultureLoader, religionLoader, "culture1", "religion1", "STATE_TEST_1", "")); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureTraitMapperTests/CultureTraitMapperTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureTraitMapperTests/CultureTraitMapperTests.cpp deleted file mode 100644 index 46a2df7..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureTraitMapperTests/CultureTraitMapperTests.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "CultureMapper/CultureTraitMapper/CultureTraitMapper.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_CultureTraitMapperTests, noMatchesGiveEmptyOptional) -{ - mappers::CultureTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/culture_trait_map.txt"); - - EXPECT_FALSE(mapper.getTraitsForCulture("nonsense", "nonsense")); -} - -TEST(Mappers_CultureTraitMapperTests, cultureMatchMatches) -{ - mappers::CultureTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/culture_trait_map.txt"); - - const auto match = mapper.getTraitsForCulture("culture1", "additional_group"); - ASSERT_TRUE(match); - - EXPECT_THAT(match->getTraits(), testing::UnorderedElementsAre("testtrait", "testtrait2")); - EXPECT_EQ("testable", match->getEthnicity()); -} - -TEST(Mappers_CultureTraitMapperTests, cultureGroupMatchMatches) -{ - mappers::CultureTraitMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/culture_trait_map.txt"); - - const auto match = mapper.getTraitsForCulture("undefined", "additional_group"); - ASSERT_TRUE(match); - - EXPECT_THAT(match->getTraits(), testing::UnorderedElementsAre("testtrait3")); - EXPECT_EQ("testable3", match->getEthnicity()); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureTraitMapperTests/CultureTraitMappingTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureTraitMapperTests/CultureTraitMappingTests.cpp deleted file mode 100644 index 84db220..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/CultureTraitMapperTests/CultureTraitMappingTests.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "CultureMapper/CultureTraitMapper/CultureTraitMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_CultureTraitMappingTests, primitivesDefaultsToBlank) -{ - std::stringstream input; - const mappers::CultureTraitMapping mapping(input); - - EXPECT_TRUE(mapping.getCulture().empty()); - EXPECT_TRUE(mapping.getCultureGroup().empty()); - EXPECT_TRUE(mapping.getTraits().empty()); - EXPECT_TRUE(mapping.getEthnicity().empty()); - EXPECT_TRUE(mapping.getGraphics().empty()); -} - -TEST(Mappers_CultureTraitMappingTests, primitivesCanBeLoaded) -{ - std::stringstream input; - input << "eu4 = culture1 eu4group = group1 trait = testtrait trait = testtrait2 ethnicity = testable graphics = something"; - const mappers::CultureTraitMapping mapping(input); - - EXPECT_EQ("culture1", mapping.getCulture()); - EXPECT_EQ("group1", mapping.getCultureGroup()); - EXPECT_THAT(mapping.getTraits(), testing::UnorderedElementsAre("testtrait", "testtrait2")); - EXPECT_EQ("testable", mapping.getEthnicity()); - EXPECT_EQ("something", mapping.getGraphics()); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListLoaderTests/NameListEntryTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListLoaderTests/NameListEntryTests.cpp deleted file mode 100644 index 82c8ccc..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListLoaderTests/NameListEntryTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "CultureMapper/NameListLoader/NameListEntry.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_NameListEntryTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - const mappers::NameListEntry entry(input); - - EXPECT_TRUE(entry.getDynastyNames().empty()); - EXPECT_TRUE(entry.getMaleNames().empty()); - EXPECT_TRUE(entry.getFemaleNames().empty()); -} - -TEST(Mappers_NameListEntryTests, EntryCanBeLoaded) -{ - std::stringstream input; - input << "dynasty_names = { dyn1 dyn2 }\n"; - input << "male_names = { male1 male2 }\n"; - input << "female_names = { female1 female2 }\n"; - const mappers::NameListEntry entry(input); - - EXPECT_THAT(entry.getDynastyNames(), testing::UnorderedElementsAre("dyn1", "dyn2")); - EXPECT_THAT(entry.getMaleNames(), testing::UnorderedElementsAre("male1", "male2")); - EXPECT_THAT(entry.getFemaleNames(), testing::UnorderedElementsAre("female1", "female2")); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListLoaderTests/NameListLoaderTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListLoaderTests/NameListLoaderTests.cpp deleted file mode 100644 index 1bea318..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListLoaderTests/NameListLoaderTests.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "CultureMapper/NameListLoader/NameListLoader.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_NameListLoaderTests, religionsCanBeRetrieved) -{ - mappers::NameListLoader loader; - loader.loadNameLists("TestFiles/configurables/name_lists.txt"); - - const auto& nameList = loader.getNameList("name_list_test2"); - ASSERT_TRUE(nameList); - - EXPECT_THAT(nameList->getDynastyNames(), testing::UnorderedElementsAre("dyn3", "dyn4")); - EXPECT_THAT(nameList->getMaleNames(), testing::UnorderedElementsAre("male3", "male4")); - EXPECT_THAT(nameList->getFemaleNames(), testing::UnorderedElementsAre("female3", "female4")); -} - -TEST(Mappers_NameListLoaderTests, MismatchReturnsNullopt) -{ - mappers::NameListLoader loader; - loader.loadNameLists("TestFiles/configurables/name_lists.txt"); - - const auto& nameList = loader.getNameList("nonsense"); - ASSERT_FALSE(nameList); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListMapperTests/NameListMapperTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListMapperTests/NameListMapperTests.cpp deleted file mode 100644 index 96ab66a..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListMapperTests/NameListMapperTests.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "CultureMapper/NameListMapper/NameListMapper.h" -#include "gtest/gtest.h" - -TEST(Mappers_NameListMapperTests, noMatchesGiveEmptyOptional) -{ - mappers::NameListMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/name_list_map.txt"); - - EXPECT_FALSE(mapper.getNamesForCulture("nonsense", "nonsense")); -} - -TEST(Mappers_NameListMapperTests, cultureMatchMatches) -{ - mappers::NameListMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/name_list_map.txt"); - - const auto match = mapper.getNamesForCulture("culture1", "additional_group"); - ASSERT_TRUE(match); - - EXPECT_EQ("name_list_test1", match->getNamePool()); -} - -TEST(Mappers_NameListMapperTests, cultureGroupMatchMatches) -{ - mappers::NameListMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/name_list_map.txt"); - - const auto match = mapper.getNamesForCulture("undefined", "additional_group"); - ASSERT_TRUE(match); - - EXPECT_EQ("name_list_test2", match->getNamePool()); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListMapperTests/NameListMappingTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListMapperTests/NameListMappingTests.cpp deleted file mode 100644 index 80db422..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/NameListMapperTests/NameListMappingTests.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "CultureMapper/NameListMapper/NameListMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_NameListMappingTests, primitivesDefaultsToBlank) -{ - std::stringstream input; - const mappers::NameListMapping mapping(input); - - EXPECT_TRUE(mapping.getCulture().empty()); - EXPECT_TRUE(mapping.getCultureGroup().empty()); - EXPECT_TRUE(mapping.getNamePool().empty()); -} - -TEST(Mappers_NameListMappingTests, primitivesCanBeLoaded) -{ - std::stringstream input; - input << "eu4 = culture1 eu4group = group1 name_pool = name_list_test1"; - const mappers::NameListMapping mapping(input); - - EXPECT_EQ("culture1", mapping.getCulture()); - EXPECT_EQ("group1", mapping.getCultureGroup()); - EXPECT_EQ("name_list_test1", mapping.getNamePool()); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/TraitDefinitionLoaderTests/TraitDefinitionEntryTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/TraitDefinitionLoaderTests/TraitDefinitionEntryTests.cpp deleted file mode 100644 index 9aa605d..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/TraitDefinitionLoaderTests/TraitDefinitionEntryTests.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "CultureMapper/TraitDefinitionLoader/TraitDefinitionEntry.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_TraitDefinitionEntryTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - const mappers::TraitDefinitionEntry entry(input); - - EXPECT_FALSE(entry.getTraitDef().isHeritageTrait); -} - -TEST(Mappers_TraitDefinitionEntryTests, EntryCanBeLoaded) -{ - std::stringstream input; - input << "heritage = yes\n"; - const mappers::TraitDefinitionEntry entry(input); - - EXPECT_TRUE(entry.getTraitDef().isHeritageTrait); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/TraitDefinitionLoaderTests/TraitDefinitionLoaderTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/TraitDefinitionLoaderTests/TraitDefinitionLoaderTests.cpp deleted file mode 100644 index fb07e60..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/TraitDefinitionLoaderTests/TraitDefinitionLoaderTests.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "CultureMapper/TraitDefinitionLoader/TraitDefinitionLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(Mappers_TraitDefinitionLoaderTests, LoaderDefaultsToDry) -{ - const mappers::TraitDefinitionLoader loader; - ASSERT_TRUE(loader.getDefinitions().empty()); -} - -TEST(Mappers_TraitDefinitionLoaderTests, TraitsCanBeRetrieved) -{ - mappers::TraitDefinitionLoader loader; - loader.loadDefinitions(modFS); - - ASSERT_TRUE(loader.getDefinitions().contains("heritage_trait_1")); - ASSERT_TRUE(loader.getDefinitions().contains("heritage_trait_2")); - ASSERT_TRUE(loader.getDefinitions().contains("nonheritage_trait_1")); - ASSERT_TRUE(loader.getDefinitions().contains("nonheritage_trait_2")); - - EXPECT_EQ("heritage_trait_1", loader.getDefinitions().at("heritage_trait_1").name); - EXPECT_TRUE(loader.getDefinitions().at("heritage_trait_1").isHeritageTrait); - EXPECT_EQ("heritage_trait_2", loader.getDefinitions().at("heritage_trait_2").name); - EXPECT_TRUE(loader.getDefinitions().at("heritage_trait_2").isHeritageTrait); - EXPECT_EQ("nonheritage_trait_1", loader.getDefinitions().at("nonheritage_trait_1").name); - EXPECT_FALSE(loader.getDefinitions().at("nonheritage_trait_1").isHeritageTrait); - EXPECT_EQ("nonheritage_trait_2", loader.getDefinitions().at("nonheritage_trait_2").name); - EXPECT_FALSE(loader.getDefinitions().at("nonheritage_trait_2").isHeritageTrait); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/WesternizationMapperTests/WesternizationMapperTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/WesternizationMapperTests/WesternizationMapperTests.cpp deleted file mode 100644 index e54fa4c..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/WesternizationMapperTests/WesternizationMapperTests.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "CultureMapper/WesternizationMapper/WesternizationMapper.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_WesternizationMapperTests, traitsCanBePinged) -{ - mappers::WesternizationMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/westernization.txt"); - - const std::set traits = {"testtrait", "testtrait2"}; - - EXPECT_EQ(10, mapper.getWesternizationForTraits(traits)); - EXPECT_EQ(5, mapper.getLiteracyForTraits(traits)); - EXPECT_EQ(5, mapper.getIndustryForTraits(traits)); -} - -TEST(Mappers_WesternizationMapperTests, MismatchedTraitsReturnMaxValues) -{ - mappers::WesternizationMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/westernization.txt"); - - const std::set traits = {"testtrait", "testtrait3"}; - - EXPECT_EQ(10, mapper.getWesternizationForTraits(traits)); - EXPECT_EQ(5, mapper.getLiteracyForTraits(traits)); - EXPECT_EQ(8, mapper.getIndustryForTraits(traits)); -} - -TEST(Mappers_WesternizationMapperTests, unknownTraitsReturnZeroAndWarn) -{ - mappers::WesternizationMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/westernization.txt"); - - const std::set traits = {"unknown", "unknown2"}; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - EXPECT_EQ(0, mapper.getWesternizationForTraits(traits)); - EXPECT_EQ(0, mapper.getLiteracyForTraits(traits)); - EXPECT_EQ(0, mapper.getIndustryForTraits(traits)); - std::cout.rdbuf(cout_buffer); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] Trait unknown has no westernization.txt link!)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] Trait unknown2 has no westernization.txt link!)")); -} diff --git a/EU5ToVic3Tests/MapperTests/CultureMapperTests/WesternizationMapperTests/WesternizationMappingTests.cpp b/EU5ToVic3Tests/MapperTests/CultureMapperTests/WesternizationMapperTests/WesternizationMappingTests.cpp deleted file mode 100644 index baecd83..0000000 --- a/EU5ToVic3Tests/MapperTests/CultureMapperTests/WesternizationMapperTests/WesternizationMappingTests.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "CultureMapper/WesternizationMapper/WesternizationMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_WesternizationMappingTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - const mappers::WesternizationMapping mapping(input); - - EXPECT_EQ(5, mapping.getWesternization()); - EXPECT_EQ(5, mapping.getLiteracy()); - EXPECT_EQ(5, mapping.getIndustry()); - EXPECT_TRUE(mapping.getTraits().empty()); -} - -TEST(Mappers_WesternizationMappingTests, mappingCanBeLoaded) -{ - std::stringstream input; - input << "westernization = 1\n"; - input << "literacy = 8\n"; - input << "industry = 0\n"; - input << "traits = {\n"; - input << " trait1 trait2\n"; - input << "}\n"; - - const mappers::WesternizationMapping mapping(input); - EXPECT_EQ(1, mapping.getWesternization()); - EXPECT_EQ(8, mapping.getLiteracy()); - EXPECT_EQ(0, mapping.getIndustry()); - EXPECT_THAT(mapping.getTraits(), testing::UnorderedElementsAre("trait1", "trait2")); -} diff --git a/EU5ToVic3Tests/MapperTests/DiplomaticMapperTests/DiplomaticMapperTests.cpp b/EU5ToVic3Tests/MapperTests/DiplomaticMapperTests/DiplomaticMapperTests.cpp deleted file mode 100644 index 0895276..0000000 --- a/EU5ToVic3Tests/MapperTests/DiplomaticMapperTests/DiplomaticMapperTests.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "DiplomaticMapper/DiplomaticMapper.h" -#include "gtest/gtest.h" - -TEST(Mappers_DiplomaticMapperTests, agreementsCanBeLoadedAndMatched) -{ - mappers::DiplomaticMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/diplomatic_map.txt"); - - EXPECT_EQ("dominion", *mapper.getAgreementType("private_enterprise")); - EXPECT_EQ("customs_union", *mapper.getAgreementType("transfer_trade_power")); - EXPECT_EQ(10, mapper.getRelationshipBoost("private_enterprise")); - EXPECT_EQ(25, mapper.getRelationshipBoost("transfer_trade_power")); -} - -TEST(Mappers_DiplomaticMapperTests, mismatchedAgreementsReturnNullAndZero) -{ - const mappers::DiplomaticMapper mapper; - - EXPECT_FALSE(mapper.getAgreementType("nonsense")); - EXPECT_EQ(0, mapper.getRelationshipBoost("nonsense")); -} diff --git a/EU5ToVic3Tests/MapperTests/ExcludedTradeCompaniesMapperTests/ExcludedTradeCompaniesMapperTests.cpp b/EU5ToVic3Tests/MapperTests/ExcludedTradeCompaniesMapperTests/ExcludedTradeCompaniesMapperTests.cpp deleted file mode 100644 index 53be0f0..0000000 --- a/EU5ToVic3Tests/MapperTests/ExcludedTradeCompaniesMapperTests/ExcludedTradeCompaniesMapperTests.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "ExcludedTradeCompaniesMapper/ExcludedTradeCompaniesMapper.h" -#include "gtest/gtest.h" - -TEST(Mappers_ExcludedTradeCompaniesMapperTests, DefaultsDefaultToDefaults) -{ - const mappers::ExcludedTradeCompaniesMapper mapper; - - EXPECT_TRUE(mapper.getExcludedTCs().empty()); -} - -TEST(Mappers_ExcludedTradeCompaniesMapperTests, TCsCanBeLoaded) -{ - mappers::ExcludedTradeCompaniesMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/excluded_trade_companies.txt"); - - ASSERT_EQ(10, mapper.getExcludedTCs().size()); - EXPECT_TRUE(mapper.getExcludedTCs().contains("trade_company_west_africa")); -} diff --git a/EU5ToVic3Tests/MapperTests/IGIdeologiesMapperTests/IGIdeologiesMapperTests.cpp b/EU5ToVic3Tests/MapperTests/IGIdeologiesMapperTests/IGIdeologiesMapperTests.cpp deleted file mode 100644 index 280756e..0000000 --- a/EU5ToVic3Tests/MapperTests/IGIdeologiesMapperTests/IGIdeologiesMapperTests.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "CountryManager/EU4Country.h" -#include "CultureMapper/CultureMapper.h" -#include "IGIdeologiesMapper/IGIdeologiesMapper.h" -#include "PoliticalManager/Country/Country.h" -#include "ReligionMapper/ReligionMapper.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_IGIdeologiesMapperTests, NoLinksProvidesNothing) -{ - const mappers::IGIdeologiesMapper mapper; - - const auto country = std::make_shared(); - const auto eu4Country = std::make_shared(); - country->setSourceCountry(eu4Country); - - const auto mods = mapper.getIGIdeologyMods(*country, {}, {}, {}); - - EXPECT_TRUE(mods.empty()); -} - -TEST(Mappers_IGIdeologiesMapperTests, modsCanBeGenerated) -{ - mappers::IGIdeologiesMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/ig_ideologies.txt"); - - // prep srccountry - std::stringstream eu4input; - eu4input << "government = { government = monarchy } active_idea_groups = { aristocracy_ideas = 7 } religion = orthodox"; - const auto eu4Country = std::make_shared("TAG", eu4input); - - // prep culture - auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - V3::ProcessedData data; - data.cultures = {"japanese", "russian"}; - country->setProcessedData(data); - - // prep cultural trait - mappers::CultureMapper culMapper; - mappers::CultureDef def; - def.name = "japanese"; - def.traits.emplace("yamato"); - culMapper.setV3CultureDefinitions({std::pair("japanese", def)}); - - // match - auto mods = mapper.getIGIdeologyMods(*country, culMapper, {}, {}); - - EXPECT_THAT(mods.at("ig_armed_forces").addedIdeologies, testing::UnorderedElementsAre("ideology_bakufu")); - EXPECT_THAT(mods.at("ig_armed_forces").removedIdeologies, testing::UnorderedElementsAre()); - EXPECT_THAT(mods.at("ig_devout").addedIdeologies, testing::UnorderedElementsAre("ideology_russian_patriarch")); - EXPECT_THAT(mods.at("ig_devout").removedIdeologies, testing::UnorderedElementsAre("ideology_patriarchal")); -} diff --git a/EU5ToVic3Tests/MapperTests/IGIdeologiesMapperTests/IGIdeologiesMappingTests.cpp b/EU5ToVic3Tests/MapperTests/IGIdeologiesMapperTests/IGIdeologiesMappingTests.cpp deleted file mode 100644 index 5fba408..0000000 --- a/EU5ToVic3Tests/MapperTests/IGIdeologiesMapperTests/IGIdeologiesMappingTests.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "CountryManager/EU4Country.h" -#include "CultureMapper/CultureMapper.h" -#include "IGIdeologiesMapper/IGIdeologiesMapping.h" -#include "PoliticalManager/Country/Country.h" -#include "ReligionMapper/ReligionMapper.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_IGIdeologiesMappingTests, EmptyLinkAltersNothing) -{ - std::map mods; - - std::stringstream input; - const mappers::IGIdeologiesMapping mapping(input); - - const auto country = std::make_shared(); - const auto eu4Country = std::make_shared(); - country->setSourceCountry(eu4Country); - - mods = mapping.alterIdeologyMods(mods, *country, {}, {}, {}); - - EXPECT_TRUE(mods.empty()); -} - -TEST(Mappers_IGIdeologiesMappingTests, LinkCanAlterMods) -{ - std::map mods; - - std::stringstream input; - input << "culturetrait = yamato eu4gov = monarchy eu4gov = theocracy ig_armed_forces = add:ideology_bakufu ig_armed_forces = add:ideology_paternalistic"; - const mappers::IGIdeologiesMapping mapping(input); - - // prep gov - std::stringstream eu4input; - eu4input << "government = { government = monarchy }"; - const auto eu4Country = std::make_shared("TAG", eu4input); - - // prep culture - auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - V3::ProcessedData data; - data.cultures = {"japanese", "russian"}; - country->setProcessedData(data); - - // prep cultural trait - mappers::CultureMapper culMapper; - mappers::CultureDef def; - def.name = "japanese"; - def.traits.emplace("yamato"); - culMapper.setV3CultureDefinitions({std::pair("japanese", def)}); - - // match - mods = mapping.alterIdeologyMods(mods, *country, culMapper, {}, {}); - - ASSERT_EQ(1, mods.size()); - EXPECT_THAT(mods.at("ig_armed_forces").addedIdeologies, testing::UnorderedElementsAre("ideology_bakufu", "ideology_paternalistic")); -} - -TEST(Mappers_IGIdeologiesMappingTests, LinkCanNullifyExistingMods) -{ - std::map mods; - mods.emplace("ig_armed_forces", mappers::IGIdeologyMod()); - mods.at("ig_armed_forces").removedIdeologies.emplace("ideology_bakufu"); - - std::stringstream input; - input << "culturetrait = yamato eu4gov = monarchy eu4gov = theocracy ig_armed_forces = add:ideology_bakufu ig_armed_forces = add:ideology_paternalistic"; - const mappers::IGIdeologiesMapping mapping(input); - - // prep gov - std::stringstream eu4input; - eu4input << "government = { government = monarchy }"; - const auto eu4Country = std::make_shared("TAG", eu4input); - - // prep culture - auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - V3::ProcessedData data; - data.cultures = {"japanese"}; - country->setProcessedData(data); - - // prep cultural trait - mappers::CultureMapper culMapper; - mappers::CultureDef def; - def.name = "japanese"; - def.traits.emplace("yamato"); - culMapper.setV3CultureDefinitions({std::pair("japanese", def)}); - - // match - mods = mapping.alterIdeologyMods(mods, *country, culMapper, {}, {}); - - ASSERT_EQ(1, mods.size()); - EXPECT_THAT(mods.at("ig_armed_forces").addedIdeologies, testing::UnorderedElementsAre("ideology_paternalistic")); -} diff --git a/EU5ToVic3Tests/MapperTests/IdeaEffectsMapperTests/IdeaEffectsMapperTests.cpp b/EU5ToVic3Tests/MapperTests/IdeaEffectsMapperTests/IdeaEffectsMapperTests.cpp deleted file mode 100644 index 7f2b14d..0000000 --- a/EU5ToVic3Tests/MapperTests/IdeaEffectsMapperTests/IdeaEffectsMapperTests.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "IdeaEffectsMapper/IdeaEffectsMapper.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_IdeaEffectsMapperTests, NonsenseIdeasReturnEmptyEffect) -{ - mappers::IdeaEffectsMapper mapper; - std::stringstream input; - mapper.loadMappingRules(input); - - std::set ideas = {"idea", "another_idea"}; - - const auto effect = mapper.getEffectForIdeas(ideas); - - EXPECT_EQ(0, effect.literacy); - EXPECT_EQ(0, effect.adm); - EXPECT_EQ(0, effect.dip); - EXPECT_EQ(0, effect.mil); - EXPECT_TRUE(effect.boostedInterestGroups.empty()); - EXPECT_TRUE(effect.suppressedInterestGroups.empty()); -} - -TEST(Mappers_IdeaEffectsMapperTests, effectCanBeCalculated) -{ - mappers::IdeaEffectsMapper mapper; - std::stringstream input; - input << "idea = { literacy = 1 adm = 2 dip = 3 mil = 4 ig = iggroup1 ig = iggroup2 noig = noiggroup1 noig = noiggroup2 }\n"; - input << "another_idea = { literacy = 3 adm = 4 dip = -5 mil = -6 ig = iggroup3 noig = iggroup1 noig = noiggroup2 }\n"; // cancelling out iggroup1 - mapper.loadMappingRules(input); - - std::set ideas = {"idea", "another_idea"}; - - const auto effect = mapper.getEffectForIdeas(ideas); - - EXPECT_EQ(4, effect.literacy); - EXPECT_EQ(6, effect.adm); - EXPECT_EQ(-2, effect.dip); - EXPECT_EQ(-2, effect.mil); - EXPECT_THAT(effect.boostedInterestGroups, testing::UnorderedElementsAre("iggroup2", "iggroup3")); - EXPECT_THAT(effect.suppressedInterestGroups, testing::UnorderedElementsAre("noiggroup1", "noiggroup2")); -} - -TEST(Mappers_IdeaEffectsMapperTests, doubleBoostedInterestGroupBecomesRuling) -{ - mappers::IdeaEffectsMapper mapper; - std::stringstream input; - input << "idea = { literacy = 1 adm = 2 dip = 3 mil = 4 ig = iggroup1 ig = iggroup2 }\n"; // iggroup1 gets boosted twice - input << "another_idea = { literacy = 3 adm = 4 dip = -5 mil = -6 ig = iggroup1 noig = iggroup2}\n"; // cancelling out iggroup2 - mapper.loadMappingRules(input); - - std::set ideas = {"idea", "another_idea"}; - - const auto effect = mapper.getEffectForIdeas(ideas); - - EXPECT_THAT(effect.rulingInterestGroups, testing::UnorderedElementsAre("iggroup1")); - EXPECT_THAT(effect.boostedInterestGroups, testing::UnorderedElementsAre("iggroup1")); - EXPECT_THAT(effect.suppressedInterestGroups, testing::UnorderedElementsAre()); -} diff --git a/EU5ToVic3Tests/MapperTests/IdeaEffectsMapperTests/IdeaEffectsMappingTests.cpp b/EU5ToVic3Tests/MapperTests/IdeaEffectsMapperTests/IdeaEffectsMappingTests.cpp deleted file mode 100644 index 4c23823..0000000 --- a/EU5ToVic3Tests/MapperTests/IdeaEffectsMapperTests/IdeaEffectsMappingTests.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "IdeaEffectsMapper/IdeaEffectsMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_IdeaEffectsMappingTests, DefaultsDefaultToDefaults) -{ - - std::stringstream input; - const mappers::IdeaEffectsMapping mapping(input); - - EXPECT_EQ(0, mapping.getLiteracy()); - EXPECT_EQ(0, mapping.getAdm()); - EXPECT_EQ(0, mapping.getDip()); - EXPECT_EQ(0, mapping.getMil()); - EXPECT_TRUE(mapping.getBoostedInterestGroups().empty()); - EXPECT_TRUE(mapping.getSuppressedInterestGroups().empty()); -} - -TEST(Mappers_IdeaEffectsMappingTests, RulesCanBeLoaded) -{ - std::stringstream input; - input << "literacy = 1 adm = 2 dip = 3 mil = 4 ig = iggroup1 ig = iggroup2 noig = noiggroup1 noig = noiggroup2"; - const mappers::IdeaEffectsMapping mapping(input); - - EXPECT_EQ(1, mapping.getLiteracy()); - EXPECT_EQ(2, mapping.getAdm()); - EXPECT_EQ(3, mapping.getDip()); - EXPECT_EQ(4, mapping.getMil()); - EXPECT_THAT(mapping.getBoostedInterestGroups(), testing::UnorderedElementsAre("iggroup1", "iggroup2")); - EXPECT_THAT(mapping.getSuppressedInterestGroups(), testing::UnorderedElementsAre("noiggroup1", "noiggroup2")); -} diff --git a/EU5ToVic3Tests/MapperTests/LawMapperTests/LawGroupTests.cpp b/EU5ToVic3Tests/MapperTests/LawMapperTests/LawGroupTests.cpp deleted file mode 100644 index a16c754..0000000 --- a/EU5ToVic3Tests/MapperTests/LawMapperTests/LawGroupTests.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "LawMapper/LawGroup.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_LawGroupTests, LawGroupDefaultToEmpty) -{ - std::stringstream input; - const auto group = mappers::LawGroup(input); - - EXPECT_TRUE(group.getLaws().empty()); -} - -TEST(Mappers_LawGroupTests, LawGroupCanBeLoaded) -{ - std::stringstream input; - input << "law1 = { ideas = { a } }\n"; - input << "law2 = { forms = { b } }\n"; - const auto laws = mappers::LawGroup(input).getLaws(); - - EXPECT_TRUE(laws.contains("law1")); - EXPECT_TRUE(laws.contains("law2")); - EXPECT_THAT(laws.at("law1").getIdeas(), testing::UnorderedElementsAre("a")); - EXPECT_THAT(laws.at("law2").getForms(), testing::UnorderedElementsAre("b")); -} diff --git a/EU5ToVic3Tests/MapperTests/LawMapperTests/LawMapperTests.cpp b/EU5ToVic3Tests/MapperTests/LawMapperTests/LawMapperTests.cpp deleted file mode 100644 index 714af11..0000000 --- a/EU5ToVic3Tests/MapperTests/LawMapperTests/LawMapperTests.cpp +++ /dev/null @@ -1,259 +0,0 @@ -#include "CountryManager/EU4Country.h" -#include "LawMapper/LawMapper.h" -#include "Loaders/LawLoader/LawLoader.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(Mappers_LawMapperTests, LawsGroupsDefaultToEmpty) -{ - const mappers::LawMapper mapper; - - EXPECT_TRUE(mapper.getLawGroups().empty()); -} - -TEST(Mappers_LawMapperTests, LawsGroupsCanBeLoaded) -{ - mappers::LawMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/law_map.txt"); - const auto& lawGroups = mapper.getLawGroups(); - - ASSERT_EQ(3, lawGroups.size()); - EXPECT_TRUE(lawGroups.contains("lawgroup_1")); - EXPECT_EQ(1, lawGroups.at("lawgroup_1").size()); - EXPECT_TRUE(lawGroups.contains("lawgroup_2")); - EXPECT_EQ(2, lawGroups.at("lawgroup_2").size()); - EXPECT_TRUE(lawGroups.contains("lawgroup_3")); - EXPECT_EQ(1, lawGroups.at("lawgroup_3").size()); -} - -TEST(Mappers_LawMapperTests, MatchingDefinitionlessLawsThrowsWarningAndReturnsNullopt) -{ - mappers::LawMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/law_map.txt"); - - // make a country, going for lawgroup_1's law_1 for reform1. - const auto eu4Country = std::make_shared(); - eu4Country->addReform("reform1"); - const auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - const auto law = mapper.grantLawFromGroup("lawgroup_1", *country); - std::cout.rdbuf(cout_buffer); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] We're trying to map to law: law_1 that has no definition! Skipping.)")); - EXPECT_FALSE(law); -} - -TEST(Mappers_LawMapperTests, SimpleLawsMatchesCanBeAssigned) -{ - mappers::LawMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/law_map.txt"); - V3::LawLoader loader; - loader.loadLaws(modFS); - mapper.loadLawDefinitions(loader.getLaws()); - - // make a country, going for lawgroup_1's law_1 for reform1. - const auto eu4Country = std::make_shared(); - eu4Country->addReform("reform1"); - const auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - - const auto law = mapper.grantLawFromGroup("lawgroup_1", *country); - ASSERT_TRUE(law); - EXPECT_EQ("law_1", *law); -} - -TEST(Mappers_LawMapperTests, HavingBlockingLawsPreventsAssignment) -{ - mappers::LawMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/law_map.txt"); - V3::LawLoader loader; - loader.loadLaws(modFS); - mapper.loadLawDefinitions(loader.getLaws()); - - // make a country, going for lawgroup_3's law_4 for reform5. - const auto eu4Country = std::make_shared(); - eu4Country->addReform("reform5"); - const auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - V3::ProcessedData data; - data.laws.emplace("law_1"); // law_1 will block law_4 - country->setProcessedData(data); - - const auto law = mapper.grantLawFromGroup("lawgroup_3", *country); - ASSERT_FALSE(law); -} - -TEST(Mappers_LawMapperTests, NotHavingBlockingLawsDoesNotPreventsAssignment) -{ - mappers::LawMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/law_map.txt"); - V3::LawLoader loader; - loader.loadLaws(modFS); - mapper.loadLawDefinitions(loader.getLaws()); - - // make a country, going for lawgroup_3's law_4 for reform5. - const auto eu4Country = std::make_shared(); - eu4Country->addReform("reform5"); - const auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - V3::ProcessedData data; - data.laws.emplace("law_2"); // law_2 will not block law_4 - country->setProcessedData(data); - - const auto law = mapper.grantLawFromGroup("lawgroup_3", *country); - ASSERT_TRUE(law); - EXPECT_EQ("law_4", *law); -} - -TEST(Mappers_LawMapperTests, HavingMissingTechsPreventsAssignment) -{ - mappers::LawMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/law_map.txt"); - V3::LawLoader loader; - loader.loadLaws(modFS); - mapper.loadLawDefinitions(loader.getLaws()); - - // make a country, going for lawgroup_2's law_2 for reforms 2 and 3 (reform 4 goes to law_3 but it's 1 score less). - const auto eu4Country = std::make_shared(); - eu4Country->addReform("reform2"); - eu4Country->addReform("reform3"); - eu4Country->addReform("reform4"); - const auto country = std::make_shared(); - country->setSourceCountry(eu4Country); // we have 0 techs, we won't get either law_2 or law_3. - - const auto law = mapper.grantLawFromGroup("lawgroup_2", *country); - ASSERT_FALSE(law); -} - -TEST(Mappers_LawMapperTests, HavingMissingTechsAllowsForNextBestAssignment) -{ - mappers::LawMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/law_map.txt"); - V3::LawLoader loader; - loader.loadLaws(modFS); - mapper.loadLawDefinitions(loader.getLaws()); - - // make a country, going for lawgroup_2's law_2 for reforms 2 and 3 (reform 4 goes to law_3 but it's 1 score less). - const auto eu4Country = std::make_shared(); - eu4Country->addReform("reform2"); - eu4Country->addReform("reform3"); - eu4Country->addReform("reform4"); - const auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - V3::ProcessedData data; - data.techs.emplace("tech2"); // tech2 only allows for law_3, not law_2 we'd prefer. - data.laws.emplace("law_1"); // law_3 also requires law_1. - country->setProcessedData(data); - - const auto law = mapper.grantLawFromGroup("lawgroup_2", *country); - ASSERT_TRUE(law); - EXPECT_EQ("law_3", *law); -} - -TEST(Mappers_LawMapperTests, HavingMissingLawsBlocksMatchAssignment) -{ - mappers::LawMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/law_map.txt"); - V3::LawLoader loader; - loader.loadLaws(modFS); - mapper.loadLawDefinitions(loader.getLaws()); - - // make a country, going for lawgroup_2's law_2 for reforms 2 and 3 (reform 4 goes to law_3 but it's 1 score less). - const auto eu4Country = std::make_shared(); - eu4Country->addReform("reform2"); - eu4Country->addReform("reform3"); - eu4Country->addReform("reform4"); - const auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - V3::ProcessedData data; - data.techs.emplace("tech2"); // tech2 only allows for law_3, not law_2 we'd prefer, but we're MISSING law_1! - country->setProcessedData(data); - - const auto law = mapper.grantLawFromGroup("lawgroup_2", *country); - ASSERT_FALSE(law); -} - -TEST(Mappers_LawMapperTests, HavingRequiredTechsAllowsForBestAssignment) -{ - mappers::LawMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/law_map.txt"); - V3::LawLoader loader; - loader.loadLaws(modFS); - mapper.loadLawDefinitions(loader.getLaws()); - - // make a country, going for lawgroup_2's law_2 for reforms 2 and 3 (reform 4 goes to law_3 but it's 1 score less). - const auto eu4Country = std::make_shared(); - eu4Country->addReform("reform2"); - eu4Country->addReform("reform3"); - eu4Country->addReform("reform4"); - const auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - V3::ProcessedData data; - data.techs.emplace("tech1"); // tech1 allows for law_2 which we're prefering. - data.techs.emplace("tech2"); // tech2 allows for law_3, not law_2 we'd prefer. - data.laws.emplace("law_1"); // law_3 also requires law_1, otherwise it's not an option. - country->setProcessedData(data); - - const auto law = mapper.grantLawFromGroup("lawgroup_2", *country); - ASSERT_TRUE(law); - EXPECT_EQ("law_2", *law); -} - -TEST(Mappers_LawMapperTests, LawsFromSameGroupAsExistingLawsDoNotGetConsidered) -{ - mappers::LawMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/law_map.txt"); - V3::LawLoader loader; - loader.loadLaws(modFS); - mapper.loadLawDefinitions(loader.getLaws()); - - // make a country, going for lawgroup_2's law_2 for reforms 2 and 3, however law_3 is already assigned! - const auto eu4Country = std::make_shared(); - eu4Country->addReform("reform2"); - eu4Country->addReform("reform3"); - eu4Country->addReform("reform4"); - const auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - V3::ProcessedData data; - data.techs.emplace("tech1"); - data.techs.emplace("tech2"); - data.laws.emplace("law_1"); - data.laws.emplace("law_3"); - country->setProcessedData(data); - - const auto law = mapper.grantLawFromGroup("lawgroup_2", *country); - ASSERT_FALSE(law); -} - -TEST(Mappers_LawMapperTests, NoMatchesDefaultsToBestNonBlockedLaw) -{ - mappers::LawMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/law_map.txt"); - V3::LawLoader loader; - loader.loadLaws(modFS); - mapper.loadLawDefinitions(loader.getLaws()); - - // Zero reforms and law_1 means both law_2 and law_3 are viable. law_3 has higher progressiveness though. - const auto eu4Country = std::make_shared(); - const auto country = std::make_shared(); - country->setSourceCountry(eu4Country); - V3::ProcessedData data; - data.techs.emplace("tech1"); - data.techs.emplace("tech2"); - data.laws.emplace("law_1"); - country->setProcessedData(data); - - const auto law = mapper.grantLawFromGroup("lawgroup_2", *country); - ASSERT_TRUE(law); - EXPECT_EQ("law_3", *law); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/MapperTests/LawMapperTests/LawMappingTests.cpp b/EU5ToVic3Tests/MapperTests/LawMapperTests/LawMappingTests.cpp deleted file mode 100644 index d26bb3e..0000000 --- a/EU5ToVic3Tests/MapperTests/LawMapperTests/LawMappingTests.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "LawMapper/LawMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_LawMappingTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - const auto mapping = mappers::LawMapping(input); - - EXPECT_TRUE(mapping.getForms().empty()); - EXPECT_TRUE(mapping.getIdeas().empty()); - EXPECT_TRUE(mapping.getReforms().empty()); -} - -TEST(Mappers_LawMappingTests, MappingCanBeLoaded) -{ - std::stringstream input; - input << "forms = { form1 form2 form3 }\n"; - input << "ideas = { idea1 idea2 idea3 }\n"; - input << "reforms = { reform1 reform2 reform3 }\n"; - const auto mapping = mappers::LawMapping(input); - - EXPECT_THAT(mapping.getForms(), testing::UnorderedElementsAre("form1", "form2", "form3")); - EXPECT_THAT(mapping.getIdeas(), testing::UnorderedElementsAre("idea1", "idea2", "idea3")); - EXPECT_THAT(mapping.getReforms(), testing::UnorderedElementsAre("reform1", "reform2", "reform3")); -} - -TEST(Mappers_LawMappingTests, MappingCanBeScored) -{ - std::stringstream input; - input << "forms = { form1 form2 form3 }\n"; - input << "ideas = { idea1 idea2 idea3 }\n"; - input << "reforms = { reform1 reform2 reform3 }\n"; - const auto mapping = mappers::LawMapping(input); - - const std::string form = "form2"; // score = 0.01 because of fallback match - const std::set ideas = {"idea1", "idea2", "idea4"}; // 2 matches, score = 2.01 - const std::set reforms = {"reform1", "reform5", "reform2"}; // 2 matches, score = 4.01 - - const auto score = mapping.getScore(form, ideas, reforms); - - EXPECT_DOUBLE_EQ(4.01, score); -} - -TEST(Mappers_LawMappingTests, NoMatchesScoresZero) -{ - std::stringstream input; - input << "forms = {}\n"; - input << "ideas = {}\n"; - input << "reforms = {}\n"; - const auto mapping = mappers::LawMapping(input); - - const std::string form = "form2"; - const std::set ideas = {"idea1", "idea2", "idea4"}; - const std::set reforms = {"reform1", "reform5", "reform2"}; - - const auto score = mapping.getScore(form, ideas, reforms); - - EXPECT_EQ(0, score); -} diff --git a/EU5ToVic3Tests/MapperTests/MinorityPopMapperTests/MinorityPopMapperTests.cpp b/EU5ToVic3Tests/MapperTests/MinorityPopMapperTests/MinorityPopMapperTests.cpp deleted file mode 100644 index 949bd4a..0000000 --- a/EU5ToVic3Tests/MapperTests/MinorityPopMapperTests/MinorityPopMapperTests.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "MinorityPopMapper/MinorityPopMapper.h" -#include "PopManager/Pops/Pop.h" -#include "gtest/gtest.h" - -TEST(Mappers_MinorityPopMapperTests, minorityReligionBlanksMajorityCulture) -{ - std::stringstream input; - input << "minority = { religion = minorityReligion }"; - const mappers::MinorityPopMapper mapper(input); - - // Let's make a V3::Pop - auto pop = V3::Pop("majorityCulture", "minorityReligion", "aristocrat", 1000); - - const auto success = mapper.blankMajorityFromMinority(pop); - - EXPECT_TRUE(success); - EXPECT_TRUE(pop.getCulture().empty()); -} - -TEST(Mappers_MinorityPopMapperTests, minorityReligionMismatchDoesNothing) -{ - std::stringstream input; - input << "minority = { religion = minorityReligion }"; - const mappers::MinorityPopMapper mapper(input); - - auto pop = V3::Pop("majorityCulture", "majorityReligion", "aristocrat", 1000); - - const auto success = mapper.blankMajorityFromMinority(pop); - - EXPECT_FALSE(success); - EXPECT_EQ("majorityCulture", pop.getCulture()); -} - -TEST(Mappers_MinorityPopMapperTests, minorityCultureBlanksMajorityReligion) -{ - std::stringstream input; - input << "minority = { culture = minorityCulture }"; - const mappers::MinorityPopMapper mapper(input); - - auto pop = V3::Pop("minorityCulture", "majorityReligion", "aristocrat", 1000); - - const auto success = mapper.blankMajorityFromMinority(pop); - - EXPECT_TRUE(success); - EXPECT_TRUE(pop.getReligion().empty()); -} - -TEST(Mappers_MinorityPopMapperTests, minorityCultureMismatchDoesNothing) -{ - std::stringstream input; - input << "minority = { culture = minorityCulture }"; - const mappers::MinorityPopMapper mapper(input); - - auto pop = V3::Pop("majorityCulture", "majorityReligion", "aristocrat", 1000); - - const auto success = mapper.blankMajorityFromMinority(pop); - - EXPECT_FALSE(success); - EXPECT_EQ("majorityReligion", pop.getReligion()); -} - -TEST(Mappers_MinorityPopMapperTests, fullIncomingMinorityDoesNotChangeButReturnsTrue) -{ - std::stringstream input; - input << "minority = { religion = minorityReligion culture = minorityCulture }"; - const mappers::MinorityPopMapper mapper(input); - - auto pop = V3::Pop("minorityCulture", "minorityReligion", "aristocrat", 1000); - - const auto success = mapper.blankMajorityFromMinority(pop); - - EXPECT_TRUE(success); - EXPECT_EQ("minorityReligion", pop.getReligion()); - EXPECT_EQ("minorityCulture", pop.getCulture()); -} - -TEST(Mappers_MinorityPopMapperTests, fullIncomingMajorityDoesNotChange) -{ - std::stringstream input; - input << "minority = { religion = minorityReligion culture = minorityCulture }"; - const mappers::MinorityPopMapper mapper(input); - - auto pop = V3::Pop("majorityCulture", "majorityReligion", "aristocrat", 1000); - - const auto success = mapper.blankMajorityFromMinority(pop); - - EXPECT_FALSE(success); - EXPECT_EQ("majorityReligion", pop.getReligion()); - EXPECT_EQ("majorityCulture", pop.getCulture()); -} diff --git a/EU5ToVic3Tests/MapperTests/MinorityPopMapperTests/MinorityPopTests.cpp b/EU5ToVic3Tests/MapperTests/MinorityPopMapperTests/MinorityPopTests.cpp deleted file mode 100644 index 34ae263..0000000 --- a/EU5ToVic3Tests/MapperTests/MinorityPopMapperTests/MinorityPopTests.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "MinorityPopMapper/MinorityPop.h" -#include "gtest/gtest.h" - -TEST(Mappers_MinorityPopTests, primitivesDefaultToEmpty) -{ - std::stringstream input; - const mappers::MinorityPop mapper(input); - - EXPECT_TRUE(mapper.getCulture().empty()); - EXPECT_TRUE(mapper.getReligion().empty()); -} - -TEST(Mappers_MinorityPopTests, primitivesCanBeLoaded) -{ - std::stringstream input; - input << "culture = ashkenazi religion = jewish"; - const mappers::MinorityPop mapper(input); - - EXPECT_EQ("ashkenazi", mapper.getCulture()); - EXPECT_EQ("jewish", mapper.getReligion()); -} diff --git a/EU5ToVic3Tests/MapperTests/NationMergeMapperTests/MergeBlocksTests.cpp b/EU5ToVic3Tests/MapperTests/NationMergeMapperTests/MergeBlocksTests.cpp deleted file mode 100644 index 7920314..0000000 --- a/EU5ToVic3Tests/MapperTests/NationMergeMapperTests/MergeBlocksTests.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "NationMergeMapper/MergeBlock.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(Mappers_MergeBlockTests, primitivesDefaultToDefaults) -{ - std::stringstream input; - const mappers::MergeBlock block(input); - - EXPECT_TRUE(block.getMaster().empty()); - EXPECT_TRUE(block.getSlaves().empty()); - EXPECT_FALSE(block.shouldMerge()); -} - -TEST(Mappers_MergeBlockTests, mergeBlockCanBeLoaded) -{ - std::stringstream input; - input << "master = FRA\n"; - input << "slave = ALE\n"; - input << "slave = ALS\n"; - input << "merge = yes\n"; - - const mappers::MergeBlock block(input); - EXPECT_EQ("FRA", block.getMaster()); - EXPECT_THAT(block.getSlaves(), UnorderedElementsAre("ALE", "ALS")); - EXPECT_TRUE(block.shouldMerge()); -} diff --git a/EU5ToVic3Tests/MapperTests/NationMergeMapperTests/NationMergeMapperTests.cpp b/EU5ToVic3Tests/MapperTests/NationMergeMapperTests/NationMergeMapperTests.cpp deleted file mode 100644 index fd058a4..0000000 --- a/EU5ToVic3Tests/MapperTests/NationMergeMapperTests/NationMergeMapperTests.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "NationMergeMapper/NationMergeMapper.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -TEST(Mappers_NationMergeMapperTests, primitivesDefaultToDefaults) -{ - std::stringstream input; - mappers::NationMergeMapper mapper; - mapper.loadNationMerge(input); - - EXPECT_FALSE(mapper.getMergeDaimyos()); - EXPECT_TRUE(mapper.getMergeBlocks().empty()); -} - -TEST(Mappers_NationMergeMapperTests, mergeDaimyosCanBeSet) -{ - std::stringstream input; - input << "merge_daimyos = yes\n"; - mappers::NationMergeMapper mapper; - mapper.loadNationMerge(input); - - EXPECT_TRUE(mapper.getMergeDaimyos()); -} - -TEST(Mappers_NationMergeMapperTests, mergeBlocksCanBeLoaded) -{ - std::stringstream input; - input << "france = {\n"; - input << " master = FRA\n"; - input << " slave = ALE\n"; - input << " slave = ALS\n"; - input << " merge = yes\n"; - input << "}\n"; - input << "ireland = {\n"; - input << " master = IRE\n"; - input << " slave = ULS\n"; - input << " slave = TYR\n"; - input << " merge = no\n"; - input << "}\n"; - mappers::NationMergeMapper mapper; - mapper.loadNationMerge(input); - - ASSERT_EQ(2, mapper.getMergeBlocks().size()); - const auto& france = mapper.getMergeBlocks()[0]; - const auto& ireland = mapper.getMergeBlocks()[1]; - - EXPECT_EQ("FRA", france.getMaster()); - EXPECT_THAT(france.getSlaves(), UnorderedElementsAre("ALE", "ALS")); - EXPECT_TRUE(france.shouldMerge()); - - EXPECT_EQ("IRE", ireland.getMaster()); - EXPECT_THAT(ireland.getSlaves(), UnorderedElementsAre("ULS", "TYR")); - EXPECT_FALSE(ireland.shouldMerge()); -} diff --git a/EU5ToVic3Tests/MapperTests/PopulationSetupMapperTests/PopulationSetupMapperTests.cpp b/EU5ToVic3Tests/MapperTests/PopulationSetupMapperTests/PopulationSetupMapperTests.cpp deleted file mode 100644 index e4a6de9..0000000 --- a/EU5ToVic3Tests/MapperTests/PopulationSetupMapperTests/PopulationSetupMapperTests.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "PopulationSetupMapper/PopulationSetupMapper.h" -#include "gtest/gtest.h" - -TEST(Mappers_PopulationSetupMapperTests, LiteracyLevelsCanBeDetermined) -{ - mappers::PopulationSetupMapper mapper; - std::stringstream input; - input << "link = { effect = level1 literacy = 0.0 }\n"; - input << "link = { effect = level2 literacy = 0.1 }\n"; - input << "link = { effect = level3 literacy = 0.2 }\n"; - input << "link = { effect = level4 literacy = 0.5 }\n"; - input << "link = { effect = level5 literacy = 0.7 }\n"; - mapper.loadMappingRules(input); - - EXPECT_EQ("level1", mapper.getLiteracyEffectForLiteracy(0)); - EXPECT_EQ("level2", mapper.getLiteracyEffectForLiteracy(0.1)); - EXPECT_EQ("level3", mapper.getLiteracyEffectForLiteracy(0.25)); - EXPECT_EQ("level4", mapper.getLiteracyEffectForLiteracy(0.5)); - EXPECT_EQ("level5", mapper.getLiteracyEffectForLiteracy(0.79)); -} - -TEST(Mappers_PopulationSetupMapperTests, WealthLevelsCanBeDetermined) -{ - mappers::PopulationSetupMapper mapper; - std::stringstream input; - input << "link = { effect = level1 averagedev = 0 }\n"; - input << "link = { effect = level2 averagedev = 10 }\n"; - input << "link = { effect = level3 averagedev = 20 }\n"; - input << "link = { effect = level4 averagedev = 50 }\n"; - input << "link = { effect = level5 averagedev = 70 }\n"; - mapper.loadMappingRules(input); - - EXPECT_EQ("level1", mapper.getWealthEffectForDev(0)); - EXPECT_EQ("level1", mapper.getWealthEffectForDev(1)); - EXPECT_EQ("level3", mapper.getWealthEffectForDev(25)); - EXPECT_EQ("level4", mapper.getWealthEffectForDev(50)); - EXPECT_EQ("level5", mapper.getWealthEffectForDev(79)); -} diff --git a/EU5ToVic3Tests/MapperTests/PopulationSetupMapperTests/PopulationSetupMappingTests.cpp b/EU5ToVic3Tests/MapperTests/PopulationSetupMapperTests/PopulationSetupMappingTests.cpp deleted file mode 100644 index fc54cd6..0000000 --- a/EU5ToVic3Tests/MapperTests/PopulationSetupMapperTests/PopulationSetupMappingTests.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "PopulationSetupMapper/PopulationSetupMapping.h" -#include "gtest/gtest.h" - -TEST(Mappers_PopulationSetupMappingTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - const mappers::PopulationSetupMapping mapping(input); - - EXPECT_FALSE(mapping.getLiteracy()); - EXPECT_FALSE(mapping.getAverageDev()); - EXPECT_TRUE(mapping.getEffect().empty()); -} - -TEST(Mappers_PopulationSetupMappingTests, mappingCanBeLoaded) -{ - std::stringstream input; - input << "effect = theEffect literacy = 0.98 averagedev = 45.98\n"; - - const mappers::PopulationSetupMapping mapping(input); - EXPECT_DOUBLE_EQ(0.98, *mapping.getLiteracy()); - EXPECT_DOUBLE_EQ(45.98, *mapping.getAverageDev()); - EXPECT_EQ("theEffect", mapping.getEffect()); -} diff --git a/EU5ToVic3Tests/MapperTests/ProvinceMapperTests/ProvinceMapperTests.cpp b/EU5ToVic3Tests/MapperTests/ProvinceMapperTests/ProvinceMapperTests.cpp deleted file mode 100644 index b4431df..0000000 --- a/EU5ToVic3Tests/MapperTests/ProvinceMapperTests/ProvinceMapperTests.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "ProvinceMapper/ProvinceMapper.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_ProvinceMapperTests, mappingsCanBeLoadedAndCreated) -{ - mappers::ProvinceMapper provinceMapper; - provinceMapper.loadProvinceMappings("TestFiles/configurables/province_mappings.txt"); - - EXPECT_EQ(4, provinceMapper.getMappings().size()); - - EXPECT_THAT(provinceMapper.getEU4Provinces("xA2E8C5"), testing::UnorderedElementsAre(1096)); - EXPECT_THAT(provinceMapper.getEU4Provinces("x90A080"), testing::UnorderedElementsAre(366, 367)); - EXPECT_THAT(provinceMapper.getV3Provinces(1096), testing::UnorderedElementsAre("xA2E8C5", "x4B7FA5", "xE8E7A2", "xA2C3E8")); - EXPECT_THAT(provinceMapper.getV3Provinces(366), testing::UnorderedElementsAre("x90A080", "x9B6D87", "x769456")); -} - -TEST(Mappers_ProvinceMapperTests, mappingsForObsoleteVersionsAreIgnored) -{ - mappers::ProvinceMapper provinceMapper; - provinceMapper.loadProvinceMappings("TestFiles/configurables/province_mappings.txt"); - - EXPECT_TRUE(provinceMapper.getEU4Provinces("x111111").empty()); - EXPECT_TRUE(provinceMapper.getV3Provinces(1).empty()); -} - - -TEST(Mappers_ProvinceMapperTests, mappingsForDroppedEU4ProvincesAreNotCreated) -{ - mappers::ProvinceMapper provinceMapper; - provinceMapper.loadProvinceMappings("TestFiles/configurables/province_mappings.txt"); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - EXPECT_TRUE(provinceMapper.getV3Provinces(368).empty()); - - std::cout.rdbuf(cout_buffer); -} - -TEST(Mappers_ProvinceMapperTests, mappingsForDroppedV3ProvincesAreNotCreated) -{ - mappers::ProvinceMapper provinceMapper; - provinceMapper.loadProvinceMappings("TestFiles/configurables/province_mappings.txt"); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - EXPECT_TRUE(provinceMapper.getEU4Provinces("x655491").empty()); - - std::cout.rdbuf(cout_buffer); -} diff --git a/EU5ToVic3Tests/MapperTests/ProvinceMapperTests/ProvinceMappingTests.cpp b/EU5ToVic3Tests/MapperTests/ProvinceMapperTests/ProvinceMappingTests.cpp deleted file mode 100644 index d00fa73..0000000 --- a/EU5ToVic3Tests/MapperTests/ProvinceMapperTests/ProvinceMappingTests.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "ProvinceMapper/ProvinceMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_ProvinceMappingTests, MappingsDefaultToEmpty) -{ - std::stringstream input; - const mappers::ProvinceMapping theMapper(input); - - EXPECT_TRUE(theMapper.getEU4Provinces().empty()); - EXPECT_TRUE(theMapper.getV3Provinces().empty()); -} - -TEST(Mappers_ProvinceMappingTests, EU4ProvincesCanBeAdded) -{ - std::stringstream input; - input << "eu4 = 2 eu4 = 1"; - const mappers::ProvinceMapping theMapper(input); - - EXPECT_THAT(theMapper.getEU4Provinces(), testing::UnorderedElementsAre(1, 2)); -} - -TEST(Mappers_ProvinceMappingTests, Vic33ProvincesCanBeAdded) -{ - std::stringstream input; - input << "vic3 = x654321 vic3 = x123456"; - const mappers::ProvinceMapping theMapper(input); - - EXPECT_THAT(theMapper.getV3Provinces(), testing::UnorderedElementsAre("x654321", "x123456")); -} diff --git a/EU5ToVic3Tests/MapperTests/ProvinceMapperTests/ProvinceMappingsVersionTests.cpp b/EU5ToVic3Tests/MapperTests/ProvinceMapperTests/ProvinceMappingsVersionTests.cpp deleted file mode 100644 index b2bc3ff..0000000 --- a/EU5ToVic3Tests/MapperTests/ProvinceMapperTests/ProvinceMappingsVersionTests.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "ProvinceMapper/ProvinceMappingsVersion.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_ProvinceMappingsVersionTests, mappingsDefaultToEmpty) -{ - std::stringstream input; - mappers::ProvinceMappingsVersion theMappingVersion(input); - - EXPECT_TRUE(theMappingVersion.getMappings().empty()); -} - -TEST(Mappers_ProvinceMappingsVersionTests, commentMappingsAreNotLoaded) -{ - std::stringstream input; - input << "link = { comment = \"+++EUROPE+++\" }\n"; - mappers::ProvinceMappingsVersion theMappingVersion(input); - - EXPECT_TRUE(theMappingVersion.getMappings().empty()); -} - -TEST(Mappers_ProvinceMappingsVersionTests, emptyMappingsAreNotLoaded) -{ - std::stringstream input; - input << "link = { }\n"; - mappers::ProvinceMappingsVersion theMappingVersion(input); - - EXPECT_TRUE(theMappingVersion.getMappings().empty()); -} - -TEST(Mappers_ProvinceMappingsVersionTests, MappingsCanBeLoaded) -{ - std::stringstream input; - input << "link = { eu4 = 1 eu4 = 2 vic3 = x123456 }\n"; - input << "link = { eu4 = 3 vic3 = xABCDEF vic3 = xFEDCBA}\n"; - - mappers::ProvinceMappingsVersion theMappingVersion(input); - - EXPECT_EQ(2, theMappingVersion.getMappings().size()); - - const auto& mapping1 = theMappingVersion.getMappings()[0]; - const auto& mapping2 = theMappingVersion.getMappings()[1]; - - EXPECT_THAT(mapping1.getEU4Provinces(), testing::UnorderedElementsAre(1, 2)); - EXPECT_THAT(mapping1.getV3Provinces(), testing::UnorderedElementsAre("x123456")); - EXPECT_THAT(mapping2.getEU4Provinces(), testing::UnorderedElementsAre(3)); - EXPECT_THAT(mapping2.getV3Provinces(), testing::UnorderedElementsAre("xABCDEF", "xFEDCBA")); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionDefinitionLoaderTests/ReligionDefinitionEntryTests.cpp b/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionDefinitionLoaderTests/ReligionDefinitionEntryTests.cpp deleted file mode 100644 index 0ba8225..0000000 --- a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionDefinitionLoaderTests/ReligionDefinitionEntryTests.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionEntry.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_ReligionDefinitionEntryTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - const mappers::ReligionDefinitionEntry entry(input); - - EXPECT_TRUE(entry.getReligionDef().name.empty()); - EXPECT_TRUE(entry.getReligionDef().texture.empty()); - EXPECT_TRUE(entry.getReligionDef().traits.empty()); - EXPECT_FALSE(entry.getReligionDef().color); - EXPECT_TRUE(entry.getReligionDef().taboos.empty()); -} - -TEST(Mappers_ReligionDefinitionEntryTests, EntryCanBeLoaded) -{ - std::stringstream input; - input << R"(texture = "gfx/interface/icons/religion_icons/shiite.dds")"; - input << R"(traits = {)"; - input << R"( muslim)"; - input << R"(})"; - input << R"(color = { 0.4 0.7 0.3 })"; - input << R"(taboos = {)"; - input << R"( liquor wine)"; - input << R"(})"; - const mappers::ReligionDefinitionEntry entry(input); - - EXPECT_TRUE(entry.getReligionDef().name.empty()); - EXPECT_EQ("gfx/interface/icons/religion_icons/shiite.dds", entry.getReligionDef().texture); - EXPECT_THAT(entry.getReligionDef().traits, testing::UnorderedElementsAre("muslim")); - EXPECT_EQ(commonItems::Color(std::array{102, 179, 77}), *entry.getReligionDef().color); - EXPECT_THAT(entry.getReligionDef().taboos, testing::UnorderedElementsAre("liquor", "wine")); -} diff --git a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionDefinitionLoaderTests/ReligionDefinitionLoaderTests.cpp b/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionDefinitionLoaderTests/ReligionDefinitionLoaderTests.cpp deleted file mode 100644 index 9115349..0000000 --- a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionDefinitionLoaderTests/ReligionDefinitionLoaderTests.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "ReligionMapper/ReligionDefinitionLoader/ReligionDefinitionLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(Mappers_ReligionDefinitionLoaderTests, religionsCanBeRetrieved) -{ - mappers::ReligionDefinitionLoader loader; - loader.loadDefinitions(modFS); - - const auto& religion = loader.getReligionDef("religion_1"); - ASSERT_TRUE(religion); - - EXPECT_EQ("religion_1", religion->name); - EXPECT_EQ("gfx/interface/icons/religion_icons/religion_1.dds", religion->texture); - EXPECT_THAT(religion->traits, testing::UnorderedElementsAre("religiontrait")); - EXPECT_EQ(commonItems::Color(std::array{1, 2, 3}), *religion->color); - EXPECT_TRUE(religion->taboos.empty()); -} - -TEST(Mappers_ReligionDefinitionLoaderTests, MismatchReturnsNullopt) -{ - mappers::ReligionDefinitionLoader loader; - loader.loadDefinitions(modFS); - - const auto& religion = loader.getReligionDef("nonsense"); - ASSERT_FALSE(religion); -} diff --git a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionGroupMapperTests/ReligionGroupMapperTests.cpp b/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionGroupMapperTests/ReligionGroupMapperTests.cpp deleted file mode 100644 index 24447c0..0000000 --- a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionGroupMapperTests/ReligionGroupMapperTests.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "ReligionMapper/ReligionGroupMapper/ReligionGroupMapper.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_ReligionGroupMapperTests, religionGroupMappingsCanBeRetrieved) -{ - mappers::ReligionGroupMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/religion_group_map.txt"); - - const auto& match = mapper.getMappingForEU4ReligionGroup("mod_group_1"); - ASSERT_TRUE(match); - - EXPECT_EQ("religiontrait_2", match->getTrait()); - EXPECT_THAT(match->getEU4Groups(), testing::UnorderedElementsAre("vanilla_group_2", "mod_group_1")); - EXPECT_THAT(match->getTaboos(), testing::UnorderedElementsAre("liquor", "wine")); - EXPECT_EQ("religion_2", match->getIcon()); -} - -TEST(Mappers_ReligionGroupMapperTests, MisMatchReturnsNullopt) -{ - mappers::ReligionGroupMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/religion_group_map.txt"); - - EXPECT_FALSE(mapper.getMappingForEU4ReligionGroup("unmapped")); -} diff --git a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionGroupMapperTests/ReligionGroupMappingTests.cpp b/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionGroupMapperTests/ReligionGroupMappingTests.cpp deleted file mode 100644 index f80a340..0000000 --- a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionGroupMapperTests/ReligionGroupMappingTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "ReligionMapper/ReligionGroupMapper/ReligionGroupMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_ReligionGroupMappingTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - const mappers::ReligionGroupMapping mapping(input); - - EXPECT_TRUE(mapping.getTrait().empty()); - EXPECT_TRUE(mapping.getEU4Groups().empty()); - EXPECT_TRUE(mapping.getTaboos().empty()); - EXPECT_TRUE(mapping.getIcon().empty()); -} - -TEST(Mappers_ReligionGroupMappingTests, MappingCanBeLoaded) -{ - std::stringstream input; - input << "vic3 = trait eu4 = religious_group taboo = some_taboo taboo = other_taboo icon = religion"; - const mappers::ReligionGroupMapping mapping(input); - - EXPECT_EQ("trait", mapping.getTrait()); - EXPECT_THAT(mapping.getEU4Groups(), testing::UnorderedElementsAre("religious_group")); - EXPECT_THAT(mapping.getTaboos(), testing::UnorderedElementsAre("some_taboo", "other_taboo")); - EXPECT_EQ("religion", mapping.getIcon()); -} diff --git a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionMapperTests.cpp b/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionMapperTests.cpp deleted file mode 100644 index b2a621f..0000000 --- a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionMapperTests.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "CommonFunctions.h" -#include "LocalizationLoader/EU4LocalizationLoader.h" -#include "ReligionLoader/ReligionLoader.h" -#include "ReligionMapper/ReligionMapper.h" -#include "gmock/gmock-matchers.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -const auto eu4FS = commonItems::ModFilesystem("TestFiles/eu4installation/", {Mod("Some mod", "TestFiles/mod/themod/")}); -} // namespace - -TEST(Mappers_ReligionMapperTests, religionsCanBeRetrieved) -{ - mappers::ReligionMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/religion_map.txt"); - - EXPECT_EQ("catholic", *mapper.getV3Religion("catholic")); - EXPECT_EQ("catholic", *mapper.getV3Religion("insular_celtic")); - EXPECT_EQ("protestant", *mapper.getV3Religion("protestant")); - EXPECT_EQ("protestant", *mapper.getV3Religion("reformed")); - EXPECT_EQ("protestant", *mapper.getV3Religion("anglican")); -} - -TEST(Mappers_ReligionMapperTests, MisMapReturnsNullopt) -{ - mappers::ReligionMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/religion_map.txt"); - - EXPECT_EQ(std::nullopt, mapper.getV3Religion("unmapped")); -} - -TEST(Mappers_ReligionMapperTests, ReligionsMappingsCanBeExpanded) -{ - mappers::ReligionMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/religion_map.txt"); - - const std::map additionalReligions = {{"additional1", EU4::Religion()}, {"additional2", EU4::Religion()}}; - - mapper.expandReligionMappings(additionalReligions); - - EXPECT_EQ("additional1", mapper.getV3Religion("additional1")); - EXPECT_EQ("additional2", mapper.getV3Religion("additional2")); -} - -TEST(Mappers_ReligionMapperTests, ReligiousDefsCanBeGenerated) -{ - EU4::ReligionLoader theReligions; - theReligions.loadReligions(eu4FS); - - std::stringstream input; - input << commonItems::utf8BOM << "l_english:\n"; - input << " religion_2: \"The Religion 2\"\n"; - input << " converted_dynamic_faith_107: \"The Religion 107\"\n"; - EU4::EU4LocalizationLoader locs; - locs.loadLocalizations(input); - - mappers::ReligionMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/religion_map.txt"); - mapper.expandReligionMappings(theReligions.getAllReligions()); - mapper.generateReligionDefinitions(modFS, "TestFiles/configurables/religion_group_map.txt", theReligions.getAllReligions(), locs); - - // eu4 religion_2 is a default mapping into vic3's religion_2 which has preset defs: - const auto& religion2 = mapper.getV3ReligionDefinitions().at("religion_2"); - EXPECT_EQ("religion_2", religion2.name); - EXPECT_EQ("gfx/interface/icons/religion_icons/religion_2.dds", religion2.texture); - EXPECT_THAT(religion2.traits, testing::UnorderedElementsAre("religiontrait_2")); - EXPECT_EQ(commonItems::Color(std::array{4, 5, 6}), *religion2.color); - EXPECT_TRUE(religion2.taboos.empty()); - EXPECT_TRUE(religion2.locBlock.empty()); // no locs since this is a preset def! - - // eu4 converted_dynamic_faith_107 is a dynamic mapping via groups (mod_group_2): - // link = { vic3 = religiontrait_3 eu4 = mod_group_2 eu4 = mod_group_3 icon = religion_2 taboo = liquor taboo = wine } - const auto& dyn7 = mapper.getV3ReligionDefinitions().at("converted_dynamic_faith_107"); - EXPECT_EQ("converted_dynamic_faith_107", dyn7.name); - // link = { vic3 = religion_1 eu4 = shamanism } - EXPECT_EQ("gfx/interface/icons/religion_icons/religion_1.dds", dyn7.texture); // from shamanism trappings. - EXPECT_THAT(dyn7.traits, testing::UnorderedElementsAre("religiontrait_3")); // from group - EXPECT_EQ(commonItems::Color(std::array{135, 55, 140}), *dyn7.color); // from eu4 defs - EXPECT_THAT(dyn7.taboos, testing::UnorderedElementsAre("liquor", "wine")); // from group - EXPECT_EQ("The Religion 107", dyn7.locBlock.at("english")); -} diff --git a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionMappingTests.cpp b/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionMappingTests.cpp deleted file mode 100644 index 0367081..0000000 --- a/EU5ToVic3Tests/MapperTests/ReligionMapperTests/ReligionMappingTests.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ReligionMapper/ReligionMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_ReligionMappingTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - const mappers::ReligionMapping mapping(input); - - EXPECT_TRUE(mapping.getV3Religion().empty()); - EXPECT_TRUE(mapping.getEU4Religions().empty()); -} - -TEST(Mappers_ReligionMappingTests, RulesCanBeLoaded) -{ - std::stringstream input; - input << "vic3 = vic eu4 = eu1 eu4 = eu1 eu4 = eu2"; - const mappers::ReligionMapping mapping(input); - - EXPECT_EQ("vic", mapping.getV3Religion()); - EXPECT_THAT(mapping.getEU4Religions(), testing::UnorderedElementsAre("eu1", "eu2")); -} diff --git a/EU5ToVic3Tests/MapperTests/SlaveCultureMapperTests/SlaveCultureMapperTests.cpp b/EU5ToVic3Tests/MapperTests/SlaveCultureMapperTests/SlaveCultureMapperTests.cpp deleted file mode 100644 index 81c4a59..0000000 --- a/EU5ToVic3Tests/MapperTests/SlaveCultureMapperTests/SlaveCultureMapperTests.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "SlaveCultureMapper/SlaveCultureMapper.h" -#include "gtest/gtest.h" - -TEST(Mappers_SlaveCultureMapperTests, MismatchReturnsNullopt) -{ - mappers::SlaveCultureMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/slave_culture_map.txt"); - - EXPECT_FALSE(mapper.getSlaveCulture("mismatch")); -} - -TEST(Mappers_SlaveCultureMapperTests, TraitCanBeMatched) -{ - mappers::SlaveCultureMapper mapper; - mapper.loadMappingRules("TestFiles/configurables/slave_culture_map.txt"); - - EXPECT_EQ("afro_american", mapper.getSlaveCulture("anglophone")); -} diff --git a/EU5ToVic3Tests/MapperTests/SlaveCultureMapperTests/SlaveCultureMappingTests.cpp b/EU5ToVic3Tests/MapperTests/SlaveCultureMapperTests/SlaveCultureMappingTests.cpp deleted file mode 100644 index 8918f53..0000000 --- a/EU5ToVic3Tests/MapperTests/SlaveCultureMapperTests/SlaveCultureMappingTests.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "SlaveCultureMapper/SlaveCultureMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_SlaveCultureMappingTests, DefaultsDefaultToDefaults) -{ - - std::stringstream input; - const mappers::SlaveCultureMapping mapping(input); - - EXPECT_TRUE(mapping.getMasterTrait().empty()); - EXPECT_TRUE(mapping.getSlaveCulture().empty()); -} - -TEST(Mappers_SlaveCultureMappingTests, RulesCanBeLoaded) -{ - std::stringstream input; - input << "master = trait slave = culture"; - const mappers::SlaveCultureMapping mapping(input); - - EXPECT_EQ("trait", mapping.getMasterTrait()); - EXPECT_EQ("culture", mapping.getSlaveCulture()); -} diff --git a/EU5ToVic3Tests/MapperTests/SuperGroupMapperTests/AssimilationParserTests.cpp b/EU5ToVic3Tests/MapperTests/SuperGroupMapperTests/AssimilationParserTests.cpp deleted file mode 100644 index 24d11d5..0000000 --- a/EU5ToVic3Tests/MapperTests/SuperGroupMapperTests/AssimilationParserTests.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "Mappers/SuperGroupMapper/AssimilationParser.h" -#include "gtest/gtest.h" - -TEST(Mappers_AssimilationParserTests, AssimilationDefaultsToOne) -{ - std::stringstream input; - const auto assimilation = mappers::AssimilationParser(input); - - EXPECT_EQ(1, assimilation.getAssimilation()); -} - -TEST(Mappers_AssimilationParserTests, AssimilationCanBeLoaded) -{ - std::stringstream input; - input << "assimilation = 6"; - const auto assimilation = mappers::AssimilationParser(input); - - EXPECT_EQ(6, assimilation.getAssimilation()); -} diff --git a/EU5ToVic3Tests/MapperTests/SuperGroupMapperTests/SuperGroupMapperTests.cpp b/EU5ToVic3Tests/MapperTests/SuperGroupMapperTests/SuperGroupMapperTests.cpp deleted file mode 100644 index fe88cb1..0000000 --- a/EU5ToVic3Tests/MapperTests/SuperGroupMapperTests/SuperGroupMapperTests.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "Mappers/SuperGroupMapper/SuperGroupMapper.h" -#include "gtest/gtest.h" - -TEST(Mappers_SuperGroupMapperTests, superGroupsCanBeLoadedAndPinged) -{ - std::stringstream input; - input << "sgroup1 = { sregion1 = {assimilation = 2}}\n"; - input << "sgroup2 = { sregion2 = {assimilation = 4}}\n"; - mappers::SuperGroupMapper superGroupMapper; - superGroupMapper.loadSuperGroups(input); - - EXPECT_NEAR(0.004375, superGroupMapper.getAssimilationFactor("sregion1"), 0.0001); - EXPECT_NEAR(0.00683594, superGroupMapper.getAssimilationFactor("sregion2"), 0.0001); - - EXPECT_EQ("sgroup1", superGroupMapper.getGroupForSuperRegion("sregion1")); - EXPECT_EQ("sgroup2", superGroupMapper.getGroupForSuperRegion("sregion2")); -} - -TEST(Mappers_SuperGroupMapperTests, superGroupNameMismatchReturnsNullopt) -{ - std::stringstream input; - input << "sgroup1 = { sregion1 = {assimilation = 5}}\n"; - input << "sgroup2 = { sregion2 = {assimilation = 8}}\n"; - mappers::SuperGroupMapper superGroupMapper; - superGroupMapper.loadSuperGroups(input); - - EXPECT_EQ(std::nullopt, superGroupMapper.getGroupForSuperRegion("sregion3")); -} - -TEST(Mappers_SuperGroupMapperTests, superGroupAssimilationMismatchReturnsDefaultAssimilation) -{ - std::stringstream input; - input << "sgroup1 = { sregion1 = {assimilation = 5}}\n"; - input << "sgroup2 = { sregion2 = {assimilation = 8}}\n"; - mappers::SuperGroupMapper superGroupMapper; - superGroupMapper.loadSuperGroups(input); - - EXPECT_DOUBLE_EQ(0.0025, superGroupMapper.getAssimilationFactor("sregion3")); -} diff --git a/EU5ToVic3Tests/MapperTests/SuperGroupMapperTests/SuperRegionParserTests.cpp b/EU5ToVic3Tests/MapperTests/SuperGroupMapperTests/SuperRegionParserTests.cpp deleted file mode 100644 index e1de024..0000000 --- a/EU5ToVic3Tests/MapperTests/SuperGroupMapperTests/SuperRegionParserTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Mappers/SuperGroupMapper/SuperRegionParser.h" -#include "gtest/gtest.h" -#include -using testing::ElementsAre; -using testing::Pair; -using testing::UnorderedElementsAre; - -TEST(Mappers_SuperRegionParserTests, PrimitivesDefaultToEmpty) -{ - std::stringstream input; - const auto superRegion = mappers::SuperRegionParser(input); - - EXPECT_TRUE(superRegion.getSuperRegionAssimilationMap().empty()); - EXPECT_TRUE(superRegion.getSuperRegionNames().empty()); -} - -TEST(Mappers_SuperRegionParserTests, SuperRegionCanBeLoaded) -{ - std::stringstream input; - input << "sregion1 = { assimilation = 2 }\n"; - input << "sregion2 = { assimilation = 3 }\n"; - const auto superRegion = mappers::SuperRegionParser(input); - - EXPECT_THAT(superRegion.getSuperRegionNames(), UnorderedElementsAre("sregion1", "sregion2")); - EXPECT_THAT(superRegion.getSuperRegionAssimilationMap(), ElementsAre(Pair("sregion1", 2), Pair("sregion2", 3))); -} diff --git a/EU5ToVic3Tests/MapperTests/TechSetupMapperTests/TechSetupMapperTests.cpp b/EU5ToVic3Tests/MapperTests/TechSetupMapperTests/TechSetupMapperTests.cpp deleted file mode 100644 index 7c223d6..0000000 --- a/EU5ToVic3Tests/MapperTests/TechSetupMapperTests/TechSetupMapperTests.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "TechSetupMapper/TechSetupMapper.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_TechSetupMapperTests, NonsenseTrackReturnEmptyTechsAndWarns) -{ - mappers::TechSetupMapper mapper; - std::stringstream input; - mapper.loadMappingRules(input); - - double score = 78.89; - std::string track = "track"; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - const auto techs = mapper.getTechsForScoreTrack(track, score); - std::cout.rdbuf(cout_buffer); - - EXPECT_TRUE(techs.empty()); - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] Attempting to get techs from track: track which doesn't exist in tech_setup.txt!)")); -} - -TEST(Mappers_TechSetupMapperTests, TechsCanBeRetrieved) -{ - mappers::TechSetupMapper mapper; - std::stringstream input; - input << "track = { tech1 = 10 tech2 = 20 tech3 = 30 tech4 = 40 tech5 = 50 }\n"; - input << "another_track = { atech1 = 10 atech2 = 20 atech3 = 30 atech4 = 40 atech5 = 50 }\n"; - mapper.loadMappingRules(input); - - EXPECT_THAT(mapper.getTechsForScoreTrack("track", 0), testing::UnorderedElementsAre()); - EXPECT_THAT(mapper.getTechsForScoreTrack("track", 10), testing::UnorderedElementsAre("tech1")); - EXPECT_THAT(mapper.getTechsForScoreTrack("track", 15), testing::UnorderedElementsAre("tech1")); - EXPECT_THAT(mapper.getTechsForScoreTrack("track", 25), testing::UnorderedElementsAre("tech1", "tech2")); - EXPECT_THAT(mapper.getTechsForScoreTrack("another_track", 50), testing::UnorderedElementsAre("atech1", "atech2", "atech3", "atech4", "atech5")); -} diff --git a/EU5ToVic3Tests/MapperTests/TechSetupMapperTests/TechSetupMappingTests.cpp b/EU5ToVic3Tests/MapperTests/TechSetupMapperTests/TechSetupMappingTests.cpp deleted file mode 100644 index 03431b8..0000000 --- a/EU5ToVic3Tests/MapperTests/TechSetupMapperTests/TechSetupMappingTests.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "TechSetupMapper/TechSetupMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_TechSetupMappingTests, DefaultsDefaultToDefaults) -{ - - std::stringstream input; - const mappers::TechSetupMapping mapping(input); - - EXPECT_TRUE(mapping.getTechScores().empty()); -} - -TEST(Mappers_TechSetupMappingTests, RulesCanBeLoaded) -{ - std::stringstream input; - input << "enclosure = 17 manufacturies = 27 shaft_mining = 33\n"; - const mappers::TechSetupMapping mapping(input); - - EXPECT_THAT(mapping.getTechScores(), - testing::UnorderedElementsAre(std::pair("enclosure", 17), std::pair("manufacturies", 27), std::pair("shaft_mining", 33))); -} diff --git a/EU5ToVic3Tests/MapperTests/VNColonialMapper/VNColonialMapperTests.cpp b/EU5ToVic3Tests/MapperTests/VNColonialMapper/VNColonialMapperTests.cpp deleted file mode 100644 index de5f5a2..0000000 --- a/EU5ToVic3Tests/MapperTests/VNColonialMapper/VNColonialMapperTests.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include - -#include "VNColonialMapper/VNColonialMapper.h" -#include "gtest/gtest.h" - -TEST(Mappers_VNColonialMapperTests, ColoniesDefaultToEmpty) -{ - std::stringstream input; - mappers::VNColonialMapper mapper; - mapper.loadMappingRules(input); - - EXPECT_TRUE(mapper.getVNColonies().empty()); -} - -TEST(Mappers_VNColonialMapperTests, ColoniesCanBeLoaded) -{ - std::stringstream input; - input << R"(link = { name = "British Pacifics" key = x112233 owner = GBR states = { STATE_A STATE_B } decolonize = FRA })"; - input << R"(link = { name = "British SEA" key = x112233 owner = GBR states = { STATE_C STATE_D } })"; - mappers::VNColonialMapper mapper; - mapper.loadMappingRules(input); - - EXPECT_EQ(2, mapper.getVNColonies().size()); - EXPECT_EQ("British Pacifics", mapper.getVNColonies()[0].getName()); - EXPECT_EQ("British SEA", mapper.getVNColonies()[1].getName()); -} - -TEST(Mappers_VNColonialMapperTests, StatesCanBePingedforColonialStatus) -{ - std::stringstream input; - input << R"(link = { name = "British Pacifics" key = x112233 owner = GBR states = { STATE_A STATE_B } decolonize = FRA })"; - input << R"(link = { name = "British SEA" key = x112233 owner = GBR states = { STATE_C STATE_D } })"; - mappers::VNColonialMapper mapper; - mapper.loadMappingRules(input); - - EXPECT_TRUE(mapper.isStateVNColonial("STATE_A")); - EXPECT_FALSE(mapper.isStateVNColonial("STATE_E")); -} - -TEST(Mappers_VNColonialMapperTests, ColonialOwnersCanBeReturned) -{ - std::stringstream input; - input << R"(link = { name = "British Pacifics" key = x112233 owner = GBR states = { STATE_A STATE_B } decolonize = FRA })"; - input << R"(link = { name = "French PACIFICS" key = x332211 owner = FRA states = { STATE_A STATE_D } })"; - mappers::VNColonialMapper mapper; - mapper.loadMappingRules(input); - - EXPECT_THAT(mapper.getVanillaOwners("STATE_A"), testing::UnorderedElementsAre("GBR", "FRA")); - EXPECT_THAT(mapper.getVanillaOwners("STATE_B"), testing::UnorderedElementsAre("GBR")); - EXPECT_THAT(mapper.getVanillaOwners("STATE_D"), testing::UnorderedElementsAre("FRA")); -} - -TEST(Mappers_VNColonialMapperTests, KeyProvinceForStateOwnerMatchCanBeReturned) -{ - std::stringstream input; - input << R"(link = { name = "British Pacifics" key = x112233 owner = GBR states = { STATE_A STATE_B } decolonize = FRA })"; - input << R"(link = { name = "French PACIFICS" key = x332211 owner = FRA states = { STATE_A STATE_D } })"; - mappers::VNColonialMapper mapper; - mapper.loadMappingRules(input); - - EXPECT_EQ("x112233", *mapper.getKeyProvince("STATE_A", "GBR")); - EXPECT_EQ("x332211", *mapper.getKeyProvince("STATE_A", "FRA")); - EXPECT_FALSE(mapper.getKeyProvince("STATE_A", "NON")); -} - -TEST(Mappers_VNColonialMapperTests, DecolonizableStatesCanBeMatchedForOwners) -{ - std::stringstream input; - // always decolonize unless owner FRA - input << R"(link = { name = "British Pacifics" key = x112233 owner = GBR states = { STATE_A STATE_B } decolonize = FRA })"; - // do not decolonize. - input << R"(link = { name = "French PACIFICS" key = x332211 owner = FRA states = { STATE_A STATE_D } })"; - mappers::VNColonialMapper mapper; - mapper.loadMappingRules(input); - - EXPECT_FALSE(mapper.isStateDecolonizable("STATE_A", "FRA", "GBR")); - EXPECT_FALSE(mapper.isStateDecolonizable("STATE_A", "FRA", "FRA")); - EXPECT_FALSE(mapper.isStateDecolonizable("STATE_A", "FRA", "NON")); - - EXPECT_TRUE(mapper.isStateDecolonizable("STATE_A", "GBR", "GBR")); - EXPECT_FALSE(mapper.isStateDecolonizable("STATE_A", "GBR", "FRA")); - EXPECT_TRUE(mapper.isStateDecolonizable("STATE_A", "GBR", "NON")); - - EXPECT_FALSE(mapper.isStateDecolonizable("STATE_A", "NON", "GBR")); - EXPECT_FALSE(mapper.isStateDecolonizable("STATE_A", "NON", "FRA")); - EXPECT_FALSE(mapper.isStateDecolonizable("STATE_A", "NON", "NON")); -} diff --git a/EU5ToVic3Tests/MapperTests/VNColonialMapper/VNColonialMappingTests.cpp b/EU5ToVic3Tests/MapperTests/VNColonialMapper/VNColonialMappingTests.cpp deleted file mode 100644 index 0f9b66c..0000000 --- a/EU5ToVic3Tests/MapperTests/VNColonialMapper/VNColonialMappingTests.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "VNColonialMapper/VNColonialMapping.h" -#include "gtest/gtest.h" -#include - -TEST(Mappers_VNColonialMappingTests, MappingDefaultsToDefaults) -{ - std::stringstream input; - const mappers::VNColonialMapping theMapping(input); - - EXPECT_TRUE(theMapping.getName().empty()); - EXPECT_TRUE(theMapping.getOwner().empty()); - EXPECT_TRUE(theMapping.getDecolonizeBlocker().empty()); - EXPECT_TRUE(theMapping.getKeyProvince().empty()); - EXPECT_TRUE(theMapping.getStates().empty()); - EXPECT_TRUE(theMapping.getSubjects().empty()); - EXPECT_TRUE(theMapping.getSubjectType().empty()); -} - -TEST(Mappers_VNColonialMappingTests, StateMappingCanBeLoaded) -{ - std::stringstream input; - input << R"(name = "Greenland" key = x8B7790 states = { STATE_ICELAND STATE_GREENLAND } owner = DEN decolonize = FRA )"; - const mappers::VNColonialMapping theMapping(input); - - EXPECT_EQ("Greenland", theMapping.getName()); - EXPECT_EQ("DEN", theMapping.getOwner()); - EXPECT_EQ("FRA", theMapping.getDecolonizeBlocker()); - EXPECT_EQ("x8B7790", theMapping.getKeyProvince()); - EXPECT_THAT(theMapping.getStates(), testing::UnorderedElementsAre("STATE_ICELAND", "STATE_GREENLAND")); -} - -TEST(Mappers_VNColonialMappingTests, SubjectMappingCanBeLoaded) -{ - std::stringstream input; - input << R"(name = "Australia" key = xE0E0C0 subjects = { NSW WAS SAS TAS } type = puppet )"; - const mappers::VNColonialMapping theMapping(input); - - EXPECT_EQ("Australia", theMapping.getName()); - EXPECT_EQ("xE0E0C0", theMapping.getKeyProvince()); - EXPECT_THAT(theMapping.getSubjects(), testing::UnorderedElementsAre("NSW", "WAS", "SAS", "TAS")); - EXPECT_EQ("puppet", theMapping.getSubjectType()); -} diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/common/countries/Aaacountry.txt b/EU5ToVic3Tests/TestFiles/eu4installation/common/countries/Aaacountry.txt deleted file mode 100644 index 67c8635..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/common/countries/Aaacountry.txt +++ /dev/null @@ -1,35 +0,0 @@ -#Country Name: comment - -graphical_culture = irrelevant - -color = { 157 51 167 } - -revolutionary_colors = { irrelevant } - -historical_idea_groups = { - irrelevant -} - -historical_units = { - irrelevant -} - -monarch_names = { - irrelevant -} - -leader_names = { - irrelevant -} - -ship_names = { - irrelevant -} - -army_names = { - irrelevant -} - -fleet_names = { - irrelevant -} diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/common/countries/Bbbcountry.txt b/EU5ToVic3Tests/TestFiles/eu4installation/common/countries/Bbbcountry.txt deleted file mode 100644 index 634d9f8..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/common/countries/Bbbcountry.txt +++ /dev/null @@ -1,27 +0,0 @@ -#Country Name: comment - -graphical_culture = irrelevant - -color = { 49 115 90 } - -revolutionary_colors = { irrelevant } - -historical_idea_groups = { - irrelevant -} - -historical_units = { - irrelevant -} - -monarch_names = { - irrelevant -} - -leader_names = { - irrelevant -} - -ship_names = { - irrelevant -} diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/common/country_tags/00_countries.txt b/EU5ToVic3Tests/TestFiles/eu4installation/common/country_tags/00_countries.txt deleted file mode 100644 index da63187..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/common/country_tags/00_countries.txt +++ /dev/null @@ -1,5 +0,0 @@ -## first country -AAA = "countries/Aaacountry.txt" #comment - -# other country -BBB = "countries/Bbbcountry.txt" # comment diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/common/cultures/00_cultures.txt b/EU5ToVic3Tests/TestFiles/eu4installation/common/cultures/00_cultures.txt deleted file mode 100644 index 141f179..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/common/cultures/00_cultures.txt +++ /dev/null @@ -1,34 +0,0 @@ -culture_group = { - culture1 = { - } - culture2 = { - } - culture3 = { - } - culture4 = { - } - culture5 = { - } -} - -additional_group = { - culture6 = { - } - culture7 = { - } - culture8 = { - } - culture9 = { - } - culture10 = { - } - dynamic-culture1-culture7-culture-num1 = { - } - dynamic-culture8-culture-num1 = { - } -} - -an_additional_group = { - unmapped_culture = { - } -} diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/common/custom_country_colors/00_custom_country_colors.txt b/EU5ToVic3Tests/TestFiles/eu4installation/common/custom_country_colors/00_custom_country_colors.txt deleted file mode 100644 index a21207d..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/common/custom_country_colors/00_custom_country_colors.txt +++ /dev/null @@ -1,3 +0,0 @@ -flag_color = { 0 1 2 } -flag_color = { 3 4 5 } -flag_color = { 6 7 8 } diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/common/religions/00_religion.txt b/EU5ToVic3Tests/TestFiles/eu4installation/common/religions/00_religion.txt deleted file mode 100644 index 5f1b248..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/common/religions/00_religion.txt +++ /dev/null @@ -1,14 +0,0 @@ -vanilla_group_1 = { - religion_1 = { - color = { 204 204 0 } - } - religion_2 = { - color = { 135 77 255 } - } -} - -vanilla_group_2 = { - religion_3 = { - color = { 0 153 0 } - } -} diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/common/trade_companies/00_trade_companies.txt b/EU5ToVic3Tests/TestFiles/eu4installation/common/trade_companies/00_trade_companies.txt deleted file mode 100644 index 14667f4..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/common/trade_companies/00_trade_companies.txt +++ /dev/null @@ -1,57 +0,0 @@ -trade_company_west_africa = { - color = { 50 0 200 } - - provinces = { - 1164 1165 1166 1096 1793 2241 1466 1097 1098 1118 1119 1151 1163 2242 1168 1306 4078 4079 4080 - 1111 - 1126 1139 1141 2257 2258 #West Africa Coast - 1147 2289 2290 2294 #Benin - 1112 1113 1116 2239 #Jolof - 1114 1117 2238 #Futa Jalon - 1167 1171 1172 1174 #Angola - } - - # Specific - # Generic - names = { - name = "TRADE_COMPANY_WEST_AFRICA_Root_Culture_GetName" - } - names = { - name = "TRADE_COMPANY_WEST_AFRICA_Africa_Trade_Company" - } -} - -trade_company_west_india = { - color = { 135 104 85 } - - provinces = { - 518 2058 2087 4501 4462 #mewar_area - 512 4502 4507 2066 #jangladesh_area - 513 514 2067 4506 #marwar_area - 504 2088 4503 4504 #sindh_area - 505 2072 4505 #northern_sindh_area - 529 530 2089 4429 #konkan_area - 515 521 2052 4454 4455 #saurashtra_area - 517 2036 4430 #tapti_area - 503 2053 4456 4480 #patan_area - 516 2051 2054 4512 4457 #ahmedabad_area - } - - # Generic - names = { - trigger = { - OR = { - tag = GBR - tag = ENG - } - primary_culture = english - } - name = "TRADE_COMPANY_INDIA_British_trade_company_south_india" - } - names = { - name = "TRADE_COMPANY_WEST_INDIA_Root_Culture_GetName" - } - names = { - name = "TRADE_COMPANY_WEST_INDIA_India_Trade_Company" - } -} diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/map/area.txt b/EU5ToVic3Tests/TestFiles/eu4installation/map/area.txt deleted file mode 100644 index 4bed58c..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/map/area.txt +++ /dev/null @@ -1,2 +0,0 @@ -land_area = { 2 3 7 9 10 } -sea_area = { 1 } diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/map/default.map b/EU5ToVic3Tests/TestFiles/eu4installation/map/default.map deleted file mode 100644 index 87e4e42..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/map/default.map +++ /dev/null @@ -1,3 +0,0 @@ -sea_starts = { 1 } -only_used_for_random = { 5 } -lakes = { 6 } diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/map/definition.csv b/EU5ToVic3Tests/TestFiles/eu4installation/map/definition.csv deleted file mode 100644 index 66c07ae..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/map/definition.csv +++ /dev/null @@ -1,11 +0,0 @@ -comment -1;1;1;1;name1;x;<- sea -2;2;2;2;name2;x;<- land -3;3;3;3;name3;x;<- land -4;4;4;4;name4;x;<- wasteland -5;5;5;5;name5;x;<- rnw -6;6;6;6;name6;x;<- lake -7;7;7;7;name7;x;<- land -8;8;8;8;name8;x;<- lake -9;9;9;9;name9;x;<- land -10;10;10;10;name10;x;<- land diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/map/region.txt b/EU5ToVic3Tests/TestFiles/eu4installation/map/region.txt deleted file mode 100644 index 7e0e2d3..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/map/region.txt +++ /dev/null @@ -1,6 +0,0 @@ -land_region = { - areas = { land_area } -} -sea_region = { - areas = { sea_area } -} diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/map/superregion.txt b/EU5ToVic3Tests/TestFiles/eu4installation/map/superregion.txt deleted file mode 100644 index 3a734e2..0000000 --- a/EU5ToVic3Tests/TestFiles/eu4installation/map/superregion.txt +++ /dev/null @@ -1,2 +0,0 @@ -land_superregion = { land_region } -sea_superregion = { sea_region } diff --git a/EU5ToVic3Tests/TestFiles/eu5installation/eu5 b/EU5ToVic3Tests/TestFiles/eu5installation/eu5 new file mode 100644 index 0000000..e69de29 diff --git a/EU5ToVic3Tests/TestFiles/eu4installation/launcher-settings.json b/EU5ToVic3Tests/TestFiles/eu5installation/launcher-settings.json similarity index 100% rename from EU5ToVic3Tests/TestFiles/eu4installation/launcher-settings.json rename to EU5ToVic3Tests/TestFiles/eu5installation/launcher-settings.json diff --git a/EU5ToVic3Tests/TestFiles/eu5installation/map/positions.txt b/EU5ToVic3Tests/TestFiles/eu5installation/map/positions.txt new file mode 100644 index 0000000..e69de29 diff --git a/EU5ToVic3Tests/V3WorldTests/.dummy b/EU5ToVic3Tests/V3WorldTests/.dummy new file mode 100644 index 0000000..e69de29 diff --git a/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/ClayManagerTests.cpp b/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/ClayManagerTests.cpp deleted file mode 100644 index ba85c10..0000000 --- a/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/ClayManagerTests.cpp +++ /dev/null @@ -1,687 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/Chunk.h" -#include "ClayManager/State/Province.h" -#include "ClayManager/State/State.h" -#include "ClayManager/State/SubState.h" -#include "CountryManager/EU4Country.h" -#include "CountryMapper/CountryMapper.h" -#include "Loaders/SuperRegionLoader/V3Region.h" -#include "Loaders/SuperRegionLoader/V3SuperRegion.h" -#include "PoliticalManager/Country/Country.h" -#include "PoliticalManager/PoliticalManager.h" -#include "PopManager/PopManager.h" -#include "ProvinceManager/ProvinceManager.h" -#include "ProvinceMapper/ProvinceMapper.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -const auto eu4FS = commonItems::ModFilesystem("TestFiles/eu4installation/", {}); - -V3::ClayManager generateChunks() -{ - EU4::DefaultMapParser defaults; - defaults.loadDefaultMap(eu4FS); - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(eu4FS); - EU4::RegionManager regionManager; - regionManager.loadRegions(eu4FS); - - std::stringstream provinceStream; - provinceStream << "-1={}\n"; // sea, no ownership - provinceStream - << "-2={ owner = TA2 base_tax=10 base_production=10 base_manpower=10 culture = culture religion = religion cores = { TA2 }}\n"; // substate TA-2&3 - provinceStream - << "-3={ owner = TA3 base_tax=1 base_production=1 base_manpower=1 culture = culture2 religion = religion2 cores = { TA3 }}\n"; // substate TA-2&3 - provinceStream << "-4={}\n"; // irrelevant - provinceStream << "-5={}\n"; // irrelevant - provinceStream << "-6={}\n"; // irrelevant - provinceStream << "-7={}\n"; // irrelevant - provinceStream << "-8={}\n"; // irrelevant - provinceStream - << "-9={ owner = TA9 base_tax=1 base_production=1 base_manpower=1 culture = culture3 religion = religion3 cores = { TA9 TA2 }}\n"; // substate TA-9 - provinceStream << "-10={}\n"; // irrelevant - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provinceStream); - // add 2 disputed capitals - provinceManager.getProvince(2)->addCapital("TA2"); - provinceManager.getProvince(3)->addCapital("TA3"); - provinceManager.loadDefaultMapParser(defaults); - provinceManager.loadDefinitionScraper(definitions); - provinceManager.classifyProvinces(regionManager); - provinceManager.buildProvinceWeights(regionManager); - provinceManager.buildPopRatios({}, false); - - mappers::ProvinceMapper provinceMapper; - provinceMapper.loadProvinceMappings("TestFiles/configurables/province_mappings_chunks.txt"); - - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - clayManager.generateChunks(provinceMapper, provinceManager); - return clayManager; -} - -V3::ClayManager distributeChunks() -{ - auto clayManager = generateChunks(); - std::stringstream countryStream; - const auto ta2 = std::make_shared("TA2", countryStream); - const auto ta3 = std::make_shared("TA3", countryStream); - const auto ta9 = std::make_shared("TA9", countryStream); - const std::map> countries = {{"TA2", ta2}, {"TA3", ta3}, {"TA9", ta9}}; - clayManager.unDisputeChunkOwnership(countries); - clayManager.splitChunksIntoSubStates(); - return clayManager; -} - -std::tuple assignSubStateOwnership() -{ - auto clayManager = distributeChunks(); - std::stringstream countryStream; - const auto ta2 = std::make_shared("TA2", countryStream); - const auto ta3 = std::make_shared("TA3", countryStream); - const auto ta9 = std::make_shared("TA9", countryStream); - const std::map> countries = {{"TA2", ta2}, {"TA3", ta3}, {"TA9", ta9}}; - auto countryMapper = std::make_shared(); - countryMapper->loadMappingRules("TestFiles/configurables/country_mappings.txt"); - V3::PoliticalManager politicalManager; - politicalManager.loadCountryMapper(countryMapper); - politicalManager.initializeVanillaCountries(modFS, modFS); - politicalManager.importEU4Countries(countries); - clayManager.assignSubStateOwnership(politicalManager.getCountries(), *countryMapper); - - V3::PopManager popManager; - popManager.initializeVanillaPops(modFS); - - clayManager.injectVanillaSubStates(modFS, politicalManager, popManager, false); - - return {clayManager, politicalManager}; -} -} // namespace - -TEST(V3World_ClayManagerTests, clayManagerCanInitializeVanillaStates) -{ - V3::ClayManager clayManager; - - EXPECT_EQ(0, clayManager.getStates().size()); - - clayManager.initializeVanillaStates(modFS); - - EXPECT_EQ(10, clayManager.getStates().size()); - EXPECT_TRUE(clayManager.getStates().contains("STATE_TEST_1")); - EXPECT_TRUE(clayManager.getStates().contains("STATE_TEST_2")); - EXPECT_TRUE(clayManager.getStates().contains("STATE_TEST_3")); - EXPECT_TRUE(clayManager.getStates().contains("STATE_TEST_4")); -} - -TEST(V3World_ClayManagerTests, clayManagerCanLoadTerrainsIntoStateProvinces) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - - const auto& state1 = clayManager.getStates().at("STATE_TEST_LAKE"); - const auto& province1 = state1->getProvinces().at("xAABBCC"); - const auto& state2 = clayManager.getStates().at("STATE_TEST_2"); - const auto& province2 = state2->getProvinces().at("xDDEEFF"); - - EXPECT_EQ("lakes", province1->getTerrain()); - EXPECT_EQ("ocean", province2->getTerrain()); -} - -TEST(V3World_ClayManagerTests, oceanProvincesGetFlaggedAsSeas) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - - const auto& state1 = clayManager.getStates().at("STATE_TEST_LAKE"); - const auto& province1 = state1->getProvinces().at("xAABBCC"); - const auto& state2 = clayManager.getStates().at("STATE_TEST_2"); - const auto& province2 = state2->getProvinces().at("xDDEEFF"); - - EXPECT_FALSE(province1->isSea()); - EXPECT_TRUE(province2->isSea()); -} - -TEST(V3World_ClayManagerTests, lakeProvincesGetFlaggedAsLakesandImpassables) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - - const auto& state1 = clayManager.getStates().at("STATE_TEST_LAKE"); - const auto& province1 = state1->getProvinces().at("xAABBCC"); - const auto& state2 = clayManager.getStates().at("STATE_TEST_2"); - const auto& province2 = state2->getProvinces().at("xDDEEFF"); - - EXPECT_TRUE(province1->isLake()); - EXPECT_TRUE(province1->isImpassable()); - EXPECT_FALSE(province2->isLake()); - EXPECT_FALSE(province2->isImpassable()); -} - -TEST(V3World_ClayManagerTests, clayManagerComplainsForMissingProvinceTerrain) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - clayManager.loadTerrainsIntoProvinces(modFS); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] Terrain for province x345678 cannot be found.)")); - - std::cout.rdbuf(cout_buffer); -} - -TEST(V3World_ClayManagerTests, clayManagerCanInitializeSuperRegions) -{ - V3::ClayManager clayManager; - - EXPECT_EQ(0, clayManager.getSuperRegions().size()); - - clayManager.initializeSuperRegions(modFS); - - EXPECT_EQ(2, clayManager.getSuperRegions().size()); - EXPECT_TRUE(clayManager.getSuperRegions().contains("test_1_strategic_regions")); - EXPECT_TRUE(clayManager.getSuperRegions().contains("test_2_strategic_regions")); -} - -TEST(V3World_ClayManagerTests, clayManagerCanLinkStatesToSuperRegions) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - const auto& superRegion1 = clayManager.getSuperRegions().at("test_1_strategic_regions"); - const auto& regionA = superRegion1->getRegions().at("region_a"); - const auto& states = regionA->getStates(); - - EXPECT_EQ(4, states.size()); - - const auto& state_test_1 = states.at("STATE_TEST_1"); - - EXPECT_TRUE(state_test_1); - EXPECT_EQ(3, state_test_1->getProvinces().size()); - EXPECT_TRUE(state_test_1->getProvinces().at("x445566")->isImpassable()); -} - -TEST(V3World_ClayManagerTests, clayManagerCanDetermineRegionValidity) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - EXPECT_TRUE(clayManager.regionIsValid("STATE_TEST_1")); // state - EXPECT_TRUE(clayManager.regionIsValid("region_a")); // region - EXPECT_TRUE(clayManager.regionIsValid("test_1_strategic_regions")); // superregion - EXPECT_FALSE(clayManager.regionIsValid("STATE_TEST_5")); // does't exist - EXPECT_FALSE(clayManager.regionIsValid("region_d")); // does't exist - EXPECT_FALSE(clayManager.regionIsValid("test_3_strategic_regions")); // does't exist -} - -TEST(V3World_ClayManagerTests, clayManagerCanDetermineHierarchy) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - EXPECT_TRUE(clayManager.stateIsInRegion("STATE_TEST_1", "STATE_TEST_1")); - EXPECT_TRUE(clayManager.stateIsInRegion("STATE_TEST_1", "region_a")); - EXPECT_TRUE(clayManager.stateIsInRegion("STATE_TEST_1", "test_1_strategic_regions")); - EXPECT_FALSE(clayManager.stateIsInRegion("STATE_TEST_1", "STATE_TEST_2")); - EXPECT_FALSE(clayManager.stateIsInRegion("STATE_TEST_1", "region_b")); - EXPECT_FALSE(clayManager.stateIsInRegion("STATE_TEST_1", "test_2_strategic_regions")); -} - -TEST(V3World_ClayManagerTests, excessSuperRegionStatesInRegionsAreObjectedAndRemoved) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.initializeSuperRegions(modFS); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - clayManager.loadStatesIntoSuperRegions(); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] Attempting to assign state STATE_TEST_EXCESS which doesn't exist to region region_c!)")); - - std::cout.rdbuf(cout_buffer); - - const auto& region_c = clayManager.getSuperRegions().at("test_2_strategic_regions")->getRegions().at("region_c"); - - EXPECT_FALSE(region_c->containsState("STATE_TEST_EXCESS")); -} - -TEST(V3World_ClayManagerTests, clayManagerCanGenerateSaneChunks) -{ - auto clayManager = generateChunks(); - const auto& chunks = clayManager.getChunks(); - - /* - link = { eu4 = 1 vic3 = x000001 vic3 = x000002 } #sea->seas // produces chunk 1 - link = { eu4 = 2 eu4 = 3 vic3 = x000003 vic3 = x000004 } #lands->lands // produces chunk 2 - link = { eu4 = 4 vic3 = x000005 } #wasteland->land // produces wasteland-only chunk 3 - link = { eu4 = 5 vic3 = x000006 } #rnw->land // doesn't produce anything as rnw isn't valid source - link = { eu4 = 6 eu4 = 7 vic3 = x000007 } #lake,land->lake // dropped because target lake is junk - link = { eu4 = 8 eu4 = 9 vic3 = x000008 vic3 = x000009 } #wasteland,land->land,lake // produces chunk 4, lake target dropped - link = { eu4 = 10 } #land->nothing // produces nothing as there's no target. - link = { vic3 = x000010 } #nothing->land // produces nothing as there's no source. - */ - - ASSERT_EQ(4, chunks.size()); - - const auto& chunk1 = chunks[0]; // sea chunk 1->x1,x2 - const auto& chunk2 = chunks[1]; // land chunk, 2,3->x3,x4 - const auto& chunk3 = chunks[2]; // wasteland chunk, 4->x5 - const auto& chunk4 = chunks[3]; // land chunk, 9->x8 - - EXPECT_TRUE(chunk1->getProvinces().contains("x000001")); - EXPECT_TRUE(chunk1->getProvinces().contains("x000002")); - EXPECT_EQ(2, chunk1->getProvinces().size()); - - EXPECT_TRUE(chunk2->getProvinces().contains("x000003")); - EXPECT_TRUE(chunk2->getProvinces().contains("x000004")); - EXPECT_EQ(2, chunk2->getProvinces().size()); - - EXPECT_TRUE(chunk3->getProvinces().contains("x000005")); - EXPECT_EQ(1, chunk3->getProvinces().size()); - - EXPECT_TRUE(chunk4->getProvinces().contains("x000008")); - EXPECT_EQ(1, chunk4->getProvinces().size()); -} - -TEST(V3World_ClayManagerTests, clayManagerCanUndisputeChunkOwnership) -{ - auto clayManager = generateChunks(); - - // Wee need some countries to link chunks to. - std::stringstream countryStream; - const auto tag = std::make_shared("TA2", countryStream); - const auto gat = std::make_shared("TA9", countryStream); - std::map> countries = {{"TA2", tag}, {"TA9", gat}}; - - clayManager.unDisputeChunkOwnership(countries); - const auto& chunks = clayManager.getChunks(); - - /* - link = { eu4 = 1 vic3 = x000001 vic3 = x000002 } #sea->seas // produces chunk 1 - dropped since no owners - link = { eu4 = 2 eu4 = 3 vic3 = x000003 vic3 = x000004 } #lands->lands // produces chunk 2 - goes to TA2 due to higher dev. - link = { eu4 = 4 vic3 = x000005 } # wasteland -> land // produces chunk 3 - goes to noone since it's unowned. - link = { eu4 = 8 eu4 = 9 vic3 = x000008 vic3 = x000009 } # wasteland,land->land,lake // produces chunk 4, goes to TA9 since only owner. - */ - - ASSERT_EQ(3, chunks.size()); - - const auto& chunk1 = chunks[0]; // land chunk, 2,3->x3,x4 - const auto& chunk2 = chunks[1]; // land chunk, 4->x5 - const auto& chunk3 = chunks[2]; // land chunk, 9->x8 - - ASSERT_TRUE(chunk1->getSourceOwnerTag()); - EXPECT_EQ("TA2", chunk1->getSourceOwnerTag()); - EXPECT_TRUE(chunk1->getProvinces().contains("x000003")); - EXPECT_TRUE(chunk1->getProvinces().contains("x000004")); - EXPECT_TRUE(chunk1->isCapital()); // Capital of owner, TA2. TA3 lost its capital. - - EXPECT_FALSE(chunk2->getSourceOwnerTag()); - EXPECT_TRUE(chunk2->getProvinces().contains("x000005")); - EXPECT_FALSE(chunk2->isCapital()); - - ASSERT_TRUE(chunk3->getSourceOwnerTag()); - EXPECT_EQ("TA9", chunk3->getSourceOwnerTag()); - EXPECT_TRUE(chunk3->getProvinces().contains("x000008")); - EXPECT_FALSE(chunk3->isCapital()); // TA9 has a capital elsewhere. -} - -TEST(V3World_ClayManagerTests, clayManagerResetsChunkOwnershipFromInvalidCountries) -{ - auto clayManager = generateChunks(); - - // Wee need some countries to link chunks to. - std::stringstream countryStream; - const auto ta9 = std::make_shared("TA9", countryStream); - std::map> countries = {{"TA9", ta9}}; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - clayManager.unDisputeChunkOwnership(countries); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] Chunk owner TA2 is invalid. Dropping chunk ownership.)")); - - std::cout.rdbuf(cout_buffer); - - const auto& chunks = clayManager.getChunks(); - - /* - link = { eu4 = 1 vic3 = x000001 vic3 = x000002 } #sea->seas // produces chunk 1 - dropped since no owners - link = { eu4 = 2 eu4 = 3 vic3 = x000003 vic3 = x000004 } #lands->lands // produces chunk 2 - goes to TA2 due to higher dev. - link = { eu4 = 4 vic3 = x000005 } # wasteland -> land // produces chunk 3 - goes to noone since it's unowned. - link = { eu4 = 8 eu4 = 9 vic3 = x000008 vic3 = x000009 } # wasteland,land->land,lake // produces chunk 4, goes to TA9 since only owner. - */ - - ASSERT_EQ(3, chunks.size()); - - const auto& chunk1 = chunks[0]; // land chunk, 2,3->x3,x4 // TA2 -> noone - const auto& chunk2 = chunks[1]; // land chunk, 4->x5 // noone - const auto& chunk3 = chunks[2]; // land chunk, 9->x8 // TA9 - - EXPECT_FALSE(chunk1->getSourceOwnerTag()); - EXPECT_TRUE(chunk1->getProvinces().contains("x000003")); - EXPECT_TRUE(chunk1->getProvinces().contains("x000004")); - - EXPECT_FALSE(chunk2->getSourceOwnerTag()); - EXPECT_TRUE(chunk2->getProvinces().contains("x000005")); - - ASSERT_TRUE(chunk3->getSourceOwnerTag()); - EXPECT_EQ("TA9", chunk3->getSourceOwnerTag()); - EXPECT_TRUE(chunk3->getProvinces().contains("x000008")); -} - -TEST(V3World_ClayManagerTests, clayManagerResetsChunkOwnershipFromInsaneCountries) -{ - auto clayManager = generateChunks(); - - // Wee need some countries to link chunks to. - std::stringstream countryStream; - const auto ta9 = std::make_shared("TA9", countryStream); - std::map> countries = {{"TA2", nullptr}, {"TA9", ta9}}; // TA2 is insane. - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - clayManager.unDisputeChunkOwnership(countries); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] Chunk owner TA2 is not initialized. Dropping chunk ownership.)")); - - std::cout.rdbuf(cout_buffer); - - const auto& chunks = clayManager.getChunks(); - - /* - link = { eu4 = 1 vic3 = x000001 vic3 = x000002 } #sea->seas // produces chunk 1 - dropped since no owners - link = { eu4 = 2 eu4 = 3 vic3 = x000003 vic3 = x000004 } #lands->lands // produces chunk 2 - goes to TA2 due to higher dev. - link = { eu4 = 4 vic3 = x000005 } # wasteland -> land // produces chunk 3 - goes to noone since it's unowned. - link = { eu4 = 8 eu4 = 9 vic3 = x000008 vic3 = x000009 } # wasteland,land->land,lake // produces chunk 4, goes to TA9 since only owner. - */ - - ASSERT_EQ(3, chunks.size()); - - const auto& chunk1 = chunks[0]; // land chunk, 2,3->x3,x4 // TA2 -> noone - const auto& chunk2 = chunks[1]; // land chunk, 4->x5 // noone - const auto& chunk3 = chunks[2]; // land chunk, 9->x8 // TA9 - - EXPECT_FALSE(chunk1->getSourceOwnerTag()); - EXPECT_TRUE(chunk1->getProvinces().contains("x000003")); - EXPECT_TRUE(chunk1->getProvinces().contains("x000004")); - - EXPECT_FALSE(chunk2->getSourceOwnerTag()); - EXPECT_TRUE(chunk2->getProvinces().contains("x000005")); - - ASSERT_TRUE(chunk3->getSourceOwnerTag()); - EXPECT_EQ("TA9", chunk3->getSourceOwnerTag()); - EXPECT_TRUE(chunk3->getProvinces().contains("x000008")); -} - -TEST(V3World_ClayManagerTests, clayManagerCanSplitSubstatesFromChunks) -{ - auto clayManager = distributeChunks(); - const auto& substates = clayManager.getSubStates(); - - /* - link = { eu4 = 1 vic3 = x000001 vic3 = x000002 } #sea->seas // produces chunk 1 - dropped since no owners - no substate - link = { eu4 = 2 eu4 = 3 vic3 = x000003 vic3 = x000004 } #lands->lands // produces substates 1 & 2 since x3 and x4 are in different states. - link = { eu4 = 4 vic3 = x000005 } # wasteland -> land // produces chunk 3 // produces substate 3 which has no owner - link = { eu4 = 8 eu4 = 9 vic3 = x000008 vic3 = x000009 } # lake,land->land,lake // produces substate 4, with only x8 inside as x9 is a lake. - */ - - ASSERT_EQ(4, substates.size()); - - const auto& substate1 = substates[0]; - const auto& substate2 = substates[1]; - const auto& substate3 = substates[2]; - const auto& substate4 = substates[3]; - - ASSERT_TRUE(substate1->getSourceOwnerTag()); - EXPECT_EQ("TA2", *substate1->getSourceOwnerTag()); - EXPECT_EQ(1, substate1->getProvinces().size()); - EXPECT_TRUE(substate1->getProvinces().contains("x000003")); - EXPECT_EQ("STATE_TEST_LAND1", substate1->getHomeStateName()); - EXPECT_TRUE(substate1->isCapital()); // TA2->GA2 capital goes here since it has 50% share and this one is first. - - ASSERT_TRUE(substate2->getSourceOwnerTag()); - EXPECT_EQ("TA2", *substate2->getSourceOwnerTag()); - EXPECT_EQ(1, substate2->getProvinces().size()); - EXPECT_TRUE(substate2->getProvinces().contains("x000004")); - EXPECT_EQ("STATE_TEST_LAND2", substate2->getHomeStateName()); - EXPECT_FALSE(substate2->isCapital()); // Capital already spent - - ASSERT_FALSE(substate3->getSourceOwnerTag()); - EXPECT_EQ(1, substate3->getProvinces().size()); - EXPECT_TRUE(substate3->getProvinces().contains("x000005")); - EXPECT_EQ("STATE_TEST_LAND3", substate3->getHomeStateName()); - EXPECT_FALSE(substate3->isCapital()); // Capital never set - - ASSERT_TRUE(substate4->getSourceOwnerTag()); - EXPECT_EQ("TA9", *substate4->getSourceOwnerTag()); - EXPECT_EQ(1, substate4->getProvinces().size()); - EXPECT_TRUE(substate4->getProvinces().contains("x000008")); - EXPECT_EQ("STATE_TEST_LAND4", substate4->getHomeStateName()); - EXPECT_FALSE(substate4->isCapital()); // Capital elsewhere -} - -TEST(V3World_ClayManagerTests, clayManagerCanAssignSubStatesToCountries) -{ - auto [clayManager, polManager] = assignSubStateOwnership(); - const auto& substates = clayManager.getSubStates(); - - /* - link = { eu4 = 2 eu4 = 3 vic3 = x000003 vic3 = x000004 } #lands->lands // produces substates 1 & 2 for V3's GA2. - link = { eu4 = 8 eu4 = 9 vic3 = x000008 vic3 = x000009 } # lake,land->land,lake // produces substate 4, for V3's GA9. - */ - - ASSERT_EQ(4, substates.size()); - - const auto& substate1 = substates[0]; - const auto& substate2 = substates[1]; - const auto& substate3 = substates[2]; - // we're ignoring the 4th substate which is an imported one. - - ASSERT_TRUE(substate1->getSourceOwnerTag()); - EXPECT_EQ("TA2", substate1->getSourceOwnerTag()); - EXPECT_EQ(1, substate1->getProvinces().size()); - EXPECT_TRUE(substate1->getProvinces().contains("x000003")); - EXPECT_EQ("STATE_TEST_LAND1", substate1->getHomeStateName()); - EXPECT_EQ("GA2", substate1->getOwnerTag()); - EXPECT_EQ("GA2", substate1->getOwner()->getTag()); - // linkback to this substate through getOwner() substates vector - EXPECT_EQ("STATE_TEST_LAND1", substate1->getOwner()->getSubStates()[0]->getHomeStateName()); - // linkback through state's substate ownership vector - EXPECT_EQ("GA2", substate1->getHomeState()->getSubStates()[0]->getOwnerTag()); - - ASSERT_TRUE(substate2->getSourceOwnerTag()); - EXPECT_EQ("TA2", substate2->getSourceOwnerTag()); - EXPECT_EQ(1, substate2->getProvinces().size()); - EXPECT_TRUE(substate2->getProvinces().contains("x000004")); - EXPECT_EQ("STATE_TEST_LAND2", substate2->getHomeStateName()); - EXPECT_EQ("GA2", substate2->getOwnerTag()); - EXPECT_EQ("GA2", substate2->getOwner()->getTag()); - // linkback to this substate through getOwner() substates vector - EXPECT_EQ("STATE_TEST_LAND2", substate2->getOwner()->getSubStates()[1]->getHomeStateName()); - // linkback through state's substate ownership vector - EXPECT_EQ("GA2", substate2->getHomeState()->getSubStates()[0]->getOwnerTag()); - - ASSERT_TRUE(substate3->getSourceOwnerTag()); - EXPECT_EQ("TA9", substate3->getSourceOwnerTag()); - EXPECT_EQ(1, substate3->getProvinces().size()); - EXPECT_TRUE(substate3->getProvinces().contains("x000008")); - EXPECT_EQ("STATE_TEST_LAND4", substate3->getHomeStateName()); - EXPECT_EQ("GA9", substate3->getOwnerTag()); - EXPECT_EQ("GA9", substate3->getOwner()->getTag()); - // linkback to this substate through getOwner() substates vector - EXPECT_EQ("STATE_TEST_LAND4", substate3->getOwner()->getSubStates()[0]->getHomeStateName()); - // linkback through state's substate ownership vector - EXPECT_EQ("GA9", substate3->getHomeState()->getSubStates()[0]->getOwnerTag()); -} - -TEST(V3World_ClayManagerTests, clayManagerCanAssignUnownedCoreSubStatesToOtherCountries) -{ - auto [clayManager, polManager] = assignSubStateOwnership(); - - /* - link = { eu4 = 2 eu4 = 3 vic3 = x000003 vic3 = x000004 } #lands->lands // produces substates 1 & 2 for V3's GA2. - link = { eu4 = 8 eu4 = 9 vic3 = x000008 vic3 = x000009 } # lake,land->land,lake // produces substate 4, for V3's GA9. - TA2->GA2 - unowned core in eu4 = 9 goes to STATE_TEST_LAND4 - TA3->X00 - dead core in eu4 = 3 gets split to STATE_TEST_LAND1 and STATE_TEST_LAND2 - TA9->GA9 - no unowned cores - */ - - const auto ga2 = polManager.getCountry("GA2"); - const auto x00 = polManager.getCountry("X00"); - const auto ga9 = polManager.getCountry("GA9"); - - ASSERT_EQ(1, ga2->getUnownedCoreSubStates().size()); - EXPECT_EQ("STATE_TEST_LAND4", ga2->getUnownedCoreSubStates()[0]->getHomeStateName()); - ASSERT_EQ(2, x00->getUnownedCoreSubStates().size()); - EXPECT_EQ("STATE_TEST_LAND1", x00->getUnownedCoreSubStates()[0]->getHomeStateName()); - EXPECT_EQ("STATE_TEST_LAND2", x00->getUnownedCoreSubStates()[1]->getHomeStateName()); - EXPECT_TRUE(ga9->getUnownedCoreSubStates().empty()); -} - -TEST(V3World_ClayManagerTests, clayManagerCanInjectVanillaSubStates) -{ - auto [clayManager, polManager] = assignSubStateOwnership(); - const auto& substates = clayManager.getSubStates(); - - /* - link = { eu4 = 2 eu4 = 3 vic3 = x000003 vic3 = x000004 } #lands->lands // produces substates 1 & 2 for V3's GA2. - link = { eu4 = 8 eu4 = 9 vic3 = x000008 vic3 = x000009 } # lake,land->land,lake // produces substate 4, for V3's GA9. - injected is the vic3 = x000005, x000006 one. - */ - - ASSERT_EQ(4, substates.size()); - - // we're focusing on the 4th substate - injected one. - const auto& substate4 = substates[3]; - - ASSERT_FALSE(substate4->getSourceOwnerTag()); - EXPECT_EQ(2, substate4->getProvinces().size()); - EXPECT_TRUE(substate4->getProvinces().contains("x000005")); - EXPECT_TRUE(substate4->getProvinces().contains("x000006")); - EXPECT_EQ("STATE_TEST_LAND3", substate4->getHomeStateName()); - EXPECT_EQ("CCC", substate4->getOwnerTag()); - EXPECT_EQ("CCC", substate4->getOwner()->getTag()); - // linkback to this substate through getOwner() substates vector - EXPECT_EQ("STATE_TEST_LAND3", substate4->getOwner()->getSubStates()[0]->getHomeStateName()); - // linkback through state's substate ownership vector - EXPECT_EQ("CCC", substate4->getHomeState()->getSubStates()[0]->getOwnerTag()); -} - -TEST(V3World_ClayManagerTests, clayManagerCanShoveProvincesIntoSubStates) -{ - auto [clayManager, polManager] = assignSubStateOwnership(); - - // let's grab a state. - const auto& state = clayManager.getStates().at("STATE_TEST_LAND3"); - - // it has 1 substate. - ASSERT_EQ(1, state->getSubStates().size()); - // let's grab that substate. - const auto& substate1 = state->getSubStates()[0]; - EXPECT_EQ(2, substate1->getProvinces().size()); - EXPECT_TRUE(substate1->getProvinces().contains("x000005")); - EXPECT_TRUE(substate1->getProvinces().contains("x000006")); - - // wipe its provinces. - substate1->setProvinces({}); - - // now shove them. - clayManager.shoveRemainingProvincesIntoSubStates(); - - // now state has have 2 substates. - ASSERT_EQ(2, state->getSubStates().size()); - - // and the second one has provinces shoved into it. - const auto& substate2 = state->getSubStates()[1]; - EXPECT_EQ(2, substate2->getProvinces().size()); - EXPECT_TRUE(substate2->getProvinces().contains("x000005")); - EXPECT_TRUE(substate2->getProvinces().contains("x000006")); -} - -TEST(V3World_ClayManagerTests, clayManagerCanSquashSubStates) -{ - auto [clayManager, polManager] = assignSubStateOwnership(); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - clayManager.squashAllSubStates(polManager); - std::cout.rdbuf(cout_buffer); - - // we have no squashable states - EXPECT_THAT(log.str(), testing::HasSubstr(R"([INFO] <> Substates squashed, 4 remain, 0 ditched.)")); - // so let's make one. - - // let's grab some substate. - const auto& sub = clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates()[0]; - EXPECT_EQ("GA2", sub->getOwnerTag()); - - // now refile it. - EXPECT_EQ(2, polManager.getCountry("GA2")->getSubStates().size()); - polManager.getCountry("GA2")->addSubState(sub); - EXPECT_EQ(3, polManager.getCountry("GA2")->getSubStates().size()); - - EXPECT_EQ(4, clayManager.getSubStates().size()); - clayManager.addSubState(sub); - EXPECT_EQ(5, clayManager.getSubStates().size()); - - EXPECT_EQ(1, clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates().size()); - clayManager.getStates().at("STATE_TEST_LAND1")->addSubState(sub); - EXPECT_EQ(2, clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates().size()); - - // squash again. - - cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - clayManager.squashAllSubStates(polManager); - std::cout.rdbuf(cout_buffer); - - // and it's gone. - EXPECT_THAT(log.str(), testing::HasSubstr(R"([INFO] <> Substates squashed, 4 remain, 1 ditched.)")); - EXPECT_EQ(2, polManager.getCountry("GA2")->getSubStates().size()); - EXPECT_EQ(4, clayManager.getSubStates().size()); - EXPECT_EQ(1, clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates().size()); -} - -TEST(V3World_ClayManagerTests, provinceOwnershipCanBePinged) -{ - auto [clayManager, polManager] = assignSubStateOwnership(); - - EXPECT_FALSE(clayManager.getProvinceOwnerTag("x000001")); - EXPECT_FALSE(clayManager.getProvinceOwnerTag("x000002")); - EXPECT_EQ("GA2", *clayManager.getProvinceOwnerTag("x000003")); - EXPECT_EQ("GA2", *clayManager.getProvinceOwnerTag("x000004")); - EXPECT_EQ("CCC", *clayManager.getProvinceOwnerTag("x000005")); - EXPECT_EQ("CCC", *clayManager.getProvinceOwnerTag("x000006")); - EXPECT_FALSE(clayManager.getProvinceOwnerTag("x000007")); - EXPECT_EQ("GA9", *clayManager.getProvinceOwnerTag("x000008")); - EXPECT_FALSE(clayManager.getProvinceOwnerTag("x000009")); - EXPECT_FALSE(clayManager.getProvinceOwnerTag("x000010")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/ChunkTests.cpp b/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/ChunkTests.cpp deleted file mode 100644 index e14de07..0000000 --- a/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/ChunkTests.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "ClayManager/State/Chunk.h" -#include "ProvinceManager/ProvinceManager.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto eu4FS = commonItems::ModFilesystem("TestFiles/eu4installation/", {}); - -V3::Chunk prepChunk() -{ - // make a few provinces - std::stringstream provinceStream; - provinceStream << "-2={ owner = TA2 base_tax=9 base_production=9 base_manpower=9 culture = culture religion = religion }\n"; // weight 27 - provinceStream << "-3={ owner = TA3 base_tax=1 base_production=1 base_manpower=1 culture = culture2 religion = religion2 }\n"; // weight 3 - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provinceStream); - provinceManager.getProvince(2)->addCapital("TA2"); // we're transfering this as well. - provinceManager.getProvince(3)->addCapital("TA3"); // we're making both capitals to make things dramatic. - EU4::RegionManager regionManager; - regionManager.loadRegions(eu4FS); - provinceManager.buildProvinceWeights(regionManager); - provinceManager.buildPopRatios({}, false); - - // shove provinces into a chunk. - V3::Chunk chunk; - chunk.addSourceProvinceData(*provinceManager.getProvince(2), 27); - chunk.addSourceProvinceData(*provinceManager.getProvince(3), 3); - - return chunk; -} -} // namespace - -TEST(V3World_ChunkTests, SourceProvinceDataCanBeAdded) -{ - const auto chunk = prepChunk(); - - const auto& spdata = chunk.getSourceProvinceData(); - ASSERT_EQ(2, spdata.size()); - const auto& [sp1, sp1weight] = spdata[0]; - const auto& [sp2, sp2weight] = spdata[1]; - - EXPECT_EQ("TA2", sp1.owner); - EXPECT_DOUBLE_EQ(27, sp1.weight); - ASSERT_EQ(1, sp1.popRatios.size()); - EXPECT_EQ("culture", sp1.popRatios[0].getCulture()); - EXPECT_EQ("religion", sp1.popRatios[0].getReligion()); - EXPECT_THAT(sp1.eu4Capitals, testing::UnorderedElementsAre("TA2")); - EXPECT_DOUBLE_EQ(27, sp1weight); - - EXPECT_EQ("TA3", sp2.owner); - EXPECT_DOUBLE_EQ(3, sp2.weight); - ASSERT_EQ(1, sp2.popRatios.size()); - EXPECT_EQ("culture2", sp2.popRatios[0].getCulture()); - EXPECT_EQ("religion2", sp2.popRatios[0].getReligion()); - EXPECT_THAT(sp2.eu4Capitals, testing::UnorderedElementsAre("TA3")); - EXPECT_DOUBLE_EQ(3, sp2weight); -} - -TEST(V3World_ChunkTests, CapitalsCanBeReported) -{ - const auto chunk = prepChunk(); - - EXPECT_THAT(chunk.getKnownCapitals(), testing::UnorderedElementsAre("TA2", "TA3")); -} - -TEST(V3World_ChunkTests, OwnerWeightsCanBeCalced) -{ - const auto chunk = prepChunk(); - - const auto ownerWeights = chunk.calcOwnerWeights(); - - EXPECT_THAT(ownerWeights, testing::UnorderedElementsAre(std::pair("TA2", 27), std::pair("TA3", 3))); -} - -TEST(V3World_ChunkTests, TotalSourceProvinceWeightCanBeCalced) -{ - const auto chunk = prepChunk(); - - // sum all all weight 27 + 3 = 30, divided by number of sources (2) = 15 - const auto totalWeight = chunk.getTotalSourceProvinceWeight(); - - EXPECT_DOUBLE_EQ(15, totalWeight); -} - -TEST(V3World_ChunkTests, ChunkCanDetectSourceSeaProvinces) -{ - // make a sea province - auto sea = EU4::Province(); - sea.setSea(); - - // shove province into a chunk. - V3::Chunk chunk; - chunk.addSourceProvinceData(sea, 1); - - EXPECT_TRUE(chunk.isSea()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/StateModifierTests.cpp b/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/StateModifierTests.cpp deleted file mode 100644 index 43c4d5d..0000000 --- a/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/StateModifierTests.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include "ClayManager/State/StateModifier.h" -#include "Loaders/BuildingLoader/BuildingGroupLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_StateModifierTests, DefaultsDefaultToDefaults) -{ - V3::StateModifier modifier; - - EXPECT_TRUE(modifier.getName().empty()); - EXPECT_EQ(0, modifier.getInfrastructureBonus()); - EXPECT_EQ(0, modifier.getInfrastructureMult()); - EXPECT_FALSE(modifier.getMaxBuildingBonus("building_port")); - EXPECT_FALSE(modifier.getMaxBuildingBonus("building_naval_base")); - EXPECT_TRUE(modifier.getBuildingGroupModifiersMap().empty()); - EXPECT_TRUE(modifier.getBuildingModifiersMap().empty()); - EXPECT_TRUE(modifier.getGoodsModifiersMap().empty()); -} - -TEST(V3World_StateModifierTests, InfrastructureBonusIsSet) -{ - std::stringstream input; - input << "\ticon = \"gfx/ignore/me.dds\"\n"; - input << "\tmodifier = {\n"; - input << "\t\tstate_infrastructure_add = 10\n"; - input << "\t}\n"; - - V3::StateModifier modifier; - modifier.loadStateModifier(input); - - EXPECT_EQ(10, modifier.getInfrastructureBonus()); -} - -TEST(V3World_StateModifierTests, InfrastructureModifierIsSet) -{ - std::stringstream input; - input << "\ticon = \"gfx/ignore/me.dds\"\n"; - input << "\tmodifier = {\n"; - input << "\t\tstate_infrastructure_mult = -0.4\n"; - input << "\t}\n"; - - V3::StateModifier modifier; - modifier.loadStateModifier(input); - - EXPECT_EQ(-0.4, modifier.getInfrastructureMult()); -} - -TEST(V3World_StateModifierTests, MaxBonusesAreSet) -{ - std::stringstream input; - input << "\ticon = \"gfx/ignore/me.dds\"\n"; - input << "\tmodifier = {\n"; - input << "\t\tstate_building_port_max_level_add = 2\n"; - input << "\t\tstate_building_naval_base_max_level_add = 20\n"; - input << "\t}\n"; - - V3::StateModifier modifier; - modifier.loadStateModifier(input); - - EXPECT_EQ(2, modifier.getMaxBuildingBonus("building_port")); - EXPECT_EQ(20, modifier.getMaxBuildingBonus("building_naval_base")); -} - -TEST(V3World_StateModifierTests, BuildingGroupModifiersAreSet) -{ - std::stringstream input; - input << "\ticon = \"gfx/ignore/me.dds\"\n"; - input << "\tmodifier = {\n"; - input << "\t\tbuilding_group_bg_agri_throughput_mult = 0.2\n"; - input << "\t\tbuilding_group_bg_fish_throughput_mult = 0.3\n"; - input << "\t}\n"; - - V3::StateModifier modifier; - modifier.loadStateModifier(input); - - EXPECT_DOUBLE_EQ(0.2, modifier.getBuildingGroupModifier("bg_agri", V3::BuildingGroups()).value()); - EXPECT_DOUBLE_EQ(0.3, modifier.getBuildingGroupModifier("bg_fish", V3::BuildingGroups()).value()); -} - -TEST(V3World_StateModifierTests, BuildingModifiersAreSet) -{ - std::stringstream input; - input << "\ticon = \"gfx/ignore/me.dds\"\n"; - input << "\tmodifier = {\n"; - input << "\t\tbuilding_house_throughput_mult = 0.2\n"; - input << "\t\tbuilding_factory_throughput_mult = 0.3\n"; - input << "\t}\n"; - - V3::StateModifier modifier; - modifier.loadStateModifier(input); - - EXPECT_DOUBLE_EQ(0.2, modifier.getBuildingModifier("building_house").value()); - EXPECT_DOUBLE_EQ(0.3, modifier.getBuildingModifier("building_factory").value()); -} - -TEST(V3World_StateModifierTests, GoodsModifiersAreSet) -{ - std::stringstream input; - input << "\ticon = \"gfx/ignore/me.dds\"\n"; - input << "\tmodifier = {\n"; - input << "\t\tbuilding_output_lime_mult = 0.2\n"; - input << "\t\tbuilding_output_coconut_mult = 0.3\n"; - input << "\t}\n"; - - V3::StateModifier modifier; - modifier.loadStateModifier(input); - - EXPECT_DOUBLE_EQ(0.2, modifier.getGoodsModifier("building_output_lime").value()); - EXPECT_DOUBLE_EQ(0.3, modifier.getGoodsModifier("building_output_coconut").value()); -} - -TEST(V3World_StateModifierTests, RegexDontCollide) -{ - std::stringstream input; - input << "\ticon = \"gfx/ignore/me.dds\"\n"; - input << "\tmodifier = {\n"; - input << "\t\tbuilding_group_bg_fish_throughput_mult = 0.4\n"; - input << "\t\tbuilding_output_coconut_mult = 0.3\n"; - input << "\t\tbuilding_house_throughput_mult = 0.2\n"; - input << "\t}\n"; - - V3::StateModifier modifier; - modifier.loadStateModifier(input); - - EXPECT_DOUBLE_EQ(0.2, modifier.getBuildingModifier("building_house").value()); - EXPECT_DOUBLE_EQ(0.3, modifier.getGoodsModifier("building_output_coconut").value()); - EXPECT_DOUBLE_EQ(0.4, modifier.getBuildingGroupModifier("bg_fish", V3::BuildingGroups()).value()); -} - -TEST(V3World_StateModifierTests, GettingBuildingGroupDataTravelsHeirarchy) -{ - std::stringstream input; - input << "\ticon = \"gfx/ignore/me.dds\"\n"; - input << "\tmodifier = {\n"; - input << "\t\tbuilding_group_bg_manufacturing_throughput_mult = 0.2\n"; - input << "\t}\n"; - - V3::StateModifier modifier; - modifier.loadStateModifier(input); - - V3::BuildingGroupLoader buildingGroupLoader; - buildingGroupLoader.loadBuildingGroups(modFS); - auto buildingGroups = buildingGroupLoader.getBuildingGroups(); - - EXPECT_DOUBLE_EQ(0.2, modifier.getBuildingGroupModifier("bg_light_industry", buildingGroups).value_or(0)); -} - -TEST(V3World_StateModifierTests, GetAllBonusesCombinesLikeBonuses) -{ - std::stringstream input; - input << "\ticon = \"gfx/ignore/me.dds\"\n"; - input << "\tmodifier = {\n"; - input << "\t\tbuilding_group_bg_manufacturing_throughput_mult = 0.2\n"; - input << "\t\tbuilding_group_bg_fish_throughput_mult = 0.4\n"; - input << "\t\tbuilding_group_bg_coconut_throughput_mult = -0.1\n"; - input << "\t\tbuilding_output_lime_mult = 0.1\n"; - input << "\t\tbuilding_output_coconut_mult = 0.2\n"; - input << "\t}\n"; - - V3::StateModifier modifier; - modifier.loadStateModifier(input); - - EXPECT_DOUBLE_EQ(0.5, V3::StateModifier::getAllBonuses(modifier.getBuildingGroupModifiersMap())); - EXPECT_DOUBLE_EQ(0, V3::StateModifier::getAllBonuses(modifier.getBuildingModifiersMap())); - EXPECT_DOUBLE_EQ(0.3, V3::StateModifier::getAllBonuses(modifier.getGoodsModifiersMap())); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/StateTests.cpp b/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/StateTests.cpp deleted file mode 100644 index ca7ac03..0000000 --- a/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/StateTests.cpp +++ /dev/null @@ -1,455 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/Province.h" -#include "ClayManager/State/State.h" -#include "ClayManager/State/SubState.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_StateTests, nameCanBeSetAndRetrieved) -{ - V3::State state; - - EXPECT_EQ(std::string(), state.getName()); - state.setStateName("test_name"); - EXPECT_EQ("test_name", state.getName()); -} - -TEST(V3World_StateTests, stateCanInitializeProvinces) -{ - std::stringstream input; - input << "id = 3002\n"; - input << "provinces = { \"x112233\" \"x445566\"}\n "; - V3::State state; - state.loadState(input); - - EXPECT_EQ(2, state.getProvinces().size()); - EXPECT_TRUE(state.containsProvince("x112233")); - EXPECT_TRUE(state.containsProvince("x445566")); - EXPECT_FALSE(state.containsProvince("x778899")); -} - -TEST(V3World_StateTests, provinceNamesAreUppercased) -{ - std::stringstream input; - input << "provinces = { \"xabcdef\" }\n "; - V3::State state; - state.loadState(input); - - EXPECT_TRUE(state.containsProvince("xABCDEF")); -} - -TEST(V3World_StateTests, provincesCanBeRequisitioned) -{ - std::stringstream input; - input << "provinces = { \"xabcdef\" }\n "; - V3::State state; - state.loadState(input); - - const auto& province = state.getProvince("xABCDEF"); - - EXPECT_EQ("xABCDEF", province->getName()); -} - -TEST(V3World_StateTests, InvalidProvinceRequestReturnsNullptr) -{ - std::stringstream input; - input << "provinces = { \"xabcdef\" }\n "; - V3::State state; - state.loadState(input); - - const auto& province = state.getProvince("x111111"); - - EXPECT_EQ(nullptr, province); -} - -TEST(V3World_StateTests, invalidProvinceLengthNamesAreUppercasedAndObjected) -{ - std::stringstream input; - input << "provinces = { \"x12345\" \"x1234567\" \"0x123456\" }\n "; - V3::State state; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - state.loadState(input); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Loading province X12345 in unknown format!)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Loading province X1234567 in unknown format!)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Loading province 0X123456 in unknown format!)")); - - std::cout.rdbuf(cout_buffer); -} - - -TEST(V3World_StateTests, primeProvincesGetFlagged) -{ - std::stringstream input; - input << "id = 3002\n"; - input << "provinces = { \"x112233\" \"x445566\"}\n "; - input << "prime_land = { \"x445566\"}\n "; - V3::State state; - state.loadState(input); - - const auto& province1 = state.getProvinces().at("x112233"); - const auto& province2 = state.getProvinces().at("x445566"); - - EXPECT_FALSE(province1->isPrime()); - EXPECT_TRUE(province2->isPrime()); -} - - -TEST(V3World_StateTests, primeProvinceNamesAreUppercasedBeforeMatching) -{ - std::stringstream input; - input << "provinces = { \"xABCDEF\" }\n "; - input << "prime_land = { \"xabcdef\"}\n "; - V3::State state; - state.loadState(input); - - const auto& province1 = state.getProvinces().at("xABCDEF"); - EXPECT_TRUE(province1->isPrime()); -} - -TEST(V3World_StateTests, invalidPrimeProvinceLengthNamesAreUppercasedAndObjected) -{ - std::stringstream input; - input << "provinces = { \"x12345\" \"x1234567\" \"0x123456\" }\n "; - input << "prime_land = { \"x12345\" \"x1234567\" \"0x123456\" }\n "; - V3::State state; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - state.loadState(input); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Encountered prime province X12345 in unknown format!)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Encountered prime province X1234567 in unknown format!)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Encountered prime province 0X123456 in unknown format!)")); - - std::cout.rdbuf(cout_buffer); -} - -TEST(V3World_StateTests, excessPrimeProvincesAreSimplyIgnored) -{ - std::stringstream input; - input << "provinces = { \"x123456\" }\n "; - input << "prime_land = { \"x123456\" \"x123457\" \"x123458\" }\n "; - V3::State state; - state.setStateName("test"); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - state.loadState(input); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Prime province x123457 isn't defined in the state test! Ignoring.)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Prime province x123458 isn't defined in the state test! Ignoring.)")); - - std::cout.rdbuf(cout_buffer); - - const auto& province1 = state.getProvinces().at("x123456"); - EXPECT_TRUE(province1->isPrime()); - - EXPECT_FALSE(state.getProvinces().contains("x123457")); - EXPECT_FALSE(state.getProvinces().contains("x123458")); -} - -TEST(V3World_StateTests, impassableProvincesGetFlagged) -{ - std::stringstream input; - input << "id = 3002\n"; - input << "provinces = { \"x112233\" \"x445566\"}\n "; - input << "impassable = { \"x445566\"}\n "; - V3::State state; - state.loadState(input); - - const auto& province1 = state.getProvinces().at("x112233"); - const auto& province2 = state.getProvinces().at("x445566"); - - EXPECT_FALSE(province1->isImpassable()); - EXPECT_TRUE(province2->isImpassable()); -} - - -TEST(V3World_StateTests, impassableProvinceNamesAreUppercasedBeforeMatching) -{ - std::stringstream input; - input << "provinces = { \"xABCDEF\" }\n "; - input << "impassable = { \"xabcdef\"}\n "; - V3::State state; - state.loadState(input); - - const auto& province1 = state.getProvinces().at("xABCDEF"); - EXPECT_TRUE(province1->isImpassable()); -} - -TEST(V3World_StateTests, invalidImpassableProvinceLengthNamesAreUppercasedAndObjected) -{ - std::stringstream input; - input << "provinces = { \"x12345\" \"x1234567\" \"0x123456\" }\n "; - input << "impassable = { \"x12345\" \"x1234567\" \"0x123456\" }\n "; - V3::State state; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - state.loadState(input); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Encountered impassable province X12345 in unknown format!)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Encountered impassable province X1234567 in unknown format!)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Encountered impassable province 0X123456 in unknown format!)")); - - std::cout.rdbuf(cout_buffer); -} - -TEST(V3World_StateTests, excessImpassableProvincesAreSimplyIgnored) -{ - std::stringstream input; - input << "provinces = { \"x123456\" }\n "; - input << "impassable = { \"x123456\" \"x123457\" \"x123458\" }\n "; - V3::State state; - state.setStateName("test"); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - state.loadState(input); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Impassable province x123457 isn't defined in the state test! Ignoring.)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Impassable province x123458 isn't defined in the state test! Ignoring.)")); - - std::cout.rdbuf(cout_buffer); - - const auto& province1 = state.getProvinces().at("x123456"); - EXPECT_TRUE(province1->isImpassable()); - - EXPECT_FALSE(state.getProvinces().contains("x123457")); - EXPECT_FALSE(state.getProvinces().contains("x123458")); -} - - -TEST(V3World_StateTests, arableLandValueSet) -{ - std::stringstream input; - input << "id = 3002\n"; - input << "provinces = { \"x112233\" }\n "; - input << "arable_land = 36\n "; - V3::State state; - - EXPECT_EQ(state.getCappedResources().find("bg_agriculture"), state.getCappedResources().end()); - state.loadState(input); - EXPECT_EQ(state.getCappedResources().at("bg_agriculture"), 36); -} - - -TEST(V3World_StateTests, cappedResourcesValueSet) -{ - std::stringstream input; - input << "id = 3002\n"; - input << "provinces = { \"x112233\" }\n "; - input << "capped_resources = { iron = 40 lead = 18 }\n "; - V3::State state; - - EXPECT_EQ(state.getCappedResources().find("iron"), state.getCappedResources().end()); - EXPECT_EQ(state.getCappedResources().find("lead"), state.getCappedResources().end()); - state.loadState(input); - EXPECT_EQ(state.getCappedResources().at("iron"), 40); - EXPECT_EQ(state.getCappedResources().at("lead"), 18); -} - -TEST(V3World_StateTests, navalExitFlagsStateAsCoastal) -{ - std::stringstream input; - input << "id = 3002\n"; - input << "provinces = { \"x112233\" \"x445566\"}\n "; - input << "impassable = { \"x445566\"}\n "; - input << "naval_exit_id = 3026\n "; - V3::State state; - - EXPECT_FALSE(state.isCoastal()); - state.loadState(input); - EXPECT_TRUE(state.isCoastal()); -} - - -TEST(V3World_StateTests, landshareAccountsForPrimeAndImpassable) -{ - std::stringstream input; - input << "id = 3002\n"; - input << "provinces = { \"x112233\" \"x112234\" \"x112235\" \"x112236\" \"x112237\" \"x445566\"}\n "; - input << "prime_land = {\"x112234\"}\n "; - input << "impassable = { \"x445566\"}\n "; - V3::State state; - - state.loadState(input); - - const auto pm = state.getProvinces(); - - const auto zeroth = std::make_shared(); - const auto first = std::make_shared(); - const auto second = std::make_shared(); - zeroth->setProvinces(std::map>{{"x112233", pm.at("x112233")}, {"x112234", pm.at("x112234")}}); - first->setProvinces(std::map>{{"x112235", pm.at("x112235")}, {"x112236", pm.at("x112236")}}); - second->setProvinces(std::map>{{"x112237", pm.at("x112237")}, {"x112234", pm.at("x445566")}}); - - state.addSubState(zeroth); - state.addSubState(first); - state.addSubState(second); - - state.distributeLandshares(); - - const auto& substates = state.getSubStates(); - EXPECT_DOUBLE_EQ(substates[0]->getLandshare(), 6.0 / 9); - EXPECT_DOUBLE_EQ(substates[1]->getLandshare(), 2.0 / 9); - EXPECT_DOUBLE_EQ(substates[2]->getLandshare(), 1.0 / 9); -} - -TEST(V3World_StateTests, distributeResourcesTruncatesDoubles) -{ - std::stringstream input; - input << "id = 3002\n"; - input << "provinces = { \"x112233\" \"x112234\" \"x112235\" \"x112236\" \"x112237\" \"x445566\"}\n "; - input << "prime_land = {\"x112234\"}\n "; - input << "impassable = { \"x445566\"}\n "; - input << "arable_land = 36\n "; - input << "arable_resources = { rice wheat }\n"; - input << "capped_resources = { iron = 53 }\n "; - V3::State state; - - state.loadState(input); - - const auto zeroth = std::make_shared(); - const auto first = std::make_shared(); - const auto second = std::make_shared(); - - zeroth->setLandshare(5.0 / 10); - first->setLandshare(3.0 / 10); - second->setLandshare(3.8 / 9); - - state.addSubState(zeroth); - state.addSubState(first); - state.addSubState(second); - - state.distributeResources(); - - const auto& substates = state.getSubStates(); - EXPECT_EQ(substates[0]->getResource("bg_agriculture"), 18); - EXPECT_EQ(substates[1]->getResource("bg_agriculture"), 10); - EXPECT_EQ(substates[2]->getResource("bg_agriculture"), 15); - - EXPECT_EQ(substates[0]->getResource("iron"), 26); - EXPECT_EQ(substates[1]->getResource("iron"), 15); - EXPECT_EQ(substates[2]->getResource("iron"), 22); -} - -TEST(V3World_StateTests, StateSeasCanBePinged) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - - const auto& state1 = clayManager.getStates().at("STATE_TEST_OCEAN1"); - const auto& state2 = clayManager.getStates().at("STATE_TEST_LAND1"); - - EXPECT_TRUE(state1->isSea()); - EXPECT_FALSE(state2->isSea()); -} - -TEST(V3World_StateTests, StateLakesCanBePinged) -{ - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - - const auto& state1 = clayManager.getStates().at("STATE_TEST_OCEAN1"); - const auto& state2 = clayManager.getStates().at("STATE_TEST_LAKE"); - const auto& state3 = clayManager.getStates().at("STATE_TEST_LAND1"); - - EXPECT_FALSE(state1->isLake()); - EXPECT_TRUE(state2->isLake()); - EXPECT_FALSE(state3->isLake()); -} - -TEST(V3World_StateTests, stateCanDetectUnassignedProvinces) -{ - std::stringstream input; - input << "provinces = { x000001 x000002 x000003 }\n "; - V3::State state; - state.loadState(input); - - // assign some provinces to substates. - const auto prov1 = state.getProvinces().at("x000001"); - const auto prov2 = state.getProvinces().at("x000002"); - - const auto sub1 = std::make_shared(); - sub1->setProvinces({std::pair("x000001", prov1)}); - - const auto sub2 = std::make_shared(); - sub2->setProvinces({std::pair("x000002", prov2)}); - - state.addSubState(sub1); - state.addSubState(sub2); - - EXPECT_TRUE(state.hasUnassignedProvinces()); -} - -TEST(V3World_StateTests, stateCanReturnUnassignedProvinces) -{ - std::stringstream input; - input << "provinces = { x000001 x000002 x000003 x000004 }\n "; - V3::State state; - state.loadState(input); - - // assign some provinces to substates. - const auto prov1 = state.getProvinces().at("x000001"); - const auto prov2 = state.getProvinces().at("x000002"); - - const auto sub1 = std::make_shared(); - sub1->setProvinces({std::pair("x000001", prov1)}); - - const auto sub2 = std::make_shared(); - sub2->setProvinces({std::pair("x000002", prov2)}); - - state.addSubState(sub1); - state.addSubState(sub2); - - ASSERT_EQ(2, state.getUnassignedProvinces().size()); - EXPECT_EQ("x000003", state.getUnassignedProvinces().at("x000003")->getName()); - EXPECT_EQ("x000004", state.getUnassignedProvinces().at("x000004")->getName()); -} - -TEST(V3World_StateTests, stateCanSumItsPops) -{ - V3::State state; - const auto sub1 = std::make_shared(); - const auto sub2 = std::make_shared(); - V3::SubStatePops somePops; - somePops.setPops({V3::Pop("a", "A", "", 10), V3::Pop("a", "A", "", 30)}); - sub1->setSubStatePops(somePops); - state.addSubState(sub1); - state.addSubState(sub2); - - EXPECT_EQ(40, state.getStatePopCount()); -} - -TEST(V3World_StateTests, stateCanSumItsWeights) -{ - V3::State state; - const auto sub1 = std::make_shared(); - const auto sub2 = std::make_shared(); - sub1->setWeight(256.0); - state.addSubState(sub1); - state.addSubState(sub2); - - EXPECT_EQ(256.0, state.getTotalSubStateWeight()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/SubStateTests.cpp b/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/SubStateTests.cpp deleted file mode 100644 index 6e98e44..0000000 --- a/EU5ToVic3Tests/V3WorldTests/ClayManagerTests/StateTests/SubStateTests.cpp +++ /dev/null @@ -1,430 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/Province.h" -#include "ClayManager/State/State.h" -#include "ClayManager/State/StateModifier.h" -#include "ClayManager/State/SubState.h" -#include "CultureLoader/CultureLoader.h" -#include "Loaders/TechLoader/TechLoader.h" -#include "Mappers/CultureMapper/CultureMapper.h" -#include "Mappers/ReligionMapper/ReligionMapper.h" -#include "PoliticalManager/Country/Country.h" -#include "ReligionLoader/ReligionLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_SubStateTests, OwnerTagCanBeSetAndRetrieved) -{ - V3::SubState subState; - - EXPECT_FALSE(subState.getOwnerTag()); - - const auto owner = std::make_shared(); - owner->setTag("AAA"); - subState.setOwner(owner); - - EXPECT_EQ("AAA", subState.getOwnerTag()); -} - -TEST(V3World_SubStateTests, HomeStateNameCanBeSetAndRetrieved) -{ - V3::SubState subState; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - auto name = subState.getHomeStateName(); - std::cout.rdbuf(cout_buffer); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] Attempted to access the name of a nullptr state from a substate. Returning empty name.)")); - EXPECT_TRUE(name.empty()); - - const auto state = std::make_shared(); - state->setStateName("TEST_NAME"); - subState.setHomeState(state); - - name = subState.getHomeStateName(); - - EXPECT_EQ("TEST_NAME", name); -} - -TEST(V3World_SubStateTests, SubStateCanConvertDemograhics) -{ - V3::SubState subState; - auto state = std::make_shared(); - state->setStateName("STATE_TEST_LAND1"); - subState.setHomeState(state); - const auto owner = std::make_shared(); - owner->setTag("AAA"); - subState.setOwner(owner); - - // let's make some source data. - auto ratio = EU4::PopRatio("culture4", "anglican"); - V3::SourceProvinceData data; - data.popRatios.push_back(ratio); - subState.setSourceProvinceData({std::pair(data, 1)}); - - // prep mappers. - V3::ClayManager clayManager; - - mappers::ReligionMapper religionMapper; - religionMapper.loadMappingRules("TestFiles/configurables/religion_map.txt"); - // link = { vic3 = protestant eu4 = protestant eu4 = reformed eu4 = anglican } <- - - mappers::CultureMapper cultureMapper; - cultureMapper.loadMappingRules("TestFiles/configurables/culture_map.txt"); - // link = { vic3 = vculture4 eu4 = culture4 religion = religion_2 owner = TAG } - // link = {vic3 = vculture5 eu4 = culture4 religion = religion_2} - // link = {vic3 = vculture6 eu4 = culture4} <- - - EU4::CultureLoader cultureLoader; - EU4::ReligionLoader religionLoader; - - subState.convertDemographics(clayManager, cultureMapper, religionMapper, cultureLoader, religionLoader); - - ASSERT_EQ(1, subState.getDemographics().size()); - auto demo = subState.getDemographics()[0]; - EXPECT_EQ("vculture6", demo.culture); - EXPECT_EQ("protestant", demo.religion); - EXPECT_EQ(1, demo.upperRatio); - EXPECT_EQ(1, demo.middleRatio); - EXPECT_EQ(1, demo.lowerRatio); -} - -TEST(V3World_SubStateTests, SubStateCanGeneratePopsFromDemographics) -{ - V3::SubState subState; - V3::Demographic demo1; - demo1.culture = "cul1"; - demo1.religion = "rel1"; - demo1.upperRatio = 0.15; // total ratio sum 0.3 - demo1.middleRatio = 0.075; - demo1.lowerRatio = 0.075; - - V3::Demographic demo2; - demo2.culture = "cul2"; - demo2.religion = "rel2"; - demo2.upperRatio = 0.1; // total ratio sum 0.7 - demo2.middleRatio = 0.1; - demo2.lowerRatio = 0.5; - - subState.setDemographics({demo1, demo2}); - - subState.generatePops(1000, 200); - - const auto& pops = subState.getSubStatePops().getPops(); - ASSERT_EQ(4, pops.size()); - const auto& pop1 = pops[0]; - const auto& pop2 = pops[1]; - const auto& pop3 = pops[2]; - const auto& pop4 = pops[3]; - - EXPECT_EQ("cul1", pop1.getCulture()); - EXPECT_EQ("rel1", pop1.getReligion()); - EXPECT_TRUE(pop1.getType().empty()); - EXPECT_EQ(240, pop1.getSize()); - - EXPECT_EQ("cul1", pop2.getCulture()); - EXPECT_EQ("rel1", pop2.getReligion()); - EXPECT_EQ("slaves", pop2.getType()); - EXPECT_EQ(60, pop2.getSize()); - - EXPECT_EQ("cul2", pop3.getCulture()); - EXPECT_EQ("rel2", pop3.getReligion()); - EXPECT_TRUE(pop3.getType().empty()); - EXPECT_EQ(560, pop3.getSize()); - - EXPECT_EQ("cul2", pop4.getCulture()); - EXPECT_EQ("rel2", pop4.getReligion()); - EXPECT_EQ("slaves", pop4.getType()); - EXPECT_EQ(140, pop4.getSize()); -} - -TEST(V3World_SubStateTests, SubStateCanReturnPrimaryCulture) -{ - V3::SubState subState; - V3::Demographic demo1; - demo1.culture = "cul1"; - demo1.religion = "rel1"; - demo1.upperRatio = 0.15; - demo1.middleRatio = 0.075; - demo1.lowerRatio = 0.075; - - V3::Demographic demo2; - demo2.culture = "cul2"; - demo2.religion = "rel2"; - demo2.upperRatio = 0.1; - demo2.middleRatio = 0.1; - demo2.lowerRatio = 0.5; - - subState.setDemographics({demo1, demo2}); - - subState.generatePops(1000, 0); - - const auto& pops = subState.getSubStatePops().getPops(); - ASSERT_EQ(2, pops.size()); - const auto& pop1 = pops[0]; - const auto& pop2 = pops[1]; - - EXPECT_EQ("cul1", pop1.getCulture()); - EXPECT_EQ(300, pop1.getSize()); - - EXPECT_EQ("cul2", pop2.getCulture()); - EXPECT_EQ(700, pop2.getSize()); // <- primary culture - - ASSERT_TRUE(subState.getPrimaryCulture()); - EXPECT_EQ("cul2", *subState.getPrimaryCulture()); -} - -TEST(V3World_SubStateTests, SubStateGeneratesNoPopsForZeroPopsize) -{ - V3::SubState subState; - V3::Demographic demo1; - demo1.culture = "cul1"; - demo1.religion = "rel1"; - demo1.upperRatio = 0.15; - demo1.middleRatio = 0.075; - demo1.lowerRatio = 0.075; - - V3::Demographic demo2; - demo2.culture = "cul2"; - demo2.religion = "rel2"; - demo2.upperRatio = 0.1; - demo2.middleRatio = 0.1; - demo2.lowerRatio = 0.5; - - subState.setDemographics({demo1, demo2}); - - subState.generatePops(0, 0); - - const auto& pops = subState.getSubStatePops().getPops(); - ASSERT_EQ(0, pops.size()); - - ASSERT_FALSE(subState.getPrimaryCulture()); -} - -TEST(V3World_SubStateTests, TerrainFrequencyNormalizes) -{ - auto substate = V3::SubState(); - - auto p0 = std::make_shared(); - p0->setName("x112233"); - p0->setTerrain("desert"); - auto p1 = std::make_shared(); - p1->setName("x445566"); - p1->setTerrain("plains"); - auto p2 = std::make_shared(); - p2->setName("x778899"); - p2->setTerrain("plains"); - - const V3::ProvinceMap provinces{{p0->getName(), p0}, {p1->getName(), p1}, {p2->getName(), p2}}; - substate.setProvinces(provinces); - - EXPECT_DOUBLE_EQ(1.0 / 3, substate.getTerrainFrequency("desert")); - EXPECT_DOUBLE_EQ(2.0 / 3, substate.getTerrainFrequency("plains")); -} - -TEST(V3World_SubStateTests, coastalFlagCountsAsTerrain) -{ - auto substate = V3::SubState(); - - auto p0 = std::make_shared(); - p0->setName("x112233"); - p0->setTerrain("desert"); - p0->setCoastal(); - auto p1 = std::make_shared(); - p1->setName("x445566"); - p1->setTerrain("plains"); - auto p2 = std::make_shared(); - p2->setName("x778899"); - p2->setTerrain("plains"); - - const V3::ProvinceMap provinces{{p0->getName(), p0}, {p1->getName(), p1}, {p2->getName(), p2}}; - substate.setProvinces(provinces); - - EXPECT_DOUBLE_EQ(0.5 / 3, substate.getTerrainFrequency("desert")); - EXPECT_DOUBLE_EQ(2.0 / 3, substate.getTerrainFrequency("plains")); - EXPECT_DOUBLE_EQ(0.5 / 3, substate.getTerrainFrequency("coastal")); -} - -TEST(V3World_SubStateTests, InfrastructureCalculationIsolateStateModifieres) -{ - auto country = std::make_shared(); - auto state = std::make_shared(); - auto substate = V3::SubState(); - - substate.setOwner(country); - substate.setHomeState(state); - substate.setIncorporated(true); - - std::stringstream input; - input << "id = 3002\n"; - input << "provinces = { \"x112233\" }\n"; - input << "traits = { \"trait0\" \"trait1\"\n }"; - - state->loadState(input); - - std::stringstream modifierInput0; - modifierInput0 << "\tmodifier = {\n"; - modifierInput0 << "\t\tstate_infrastructure_add = 10\n"; - modifierInput0 << "\t}\n"; - - auto modifier0 = std::make_shared(); - modifier0->loadStateModifier(modifierInput0); - modifier0->setName("trait0"); - - std::stringstream modifierInput1; - modifierInput1 << "\tmodifier = {\n"; - modifierInput1 << "\t\tstate_infrastructure_mult = -0.2\n"; - modifierInput1 << "\t}\n"; - - auto modifier1 = std::make_shared(); - modifier1->loadStateModifier(modifierInput1); - modifier1->setName("trait1"); - - substate.calculateInfrastructure(V3::StateModifiers{{modifier0->getName(), modifier0}, {modifier1->getName(), modifier1}}, {}); - - EXPECT_DOUBLE_EQ(10.4, substate.getInfrastructure()); -} - -TEST(V3World_SubStateTests, InfrastructureCalculationIsolatePopFactor) -{ - // Setup Country - auto country = std::make_shared(); - auto state = std::make_shared(); - - V3::ProcessedData data; - data.techs.emplace("tech_1"); - country->setProcessedData(data); - - auto substate0 = V3::SubState(); - auto substate1 = V3::SubState(); - - substate0.setOwner(country); - substate0.setHomeState(state); - substate0.setIncorporated(true); - substate1.setOwner(country); - substate1.setHomeState(state); - substate1.setIncorporated(true); - - V3::Pop pop0; - V3::Pop pop1; - pop0.setSize(10000); - pop1.setSize(10000000); - - substate0.addPop(pop0); - substate1.addPop(pop1); - - - // Setup Loader - V3::TechLoader techLoader; - techLoader.loadTechs(modFS); - - substate0.calculateInfrastructure({}, techLoader.getTechs()); - substate1.calculateInfrastructure({}, techLoader.getTechs()); - - EXPECT_DOUBLE_EQ(3.2, substate0.getInfrastructure()); - EXPECT_DOUBLE_EQ(43, substate1.getInfrastructure()); -} - - -TEST(V3World_SubStateTests, InfrastructureCalculationFactorsFromPrivateVariables) -{ - auto country = std::make_shared(); - auto state = std::make_shared(); - auto substate = V3::SubState(); - - substate.setOwner(country); - substate.setHomeState(state); - substate.setIncorporated(true); - - substate.calculateInfrastructure(V3::StateModifiers{}, {}); - EXPECT_DOUBLE_EQ(3, substate.getInfrastructure()); - - substate.setMarketCapital(); - substate.calculateInfrastructure(V3::StateModifiers{}, {}); - EXPECT_DOUBLE_EQ(3.75, substate.getInfrastructure()); - - substate.setIncorporated(false); - substate.calculateInfrastructure(V3::StateModifiers{}, {}); - EXPECT_DOUBLE_EQ(3, substate.getInfrastructure()); -} - - -TEST(V3World_SubStateTests, InfrastructureCalculationExcessNegativeModifiersCap) -{ - auto country = std::make_shared(); - auto state = std::make_shared(); - auto substate = V3::SubState(); - - substate.setOwner(country); - substate.setHomeState(state); - - std::stringstream input; - input << "id = 3002\n"; - input << "provinces = { \"x112233\" }\n"; - input << "traits = { \"trait0\" \"trait1\"\n }"; - - state->loadState(input); - - std::stringstream modifierInput0; - modifierInput0 << "\tmodifier = {\n"; - modifierInput0 << "\t\tstate_infrastructure_add = -10\n"; - modifierInput0 << "\t}\n"; - - auto modifier0 = std::make_shared(); - modifier0->loadStateModifier(modifierInput0); - modifier0->setName("trait0"); - - std::stringstream modifierInput1; - modifierInput1 << "\tmodifier = {\n"; - modifierInput1 << "\t\tstate_infrastructure_mult = -1.2\n"; - modifierInput1 << "\t}\n"; - - auto modifier1 = std::make_shared(); - modifier1->loadStateModifier(modifierInput1); - modifier1->setName("trait1"); - - substate.calculateInfrastructure(V3::StateModifiers{{modifier0->getName(), modifier0}, {modifier1->getName(), modifier1}}, {}); - - EXPECT_DOUBLE_EQ(0.0, substate.getInfrastructure()); -} - -TEST(V3World_SubStateTests, AddBuilding) -{ - auto substate = V3::SubState(); - V3::Building templateBuilding; - templateBuilding.setName("port"); - templateBuilding.setLevel(1); - - const auto building1 = std::make_shared(templateBuilding); - const auto building2 = std::make_shared(templateBuilding); - - building2->setLevel(2); - - substate.addBuilding(building1); - substate.addBuilding(building2); - - EXPECT_EQ("port", substate.getBuildings()[0]->getName()); - EXPECT_EQ(1, substate.getBuildings()[0]->getLevel()); - EXPECT_EQ("port", substate.getBuildings()[1]->getName()); - EXPECT_EQ(2, substate.getBuildings()[1]->getLevel()); -} - -TEST(DISABLED_V3World_SubStateTests, WeightBuildings) -{ - auto substate = V3::SubState(); - - EXPECT_FALSE(substate.getBuildings().empty()); -} - -TEST(DISABLED_V3World_SubStateTests, CalcBuildingWeight) -{ - auto substate = V3::SubState(); - - EXPECT_FALSE(substate.getBuildings().empty()); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/BuildingGroupsTests.cpp b/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/BuildingGroupsTests.cpp deleted file mode 100644 index 5161698..0000000 --- a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/BuildingGroupsTests.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "EconomyManager/Building/BuildingGroups.h" -#include "Loaders/BuildingLoader/BuildingGroupLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_BuildingGroupsTests, GettersReturnNullOptionals) -{ - V3::BuildingGroupLoader buildingGroupLoader; - buildingGroupLoader.loadBuildingGroups(modFS); - const auto buildingGroups = buildingGroupLoader.getBuildingGroups(); - - const auto parentName = buildingGroups.tryGetParentName("not_a_key0"); - const auto infrastructureCost = buildingGroups.tryGetInfraCost("not_a_key1"); - - EXPECT_EQ(std::nullopt, parentName); - EXPECT_EQ(std::nullopt, infrastructureCost); -} - -TEST(V3World_BuildingGroupsTests, BuildingsGroupsSetHierarchyAndCost) -{ - V3::BuildingGroupLoader buildingGroupLoader; - buildingGroupLoader.loadBuildingGroups(modFS); - const auto buildingGroups = buildingGroupLoader.getBuildingGroups(); - - EXPECT_FALSE(buildingGroups.tryGetParentName("bg_manufacturing")); - EXPECT_FALSE(buildingGroups.tryGetInfraCost("bg_manufacturing")); - - EXPECT_EQ("bg_manufacturing", buildingGroups.tryGetParentName("bg_light_industry").value()); - EXPECT_DOUBLE_EQ(2, buildingGroups.tryGetInfraCost("bg_light_industry").value()); - - EXPECT_EQ("bg_mega_industry", buildingGroups.tryGetParentName("bg_giga_industry").value()); - EXPECT_DOUBLE_EQ(1, buildingGroups.tryGetInfraCost("bg_giga_industry").value()); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/BuildingTests.cpp b/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/BuildingTests.cpp deleted file mode 100644 index 26377ff..0000000 --- a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/BuildingTests.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include "EconomyManager/Building/Building.h" -#include "Loaders/DefinesLoader/BuildingScriptValuesLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_BuildingTests, NameCanBeSet) -{ - V3::Building building; - - EXPECT_TRUE(building.getName().empty()); - - building.setName("name"); - - EXPECT_EQ("name", building.getName()); -} - -TEST(V3World_SubStateTests, DefaultsDefaultToDefault) -{ - std::map emptyCostTiers; - std::stringstream input; - - V3::Building building; - building.loadBuilding(input, emptyCostTiers); - - EXPECT_TRUE(building.getName().empty()); - EXPECT_TRUE(building.isBuildable()); - EXPECT_FALSE(building.isCappedByGov()); - EXPECT_TRUE(building.getUnlockingTechs().empty()); - EXPECT_TRUE(building.getBuildingGroup().empty()); - EXPECT_EQ(50, building.getConstructionCost()); -} - -TEST(V3World_BuildingTests, ParserLoadsInValues) -{ - V3::BuildingScriptValuesLoader buildingScriptValuesLoader; - buildingScriptValuesLoader.loadBuildingScriptValues(modFS); - const auto& costTiers = buildingScriptValuesLoader.getBuildingCostConstants(); - - std::stringstream input; - input << "\tbuilding_group = group_one\n"; - input << "\tbuildable = no\n"; - input << "\thas_max_level = yes\n"; - input << "\tunlocking_technologies = { fire mistake }\n"; - input << "\tproduction_method_groups = { pmg_group_base pmg_group_secondary }\n"; - input << "\trequired_construction = construction_cost_medium\n"; - - V3::Building building; - building.loadBuilding(input, costTiers); - - EXPECT_THAT("group_one", building.getBuildingGroup()); - EXPECT_FALSE(building.isBuildable()); - EXPECT_TRUE(building.isCappedByGov()); - EXPECT_THAT(building.getUnlockingTechs(), testing::UnorderedElementsAre("fire", "mistake")); - EXPECT_THAT(building.getPMGroups(), testing::UnorderedElementsAre("pmg_group_base", "pmg_group_secondary")); - EXPECT_EQ(300, building.getConstructionCost()); -} - -TEST(V3World_BuildingTests, LiteralConstructionCostIsParsed) -{ - V3::BuildingScriptValuesLoader buildingScriptValuesLoader; - buildingScriptValuesLoader.loadBuildingScriptValues(modFS); - const auto& costTiers = buildingScriptValuesLoader.getBuildingCostConstants(); - - std::stringstream input; - input << "\tbuilding_group = group_one\n"; - input << "\tunlocking_technologies = { fire }\n"; - input << "\tproduction_method_groups = { pmg_group_base pmg_group_secondary }\n"; - input << "\trequired_construction = 327\n"; - - V3::Building building; - building.loadBuilding(input, costTiers); - - EXPECT_THAT("group_one", building.getBuildingGroup()); - EXPECT_THAT(building.getUnlockingTechs(), testing::UnorderedElementsAre("fire")); - EXPECT_THAT(building.getPMGroups(), testing::UnorderedElementsAre("pmg_group_base", "pmg_group_secondary")); - EXPECT_EQ(327, building.getConstructionCost()); -} - -TEST(V3World_BuildingTests, UnkownConstructionCostIsCaught) -{ - V3::BuildingScriptValuesLoader buildingScriptValuesLoader; - buildingScriptValuesLoader.loadBuildingScriptValues(modFS); - const auto& costTiers = buildingScriptValuesLoader.getBuildingCostConstants(); - - std::stringstream input; - input << "\tbuilding_group = group_one\n"; - input << "\tunlocking_technologies = { fire }\n"; - input << "\tproduction_method_groups = { pmg_group_base pmg_group_secondary }\n"; - input << "\trequired_construction = a_lot\n"; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - V3::Building building; - building.loadBuilding(input, costTiers); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([ERROR] Failed to understand building cost a_lot:)")); - - EXPECT_THAT("group_one", building.getBuildingGroup()); - EXPECT_THAT(building.getUnlockingTechs(), testing::UnorderedElementsAre("fire")); - EXPECT_THAT(building.getPMGroups(), testing::UnorderedElementsAre("pmg_group_base", "pmg_group_secondary")); - EXPECT_EQ(50, building.getConstructionCost()); - - std::cout.rdbuf(cout_buffer); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/ProductionMethodGroupTests.cpp b/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/ProductionMethodGroupTests.cpp deleted file mode 100644 index ab3685e..0000000 --- a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/ProductionMethodGroupTests.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "EconomyManager/Building/ProductionMethods/ProductionMethodGroup.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_ProductionMethodGroupsTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - - V3::ProductionMethodGroup PMGroup; - PMGroup.loadProductionMethodGroup(input); - - EXPECT_TRUE(PMGroup.getPMs().empty()); -} - -TEST(V3World_ProductionMethodGroupsTests, ProductionMethodGroupLoadsPMList) -{ - std::stringstream input; - input << "\tai_selection = most_productive\n"; - input << "\tproduction_methods = { pm_one pm_two }\n"; - - V3::ProductionMethodGroup PMGroup; - PMGroup.loadProductionMethodGroup(input); - - EXPECT_THAT(PMGroup.getPMs(), testing::UnorderedElementsAre("pm_one", "pm_two")); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/ProductionMethodTests.cpp b/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/ProductionMethodTests.cpp deleted file mode 100644 index f37d016..0000000 --- a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/BuildingTests/ProductionMethodTests.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "EconomyManager/Building/ProductionMethods/ProductionMethod.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_ProductionMethodTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - - V3::ProductionMethod PM; - PM.loadProductionMethod(input); - - EXPECT_TRUE(PM.getUnlockingTechs().empty()); - EXPECT_EQ(0, PM.getBureaucracy()); - EXPECT_TRUE(PM.getEmployment().empty()); - EXPECT_TRUE(PM.getName().empty()); -} - -TEST(V3World_ProductionMethodTests, ProductionMethodLoadsPMData) -{ - std::stringstream input; - - input << "\tunlocking_technologies = { fire }\n"; - input << "\tcountry_modifiers = { workforce_scaled = { country_bureaucracy_add = 35 } }\n"; - input << "\tbuilding_modifiers = { level_scaled = { building_employment_clerks_add = 4000 } }\n"; - input << "\tbuilding_modifiers = { level_scaled = { building_employment_mounties_add = 50 } }\n"; - - V3::ProductionMethod PM; - PM.loadProductionMethod(input); - - EXPECT_THAT(PM.getUnlockingTechs(), testing::UnorderedElementsAre("fire")); - EXPECT_EQ(35, PM.getBureaucracy()); - EXPECT_THAT(PM.getEmployment(), testing::UnorderedElementsAre(std::make_pair("clerks", 4000), std::make_pair("mounties", 50))); -} - -TEST(V3World_ProductionMethodTests, DuplicatesOverride) -{ - std::stringstream input; - - input << "\tcountry_modifiers = { workforce_scaled = { country_bureaucracy_add = 35 } }\n"; - input << "\tcountry_modifiers = { workforce_scaled = { country_bureaucracy_add = 5 } }\n"; - input << "\tbuilding_modifiers = { level_scaled = { building_employment_clerks_add = 4000 } }\n"; - input << "\tbuilding_modifiers = { level_scaled = { building_employment_clerks_add = 50 } }\n"; - - V3::ProductionMethod PM; - PM.loadProductionMethod(input); - - EXPECT_EQ(5, PM.getBureaucracy()); - EXPECT_THAT(PM.getEmployment(), testing::UnorderedElementsAre(std::make_pair("clerks", 50))); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/EconomyManagerTests.cpp b/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/EconomyManagerTests.cpp deleted file mode 100644 index 5748b9a..0000000 --- a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/EconomyManagerTests.cpp +++ /dev/null @@ -1,183 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/SubState.h" -#include "CountryManager/EU4Country.h" -#include "CountryMapper/CountryMapper.h" -#include "CultureLoader/CultureLoader.h" -#include "CultureMapper/CultureMapper.h" -#include "EconomyManager/EconomyManager.h" -#include "PoliticalManager/Country/Country.h" -#include "PopManager/PopManager.h" -#include "ProvinceManager/ProvinceManager.h" -#include "ProvinceMapper/ProvinceMapper.h" -#include "ReligionLoader/ReligionLoader.h" -#include "ReligionMapper/ReligionMapper.h" -#include "gtest/gtest.h" -#include - - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -const auto eu4FS = commonItems::ModFilesystem("TestFiles/eu4installation/", {Mod("Some mod", "TestFiles/mod/themod/")}); - -std::tuple prepManagers() -{ - EU4::DefaultMapParser defaults; - defaults.loadDefaultMap(eu4FS); - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(eu4FS); - EU4::RegionManager regionManager; - regionManager.loadRegions(eu4FS); - - std::stringstream provinceStream; - provinceStream << "-1={}\n"; // sea, no ownership - provinceStream << "-2={ owner = TA2 base_tax=10 base_production=10 base_manpower=10 culture = culture1 religion = catholic }\n"; // substate TA-2&3 - provinceStream << "-3={ owner = TA3 base_tax=1 base_production=1 base_manpower=1 culture = culture2 religion = protestant }\n"; // substate TA-2&3 - provinceStream << "-4={}\n"; // irrelevant - provinceStream << "-5={}\n"; // irrelevant - provinceStream << "-6={}\n"; // irrelevant - provinceStream << "-7={}\n"; // irrelevant - provinceStream << "-8={}\n"; // irrelevant - provinceStream << "-9={ owner = TA9 base_tax=1 base_production=1 base_manpower=1 culture = culture3 religion = anglican }\n"; // substate TA-9 - provinceStream << "-10={}\n"; // irrelevant - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provinceStream); - provinceManager.loadDefaultMapParser(defaults); - provinceManager.loadDefinitionScraper(definitions); - provinceManager.classifyProvinces(regionManager); - provinceManager.buildProvinceWeights(regionManager); - provinceManager.buildPopRatios({}, false); - - mappers::ProvinceMapper provinceMapper; - provinceMapper.loadProvinceMappings("TestFiles/configurables/province_mappings_chunks.txt"); - - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - clayManager.generateChunks(provinceMapper, provinceManager); - - std::stringstream countryStream; - const auto ta2 = std::make_shared("TA2", countryStream); - const auto ta3 = std::make_shared("TA3", countryStream); - const auto ta9 = std::make_shared("TA9", countryStream); - const std::map> countries = {{"TA2", ta2}, {"TA3", ta3}, {"TA9", ta9}}; - clayManager.unDisputeChunkOwnership(countries); - clayManager.splitChunksIntoSubStates(); - - auto countryMapper = std::make_shared(); - countryMapper->loadMappingRules("TestFiles/configurables/country_mappings.txt"); - V3::PoliticalManager politicalManager; - politicalManager.loadCountryMapper(countryMapper); - politicalManager.importEU4Countries(countries); - clayManager.assignSubStateOwnership(politicalManager.getCountries(), *countryMapper); - - return {clayManager, politicalManager}; -} - -V3::PoliticalManager prepWorld() -{ - EU4::ReligionLoader religionLoader; - religionLoader.loadReligions(eu4FS); - EU4::CultureLoader cultureLoader; - cultureLoader.loadCultures(eu4FS); - - auto [clayManager, politicalManager] = prepManagers(); - mappers::ReligionMapper relMapper; - relMapper.loadMappingRules("TestFiles/configurables/religion_map.txt"); - relMapper.expandReligionMappings(religionLoader.getAllReligions()); - - mappers::CultureMapper culMapper; - culMapper.loadMappingRules("TestFiles/configurables/culture_map.txt"); - culMapper.expandCulturalMappings(clayManager, cultureLoader, religionLoader); - - V3::PopManager popManager; - popManager.initializeVanillaPops(modFS); - popManager.initializeDWPops(modFS); - popManager.convertDemographics(clayManager, culMapper, relMapper, cultureLoader, religionLoader); - clayManager.shoveRemainingProvincesIntoSubStates(); - politicalManager.generateDecentralizedCountries(clayManager, popManager); - - popManager.generatePops(clayManager, Configuration::POPSHAPES::Vanilla, 1); - - return politicalManager; -} - -} // namespace - -TEST(V3World_EconomyManagerTests, EconomyManagerStoresOnlyCentralizedStates) -{ - V3::EconomyManager econManager; - - auto politicalManager = prepWorld(); - - EXPECT_EQ(0, econManager.getCentralizedCountries().size()); - EXPECT_EQ(5, politicalManager.getCountries().size()); - - econManager.loadCentralizedStates(politicalManager.getCountries()); - - EXPECT_EQ(2, econManager.getCentralizedCountries().size()); - EXPECT_EQ("GA2", econManager.getCentralizedCountries()[0]->getTag()); - EXPECT_EQ("GA9", econManager.getCentralizedCountries()[1]->getTag()); -} - -TEST(V3World_EconomyManagerTests, GlobalCPScalesByPopulation) -{ - auto politicalManager = prepWorld(); - - V3::EconomyManager econManager; - econManager.loadCentralizedStates(politicalManager.getCountries()); - econManager.loadMappersAndConfigs(modFS, "TestFiles/"); - - EXPECT_EQ(5500, politicalManager.getWorldPopCount()); - EXPECT_EQ(4600, V3::PoliticalManager::getCountriesPopCount(econManager.getCentralizedCountries())); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - econManager.assignCountryCPBudgets(Configuration::ECONOMY::Test, Configuration::STARTDATE::Vanilla, DatingData(), politicalManager); - - std::cout.rdbuf(cout_buffer); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([INFO] <> The world is 84% Centralized by population. Adjusting global CP values by: -14%)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"([INFO] <> The world has 1245324 CP to spend on industry.)")); -} - -TEST(DISABLED_V3World_EconomyManagerTests, GlobalCPScalesByDate) -{ - auto politicalManager = prepWorld(); - - V3::EconomyManager econManager; - econManager.loadCentralizedStates(politicalManager.getCountries()); -} - -TEST(DISBALED_V3World_EconomyManagerTests, GlobalCPDistributionTechGroup) -{ - auto politicalManager = prepWorld(); - - V3::EconomyManager econManager; - econManager.loadCentralizedStates(politicalManager.getCountries()); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - econManager.assignCountryCPBudgets(Configuration::ECONOMY::CivLevel, Configuration::STARTDATE::Vanilla, DatingData(), politicalManager); - - std::cout.rdbuf(cout_buffer); -} - -TEST(DISABLED_V3World_EconomyManagerTests, GlobalCPDistributionDev) -{ -} - -TEST(DISABLED_V3World_EconomyManagerTests, AssignSubStateCPBudgetsTechGroup) -{ -} - -TEST(DISABLED_V3World_EconomyManagerTests, AssignSubStateCPBudgetsDev) -{ -} diff --git a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/NationalBudgetTests/SectorTests.cpp b/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/NationalBudgetTests/SectorTests.cpp deleted file mode 100644 index 473c90a..0000000 --- a/EU5ToVic3Tests/V3WorldTests/EconomyManagerTests/NationalBudgetTests/SectorTests.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "CountryManager/EU4Country.h" -#include "EconomyManager/NationalBudget/Sector.h" -#include "Loaders/NationalBudgetLoader/SectorLoader.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" -#include - - -TEST(V3World_SectorTests, SectorsCanLoadFromBlueprint) -{ - std::stringstream input; - - input << "weight = 12\n"; - input << "building_barracks building_fort\n"; - input << "multiply = {value = 0.1 vic3_law = law_quality}\n"; - input << "multiply = { value = 1.5 vic3_law = law_peasant_levy }\n"; - input << "add = { value = 1 is_colony = no }\n"; - - V3::SectorLoader sectorBlueprint; - sectorBlueprint.loadSector(input); - - const auto country = std::make_shared(); - country->setSourceCountry(std::make_shared()); - V3::ProcessedData data; - data.laws.emplace("law_quality"); - data.laws.emplace("law_peasant_levy"); - data.CPBudget = 1000; - country->setProcessedData(data); - - V3::Sector sector(sectorBlueprint, *country); - - EXPECT_THAT(sector.getBuildings(), testing::UnorderedElementsAre("building_barracks", "building_fort")); - EXPECT_EQ(0, sector.getCPBudget()); - - sector.calculateBudget(10, country->getCPBudget()); // The sector for this country should have a weight of 7.8 - - EXPECT_EQ(780, sector.getCPBudget()); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/FlagCrafterTests/FlagColorLoaderTests/FlagColorLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/FlagCrafterTests/FlagColorLoaderTests/FlagColorLoaderTests.cpp deleted file mode 100644 index 5da2c3d..0000000 --- a/EU5ToVic3Tests/V3WorldTests/FlagCrafterTests/FlagColorLoaderTests/FlagColorLoaderTests.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "FlagCrafter/FlagColorLoader/FlagColorLoader.h" -#include "gtest/gtest.h" - -TEST(Mappers_FlagColorLoaderTests, flagColorsStartEmpty) -{ - std::stringstream input; - const V3::FlagColorLoader mapper; - - EXPECT_EQ(0, mapper.getNumFlagColors()); -} - -TEST(Mappers_FlagColorLoaderTests, flagColorsCanBeLoaded) -{ - V3::FlagColorLoader mapper; - mapper.loadFlagColors("TestFiles/eu4installation/common/custom_country_colors/00_custom_country_colors.txt"); - - EXPECT_EQ(3, mapper.getNumFlagColors()); -} - -TEST(Mappers_FlagColorLoaderTests, colorsCanBeRetrieved) -{ - V3::FlagColorLoader mapper; - mapper.loadFlagColors("TestFiles/eu4installation/common/custom_country_colors/00_custom_country_colors.txt"); - - const auto& color2 = mapper.getFlagColorByIndex(1); - - ASSERT_TRUE(color2); - EXPECT_EQ("= rgb { 3 4 5 }", color2->outputRgb()); -} - -TEST(Mappers_FlagColorLoaderTests, mismatchReturnsNullopt) -{ - V3::FlagColorLoader mapper; - mapper.loadFlagColors("TestFiles/eu4installation/common/custom_country_colors/00_custom_country_colors.txt"); - - const auto& color5 = mapper.getFlagColorByIndex(4); - EXPECT_EQ(std::nullopt, color5); -} diff --git a/EU5ToVic3Tests/V3WorldTests/FlagCrafterTests/FlagCrafterTests.cpp b/EU5ToVic3Tests/V3WorldTests/FlagCrafterTests/FlagCrafterTests.cpp deleted file mode 100644 index b50c93d..0000000 --- a/EU5ToVic3Tests/V3WorldTests/FlagCrafterTests/FlagCrafterTests.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include "CountryManager/EU4Country.h" -#include "FlagCrafter/FlagCrafter.h" -#include "Mappers/CountryMapper/CountryMapper.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_FlagNameLoaderTests, NoLoadedMatchFails) -{ - V3::FlagCrafter flagCrafter; - - EXPECT_FALSE(flagCrafter.getFlagsForEntity("nonsense")); -} - -TEST(V3World_FlagNameLoaderTests, DirectLoadedMatchesCanBeReturnedOnce) -{ - V3::FlagCrafter flagCrafter; - flagCrafter.loadAvailableFlags("TestFiles/configurables/blankMod/output/common/coat_of_arms/coat_of_arms/", ""); - - auto match = flagCrafter.getFlagsForEntity("AAA"); - - ASSERT_TRUE(match); - EXPECT_THAT(*match, - testing::UnorderedElementsAre(std::pair(V3::FlagCrafter::FLAGTYPE::Default, "legacy_AAA"), - std::pair(V3::FlagCrafter::FLAGTYPE::Republic, "legacy_AAA_republic"), - std::pair(V3::FlagCrafter::FLAGTYPE::Monarchy, "legacy_AAA_monarchy"), - std::pair(V3::FlagCrafter::FLAGTYPE::Fascist, "legacy_AAA_fascist"), - std::pair(V3::FlagCrafter::FLAGTYPE::Communist, "legacy_AAA_communist"))); - - match = flagCrafter.getFlagsForEntity("AAA"); - ASSERT_FALSE(match); -} - -TEST(V3World_FlagNameLoaderTests, FuzzyMatchingWorksAsLongAsThereAreCandidates) -{ - V3::FlagCrafter flagCrafter; - flagCrafter.loadAvailableFlags("TestFiles/configurables/blankMod/output/common/coat_of_arms/coat_of_arms/", ""); - - auto match = flagCrafter.getFlagsForEntity("title"); - - ASSERT_TRUE(match); - EXPECT_THAT(*match, - testing::UnorderedElementsAre(std::pair(V3::FlagCrafter::FLAGTYPE::Default, "legacy_e_title"), - std::pair(V3::FlagCrafter::FLAGTYPE::Republic, "legacy_e_title_republic"), - std::pair(V3::FlagCrafter::FLAGTYPE::Monarchy, "legacy_e_title_monarchy"), - std::pair(V3::FlagCrafter::FLAGTYPE::Fascist, "legacy_e_title_fascist"), - std::pair(V3::FlagCrafter::FLAGTYPE::Communist, "legacy_e_title_communist"))); - - match = flagCrafter.getFlagsForEntity("title"); - ASSERT_TRUE(match); - EXPECT_THAT(*match, - testing::UnorderedElementsAre(std::pair(V3::FlagCrafter::FLAGTYPE::Default, "legacy_d_title"), - std::pair(V3::FlagCrafter::FLAGTYPE::Republic, "legacy_d_title_republic"), - std::pair(V3::FlagCrafter::FLAGTYPE::Monarchy, "legacy_d_title_monarchy"), - std::pair(V3::FlagCrafter::FLAGTYPE::Fascist, "legacy_d_title_fascist"), - std::pair(V3::FlagCrafter::FLAGTYPE::Communist, "legacy_d_title_communist"))); - - match = flagCrafter.getFlagsForEntity("title"); - ASSERT_FALSE(match); -} - -TEST(V3World_FlagNameLoaderTests, FlagsCanBeAssignedViaFlagCodes) -{ - V3::FlagCrafter flagCrafter; - flagCrafter.loadAvailableFlags("TestFiles/configurables/blankMod/output/common/coat_of_arms/coat_of_arms/", ""); - - mappers::CountryMapper countryMapper; - std::stringstream countryInput; - countryInput << "link = {eu4 = TA8 flag_code = legacy_d_title}"; // <- we want TA8 to have "title" flagcode. - countryMapper.loadMappingRules(countryInput); - const auto eu4country = std::make_shared(); // make TA8. - eu4country->setTag("TA8"); - const auto v3Tag = countryMapper.assignV3TagToEU4Country(eu4country); - EXPECT_EQ("X00", v3Tag); // got a tag for V3 country. - auto country = std::make_shared(); - country->setTag(v3Tag); - - std::map> countries; - countries.emplace(v3Tag, country); - - // now assign flags. - flagCrafter.distributeAvailableFlags(countries, countryMapper, commonItems::ModFilesystem()); - - // do we have them yet? - const auto& flags = country->getFlags(); - - EXPECT_THAT(flags, - testing::UnorderedElementsAre(std::pair(V3::FlagCrafter::FLAGTYPE::Default, "legacy_d_title"), - std::pair(V3::FlagCrafter::FLAGTYPE::Republic, "legacy_d_title_republic"), - std::pair(V3::FlagCrafter::FLAGTYPE::Monarchy, "legacy_d_title_monarchy"), - std::pair(V3::FlagCrafter::FLAGTYPE::Fascist, "legacy_d_title_fascist"), - std::pair(V3::FlagCrafter::FLAGTYPE::Communist, "legacy_d_title_communist"))); -} - -TEST(V3World_FlagNameLoaderTests, FlagsCanBeAssignedViaTAGs) -{ - V3::FlagCrafter flagCrafter; - flagCrafter.loadAvailableFlags("TestFiles/configurables/blankMod/output/common/coat_of_arms/coat_of_arms/", ""); - - mappers::CountryMapper countryMapper; - std::stringstream countryInput; - countryInput << "link = {eu4 = TA8 vic3 = AAA }"; // <- we want TA8 to map to AAA since we have AAA flags. - countryMapper.loadMappingRules(countryInput); - const auto eu4country = std::make_shared(); // make TA8. - eu4country->setTag("TA8"); - const auto v3Tag = countryMapper.assignV3TagToEU4Country(eu4country); - EXPECT_EQ("AAA", v3Tag); // got a tag for V3 country. - auto country = std::make_shared(); - country->setTag(v3Tag); - - std::map> countries; - countries.emplace(v3Tag, country); - - // now assign flags. - flagCrafter.distributeAvailableFlags(countries, countryMapper, commonItems::ModFilesystem()); - - // do we have them yet? - const auto& flags = country->getFlags(); - - EXPECT_THAT(flags, - testing::UnorderedElementsAre(std::pair(V3::FlagCrafter::FLAGTYPE::Default, "legacy_AAA"), - std::pair(V3::FlagCrafter::FLAGTYPE::Republic, "legacy_AAA_republic"), - std::pair(V3::FlagCrafter::FLAGTYPE::Monarchy, "legacy_AAA_monarchy"), - std::pair(V3::FlagCrafter::FLAGTYPE::Fascist, "legacy_AAA_fascist"), - std::pair(V3::FlagCrafter::FLAGTYPE::Communist, "legacy_AAA_communist"))); -} - -TEST(V3World_FlagNameLoaderTests, FlagsCanBeAssignedViaNameMatch) -{ - V3::FlagCrafter flagCrafter; - flagCrafter.loadAvailableFlags("TestFiles/configurables/blankMod/output/common/coat_of_arms/coat_of_arms/", ""); - - const mappers::CountryMapper countryMapper; // no rules whatsoever. - - auto country = std::make_shared(); // no eu4 country. not relevant. Get it some name. - V3::ProcessedData data; - data.namesByLanguage.emplace("english", "Title"); // this should match e_title in flags. - country->setProcessedData(data); - - std::map> countries; - countries.emplace("TAG", country); - - // now assign flags. - flagCrafter.distributeAvailableFlags(countries, countryMapper, commonItems::ModFilesystem()); - - // do we have them yet? - const auto& flags = country->getFlags(); - - EXPECT_THAT(flags, - testing::UnorderedElementsAre(std::pair(V3::FlagCrafter::FLAGTYPE::Default, "legacy_e_title"), - std::pair(V3::FlagCrafter::FLAGTYPE::Republic, "legacy_e_title_republic"), - std::pair(V3::FlagCrafter::FLAGTYPE::Monarchy, "legacy_e_title_monarchy"), - std::pair(V3::FlagCrafter::FLAGTYPE::Fascist, "legacy_e_title_fascist"), - std::pair(V3::FlagCrafter::FLAGTYPE::Communist, "legacy_e_title_communist"))); -} - -TEST(V3World_FlagNameLoaderTests, FlagsWithVanillaMatchesWillNotBeAssigned) -{ - V3::FlagCrafter flagCrafter; - flagCrafter.loadAvailableFlags("TestFiles/configurables/blankMod/output/common/coat_of_arms/coat_of_arms/", - "TestFiles/vic3installation/game/common/flag_definitions/"); - - const mappers::CountryMapper countryMapper; // no rules whatsoever. - - auto country = std::make_shared(); // no eu4 country. not relevant. Get it some name. - V3::ProcessedData data; - data.namesByLanguage.emplace("english", "Title"); // this should match e_title in flags. - country->setProcessedData(data); - - std::map> countries; - countries.emplace("ABC", country); // ABC has an override in vanilla flag definitions and will not be assigned a flag. - - // now assign flags. - flagCrafter.distributeAvailableFlags(countries, countryMapper, commonItems::ModFilesystem()); - - // do we have them yet? - const auto& flags = country->getFlags(); - - EXPECT_TRUE(flags.empty()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/FlagCrafterTests/FlagNameLoaderTests/FlagNameLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/FlagCrafterTests/FlagNameLoaderTests/FlagNameLoaderTests.cpp deleted file mode 100644 index a2afed8..0000000 --- a/EU5ToVic3Tests/V3WorldTests/FlagCrafterTests/FlagNameLoaderTests/FlagNameLoaderTests.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "FlagCrafter/FlagNameLoader/FlagNameLoader.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_FlagNameLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::FlagNameLoader flagNameLoader; - - EXPECT_TRUE(flagNameLoader.getKnownFlags().empty()); -} - -TEST(V3World_FlagNameLoaderTests, flagNamesCanBeLoaded) -{ - V3::FlagNameLoader flagNameLoader; - flagNameLoader.loadKnownFlags("TestFiles/configurables/blankMod/output/common/coat_of_arms/coat_of_arms/"); - - EXPECT_THAT(flagNameLoader.getKnownFlags(), - testing::UnorderedElementsAre("legacy_AAA", - "legacy_AAA_communist", - "legacy_AAA_fascist", - "legacy_AAA_monarchy", - "legacy_AAA_republic", - "legacy_e_title", - "legacy_e_title_communist", - "legacy_e_title_fascist", - "legacy_e_title_monarchy", - "legacy_e_title_republic", - "legacy_d_title", - "legacy_d_title_communist", - "legacy_d_title_fascist", - "legacy_d_title_monarchy", - "legacy_d_title_republic")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/BuildingGroupLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/BuildingGroupLoaderTests.cpp deleted file mode 100644 index d82073a..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/BuildingGroupLoaderTests.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "EconomyManager/Building/BuildingGroups.h" -#include "Loaders/BuildingLoader/BuildingGroupLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_BuildingGroupLoaderTests, BuildingGroupLoaderCanLoadBuildingGroups) -{ - V3::BuildingGroupLoader buildingGroupLoader; - EXPECT_TRUE(buildingGroupLoader.getBuildingGroups().getBuildingGroupMap().empty()); - buildingGroupLoader.loadBuildingGroups(modFS); - EXPECT_EQ(6, buildingGroupLoader.getBuildingGroups().getBuildingGroupMap().size()); -} - -TEST(V3World_BuildingGroupLoaderTests, BuildingGroupLoaderTracksHierarchy) -{ - V3::BuildingGroupLoader buildingGroupLoader; - buildingGroupLoader.loadBuildingGroups(modFS); - const auto buildingGroups = buildingGroupLoader.getBuildingGroups(); - - EXPECT_FALSE(buildingGroups.tryGetParentName("bg_manufacturing")); - EXPECT_EQ("bg_manufacturing", buildingGroups.tryGetParentName("bg_light_industry").value()); - EXPECT_EQ("bg_manufacturing", buildingGroups.tryGetParentName("bg_heavy_industry").value()); - EXPECT_EQ("bg_heavy_industry", buildingGroups.tryGetParentName("bg_ultra_industry").value()); - EXPECT_EQ("bg_ultra_industry", buildingGroups.tryGetParentName("bg_mega_industry").value()); - EXPECT_EQ("bg_mega_industry", buildingGroups.tryGetParentName("bg_giga_industry").value()); -} - -TEST(V3World_BuildingGroupLoaderTests, BuildingGroupLoaderSetsInfrastructureInheritance) -{ - V3::BuildingGroupLoader buildingGroupLoader; - buildingGroupLoader.loadBuildingGroups(modFS); - const auto buildingGroups = buildingGroupLoader.getBuildingGroups(); - - EXPECT_FALSE(buildingGroups.tryGetInfraCost("bg_manufacturing")); - EXPECT_DOUBLE_EQ(2, buildingGroups.tryGetInfraCost("bg_light_industry").value()); - EXPECT_DOUBLE_EQ(3, buildingGroups.tryGetInfraCost("bg_heavy_industry").value()); - EXPECT_DOUBLE_EQ(1, buildingGroups.tryGetInfraCost("bg_ultra_industry").value()); - EXPECT_DOUBLE_EQ(1, buildingGroups.tryGetInfraCost("bg_mega_industry").value()); - EXPECT_DOUBLE_EQ(1, buildingGroups.tryGetInfraCost("bg_giga_industry").value()); -} - -TEST(V3World_BuildingGroupLoaderTests, BuildingGroupLoaderSetsCappedResourcesFromInheritance) -{ - V3::BuildingGroupLoader buildingGroupLoader; - buildingGroupLoader.loadBuildingGroups(modFS); - const auto buildingGroups = buildingGroupLoader.getBuildingGroups(); - - EXPECT_TRUE(buildingGroups.tryGetIsCapped("bg_manufacturing").value()); - EXPECT_TRUE(buildingGroups.tryGetIsCapped("bg_light_industry").value()); - EXPECT_FALSE(buildingGroups.tryGetIsCapped("bg_heavy_industry").value()); - EXPECT_FALSE(buildingGroups.tryGetIsCapped("bg_ultra_industry").value()); - EXPECT_TRUE(buildingGroups.tryGetIsCapped("bg_mega_industry").value()); - EXPECT_TRUE(buildingGroups.tryGetIsCapped("bg_giga_industry").value()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/BuildingLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/BuildingLoaderTests.cpp deleted file mode 100644 index e271101..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/BuildingLoaderTests.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "EconomyManager/Building/Building.h" -#include "Loaders/BuildingLoader/BuildingLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_BuildingLoaderTests, BuildingLoaderCanLoadBuildings) -{ - V3::BuildingLoader buildingLoader; - EXPECT_TRUE(buildingLoader.getBuildings().empty()); - buildingLoader.loadBuildings(modFS); - - const auto buildings = buildingLoader.getBuildings(); - EXPECT_EQ(3, buildings.size()); - - EXPECT_THAT("bg_light_industry", buildings.at("building_food_industry").getBuildingGroup()); - EXPECT_TRUE(buildings.at("building_food_industry").getUnlockingTechs().contains("manufacturies")); - EXPECT_EQ(300, buildings.at("building_food_industry").getConstructionCost()); - EXPECT_THAT(buildings.at("building_food_industry").getPMGroups(), - testing::UnorderedElementsAre("pmg_food", "pmg_canning", "pmg_distillery", "pmg_automation", "pmg_ownership")); - - EXPECT_EQ(239, buildings.at("building_textile_mills").getConstructionCost()); - EXPECT_THAT(buildings.at("building_textile_mills").getPMGroups(), - testing::UnorderedElementsAre("pmg_textile", "pmg_luxury", "pmg_automation", "pmg_ownership")); - - EXPECT_EQ(50, buildings.at("building_furniture_manufacturies").getConstructionCost()); - EXPECT_THAT(buildings.at("building_furniture_manufacturies").getPMGroups(), - testing::UnorderedElementsAre("pmg_furniture", "pmg_luxury", "pmg_automation", "pmg_ownership")); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/ProductionMethodGroupLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/ProductionMethodGroupLoaderTests.cpp deleted file mode 100644 index 1cab760..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/ProductionMethodGroupLoaderTests.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodGroupLoader.h" -#include "ModLoader/ModFilesystem.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_ProductionMethodGroupLoaderTests, ProductionMethodGroupLoaderCanLoadProductionMethodGroups) -{ - V3::ProductionMethodGroupLoader PMGroupLoader; - EXPECT_TRUE(PMGroupLoader.getPMGroups().empty()); - PMGroupLoader.loadPMGroups(modFS); - const auto PMGroups = PMGroupLoader.getPMGroups(); - EXPECT_EQ(8, PMGroups.size()); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/ProductionMethodLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/ProductionMethodLoaderTests.cpp deleted file mode 100644 index 02e02ab..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/BuildingLoaderTests/ProductionMethodLoaderTests.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "Loaders/BuildingLoader/ProductionMethodLoader/ProductionMethodLoader.h" -#include "ModLoader/ModFilesystem.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_ProductionMethodLoaderTests, ProductionMethodLoaderCanLoadProductionMethods) -{ - V3::ProductionMethodLoader PMLoader; - EXPECT_TRUE(PMLoader.getPMs().empty()); - PMLoader.loadPMs(modFS); - const auto PMs = PMLoader.getPMs(); - EXPECT_EQ(18, PMs.size()); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/CountryDefinitionLoaderTests/CountryDefinitionLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/CountryDefinitionLoaderTests/CountryDefinitionLoaderTests.cpp deleted file mode 100644 index 73236a9..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/CountryDefinitionLoaderTests/CountryDefinitionLoaderTests.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "Loaders/CountryDefinitionLoader/CountryDefinitionLoader.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_CountryDefinitionLoaderTests, CountryDefinitionLoaderCanLoadCountries) -{ - V3::CountryDefinitionLoader countryLoader; - EXPECT_EQ(0, countryLoader.getCountries().size()); - countryLoader.loadCommonCountries(modFS); - ASSERT_EQ(4, countryLoader.getCountries().size()); - - const auto& country1 = countryLoader.getCountries().at("TAG"); - const auto& country2 = countryLoader.getCountries().at("GAT"); - const auto& country3 = countryLoader.getCountries().at("TGA"); - const auto& country4 = countryLoader.getCountries().at("CCC"); - - EXPECT_EQ("TAG", country1->getTag()); - EXPECT_EQ("GAT", country2->getTag()); - EXPECT_EQ("TGA", country3->getTag()); - EXPECT_EQ("CCC", country4->getTag()); -} - -TEST(V3World_CountryDefinitionLoaderTests, nonTXTfilesAreIgnored) -{ - V3::CountryDefinitionLoader countryLoader; - EXPECT_EQ(0, countryLoader.getCountries().size()); - countryLoader.loadCommonCountries(modFS); - - EXPECT_FALSE(countryLoader.getCountries().contains("IGN")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/DefinesLoaderTests/BuildingScriptValuesLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/DefinesLoaderTests/BuildingScriptValuesLoaderTests.cpp deleted file mode 100644 index 877e580..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/DefinesLoaderTests/BuildingScriptValuesLoaderTests.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "Loaders/DefinesLoader/BuildingScriptValuesLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_BuildingScriptValuesLoaderTests, CostTiersCanBeLoaded) -{ - V3::BuildingScriptValuesLoader buildingScriptValuesLoader; - EXPECT_TRUE(buildingScriptValuesLoader.getBuildingCostConstants().empty()); - buildingScriptValuesLoader.loadBuildingScriptValues(modFS); - const auto costTiers = buildingScriptValuesLoader.getBuildingCostConstants(); - EXPECT_EQ(3, costTiers.size()); - - EXPECT_THAT(costTiers, - testing::UnorderedElementsAre(std::pair("construction_cost_very_low", 50), - std::pair("construction_cost_low", 150), - std::pair("construction_cost_medium", 300))); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/DefinesLoaderTests/EconDefniesLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/DefinesLoaderTests/EconDefniesLoaderTests.cpp deleted file mode 100644 index a82d630..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/DefinesLoaderTests/EconDefniesLoaderTests.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "Loaders/DefinesLoader/EconDefinesLoader.h" -#include "gtest/gtest.h" -#include - - -TEST(V3World_EconDefinesLoaderTests, EconDefinesCanBeLoaded) -{ - V3::EconDefinesLoader econDefinesLoader; - - EXPECT_EQ(0, econDefinesLoader.getGlobalCP()); - EXPECT_DOUBLE_EQ(0, econDefinesLoader.getCentralizedPopRatio()); - EXPECT_DOUBLE_EQ(0, econDefinesLoader.getMeanCivlevel()); - EXPECT_DOUBLE_EQ(0, econDefinesLoader.getStateTraitStrength()); - EXPECT_DOUBLE_EQ(0, econDefinesLoader.getPacketFactor()); - EXPECT_DOUBLE_EQ(0, econDefinesLoader.getIncorporatedModifier()); - EXPECT_DOUBLE_EQ(0, econDefinesLoader.getMinDevPerPop()); - EXPECT_DOUBLE_EQ(1, econDefinesLoader.getMaxDevPerPop()); - - econDefinesLoader.loadEconDefines("TestFiles/configurables/economy/econ_defines.txt"); - - EXPECT_EQ(1451750, econDefinesLoader.getGlobalCP()); - EXPECT_DOUBLE_EQ(0.975, econDefinesLoader.getCentralizedPopRatio()); - EXPECT_DOUBLE_EQ(80, econDefinesLoader.getMeanCivlevel()); - EXPECT_DOUBLE_EQ(0.5, econDefinesLoader.getStateTraitStrength()); - EXPECT_DOUBLE_EQ(-0.5, econDefinesLoader.getPacketFactor()); - EXPECT_DOUBLE_EQ(-0.3, econDefinesLoader.getIncorporatedModifier()); - EXPECT_DOUBLE_EQ(0.0000016, econDefinesLoader.getMinDevPerPop()); - EXPECT_DOUBLE_EQ(0.002, econDefinesLoader.getMaxDevPerPop()); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/LawLoaderTests/LawEntryTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/LawLoaderTests/LawEntryTests.cpp deleted file mode 100644 index 61d272d..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/LawLoaderTests/LawEntryTests.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "Loaders/LawLoader/LawEntry.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_LawEntryTests, DefaultsDefaultToDefaults) -{ - const V3::LawEntry entry; - const auto& law = entry.getLaw(); - - EXPECT_TRUE(law.group.empty()); - EXPECT_EQ(0, law.progressiveness); - EXPECT_TRUE(law.requiredTechs.empty()); - EXPECT_TRUE(law.requiredLaws.empty()); - EXPECT_TRUE(law.blockingLaws.empty()); -} - -TEST(V3World_LawEntryTests, LawCanBeLoaded) -{ - std::stringstream input; - input << "group = lawGroup\n "; - input << "progressiveness = -89\n "; - input << "unlocking_technologies = {\n"; - input << " tech1 tech2 tech3\n"; - input << "}\n"; - input << "unlocking_laws = {\n"; - input << " u1 u2 u3\n"; - input << "}\n "; - input << "disallowing_laws = {\n "; - input << " b1 b2 b3\n"; - input << "}\n "; - input << "institution = i1\n"; - input << "modifier = {\n "; - input << "\tstate_bureaucracy_population_base_cost_factor_mult = -0.14\n"; - input << "\tstate_building_barracks_max_level_add = 30\n"; - input << "}\n "; - const V3::LawEntry entry(input); - const auto& law = entry.getLaw(); - - EXPECT_EQ("lawGroup", law.group); - EXPECT_EQ(-89, law.progressiveness); - EXPECT_THAT(law.requiredTechs, testing::UnorderedElementsAre("tech1", "tech2", "tech3")); - EXPECT_THAT(law.requiredLaws, testing::UnorderedElementsAre("u1", "u2", "u3")); - EXPECT_THAT(law.blockingLaws, testing::UnorderedElementsAre("b1", "b2", "b3")); - EXPECT_EQ("i1", law.institution); - EXPECT_EQ(-0.14, law.bureaucracyCostMult); - EXPECT_EQ(30, law.maxBuildingLevels.at("building_barracks")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/LawLoaderTests/LawLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/LawLoaderTests/LawLoaderTests.cpp deleted file mode 100644 index 0d4ccd7..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/LawLoaderTests/LawLoaderTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Loaders/LawLoader/LawLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_LawLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::LawLoader loader; - - EXPECT_TRUE(loader.getLaws().empty()); -} - -TEST(V3World_LawLoaderTests, LawsCanBeLoaded) -{ - V3::LawLoader loader; - loader.loadLaws(modFS); - - ASSERT_EQ(4, loader.getLaws().size()); - EXPECT_TRUE(loader.getLaws().contains("law_1")); - EXPECT_TRUE(loader.getLaws().contains("law_2")); - EXPECT_TRUE(loader.getLaws().contains("law_3")); - EXPECT_TRUE(loader.getLaws().contains("law_4")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/LocLoaderTests/LocalizationLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/LocLoaderTests/LocalizationLoaderTests.cpp deleted file mode 100644 index 9072434..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/LocLoaderTests/LocalizationLoaderTests.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "CommonFunctions.h" -#include "Loaders/LocLoader/LocalizationLoader.h" -#include "gtest/gtest.h" -#include -using testing::UnorderedElementsAre; - -V3::LocalizationLoader prepLoader() -{ - std::stringstream input; - input << commonItems::utf8BOM << "l_english:\n"; - input << " key1: \"value 1\" # comment\n"; - input << " key2: \"value \"subquoted\" 2\"\n"; - std::stringstream input2; - input2 << commonItems::utf8BOM << "l_french:\n"; - input2 << " key1: \"valuee 1\"\n"; - input2 << " key2: \"valuee \"subquoted\" 2\"\n"; - std::stringstream input3; - input3 << commonItems::utf8BOM << "l_english:\n"; - input3 << " key1: \"replaced value 1\"\n"; // <- modded overrides - - V3::LocalizationLoader locs; - locs.scrapeStream(input, "english"); - locs.scrapeStream(input2, "french"); - locs.scrapeStream(input3, "english"); - - return locs; -} - -TEST(V3World_LocalizationLoaderTests, localizationsReturnsLocMapForKey) -{ - const auto& locs = prepLoader(); - - EXPECT_THAT(*locs.getLocMapForKey("key1"), testing::UnorderedElementsAre(testing::Pair("english", "replaced value 1"), testing::Pair("french", "valuee 1"))); - EXPECT_THAT(*locs.getLocMapForKey("key2"), - testing::UnorderedElementsAre(testing::Pair("english", "value \"subquoted\" 2"), testing::Pair("french", "valuee \"subquoted\" 2"))); -} - -TEST(V3World_LocalizationLoaderTests, localizationsReturnsLocValueForKey) -{ - const auto& locs = prepLoader(); - - EXPECT_EQ("replaced value 1", locs.getLocForKey("key1", "english")); - EXPECT_EQ("valuee \"subquoted\" 2", locs.getLocForKey("key2", "french")); -} - -TEST(V3World_LocalizationLoaderTests, localizationsReturnsEnglishWhenStuck) -{ - const auto& locs = prepLoader(); - - EXPECT_EQ("replaced value 1", *locs.getLocForKey("key1", "alien")); - EXPECT_EQ("value \"subquoted\" 2", *locs.getLocForKey("key2", "alien")); -} - -TEST(V3World_LocalizationLoaderTests, localizationsReturnsNulloptMapForMissingKeyMap) -{ - const auto& locs = prepLoader(); - - const auto& locMap = locs.getLocMapForKey("key3"); - - EXPECT_FALSE(locMap); -} - -TEST(V3World_LocalizationLoaderTests, localizationsReturnsNulloptMapForMissingKey) -{ - const auto& locs = prepLoader(); - - const auto& value = locs.getLocForKey("key3", "english"); - - EXPECT_FALSE(value); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/MajorFormablesLoaderTests/MajorFormablesEntryTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/MajorFormablesLoaderTests/MajorFormablesEntryTests.cpp deleted file mode 100644 index f940b22..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/MajorFormablesLoaderTests/MajorFormablesEntryTests.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "Loaders/MajorFormablesLoader/MajorFormablesEntry.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_MajorFormablesEntryTests, DefaultsDefaultToDefaults) -{ - const V3::MajorFormablesEntry entry; - - EXPECT_TRUE(entry.getStanzas().empty()); - EXPECT_TRUE(entry.getCultures().empty()); - EXPECT_TRUE(entry.getRequiredTechnology().empty()); -} - -TEST(V3World_MajorFormablesEntryTests, FormableCanBeLoaded) -{ - std::stringstream input; - input << "stanza = something\n"; - input << "stanza2 = { something else }\n"; - input << "possible = {\n"; - input << " OR = {\n"; - input << " country_has_primary_culture = cu:cul1\n"; - input << " country_has_primary_culture = cu:cul2\n"; - input << " }\n"; - input << " any_country = {\n"; - input << " OR = {\n "; - input << " country_has_primary_culture = cu:cul1\n"; - input << " country_has_primary_culture = cu:cul2\n"; - input << " }\n"; - input << " has_technology_researched = theTechnology\n"; - input << " }\n"; - input << " possibleStanza1 = { theStanza1 }\n"; - input << " possibleStanza2 = theStanza2\n"; - input << "}\n"; - const V3::MajorFormablesEntry entry(input); - - ASSERT_EQ(2, entry.getStanzas().size()); - EXPECT_EQ("stanza = something", entry.getStanzas()[0]); - EXPECT_EQ("stanza2 = { something else }", entry.getStanzas()[1]); - ASSERT_EQ(2, entry.getPossibleStanzas().size()); - EXPECT_EQ("possibleStanza1 = { theStanza1 }", entry.getPossibleStanzas()[0]); - EXPECT_EQ("possibleStanza2 = theStanza2", entry.getPossibleStanzas()[1]); - EXPECT_THAT(entry.getCultures(), testing::UnorderedElementsAre("cul1", "cul2")); - EXPECT_EQ("theTechnology", entry.getRequiredTechnology()); -} - -TEST(V3World_MajorFormablesEntryTests, FilteredFormableCanBeLoaded) -{ - std::stringstream input; - input << "stanza = something\n"; - input << "stanza2 = { something else }\n"; - input << "possible = {\n"; - input << " OR = {\n"; - input << " country_has_primary_culture = cu:cul1\n"; - input << " country_has_primary_culture = cu:cul2\n"; - input << " }\n"; - input << " any_country = {\n"; - input << " filter = {\n"; - input << " OR = {\n "; - input << " country_has_primary_culture = cu:cul1\n"; - input << " country_has_primary_culture = cu:cul2\n"; - input << " }\n"; - input << " }\n"; - input << " has_technology_researched = theTechnology\n"; - input << " percent = 1\n "; - input << " }\n"; - input << " possibleStanza1 = { theStanza1 }\n"; - input << " possibleStanza2 = theStanza2\n"; - input << "}\n"; - const V3::MajorFormablesEntry entry(input); - - ASSERT_EQ(2, entry.getStanzas().size()); - EXPECT_EQ("stanza = something", entry.getStanzas()[0]); - EXPECT_EQ("stanza2 = { something else }", entry.getStanzas()[1]); - ASSERT_EQ(2, entry.getPossibleStanzas().size()); - EXPECT_EQ("possibleStanza1 = { theStanza1 }", entry.getPossibleStanzas()[0]); - EXPECT_EQ("possibleStanza2 = theStanza2", entry.getPossibleStanzas()[1]); - EXPECT_THAT(entry.getCultures(), testing::UnorderedElementsAre("cul1", "cul2")); - EXPECT_EQ("theTechnology", entry.getRequiredTechnology()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/MajorFormablesLoaderTests/MajorFormablesLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/MajorFormablesLoaderTests/MajorFormablesLoaderTests.cpp deleted file mode 100644 index 8e3f6cb..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/MajorFormablesLoaderTests/MajorFormablesLoaderTests.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "Loaders/MajorFormablesLoader/MajorFormablesLoader.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_MajorFormablesLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::MajorFormablesLoader loader; - - EXPECT_TRUE(loader.getMajorFormables().empty()); -} - -TEST(V3World_MajorFormablesLoaderTests, FormablesCanBeLoaded) -{ - V3::MajorFormablesLoader loader; - loader.loadMajorFormables("TestFiles/vic3installation/game/common/country_formation/00_major_formables.txt"); - - auto formables = loader.getMajorFormables(); - - ASSERT_EQ(3, formables.size()); - EXPECT_EQ(6, formables["GER"].getStanzas().size()); - EXPECT_EQ("nationalism", formables["GER"].getRequiredTechnology()); - EXPECT_THAT(formables["GER"].getCultures(), testing::UnorderedElementsAre("north_german", "south_german", "weder_german")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/NationalBudgetLoaderTests/MathScriptTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/NationalBudgetLoaderTests/MathScriptTests.cpp deleted file mode 100644 index bf5513c..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/NationalBudgetLoaderTests/MathScriptTests.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "CountryManager/EU4Country.h" -#include "Loaders/NationalBudgetLoader/Script/AddScript.h" -#include "Loaders/NationalBudgetLoader/Script/MultiplyScript.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" - - -TEST(V3World_MathScriptTests, MathScriptTriggersAreRecognized) -{ - std::stringstream lawInput; - std::stringstream techInput; - std::stringstream colonyInput; - std::stringstream tcInput; - std::stringstream GPInput; - std::stringstream industryInput; - std::stringstream invalidInput; - - lawInput << "\tvic3_law = law_serfdom"; - techInput << "\tvic3_tech = centralization"; - colonyInput << "\tis_colony = yes"; - tcInput << "\tis_trade_company = yes"; - GPInput << "\tis_eu4_gp = yes"; - industryInput << "\tindustry_score_less_than = 2"; - invalidInput << "\tis_awesome = yes"; - - V3::MathScript law; - law.loadMathScript(lawInput); - V3::MathScript tech; - tech.loadMathScript(techInput); - V3::MathScript colony; - colony.loadMathScript(colonyInput); - V3::MathScript tc; - tc.loadMathScript(tcInput); - V3::MathScript gp; - gp.loadMathScript(GPInput); - V3::MathScript industry; - industry.loadMathScript(industryInput); - V3::MathScript invalid; - invalid.loadMathScript(invalidInput); - - V3::Country country; - country.setSourceCountry(std::make_shared()); - - EXPECT_FALSE(law.isValid(country)); - EXPECT_FALSE(tech.isValid(country)); - EXPECT_FALSE(colony.isValid(country)); - EXPECT_FALSE(tc.isValid(country)); - EXPECT_FALSE(gp.isValid(country)); - EXPECT_FALSE(industry.isValid(country)); - EXPECT_FALSE(invalid.isValid(country)); - - - V3::ProcessedData data; - data.laws.emplace("law_serfdom"); - data.techs.emplace("centralization"); - data.industryFactor = 0.2; - - std::stringstream eu4Input; - eu4Input << "colonial_parent = AAA"; - - auto sourceCountry = std::make_shared("TAG", eu4Input); - sourceCountry->setGP(); - sourceCountry->setTradeCompany(); - - country.setProcessedData(data); - country.setSourceCountry(sourceCountry); - - - EXPECT_TRUE(law.isValid(country)); - EXPECT_TRUE(tech.isValid(country)); - EXPECT_TRUE(colony.isValid(country)); - EXPECT_TRUE(tc.isValid(country)); - EXPECT_TRUE(gp.isValid(country)); - EXPECT_TRUE(industry.isValid(country)); -} - -TEST(V3World_AddScriptTests, AddScriptsAdds) -{ - std::stringstream input0; - std::stringstream input1; - - input0 << "\tvalue = 3"; - input1 << "\tvalue = 2"; - - V3::AddScript script0; - V3::AddScript script1; - - script0.loadMathScript(input0); - script1.loadMathScript(input1); - - EXPECT_DOUBLE_EQ(4, script0 + 1); - EXPECT_DOUBLE_EQ(3, script1 + 1); - EXPECT_DOUBLE_EQ(6, V3::AddScript::combine({script0, script1}) + 1); -} - -TEST(V3World_MultiplyScriptTests, MultiplyScriptsMultiplyAfterAdditivelyCombining) -{ - std::stringstream input0; - std::stringstream input1; - - input0 << "\tvalue = 1.5"; - input1 << "\tvalue = 2"; - - V3::MultiplyScript script0; - V3::MultiplyScript script1; - - script0.loadMathScript(input0); - script1.loadMathScript(input1); - - EXPECT_DOUBLE_EQ(3, script0 * 2); - EXPECT_DOUBLE_EQ(4, script1 * 2); - EXPECT_DOUBLE_EQ(5, V3::MultiplyScript::combine({script0, script1}) * 2); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/NationalBudgetLoaderTests/NationalBudgetLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/NationalBudgetLoaderTests/NationalBudgetLoaderTests.cpp deleted file mode 100644 index f5d3640..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/NationalBudgetLoaderTests/NationalBudgetLoaderTests.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "Loaders/NationalBudgetLoader/NationalBudgetLoader.h" -#include "gtest/gtest.h" -#include - - -TEST(V3World_NationalBudgetLoaderTests, NationalBudgetLoaderLoadsSectors) -{ - V3::NationalBudgetLoader nationalBudgetLoader; - - EXPECT_EQ(0, nationalBudgetLoader.getSectorBlueprints().size()); - nationalBudgetLoader.loadNationalBudget("TestFiles/configurables/economy/national_budget.txt"); - EXPECT_EQ(6, nationalBudgetLoader.getSectorBlueprints().size()); - - std::vector nameList = {"construction", "infrastructure", "test", "farming", "military", "extraction"}; - - for (const auto& sectorBlueprint: nationalBudgetLoader.getSectorBlueprints()) - { - EXPECT_THAT(std::vector{sectorBlueprint.getName()}, testing::IsSubsetOf(nameList)); - } -} - -TEST(V3World_NationalBudgetLoaderTests, NationalBudgetLoaderBuildingsMapToSectors) -{ - V3::NationalBudgetLoader nationalBudgetLoader; - nationalBudgetLoader.loadNationalBudget("TestFiles/configurables/economy/national_budget.txt"); - EXPECT_TRUE(nationalBudgetLoader.getBuildingSectorMap().empty()); - - nationalBudgetLoader.buildBuildingSectorMap(); - - EXPECT_THAT(nationalBudgetLoader.getBuildingSectorMap(), - testing::UnorderedElementsAre(std::pair("building_construction_center", "construction"), - std::pair("building_port", "infrastructure"), - std::pair("building_railway", "infrastructure"), - std::pair("building_barracks", "military"), - std::pair("building_fort", "military"), - std::pair("building_chemical_plant", "test"), - std::pair("building_steel_mills", "test"), - std::pair("building_motor_industries", "test"), - std::pair("building_munition_plants", "test"), - std::pair("building_rye_farm", "farming"), - std::pair("building_rice_farm", "farming"), - std::pair("building_wheat_farm", "farming"), - std::pair("building_maize_farm", "farming"), - std::pair("building_millet_farm", "farming"), - std::pair("building_livestock_ranch", "farming"), - std::pair("building_logging_camp", "extraction"), - std::pair("building_fishing_wharf", "extraction"))); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/NationalBudgetLoaderTests/SectorLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/NationalBudgetLoaderTests/SectorLoaderTests.cpp deleted file mode 100644 index 7ad8765..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/NationalBudgetLoaderTests/SectorLoaderTests.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "CountryManager/EU4Country.h" -#include "Loaders/NationalBudgetLoader/SectorLoader.h" -#include "PoliticalManager/Country/Country.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_SectorLoaderTests, DefaultsDefaultToDefaults) -{ - std::stringstream input; - - V3::SectorLoader sectorBlueprint; - sectorBlueprint.loadSector(input); - - V3::Country country; - country.setSourceCountry(std::make_shared()); - - EXPECT_DOUBLE_EQ(0, sectorBlueprint.calculateWeight(country)); - EXPECT_TRUE(sectorBlueprint.getBuildings().empty()); -} - -TEST(V3World_SectorLoaderTests, SectorLoaderCanLoadSector) -{ - std::stringstream input; - - input << "weight = 12\n"; - input << "building_barracks building_fort\n"; - input << "multiply = { value = 0.1 vic3_law = law_quality }\n"; - input << "multiply = { value = 1.5 vic3_law = law_peasant_levy }\n"; - input << "add = { value = 1 is_colony = no }\n"; - - V3::SectorLoader sectorBlueprint; - sectorBlueprint.loadSector(input); - - V3::Country country; - country.setSourceCountry(std::make_shared()); - V3::ProcessedData data; - data.laws.emplace("law_quality"); - data.laws.emplace("law_peasant_levy"); - country.setProcessedData(data); - - - EXPECT_DOUBLE_EQ(7.8, sectorBlueprint.calculateWeight(country)); - EXPECT_THAT(sectorBlueprint.getBuildings(), testing::UnorderedElementsAre("building_barracks", "building_fort")); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/PopEntryTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/PopEntryTests.cpp deleted file mode 100644 index 480a156..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/PopEntryTests.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "Loaders/PopLoader/PopEntry.h" -#include "gtest/gtest.h" - -TEST(V3World_PopEntryTests, DefaultsDefaultToDefaults) -{ - const V3::PopEntry popEntry; - - EXPECT_TRUE(popEntry.getPop().getCulture().empty()); - EXPECT_TRUE(popEntry.getPop().getReligion().empty()); - EXPECT_TRUE(popEntry.getPop().getType().empty()); - EXPECT_FALSE(popEntry.getPop().isMinority()); - EXPECT_EQ(0, popEntry.getPop().getSize()); -} - -TEST(V3World_PopEntryTests, PopCanBeLoaded) -{ - V3::PopEntry popEntry; - std::stringstream input; - input << "culture = cul\n"; - input << "religion = rel\n "; - input << "pop_type = typ\n"; - input << "size = 10\n "; - popEntry.loadPop(input); - - EXPECT_EQ("cul", popEntry.getPop().getCulture()); - EXPECT_EQ("rel", popEntry.getPop().getReligion()); - EXPECT_EQ("typ", popEntry.getPop().getType()); - EXPECT_FALSE(popEntry.getPop().isMinority()); - EXPECT_EQ(10, popEntry.getPop().getSize()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/PopLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/PopLoaderTests.cpp deleted file mode 100644 index 4dfbaae..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/PopLoaderTests.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "Loaders/PopLoader/PopLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_PopLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::PopLoader popLoader; - - EXPECT_TRUE(popLoader.getStatePops().empty()); -} - -TEST(V3World_PopLoaderTests, PopsCanBeLoadedFromMultipleFiles) -{ - V3::PopLoader popLoader; - popLoader.loadPops(modFS); - - ASSERT_EQ(4, popLoader.getStatePops().size()); - - const auto& sp1 = popLoader.getStatePops().at("STATE_TEST_LAND1"); - const auto& sp2 = popLoader.getStatePops().at("STATE_TEST_LAND2"); - const auto& sp3 = popLoader.getStatePops().at("STATE_TEST_LAND3"); - const auto& sp4 = popLoader.getStatePops().at("STATE_TEST_LAND4"); - - EXPECT_EQ("STATE_TEST_LAND1", sp1.getStateName()); - EXPECT_EQ(600, sp1.getPopCount()); - - EXPECT_EQ("STATE_TEST_LAND2", sp2.getStateName()); - EXPECT_EQ(3000, sp2.getPopCount()); - - EXPECT_EQ("STATE_TEST_LAND3", sp3.getStateName()); - EXPECT_EQ(900, sp3.getPopCount()); - - EXPECT_EQ("STATE_TEST_LAND4", sp4.getStateName()); - EXPECT_EQ(1000, sp4.getPopCount()); -} - -TEST(V3World_PopLoaderTests, PopLoaderIgnoresNonTXTFiles) -{ - V3::PopLoader popLoader; - popLoader.loadPops(modFS); - - EXPECT_FALSE(popLoader.getStatePops().contains("STATE_TEST_EXCESS")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/StateEntriesTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/StateEntriesTests.cpp deleted file mode 100644 index a7ecd61..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/StateEntriesTests.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "Loaders/PopLoader/StateEntries.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_StateEntriesTests, DefaultsDefaultToDefaults) -{ - V3::StateEntries se; - - EXPECT_TRUE(se.getStatePops().empty()); -} - -TEST(V3World_StateEntriesTests, StatePopsCanBeLoaded) -{ - V3::StateEntries se; - std::stringstream input; - input << "s:STATE_TEST1 = {\n"; - input << " region_state:AAA = {\n"; - input << " create_pop = {\n"; - input << " culture = cul\n"; - input << " religion = rel\n "; - input << " size = 10\n "; - input << " }\n"; - input << " create_pop = {\n"; - input << " culture = cul2\n"; - input << " religion = rel2\n "; - input << " size = 20\n "; - input << " }\n"; - input << " }\n"; - input << " region_state:BBB = {\n"; - input << " create_pop = {\n"; - input << " culture = cul3\n"; - input << " religion = rel3\n "; - input << " size = 100\n "; - input << " }\n"; - input << " }\n"; - input << "}\n"; - input << "s:STATE_TEST2 = {\n"; - input << " region_state:AAA = {\n"; - input << " create_pop = {\n"; - input << " culture = cul\n"; - input << " religion = rel\n "; - input << " size = 1000\n "; - input << " }\n"; - input << " }\n"; - input << "}\n"; - se.loadStates(input); - - ASSERT_EQ(2, se.getStatePops().size()); - - const auto& sp1 = se.getStatePops().at("STATE_TEST1"); - const auto& sp2 = se.getStatePops().at("STATE_TEST2"); - - EXPECT_EQ("STATE_TEST1", sp1.getStateName()); - EXPECT_EQ("STATE_TEST2", sp2.getStateName()); - - EXPECT_EQ(130, sp1.getPopCount()); - EXPECT_EQ(1000, sp2.getPopCount()); -} - -TEST(V3World_StateEntriesTests, StateEntiresWarnsForCrapStateNameAndIgnoresIt) -{ - V3::StateEntries se; - std::stringstream input; - input << "s:A = {\n"; - input << " region_state:AAA = {\n"; - input << " create_pop = {\n"; - input << " culture = cul\n"; - input << " religion = rel\n "; - input << " size = 1000\n "; - input << " }\n"; - input << " }\n"; - input << "}\n"; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - se.loadStates(input); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] Incoming pops within state s:A have no parsable state. Deleting Pops!)")); - std::cout.rdbuf(cout_buffer); - - EXPECT_TRUE(se.getStatePops().empty()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/SubStateEntriesTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/SubStateEntriesTests.cpp deleted file mode 100644 index 7125b0a..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/SubStateEntriesTests.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "Loaders/PopLoader/SubStateEntries.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_SubStateEntriesTests, DefaultsDefaultToDefaults) -{ - V3::SubStateEntries sse; - - EXPECT_TRUE(sse.getSubStatePops().empty()); -} - -TEST(V3World_SubStateEntriesTests, SubStatePopsCanBeLoaded) -{ - V3::SubStateEntries sse; - std::stringstream input; - input << "region_state:AAA = {\n"; - input << " create_pop = {\n"; - input << " culture = cul\n"; - input << " religion = rel\n "; - input << " size = 10\n "; - input << " }\n"; - input << " create_pop = {\n"; - input << " culture = cul2\n"; - input << " religion = rel2\n "; - input << " size = 20\n "; - input << " }\n"; - input << "}\n"; - input << "region_state:BBB = {\n"; - input << " create_pop = {\n"; - input << " culture = cul3\n"; - input << " religion = rel3\n "; - input << " size = 100\n "; - input << " }\n"; - input << "}\n"; - sse.loadSubStates(input); - - ASSERT_EQ(2, sse.getSubStatePops().size()); - const auto& ssp1 = sse.getSubStatePops()[0]; - const auto& ssp2 = sse.getSubStatePops()[1]; - - EXPECT_EQ("AAA", ssp1.getTag()); - EXPECT_EQ("BBB", ssp2.getTag()); - - EXPECT_EQ(30, ssp1.getPopCount()); - EXPECT_EQ(100, ssp2.getPopCount()); -} - -TEST(V3World_SubStateEntriesTests, SubStateEntiresWarnsForCrapOwnerTagAndClearsIt) -{ - V3::SubStateEntries sse; - std::stringstream input; - input << "region_state:A = {\n"; - input << " create_pop = {\n"; - input << " culture = cul2\n"; - input << " religion = rel2\n "; - input << " size = 20\n "; - input << " }\n"; - input << "}\n"; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - sse.loadSubStates(input); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] Incoming pops within substate region_state:A have no parsable TAG. Filing pops as unclaimed.)")); - std::cout.rdbuf(cout_buffer); - - - ASSERT_EQ(1, sse.getSubStatePops().size()); - const auto& ssp1 = sse.getSubStatePops()[0]; - - EXPECT_TRUE(ssp1.getTag().empty()); - EXPECT_EQ(20, ssp1.getPopCount()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/SubStatePopEntriesTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/SubStatePopEntriesTests.cpp deleted file mode 100644 index 2a08a09..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/PopLoaderTests/SubStatePopEntriesTests.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "Loaders/PopLoader/SubStatePopEntries.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_SubStatePopEntriesTests, DefaultsDefaultToDefaults) -{ - const V3::SubStatePopEntries sspe; - - EXPECT_TRUE(sspe.getPops().empty()); -} - -TEST(V3World_SubStatePopEntriesTests, PopsCanBeLoaded) -{ - V3::SubStatePopEntries sspe; - std::stringstream input; - input << "create_pop = {\n"; - input << " culture = cul\n"; - input << " religion = rel\n "; - input << "}\n"; - input << "create_pop = {\n"; - input << " culture = cul2\n"; - input << " religion = rel2\n "; - input << "}\n"; - sspe.loadPops(input); - - EXPECT_THAT(sspe.getPops(), testing::UnorderedElementsAre(V3::Pop("cul", "rel", "", 0), V3::Pop("cul2", "rel2", "", 0))); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/StateLoaderTests/StateLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/StateLoaderTests/StateLoaderTests.cpp deleted file mode 100644 index e8b21c3..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/StateLoaderTests/StateLoaderTests.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "ClayManager/State/State.h" -#include "Loaders/StateLoader/StateLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_StateLoaderTests, stateLoaderCanLoadStates) -{ - V3::StateLoader stateLoader; - - EXPECT_EQ(0, stateLoader.getStates().size()); - - stateLoader.loadStates(modFS); - - EXPECT_EQ(10, stateLoader.getStates().size()); - - const auto& state1 = stateLoader.getStates().at("STATE_TEST_1"); - const auto& state2 = stateLoader.getStates().at("STATE_TEST_2"); - const auto& state3 = stateLoader.getStates().at("STATE_TEST_3"); - const auto& state4 = stateLoader.getStates().at("STATE_TEST_4"); - const auto& state5 = stateLoader.getStates().at("STATE_TEST_LAKE"); - - EXPECT_TRUE(state1->isCoastal()); - EXPECT_EQ("STATE_TEST_1", state1->getName()); - EXPECT_TRUE(state1->containsProvince("x112233")); - EXPECT_TRUE(state1->containsProvince("x445566")); - EXPECT_TRUE(state1->containsProvince("x778899")); - - EXPECT_FALSE(state2->isCoastal()); - EXPECT_EQ("STATE_TEST_2", state2->getName()); - EXPECT_TRUE(state2->containsProvince("xDDEEFF")); - - EXPECT_TRUE(state3->isCoastal()); - EXPECT_EQ("STATE_TEST_3", state3->getName()); - EXPECT_TRUE(state3->containsProvince("x123456")); - EXPECT_TRUE(state3->containsProvince("x7890AB")); - EXPECT_TRUE(state3->containsProvince("xCDEF12")); - - EXPECT_FALSE(state4->isCoastal()); - EXPECT_EQ("STATE_TEST_4", state4->getName()); - EXPECT_TRUE(state4->containsProvince("x345678")); - EXPECT_TRUE(state4->containsProvince("x9ABCDE")); - - EXPECT_FALSE(state5->isCoastal()); - EXPECT_EQ("STATE_TEST_LAKE", state5->getName()); - EXPECT_TRUE(state5->containsProvince("xAABBCC")); -} - -TEST(V3World_StateLoaderTests, nonTXTfilesAreIgnored) -{ - V3::StateLoader stateLoader; - - EXPECT_EQ(0, stateLoader.getStates().size()); - - stateLoader.loadStates(modFS); - - EXPECT_EQ(10, stateLoader.getStates().size()); - - EXPECT_FALSE(stateLoader.getStates().contains("STATE_TEST_5")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/StateModifierLoaderTests/StateModifierLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/StateModifierLoaderTests/StateModifierLoaderTests.cpp deleted file mode 100644 index f651cc3..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/StateModifierLoaderTests/StateModifierLoaderTests.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "ClayManager/State/StateModifier.h" -#include "Loaders/StateModifierLoader/StateModifierLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_StateModifierLoaderTests, StateModiferLoaderCanLoadStateModifiers) -{ - V3::StateModifierLoader stateModifierLoader; - EXPECT_TRUE(stateModifierLoader.getStateModifiers().empty()); - stateModifierLoader.loadStateModifiers(modFS); - EXPECT_EQ(3, stateModifierLoader.getStateModifiers().size()); -} - -TEST(V3World_StateModifierLoaderTests, StateModiferLoaderSetsStateModifierNames) -{ - V3::StateModifierLoader stateModifierLoader; - stateModifierLoader.loadStateModifiers(modFS); - - const auto stateModifiers = stateModifierLoader.getStateModifiers(); - - EXPECT_THAT("state_trait_harbor", stateModifiers.at("state_trait_harbor").getName()); - EXPECT_THAT("state_trait_falls", stateModifiers.at("state_trait_falls").getName()); - EXPECT_THAT("state_trait_prairies", stateModifiers.at("state_trait_prairies").getName()); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/SuperRegionLoaderTests/SuperRegionLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/SuperRegionLoaderTests/SuperRegionLoaderTests.cpp deleted file mode 100644 index c2e61d4..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/SuperRegionLoaderTests/SuperRegionLoaderTests.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "Loaders/SuperRegionLoader/SuperRegionLoader.h" -#include "Loaders/SuperRegionLoader/V3Region.h" -#include "Loaders/SuperRegionLoader/V3SuperRegion.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_V3SuperRegionLoaderTests, superRegionLoaderCanLoadFromDisk) -{ - V3::SuperRegionLoader superRegionLoader; - - EXPECT_EQ(0, superRegionLoader.getSuperRegions().size()); - - superRegionLoader.loadSuperRegions(modFS); - - EXPECT_EQ(2, superRegionLoader.getSuperRegions().size()); - - EXPECT_TRUE(superRegionLoader.getSuperRegions().contains("test_1_strategic_regions")); - EXPECT_TRUE(superRegionLoader.getSuperRegions().contains("test_2_strategic_regions")); - - const auto& test1sr = superRegionLoader.getSuperRegions().at("test_1_strategic_regions"); - const auto& test2sr = superRegionLoader.getSuperRegions().at("test_2_strategic_regions"); - - EXPECT_TRUE(test1sr->containsRegion("region_a")); - EXPECT_TRUE(test1sr->containsRegion("region_b")); - EXPECT_TRUE(test2sr->containsRegion("region_c")); - - const auto& region_a = test1sr->getRegions().at("region_a"); - const auto& region_b = test1sr->getRegions().at("region_b"); - const auto& region_c = test2sr->getRegions().at("region_c"); - - EXPECT_TRUE(region_a->containsState("STATE_TEST_1")); - EXPECT_TRUE(region_a->containsState("STATE_TEST_2")); - EXPECT_TRUE(region_b->containsState("STATE_TEST_3")); - EXPECT_TRUE(region_c->containsState("STATE_TEST_4")); -} - -TEST(V3World_V3SuperRegionLoaderTests, nonTXTfilesAreIgnored) -{ - V3::SuperRegionLoader superRegionLoader; - - EXPECT_EQ(0, superRegionLoader.getSuperRegions().size()); - - superRegionLoader.loadSuperRegions(modFS); - - EXPECT_FALSE(superRegionLoader.getSuperRegions().contains("ignored_region")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/SuperRegionLoaderTests/V3RegionTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/SuperRegionLoaderTests/V3RegionTests.cpp deleted file mode 100644 index 4c30cc8..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/SuperRegionLoaderTests/V3RegionTests.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "Loaders/SuperRegionLoader/V3Region.h" -#include "gtest/gtest.h" - -TEST(V3World_V3RegionTests, regionCanBeInitialized) -{ - V3::Region region; - - EXPECT_EQ(std::string(), region.getName()); - EXPECT_EQ(0, region.getStates().size()); - - std::stringstream input; - input << "states = { STATE_TEST_1 STATE_TEST_2 }\n"; - region.initializeRegion(input); - region.setName("test_region"); - - EXPECT_EQ("test_region", region.getName()); - EXPECT_EQ(2, region.getStates().size()); - EXPECT_TRUE(region.containsState("STATE_TEST_1")); - EXPECT_TRUE(region.containsState("STATE_TEST_2")); - EXPECT_FALSE(region.containsState("STATE_TEST_3")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/SuperRegionLoaderTests/V3SuperRegionTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/SuperRegionLoaderTests/V3SuperRegionTests.cpp deleted file mode 100644 index 5b880d3..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/SuperRegionLoaderTests/V3SuperRegionTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Loaders/SuperRegionLoader/V3SuperRegion.h" -#include "gtest/gtest.h" - -TEST(V3World_V3SuperRegionTests, superRegionCanBeInitialized) -{ - V3::SuperRegion superRegion; - - EXPECT_EQ(std::string(), superRegion.getName()); - EXPECT_EQ(0, superRegion.getRegions().size()); - - std::stringstream input; - input << "region_a = {\n"; - input << " states = { STATE_TEST_1 STATE_TEST_2 }\n"; - input << "}\n"; - input << "region_b = {\n"; - input << " states = { STATE_TEST_3 }\n"; - input << "}\n"; - superRegion.initializeSuperRegion(input); - superRegion.setName("test_superregion"); - - EXPECT_EQ("test_superregion", superRegion.getName()); - EXPECT_EQ(2, superRegion.getRegions().size()); - EXPECT_TRUE(superRegion.containsRegion("region_a")); - EXPECT_TRUE(superRegion.containsRegion("region_b")); - EXPECT_FALSE(superRegion.containsRegion("region_c")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/TechLoaderTests/TechEntryTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/TechLoaderTests/TechEntryTests.cpp deleted file mode 100644 index de8c2e2..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/TechLoaderTests/TechEntryTests.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "Loaders/TechLoader/TechEntry.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_TechEntryTests, DefaultsDefaultToDefaults) -{ - const V3::TechEntry entry; - const auto& tech = entry.getTech(); - - EXPECT_EQ(0, tech.infrastructureMax); - EXPECT_DOUBLE_EQ(0.0, tech.infrastructureMult); -} - -TEST(V3World_TechEntryTests, TechCanBeLoaded) -{ - std::stringstream input; - input << "modifier = {\n "; - input << "\tstate_infrastructure_from_population_add = 0.15\n"; - input << "\tstate_infrastructure_from_population_max_add = 5\n"; - input << "\tstate_building_port_max_level_add = 2\n"; - input << "\tstate_building_naval_base_max_level_add = 20\n"; - input << "\tbuilding_economy_of_scale_level_cap_add = 15\n"; - input << "}\n "; - const V3::TechEntry entry(input); - const auto& tech = entry.getTech(); - - EXPECT_DOUBLE_EQ(0.15, tech.infrastructureMult); - EXPECT_EQ(5, tech.infrastructureMax); - EXPECT_EQ(2, tech.maxBuildingLevels.at("building_port")); - EXPECT_EQ(20, tech.maxBuildingLevels.at("building_naval_base")); - EXPECT_EQ(15, tech.throughputMax); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/TechLoaderTests/TechLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/TechLoaderTests/TechLoaderTests.cpp deleted file mode 100644 index 029d864..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/TechLoaderTests/TechLoaderTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Loaders/TechLoader/TechLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_TechLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::TechLoader loader; - - EXPECT_TRUE(loader.getTechs().empty()); -} - -TEST(V3World_TechLoaderTests, TechsCanBeLoaded) -{ - V3::TechLoader loader; - loader.loadTechs(modFS); - - ASSERT_EQ(4, loader.getTechs().size()); - EXPECT_TRUE(loader.getTechs().contains("tech_1")); - EXPECT_TRUE(loader.getTechs().contains("tech_2")); - EXPECT_TRUE(loader.getTechs().contains("tech_3")); - EXPECT_TRUE(loader.getTechs().contains("tech_4")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/TerrainLoaderTests/TerrainLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/TerrainLoaderTests/TerrainLoaderTests.cpp deleted file mode 100644 index 76ede5f..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/TerrainLoaderTests/TerrainLoaderTests.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "Loaders/TerrainLoader/TerrainLoader.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_TerrainLoaderTests, terrainLoaderCanLoadTerrains) -{ - V3::TerrainLoader terrainLoader; - - EXPECT_EQ(0, terrainLoader.getTerrains().size()); - - terrainLoader.loadTerrains(modFS); - - EXPECT_EQ(22, terrainLoader.getTerrains().size()); - - EXPECT_THAT(terrainLoader.getTerrains(), - testing::UnorderedElementsAre(testing::Pair("x112233", "desert"), - testing::Pair("x445566", "plains"), - testing::Pair("x778899", "plains"), - testing::Pair("xAABBCC", "lakes"), - testing::Pair("xDDEEFF", "ocean"), - testing::Pair("x123456", "wetland"), - testing::Pair("x7890AB", "mountain"), - testing::Pair("xCDEF12", "tundra"), - testing::Pair("x9ABCDE", "lakes"), - testing::Pair("X1111111", "test"), - testing::Pair("X11111", "test"), - testing::Pair("0X654321", "test"), - testing::Pair("x000001", "ocean"), - testing::Pair("x000002", "ocean"), - testing::Pair("x000003", "plains"), - testing::Pair("x000004", "plains"), - testing::Pair("x000005", "plains"), - testing::Pair("x000006", "plains"), - testing::Pair("x000007", "lakes"), - testing::Pair("x000008", "plains"), - testing::Pair("x000009", "lakes"), - testing::Pair("x000010", "plains"))); -} - -TEST(V3World_TerrainLoaderTests, terrainLoaderUppercasesProvinceNames) -{ - V3::TerrainLoader terrainLoader; - - EXPECT_EQ(0, terrainLoader.getTerrains().size()); - - terrainLoader.loadTerrains(modFS); - - EXPECT_TRUE(terrainLoader.getTerrains().contains("x9ABCDE")); // x9abcde in the file -} - -TEST(V3World_TerrainLoaderTests, terrainLoaderComplainsAtInvalidNames) -{ - V3::TerrainLoader terrainLoader; - - EXPECT_EQ(0, terrainLoader.getTerrains().size()); - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - terrainLoader.loadTerrains(modFS); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Encountered terrain for province X1111111 in unknown format!)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Encountered terrain for province X11111 in unknown format!)")); - EXPECT_THAT(log.str(), testing::HasSubstr(R"( [WARNING] Encountered terrain for province 0X654321 in unknown format!)")); - - std::cout.rdbuf(cout_buffer); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/TerrainLoaderTests/TerrainModifierLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/TerrainLoaderTests/TerrainModifierLoaderTests.cpp deleted file mode 100644 index 2c6db4b..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/TerrainLoaderTests/TerrainModifierLoaderTests.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "Loaders/TerrainLoader/TerrainModifierLoader.h" -#include "gtest/gtest.h" -#include - - -TEST(V3World_TerrainModifierLoaderTests, terrainModifierLoaderCanLoadTerrainEffects) -{ - V3::TerrainModifierLoader terrainModifierLoader; - - std::stringstream input; - - input << "coastal = {\n"; - input << "\tpriority = 0.2"; - input << "\tbuilding_cave = 0.3"; - input << "\tbuilding_fish = 1.5"; - input << "}"; - input << "desert = {\n"; - input << "\tpriority = -0.3"; - input << "}"; - input << "wetlands = {\n"; - input << "\tbuilding_fish = 1"; - input << "}"; - - EXPECT_EQ(0, terrainModifierLoader.getTerrainStateModifiers().size()); - EXPECT_EQ(0, terrainModifierLoader.getTerrainBuildingModifiers().size()); - - terrainModifierLoader.loadTerrainModifiers(input); - - EXPECT_EQ(3, terrainModifierLoader.getTerrainStateModifiers().size()); - EXPECT_EQ(2, terrainModifierLoader.getTerrainBuildingModifiers().size()); - - EXPECT_THAT(terrainModifierLoader.getTerrainStateModifiers(), - testing::UnorderedElementsAre(testing::Pair("coastal", 0.2), testing::Pair("desert", -0.3), testing::Pair("wetlands", 0))); - - EXPECT_THAT(terrainModifierLoader.getTerrainBuildingModifiers().at("coastal"), - testing::UnorderedElementsAre(testing::Pair("building_cave", 0.3), testing::Pair("building_fish", 1.5))); - EXPECT_THAT(terrainModifierLoader.getTerrainBuildingModifiers().at("wetlands"), testing::UnorderedElementsAre(testing::Pair("building_fish", 1.0))); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaBuildingLoaderTests/VanillaBuildingEntriesTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaBuildingLoaderTests/VanillaBuildingEntriesTests.cpp deleted file mode 100644 index f1e1280..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaBuildingLoaderTests/VanillaBuildingEntriesTests.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "Loaders/VanillaBuildingLoader/VanillaBuildingEntries.h" -#include "gtest/gtest.h" - -TEST(V3World_VanillaBuildingEntriesTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaBuildingEntries entries; - - EXPECT_TRUE(entries.getBuildingElements().empty()); -} - -TEST(V3World_VanillaBuildingEntriesTests, entriesCanBeLoaded) -{ - std::stringstream input; - input << "region_state:AUS = {\n"; - input << " create_building = {\n"; - input << " building = a\n"; - input << " }\n"; - input << "}\n"; - input << "region_state:SAR = {\n"; - input << " create_building = {\n"; - input << " building = b\n"; - input << " }\n"; - input << " create_building = {\n"; - input << " building = c\n"; - input << " }\n"; - input << "}\n"; - const V3::VanillaBuildingEntries entries(input); - - ASSERT_EQ(2, entries.getBuildingElements().size()); - const auto& aus = entries.getBuildingElements().at("AUS"); - const auto& sar = entries.getBuildingElements().at("SAR"); - - EXPECT_EQ("create_building = {\n\t\tbuilding = a\n\t}", aus[0]); - - EXPECT_EQ("create_building = {\n\t\tbuilding = b\n\t}", sar[0]); - EXPECT_EQ("create_building = {\n\t\tbuilding = c\n\t}", sar[1]); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaBuildingLoaderTests/VanillaBuildingLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaBuildingLoaderTests/VanillaBuildingLoaderTests.cpp deleted file mode 100644 index fdcff66..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaBuildingLoaderTests/VanillaBuildingLoaderTests.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "Loaders/VanillaBuildingLoader/VanillaBuildingLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_VanillaBuildingLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaBuildingLoader loader; - - EXPECT_TRUE(loader.getBuildingElements().empty()); -} - -TEST(V3World_VanillaBuildingLoaderTests, VanillaBuildingsCanBeLoaded) -{ - V3::VanillaBuildingLoader loader; - loader.loadVanillaBuildings(modFS); - - EXPECT_EQ(3, loader.getBuildingElements().size()); - EXPECT_EQ(1, loader.getBuildingElements().at("STATE_SVEALAND").size()); - EXPECT_EQ(1, loader.getBuildingElements().at("STATE_GOTALAND").size()); - EXPECT_EQ(2, loader.getBuildingElements().at("STATE_LOMBARDY").size()); - - EXPECT_EQ(2, loader.getBuildingElements().at("STATE_SVEALAND").at("SWE").size()); - EXPECT_EQ(1, loader.getBuildingElements().at("STATE_GOTALAND").at("SWE").size()); - EXPECT_EQ(1, loader.getBuildingElements().at("STATE_LOMBARDY").at("AUS").size()); - EXPECT_EQ(1, loader.getBuildingElements().at("STATE_LOMBARDY").at("SAR").size()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCharacterLoaderTests/VanillaCharacterEntriesTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCharacterLoaderTests/VanillaCharacterEntriesTests.cpp deleted file mode 100644 index 0251733..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCharacterLoaderTests/VanillaCharacterEntriesTests.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "Loaders/VanillaCharacterLoader/VanillaCharacterEntries.h" -#include "gtest/gtest.h" - -TEST(V3World_VanillaCharacterEntriesTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaCharacterEntries entries; - - EXPECT_TRUE(entries.getCharacterElements().empty()); -} - -TEST(V3World_VanillaCharacterEntriesTests, entriesCanBeLoaded) -{ - std::stringstream input; - input << "c:GBR = {\n"; - input << " create_character = {\n"; - input << " first_name = \"Khalifa\"\n"; - input << " }\n"; - input << "}\n"; - input << "c:AUS = {\n"; - input << " create_character = {\n"; - input << " first_name = \"al_Qasim\"\n"; - input << " }\n"; - input << " create_character = {\n"; - input << " first_name = \"Said\"\n"; - input << " }\n"; - input << "}\n"; - input << "c:AUS = {\n"; - input << " create_character = {\n"; - input << " first_name = \"Saeed\"\n"; - input << " }\n"; - input << "}\n"; - const V3::VanillaCharacterEntries entries(input); - - ASSERT_EQ(2, entries.getCharacterElements().size()); - const auto& gbr = entries.getCharacterElements().at("GBR"); - const auto& aus = entries.getCharacterElements().at("AUS"); - - EXPECT_EQ("create_character = {\n\t\tfirst_name = \"Khalifa\"\n\t}", gbr[0]); - - EXPECT_EQ("create_character = {\n\t\tfirst_name = \"al_Qasim\"\n\t}", aus[0]); - EXPECT_EQ("create_character = {\n\t\tfirst_name = \"Said\"\n\t}", aus[1]); - EXPECT_EQ("create_character = {\n\t\tfirst_name = \"Saeed\"\n\t}", aus[2]); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCharacterLoaderTests/VanillaCharacterLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCharacterLoaderTests/VanillaCharacterLoaderTests.cpp deleted file mode 100644 index 7d7665b..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCharacterLoaderTests/VanillaCharacterLoaderTests.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "Loaders/VanillaCharacterLoader/VanillaCharacterLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_VanillaCharacterLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaCharacterLoader loader; - - EXPECT_TRUE(loader.getCharacterElements().empty()); -} - -TEST(V3World_VanillaCharacterLoaderTests, VanillaCharactersCanBeLoaded) -{ - V3::VanillaCharacterLoader loader; - loader.loadVanillaCharacters(modFS); - - EXPECT_EQ(2, loader.getCharacterElements().size()); - EXPECT_EQ(2, loader.getCharacterElements().at("ABU").size()); - EXPECT_EQ(2, loader.getCharacterElements().at("ACE").size()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCountryHistoryLoaderTests/VanillaCountryHistoryEntriesTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCountryHistoryLoaderTests/VanillaCountryHistoryEntriesTests.cpp deleted file mode 100644 index c4fa1fb..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCountryHistoryLoaderTests/VanillaCountryHistoryEntriesTests.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryEntries.h" -#include "gtest/gtest.h" - -TEST(V3World_VanillaCountryHistoryEntriesTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaCountryHistoryEntries entries; - - EXPECT_TRUE(entries.getCountryHistoryElements().empty()); -} - -TEST(V3World_VanillaCountryHistoryEntriesTests, entriesCanBeLoaded) -{ - std::stringstream input; - input << "c:GBR = {\n"; - input << " set_tax_level = medium\n"; - input << " ig:ig_devout = {\n"; - input << " set_interest_group_name = ig_sunni_madrasahs\n"; - input << " }\n"; - input << "}\n"; - input << "c:AUS = {\n"; - input << " add_technology_researched = academia\n"; - input << "}\n"; - input << "c:AUS = {\n"; - input << " activate_law = law_type:law_state_religion\n"; - input << "}\n"; - const V3::VanillaCountryHistoryEntries entries(input); - - ASSERT_EQ(2, entries.getCountryHistoryElements().size()); - const auto& gbr = entries.getCountryHistoryElements().at("GBR"); - const auto& aus = entries.getCountryHistoryElements().at("AUS"); - - EXPECT_EQ("set_tax_level = medium", gbr[0]); - EXPECT_EQ("ig:ig_devout = {\n\t\tset_interest_group_name = ig_sunni_madrasahs\n\t}", gbr[1]); - - EXPECT_EQ("add_technology_researched = academia", aus[0]); - EXPECT_EQ("activate_law = law_type:law_state_religion", aus[1]); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCountryHistoryLoaderTests/VanillaCountryHistoryLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCountryHistoryLoaderTests/VanillaCountryHistoryLoaderTests.cpp deleted file mode 100644 index 6f60658..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaCountryHistoryLoaderTests/VanillaCountryHistoryLoaderTests.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "Loaders/VanillaCountryHistoryLoader/VanillaCountryHistoryLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_VanillaCountryHistoryLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaCountryHistoryLoader loader; - - EXPECT_TRUE(loader.getCountryHistoryElements().empty()); -} - -TEST(V3World_VanillaCountryHistoryLoaderTests, VanillaCountryHistoriesCanBeLoaded) -{ - V3::VanillaCountryHistoryLoader loader; - loader.loadVanillaCountryHistories(modFS); - - EXPECT_EQ(2, loader.getCountryHistoryElements().size()); - EXPECT_EQ(26, loader.getCountryHistoryElements().at("USA").size()); - EXPECT_EQ(3, loader.getCountryHistoryElements().at("UTE").size()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaAgreementEntryTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaAgreementEntryTests.cpp deleted file mode 100644 index b9c33d3..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaAgreementEntryTests.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "Loaders/VanillaDiplomacyLoader/VanillaAgreementEntry.h" -#include "gtest/gtest.h" - -TEST(V3World_VanillaAgreementEntryTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaAgreementEntry entry; - - EXPECT_TRUE(entry.getSourceTag().empty()); - EXPECT_TRUE(entry.getTargetTag().empty()); - EXPECT_TRUE(entry.getAgreementType().empty()); -} - -TEST(V3World_VanillaAgreementEntryTests, entryCanBeLoaded) -{ - std::stringstream input; - input << "country = c:POR type = defensive_pact\n"; - const V3::VanillaAgreementEntry entry(input, "GBR"); - - EXPECT_EQ("GBR", entry.getSourceTag()); - EXPECT_EQ("POR", entry.getTargetTag()); - EXPECT_EQ("defensive_pact", entry.getAgreementType()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaDiplomacyEntriesTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaDiplomacyEntriesTests.cpp deleted file mode 100644 index 25e3ac1..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaDiplomacyEntriesTests.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "Loaders/VanillaDiplomacyLoader/VanillaDiplomacyEntries.h" -#include "gtest/gtest.h" - -TEST(V3World_VanillaDiplomacyEntriesTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaDiplomacyEntries entries; - - EXPECT_TRUE(entries.getAgreementEntries().empty()); - EXPECT_TRUE(entries.getRelationEntries().empty()); - EXPECT_TRUE(entries.getTruceEntries().empty()); -} - -TEST(V3World_VanillaDiplomacyEntriesTests, entriesCanBeLoaded) -{ - std::stringstream input; - input << "c:GBR = {\n"; - input << " create_diplomatic_pact = { country = c:USA type = defensive_pact }\n"; - input << " set_relations = { country = c:BUR value = -30 }\n"; - input << " create_truce = { country = c:BEL months = 7 }\n "; - input << "}\n"; - input << "c:AUS = {\n"; - input << " create_diplomatic_pact = { country = c:MOD type = customs_union }\n"; - input << "}\n"; - input << "c:AUS = {\n"; - input << " set_relations = { country = c:KRA value = -31 }\n"; - input << " create_truce = { country = c:EGY months = 8 }\n "; - input << "}\n"; - const V3::VanillaDiplomacyEntries entries(input); - - ASSERT_EQ(2, entries.getAgreementEntries().size()); - const auto& agr1 = entries.getAgreementEntries()[0]; - const auto& agr2 = entries.getAgreementEntries()[1]; - - EXPECT_EQ("USA", agr1.getTargetTag()); - EXPECT_EQ("customs_union", agr2.getAgreementType()); - - ASSERT_EQ(2, entries.getRelationEntries().size()); - const auto& rel1 = entries.getRelationEntries()[0]; - const auto& rel2 = entries.getRelationEntries()[1]; - - EXPECT_EQ("BUR", rel1.getTargetTag()); - EXPECT_EQ(-31, rel2.getRelationValue()); - - ASSERT_EQ(2, entries.getTruceEntries().size()); - const auto& tru1 = entries.getTruceEntries()[0]; - const auto& tru2 = entries.getTruceEntries()[1]; - - EXPECT_EQ("BEL", tru1.getTargetTag()); - EXPECT_EQ(8, tru2.getDuration()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaDiplomacyLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaDiplomacyLoaderTests.cpp deleted file mode 100644 index 15a41bb..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaDiplomacyLoaderTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Loaders/VanillaDiplomacyLoader/VanillaDiplomacyLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_VanillaDiplomacyLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaDiplomacyLoader loader; - - EXPECT_TRUE(loader.getAgreementEntries().empty()); - EXPECT_TRUE(loader.getRelationEntries().empty()); - EXPECT_TRUE(loader.getTruceEntries().empty()); -} - -TEST(V3World_VanillaDiplomacyLoaderTests, VanillaAgreementsCanBeLoaded) -{ - V3::VanillaDiplomacyLoader loader; - loader.loadVanillaDiplomacy(modFS); - - EXPECT_EQ(13, loader.getAgreementEntries().size()); - EXPECT_EQ(5, loader.getRelationEntries().size()); - EXPECT_EQ(3, loader.getTruceEntries().size()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaRelationEntryTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaRelationEntryTests.cpp deleted file mode 100644 index 7ed2660..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaRelationEntryTests.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "Loaders/VanillaDiplomacyLoader/VanillaRelationEntry.h" -#include "gtest/gtest.h" - -TEST(V3World_VanillaRelationEntryTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaRelationEntry entry; - - EXPECT_TRUE(entry.getSourceTag().empty()); - EXPECT_TRUE(entry.getTargetTag().empty()); - EXPECT_EQ(0, entry.getRelationValue()); -} - -TEST(V3World_VanillaRelationEntryTests, entryCanBeLoaded) -{ - std::stringstream input; - input << "country = c:BUR value = -30\n"; - const V3::VanillaRelationEntry entry(input, "BIC"); - - EXPECT_EQ("BIC", entry.getSourceTag()); - EXPECT_EQ("BUR", entry.getTargetTag()); - EXPECT_EQ(-30, entry.getRelationValue()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaTruceEntryTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaTruceEntryTests.cpp deleted file mode 100644 index 21f9058..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomacyLoaderTests/VanillaTruceEntryTests.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "Loaders/VanillaDiplomacyLoader/VanillaTruceEntry.h" -#include "gtest/gtest.h" - -TEST(V3World_VanillaTruceEntryTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaTruceEntry entry; - - EXPECT_TRUE(entry.getSourceTag().empty()); - EXPECT_TRUE(entry.getTargetTag().empty()); - EXPECT_EQ(0, entry.getDuration()); -} - -TEST(V3World_VanillaTruceEntryTests, entryCanBeLoaded) -{ - std::stringstream input; - input << "country = c:GBR months = 6\n"; - const V3::VanillaTruceEntry entry(input, "GRE"); - - EXPECT_EQ("GRE", entry.getSourceTag()); - EXPECT_EQ("GBR", entry.getTargetTag()); - EXPECT_EQ(6, entry.getDuration()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomaticPlayLoaderTests/VanillaDiplomaticPlayEntriesTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomaticPlayLoaderTests/VanillaDiplomaticPlayEntriesTests.cpp deleted file mode 100644 index 5fef60e..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomaticPlayLoaderTests/VanillaDiplomaticPlayEntriesTests.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayEntries.h" -#include "gtest/gtest.h" - -TEST(V3World_VanillaDiplomaticPlayEntriesTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaDiplomaticPlayEntries entries; - - EXPECT_TRUE(entries.getDiploPlayElements().empty()); -} - -TEST(V3World_VanillaDiplomaticPlayEntriesTests, entriesCanBeLoaded) -{ - std::stringstream input; - input << "c:GBR = {\n"; - input << " create_diplomatic_play = {\n"; - input << " name = ragamuffin_war\n"; - input << " }\n"; - input << "}\n"; - input << "c:AUS = {\n"; - input << " create_diplomatic_play = {\n"; - input << " name = cabanagem_war\n"; - input << " }\n"; - input << " create_diplomatic_play = {\n"; - input << " name = cabanagem_war2\n"; - input << " }\n"; - input << "}\n"; - input << "c:AUS = {\n"; - input << " create_diplomatic_play = {\n"; - input << " name = cabanagem_war3\n"; - input << " }\n"; - input << "}\n"; - const V3::VanillaDiplomaticPlayEntries entries(input); - - ASSERT_EQ(2, entries.getDiploPlayElements().size()); - const auto& gbr = entries.getDiploPlayElements().at("GBR"); - const auto& aus = entries.getDiploPlayElements().at("AUS"); - - EXPECT_EQ("create_diplomatic_play = {\n\t\tname = ragamuffin_war\n\t}", gbr[0]); - - EXPECT_EQ("create_diplomatic_play = {\n\t\tname = cabanagem_war\n\t}", aus[0]); - EXPECT_EQ("create_diplomatic_play = {\n\t\tname = cabanagem_war2\n\t}", aus[1]); - EXPECT_EQ("create_diplomatic_play = {\n\t\tname = cabanagem_war3\n\t}", aus[2]); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomaticPlayLoaderTests/VanillaDiplomaticPlayLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomaticPlayLoaderTests/VanillaDiplomaticPlayLoaderTests.cpp deleted file mode 100644 index 5f20bd8..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaDiplomaticPlayLoaderTests/VanillaDiplomaticPlayLoaderTests.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "Loaders/VanillaDiplomaticPlayLoader/VanillaDiplomaticPlayLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_VanillaDiplomaticPlayLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaDiplomaticPlayLoader loader; - - EXPECT_TRUE(loader.getDiploPlayElements().empty()); -} - -TEST(V3World_VanillaDiplomaticPlayLoaderTests, VanillaDiplomaticPlaysCanBeLoaded) -{ - V3::VanillaDiplomaticPlayLoader loader; - loader.loadVanillaDiplomaticPlays(modFS); - - EXPECT_EQ(2, loader.getDiploPlayElements().size()); - EXPECT_EQ(2, loader.getDiploPlayElements().at("BRZ").size()); - EXPECT_EQ(1, loader.getDiploPlayElements().at("TEX").size()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaPopulationHistoryLoaderTests/VanillaPopulationHistoryLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaPopulationHistoryLoaderTests/VanillaPopulationHistoryLoaderTests.cpp deleted file mode 100644 index 7478aa1..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaPopulationHistoryLoaderTests/VanillaPopulationHistoryLoaderTests.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "Loaders/VanillaPopulationHistoryLoader/VanillaPopulationHistoryLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_VanillaPopulationHistoryLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaPopulationHistoryLoader loader; - - EXPECT_TRUE(loader.getPopulationHistoryElements().empty()); -} - -TEST(V3World_VanillaPopulationHistoryLoaderTests, VanillaPopulationHistoriesCanBeLoaded) -{ - V3::VanillaPopulationHistoryLoader loader; - loader.loadVanillaPopulationHistories(modFS); - - EXPECT_EQ(2, loader.getPopulationHistoryElements().size()); - EXPECT_EQ(2, loader.getPopulationHistoryElements().at("RUS").size()); - EXPECT_EQ(2, loader.getPopulationHistoryElements().at("KRA").size()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaStateEntriesTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaStateEntriesTests.cpp deleted file mode 100644 index 9ee4d47..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaStateEntriesTests.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "Loaders/VanillaStateLoader/VanillaStateEntries.h" -#include "gtest/gtest.h" - -TEST(V3World_VanillaStateEntriesTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaStateEntries entries; - - EXPECT_TRUE(entries.getStates().empty()); -} - -TEST(V3World_VanillaStateEntriesTests, StateEntriesCanBeLoaded) -{ - std::stringstream input; - input << "S:STATE_A = {\n "; - input << " create_state= {\n "; - input << " country = c:USA\n "; - input << " owned_provinces = {\n"; - input << " x5A4A79 \"x450FD3\" x7B3020\n"; - input << " }\n"; - input << " state_type = unincorporated\n"; - input << " }\n "; - input << " add_homeland = dakota\n"; - input << "}\n"; - input << "s:STATE_B = {\n "; - input << " create_state = {\n "; - input << " country = c:USB\n "; - input << " owned_provinces = {\n"; - input << " x5A4A70 \"x450FD0\" x7B3000\n"; - input << " }\n"; - input << " }\n "; - input << " add_homeland = yankee\n"; - input << "}\n"; - const V3::VanillaStateEntries entries(input); - - ASSERT_EQ(2, entries.getStates().size()); - const auto& state1 = entries.getStates().at("STATE_A"); - const auto& state2 = entries.getStates().at("STATE_B"); - - EXPECT_EQ("dakota", *state1.getHomelands().begin()); - EXPECT_EQ("yankee", *state2.getHomelands().begin()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaStateEntryTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaStateEntryTests.cpp deleted file mode 100644 index a4ffdee..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaStateEntryTests.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "Loaders/VanillaStateLoader/VanillaStateEntry.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_VanillaStateEntryTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaStateEntry entry; - - EXPECT_TRUE(entry.getHomelands().empty()); - EXPECT_TRUE(entry.getSubStates().empty()); -} - -TEST(V3World_VanillaStateEntryTests, StateEntryCanBeLoaded) -{ - std::stringstream input; - input << "create_state= {\n "; - input << " country = c:USA\n "; - input << " owned_provinces = {\n"; - input << " x5A4A79 \"x450FD3\" x7B3020\n"; - input << " }\n"; - input << " state_type = unincorporated\n"; - input << "}\n "; - input << "create_state = {\n "; - input << " country = c:USB\n "; - input << " owned_provinces = {\n"; - input << " x5A4A70 \"x450FD0\" x7B3000\n"; - input << " }\n"; - input << "}\n "; - input << "add_homeland = yankee\n"; - input << "add_homeland = dakota\n"; - const V3::VanillaStateEntry entry(input); - - EXPECT_THAT(entry.getHomelands(), testing::UnorderedElementsAre("yankee", "dakota")); - ASSERT_EQ(2, entry.getSubStates().size()); - - const auto& sub1 = entry.getSubStates()[0]; - const auto& sub2 = entry.getSubStates()[1]; - EXPECT_EQ("USA", sub1.getOwnerTag()); - EXPECT_EQ("USB", sub2.getOwnerTag()); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaStateLoaderTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaStateLoaderTests.cpp deleted file mode 100644 index adc76c4..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaStateLoaderTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Loaders/VanillaStateLoader/VanillaStateLoader.h" -#include "gtest/gtest.h" - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_VanillaStateLoaderTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaStateLoader loader; - - EXPECT_TRUE(loader.getStates().empty()); -} - -TEST(V3World_VanillaStateLoaderTests, VanillaStatesCanBeLoaded) -{ - V3::VanillaStateLoader loader; - loader.loadVanillaStates(modFS); - - ASSERT_EQ(4, loader.getStates().size()); - EXPECT_TRUE(loader.getStates().contains("STATE_TEST_LAND1")); - EXPECT_TRUE(loader.getStates().contains("STATE_TEST_LAND2")); - EXPECT_TRUE(loader.getStates().contains("STATE_TEST_LAND3")); - EXPECT_TRUE(loader.getStates().contains("STATE_TEST_LAND4")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaSubStateEntryTests.cpp b/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaSubStateEntryTests.cpp deleted file mode 100644 index 99d6238..0000000 --- a/EU5ToVic3Tests/V3WorldTests/LoaderTests/VanillaStateLoaderTests/VanillaSubStateEntryTests.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "Loaders/VanillaStateLoader/VanillaSubStateEntry.h" -#include "gtest/gtest.h" -#include - -TEST(V3World_VanillaSubStateEntryTests, DefaultsDefaultToDefaults) -{ - const V3::VanillaSubStateEntry entry; - - EXPECT_TRUE(entry.getOwnerTag().empty()); - EXPECT_TRUE(entry.getSubStateTypes().empty()); - EXPECT_TRUE(entry.getProvinces().empty()); -} - -TEST(V3World_VanillaSubStateEntryTests, entryCanBeLoaded) -{ - std::stringstream input; - input << "country = c:USA\n "; - input << "owned_provinces = {\n"; - input << " x5A4A79 \"x450FD3\" x7B3020\n"; - input << "}\n"; - input << "state_type = unincorporated\n"; - input << "state_type = treaty_port\n"; - const V3::VanillaSubStateEntry entry(input); - - EXPECT_EQ("USA", entry.getOwnerTag()); - EXPECT_THAT(entry.getSubStateTypes(), testing::UnorderedElementsAre("unincorporated", "treaty_port")); - EXPECT_THAT(entry.getProvinces(), testing::UnorderedElementsAre("x5A4A79", "x450FD3", "x7B3020")); -} - -TEST(V3World_VanillaSubStateEntryTests, oddSubStateOwnersThrowWarning) -{ - std::stringstream input; - input << "country = USA\n "; - input << "owned_provinces = {\n"; - input << " x5A4A79 \"x450FD3\" x7B3020\n"; - input << "}\n"; - input << "state_type = unincorporated\n"; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - const V3::VanillaSubStateEntry entry(input); - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([WARNING] Unrecognized substate country for USA!)")); - std::cout.rdbuf(cout_buffer); - - EXPECT_EQ("USA", entry.getOwnerTag()); - EXPECT_THAT(entry.getSubStateTypes(), testing::UnorderedElementsAre("unincorporated")); - EXPECT_THAT(entry.getProvinces(), testing::UnorderedElementsAre("x5A4A79", "x450FD3", "x7B3020")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/PoliticalManagerTests/CountryTests/CountryTests.cpp b/EU5ToVic3Tests/V3WorldTests/PoliticalManagerTests/CountryTests/CountryTests.cpp deleted file mode 100644 index 380bf29..0000000 --- a/EU5ToVic3Tests/V3WorldTests/PoliticalManagerTests/CountryTests/CountryTests.cpp +++ /dev/null @@ -1,336 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/SubState.h" -#include "CommonFunctions.h" -#include "CountryManager/EU4Country.h" -#include "CountryTierMapper/CountryTierMapper.h" -#include "CultureMapper/CultureMapper.h" -#include "Loaders/CultureLoader/CultureLoader.h" -#include "Loaders/LawLoader/LawLoader.h" -#include "Loaders/LocLoader/LocalizationLoader.h" -#include "Loaders/LocalizationLoader/EU4LocalizationLoader.h" -#include "Loaders/ReligionLoader/ReligionLoader.h" -#include "Loaders/TechLoader/TechLoader.h" -#include "PoliticalManager/Country/Country.h" -#include "ReligionMapper/ReligionMapper.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -} - -TEST(V3World_CountryTests, DefaultsDefaultToDefaults) -{ - const V3::Country country; - EXPECT_TRUE(country.getTag().empty()); - EXPECT_FALSE(country.getVanillaData()); - EXPECT_TRUE(country.getSubStates().empty()); - EXPECT_FALSE(country.getSourceCountry()); -} - -TEST(V3World_CountryTests, VanillaDataSpawnsEmptyWhenInitializedFromStream) -{ - std::stringstream input; - V3::Country country; - country.initializeCountry(input); - - ASSERT_TRUE(country.getVanillaData()); - EXPECT_TRUE(country.getVanillaData()->type.empty()); - EXPECT_TRUE(country.getVanillaData()->tier.empty()); - EXPECT_TRUE(country.getVanillaData()->cultures.empty()); - EXPECT_TRUE(country.getVanillaData()->religion.empty()); - EXPECT_TRUE(country.getVanillaData()->capitalStateName.empty()); - EXPECT_EQ(std::nullopt, country.getVanillaData()->color); - EXPECT_FALSE(country.getVanillaData()->is_named_from_capital); -} - -TEST(V3World_CountryTests, CountryCanBeInitializedViaVanillaData) -{ - std::stringstream input; - input << "country_type = recognized\n "; - input << "tier = empire\n "; - input << "cultures = { cul1 cul2 }\n "; - input << "religion = protestant\n "; - input << "capital = STATE_TEST_1\n "; - input << "color = {147 130 110}\n "; - input << "is_named_from_capital = yes\n "; - V3::Country country; - country.initializeCountry(input); - - EXPECT_EQ("recognized", country.getVanillaData()->type); - EXPECT_EQ("empire", country.getVanillaData()->tier); - EXPECT_THAT(country.getVanillaData()->cultures, testing::UnorderedElementsAre("cul1", "cul2")); - EXPECT_EQ("protestant", country.getVanillaData()->religion); - EXPECT_EQ("STATE_TEST_1", country.getVanillaData()->capitalStateName); - EXPECT_EQ(commonItems::Color(std::array{147, 130, 110}), country.getVanillaData()->color); - EXPECT_TRUE(country.getVanillaData()->is_named_from_capital); -} - -TEST(V3World_CountryTests, CountryTagCanBeSetAndGet) -{ - V3::Country country; - country.setTag("TAG"); - EXPECT_EQ("TAG", country.getTag()); -} - -TEST(V3World_CountryTests, CountryCanImportColorFromEU4) -{ - const V3::ClayManager clayManager; - - V3::Country country; - country.setTag("GAT"); - const auto srcCountry = std::make_shared(); - srcCountry->setTag("TAG"); - srcCountry->setMapColor(commonItems::Color(std::array{1, 2, 3})); - country.setSourceCountry(srcCountry); - - mappers::CultureMapper culMapper; - country.convertFromEU4Country(clayManager, culMapper, {}, {}, {}, {}, {}, false); - - EXPECT_TRUE(country.getProcessedData().color); - EXPECT_EQ(commonItems::Color(std::array{1, 2, 3}), country.getProcessedData().color); -} - -TEST(V3World_CountryTests, CountryWillOverrideVic3colorWithEU4Color) -{ - const V3::ClayManager clayManager; - - std::stringstream input; - input << "color = { 4 5 6 }"; - V3::Country country; - country.initializeCountry(input); - country.setTag("GAT"); - - const auto srcCountry = std::make_shared(); - srcCountry->setTag("TAG"); - srcCountry->setMapColor(commonItems::Color(std::array{1, 2, 3})); - country.setSourceCountry(srcCountry); - - mappers::CultureMapper culMapper; - country.convertFromEU4Country(clayManager, culMapper, {}, {}, {}, {}, {}, false); - - EXPECT_TRUE(country.getProcessedData().color); - EXPECT_EQ(commonItems::Color(std::array{1, 2, 3}), country.getProcessedData().color); -} - -TEST(V3World_CountryTests, CountryWillNotOverrideVic3colorWithEU4ColorIfNone) -{ - const V3::ClayManager clayManager; - - std::stringstream input; - input << "color = { 4 5 6 }"; - V3::Country country; - country.initializeCountry(input); - country.setTag("GAT"); - - const auto srcCountry = std::make_shared(); - srcCountry->setTag("TAG"); - country.setSourceCountry(srcCountry); - - mappers::CultureMapper culMapper; - country.convertFromEU4Country(clayManager, culMapper, {}, {}, {}, {}, {}, false); - - EXPECT_TRUE(country.getProcessedData().color); - EXPECT_EQ(commonItems::Color(std::array{4, 5, 6}), country.getProcessedData().color); -} - -TEST(V3World_CountryTests, LocalizationsAreAvailable) -{ - const V3::ClayManager clayManager; - - const auto srcCountry = std::make_shared(); - srcCountry->setTag("TAG"); - srcCountry->setLocalizationName("english", "Name1"); - srcCountry->setLocalizationName("albanian", "Name2"); - srcCountry->setLocalizationName("alien", "Name3"); - srcCountry->setLocalizationAdjective("english", "Adj1"); - srcCountry->setLocalizationAdjective("albanian", "Adj2"); - srcCountry->setLocalizationAdjective("alien", "Adj3"); - - V3::Country country; - country.setTag("GAT"); - country.setSourceCountry(srcCountry); - mappers::CultureMapper culMapper; - country.convertFromEU4Country(clayManager, culMapper, {}, {}, {}, {}, {}, false); - - EXPECT_EQ("Name1", country.getName("english")); - EXPECT_EQ("Name2", country.getName("albanian")); - EXPECT_EQ("Name3", country.getName("alien")); - EXPECT_EQ("Adj1", country.getAdjective("english")); - EXPECT_EQ("Adj2", country.getAdjective("albanian")); - EXPECT_EQ("Adj3", country.getAdjective("alien")); -} - -TEST(V3World_CountryTests, MissingLocalizationsDefaultToEnglish) -{ - const V3::ClayManager clayManager; - - const auto srcCountry = std::make_shared(); - srcCountry->setTag("TAG"); - srcCountry->setLocalizationName("english", "Name1"); - srcCountry->setLocalizationAdjective("english", "Adj1"); - - V3::Country country; - country.setTag("GAT"); - country.setSourceCountry(srcCountry); - mappers::CultureMapper culMapper; - country.convertFromEU4Country(clayManager, culMapper, {}, {}, {}, {}, {}, false); - - EXPECT_EQ("Name1", country.getName("english")); - EXPECT_EQ("Name1", country.getName("albanian")); - EXPECT_EQ("Name1", country.getName("alien")); - EXPECT_EQ("Adj1", country.getAdjective("english")); - EXPECT_EQ("Adj1", country.getAdjective("albanian")); - EXPECT_EQ("Adj1", country.getAdjective("alien")); -} - -TEST(V3World_CountryTests, AbsentLocalizationsDefaultToTag) -{ - const V3::ClayManager clayManager; - - const auto srcCountry = std::make_shared(); - srcCountry->setTag("TAG"); - - V3::Country country; - country.setTag("GAT"); - country.setSourceCountry(srcCountry); - mappers::CultureMapper culMapper; - country.convertFromEU4Country(clayManager, culMapper, {}, {}, {}, {}, {}, false); - - EXPECT_EQ("GAT", country.getName("english")); - EXPECT_EQ("GAT_ADJ", country.getAdjective("english")); -} - -TEST(V3World_CountryTests, CountryCanSpeedCopyVanillaData) -{ - std::stringstream input; - input << "country_type = recognized\n "; - input << "tier = empire\n "; - input << "cultures = { cul1 cul2 }\n "; - input << "religion = protestant\n "; - input << "capital = STATE_TEST_1\n "; - input << "color = {147 130 110}\n "; - input << "is_named_from_capital = yes\n "; - V3::Country country; - country.setTag("AAA"); - country.initializeCountry(input); - - V3::LocalizationLoader locLoader; - std::stringstream locInput; - locInput << commonItems::utf8BOM << "l_english:\n"; - locInput << " AAA: \"The country\"\n"; - locInput << " AAA_ADJ: \"The adjective\"\n"; - locLoader.scrapeStream(locInput, "english"); - - country.copyVanillaData(locLoader, EU4::EU4LocalizationLoader()); - - EXPECT_EQ("recognized", country.getProcessedData().type); - EXPECT_EQ("empire", country.getProcessedData().tier); - EXPECT_THAT(country.getProcessedData().cultures, testing::UnorderedElementsAre("cul1", "cul2")); - EXPECT_EQ("protestant", country.getProcessedData().religion); - EXPECT_EQ("STATE_TEST_1", country.getProcessedData().capitalStateName); - EXPECT_EQ(commonItems::Color(std::array{147, 130, 110}), country.getProcessedData().color); - EXPECT_TRUE(country.getProcessedData().is_named_from_capital); - EXPECT_EQ("The country", country.getProcessedData().namesByLanguage.at("english")); - EXPECT_EQ("The adjective", country.getProcessedData().adjectivesByLanguage.at("english")); -} - -TEST(V3World_CountryTests, CountryWontSpeedCopyMissingVanillaData) -{ - V3::Country country; - - country.copyVanillaData(V3::LocalizationLoader(), EU4::EU4LocalizationLoader()); - - EXPECT_TRUE(country.getProcessedData().type.empty()); - EXPECT_TRUE(country.getProcessedData().tier.empty()); - EXPECT_TRUE(country.getProcessedData().cultures.empty()); - EXPECT_TRUE(country.getProcessedData().religion.empty()); - EXPECT_TRUE(country.getProcessedData().capitalStateName.empty()); - EXPECT_FALSE(country.getProcessedData().color); - EXPECT_FALSE(country.getProcessedData().is_named_from_capital); -} - -TEST(V3World_CountryTests, PopCounterSumsSubStatePop) -{ - V3::Country country; - std::vector> substates; - - EXPECT_EQ(0, country.getPopCount()); - EXPECT_EQ(0, V3::Country::getPopCount(substates)); - - auto sub0 = std::make_shared(); - auto sub1 = std::make_shared(); - - V3::Pop pop0, pop1; - pop0.setSize(1000); - pop1.setSize(500); - - sub0->addPop(pop0); - sub1->addPop(pop1); - - substates.push_back(sub0); - substates.push_back(sub1); - - EXPECT_EQ(0, country.getPopCount()); - EXPECT_EQ(1500, V3::Country::getPopCount(substates)); - - country.addSubState(sub0); - country.addSubState(sub1); - - EXPECT_EQ(1500, country.getPopCount()); -} - -TEST(V3World_CountryTests, InfrastructureFromCountryTech) -{ - V3::Country country; - - V3::TechLoader techLoader; - techLoader.loadTechs(modFS); - - V3::ProcessedData data; - data.techs.emplace("tech_1"); // Mult 20%, Max of 40 - data.techs.emplace("tech_2"); // Mult 5%, Max of 10 - data.techs.emplace("tech_4"); // No effect - - country.setProcessedData(data); - - EXPECT_EQ(50, country.getTechInfraCap(techLoader.getTechs())); - EXPECT_DOUBLE_EQ(0.25, country.getTechInfraMult(techLoader.getTechs())); -} - -TEST(V3World_CountryTests, GetGovernmentBuildingMaxCapacities) -{ - V3::Country country; - - V3::LawLoader lawLoader; - lawLoader.loadLaws(modFS); - - V3::TechLoader techLoader; - techLoader.loadTechs(modFS); - - - V3::ProcessedData data; - data.laws.emplace("law_2"); // None - data.laws.emplace("law_3"); // 70 Barracks - data.laws.emplace("law_4"); // 30 Barracks - data.techs.emplace("tech_2"); // 15 Bases, 2 Ports - data.techs.emplace("tech_3"); // None - data.techs.emplace("tech_4"); // 10 Bases, 4 Ports - - country.setProcessedData(data); - - EXPECT_EQ(100, country.getGovBuildingMax("building_barracks", lawLoader.getLaws(), techLoader.getTechs())); - EXPECT_EQ(25, country.getGovBuildingMax("building_naval_base", lawLoader.getLaws(), techLoader.getTechs())); - EXPECT_EQ(6, country.getGovBuildingMax("building_port", lawLoader.getLaws(), techLoader.getTechs())); -} - -TEST(V3World_CountryTests, YearCapFactorHitsCurve) -{ - EXPECT_NEAR(1, V3::Country::yearCapFactor(date("1836.1.1")), 0.01); - EXPECT_NEAR(0.85, V3::Country::yearCapFactor(date("1821.1.1")), 0.01); - EXPECT_NEAR(0.5, V3::Country::yearCapFactor(date("1750.1.1")), 0.01); - EXPECT_NEAR(0.3, V3::Country::yearCapFactor(date("1650.1.1")), 0.015); - EXPECT_NEAR(0.2, V3::Country::yearCapFactor(date("1490.1.1")), 0.01); - EXPECT_NEAR(0.15, V3::Country::yearCapFactor(date("1350.1.1")), 0.01); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/PoliticalManagerTests/PoliticalManagerTests.cpp b/EU5ToVic3Tests/V3WorldTests/PoliticalManagerTests/PoliticalManagerTests.cpp deleted file mode 100644 index d4910db..0000000 --- a/EU5ToVic3Tests/V3WorldTests/PoliticalManagerTests/PoliticalManagerTests.cpp +++ /dev/null @@ -1,279 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/State.h" -#include "ClayManager/State/SubState.h" -#include "CountryManager/EU4Country.h" -#include "CountryMapper/CountryMapper.h" -#include "CultureLoader/CultureLoader.h" -#include "CultureMapper/CultureMapper.h" -#include "Loaders/LocLoader/LocalizationLoader.h" -#include "LocalizationLoader/EU4LocalizationLoader.h" -#include "PoliticalManager/Country/Country.h" -#include "PoliticalManager/PoliticalManager.h" -#include "PopManager/PopManager.h" -#include "ProvinceManager/ProvinceManager.h" -#include "ProvinceMapper/ProvinceMapper.h" -#include "ReligionLoader/ReligionLoader.h" -#include "ReligionMapper/ReligionMapper.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); -const auto eu4FS = commonItems::ModFilesystem("TestFiles/eu4installation/", {}); - -std::tuple -prepMappers() -{ - EU4::DefaultMapParser defaults; - defaults.loadDefaultMap(eu4FS); - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(eu4FS); - EU4::RegionManager regionMapper; - regionMapper.loadRegions(eu4FS); - - std::stringstream provinceStream; - provinceStream << "-1={}\n"; // sea, no ownership - provinceStream << "-2={ owner = TA2 base_tax=10 base_production=10 base_manpower=10 culture = culture1 religion = catholic }\n"; // substate TA-2&3 - provinceStream << "-3={ owner = TA3 base_tax=1 base_production=1 base_manpower=1 culture = culture2 religion = protestant }\n"; // substate TA-2&3 - provinceStream << "-4={}\n"; // irrelevant - provinceStream << "-5={}\n"; // irrelevant - provinceStream << "-6={}\n"; // irrelevant - provinceStream << "-7={}\n"; // irrelevant - provinceStream << "-8={}\n"; // irrelevant - provinceStream << "-9={ owner = TA9 base_tax=1 base_production=1 base_manpower=1 culture = culture3 religion = anglican }\n"; // substate TA-9 - provinceStream << "-10={}\n"; // irrelevant - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provinceStream); - provinceManager.loadDefaultMapParser(defaults); - provinceManager.loadDefinitionScraper(definitions); - provinceManager.classifyProvinces(regionMapper); - provinceManager.buildProvinceWeights({}); - provinceManager.buildPopRatios({}, false); - - mappers::ProvinceMapper provinceMapper; - provinceMapper.loadProvinceMappings("TestFiles/configurables/province_mappings_chunks.txt"); - - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - clayManager.generateChunks(provinceMapper, provinceManager); - - std::stringstream countryStream; - const auto ta2 = std::make_shared("TA2", countryStream); - const auto ta3 = std::make_shared("TA3", countryStream); - const auto ta9 = std::make_shared("TA9", countryStream); - const std::map> countries = {{"TA2", ta2}, {"TA3", ta3}, {"TA9", ta9}}; - clayManager.unDisputeChunkOwnership(countries); - clayManager.splitChunksIntoSubStates(); - - auto countryMapper = std::make_shared(); - countryMapper->loadMappingRules("TestFiles/configurables/country_mappings.txt"); - V3::PoliticalManager politicalManager; - politicalManager.loadCountryMapper(countryMapper); - politicalManager.importEU4Countries(countries); - clayManager.assignSubStateOwnership(politicalManager.getCountries(), *countryMapper); - - EU4::ReligionLoader religionLoader; - religionLoader.loadReligions(eu4FS); - EU4::CultureLoader cultureLoader; - cultureLoader.loadCultures(eu4FS); - - mappers::ReligionMapper relMapper; - relMapper.loadMappingRules("TestFiles/configurables/religion_map.txt"); - relMapper.expandReligionMappings(religionLoader.getAllReligions()); - - mappers::CultureMapper culMapper; - culMapper.loadMappingRules("TestFiles/configurables/culture_map.txt"); - culMapper.expandCulturalMappings(clayManager, cultureLoader, religionLoader); - - V3::PopManager popManager; - popManager.initializeVanillaPops(modFS); - popManager.initializeDWPops(modFS); - popManager.convertDemographics(clayManager, culMapper, relMapper, cultureLoader, religionLoader); - - politicalManager.initializeVanillaCountries(modFS, modFS); - politicalManager.loadCountryMapper(countryMapper); - politicalManager.importEU4Countries(countries); - - return std::tuple{politicalManager, popManager, culMapper, relMapper, clayManager, cultureLoader, religionLoader}; -} -} // namespace - -TEST(V3World_PoliticalManagerTests, PoliticalManagerCanInitializeVanillaCountries) -{ - V3::PoliticalManager politicalManager; - - EXPECT_EQ(0, politicalManager.getCountries().size()); - - politicalManager.initializeVanillaCountries(modFS, modFS); - - ASSERT_EQ(4, politicalManager.getCountries().size()); - - const auto& country1 = politicalManager.getCountry("TAG"); - const auto& country2 = politicalManager.getCountry("GAT"); - const auto& country3 = politicalManager.getCountry("TGA"); - const auto& country4 = politicalManager.getCountry("CCC"); - - EXPECT_EQ("TAG", country1->getTag()); - EXPECT_EQ("GAT", country2->getTag()); - EXPECT_EQ("TGA", country3->getTag()); - EXPECT_EQ("CCC", country4->getTag()); - - EXPECT_FALSE(politicalManager.isTagDecentralized("TAG")); - EXPECT_FALSE(politicalManager.isTagDecentralized("GAT")); - EXPECT_FALSE(politicalManager.isTagDecentralized("TGA")); - EXPECT_TRUE(politicalManager.isTagDecentralized("CCC")); -} - -TEST(V3World_PoliticalManagerTests, PoliticalManagerCanImportCountries) -{ - const auto countryMapper = std::make_shared(); - countryMapper->loadMappingRules("TestFiles/configurables/country_mappings.txt"); - - std::stringstream countryStream; - const auto ta2 = std::make_shared("TA2", countryStream); - const auto ta3 = std::make_shared("TA3", countryStream); - const auto ta9 = std::make_shared("TA9", countryStream); - const std::map> countries = {{"TA2", ta2}, {"TA3", ta3}, {"TA9", ta9}}; - - V3::PoliticalManager politicalManager; - politicalManager.loadCountryMapper(countryMapper); - politicalManager.importEU4Countries(countries); - - EXPECT_EQ(3, politicalManager.getCountries().size()); - - const auto& country1 = politicalManager.getCountries().at("GA2"); - const auto& country2 = politicalManager.getCountries().at("X00"); - const auto& country3 = politicalManager.getCountries().at("GA9"); - - EXPECT_EQ("TA2", country1->getSourceCountry()->getTag()); - EXPECT_EQ("TA3", country2->getSourceCountry()->getTag()); - EXPECT_EQ("TA9", country3->getSourceCountry()->getTag()); -} - -TEST(V3World_PoliticalManagerTests, PoliticalManagerCanConvertVanillaCountries) -{ - const V3::ClayManager clayManager; - const EU4::EU4LocalizationLoader eu4LocLoader; - const V3::LocalizationLoader v3LocLoader; - - const auto countryMapper = std::make_shared(); - countryMapper->loadMappingRules("TestFiles/configurables/country_mappings.txt"); - - std::stringstream countryStream; - const auto ta2 = std::make_shared("TA2", countryStream); - const auto ta3 = std::make_shared("TA3", countryStream); - const auto ta9 = std::make_shared("TA9", countryStream); - const std::map> countries = {{"TA2", ta2}, {"TA3", ta3}, {"TA9", ta9}}; - - V3::PoliticalManager politicalManager; - - EXPECT_EQ(0, politicalManager.getCountries().size()); - politicalManager.initializeVanillaCountries(modFS, modFS); - EXPECT_EQ(4, politicalManager.getCountries().size()); // we have 4 vanilla vic3 countries, unrelated to eu4. - politicalManager.loadCountryMapper(countryMapper); - politicalManager.importEU4Countries(countries); - EXPECT_EQ(7, politicalManager.getCountries().size()); // we append the 3 imported eu4 countries. - - const auto& country1 = politicalManager.getCountries().at("GA2"); - const auto& country2 = politicalManager.getCountries().at("X00"); - const auto& country3 = politicalManager.getCountries().at("GA9"); - const auto& country4 = politicalManager.getCountries().at("TAG"); - const auto& country5 = politicalManager.getCountries().at("GAT"); - const auto& country6 = politicalManager.getCountries().at("TGA"); - const auto& country7 = politicalManager.getCountries().at("CCC"); - - EXPECT_FALSE(country1->getProcessedData().color); // these 3 eu4 countries have no color. - EXPECT_FALSE(country2->getProcessedData().color); - EXPECT_FALSE(country3->getProcessedData().color); - EXPECT_FALSE(country4->getProcessedData().color); // these 3 vanilla ones are also blank. - EXPECT_FALSE(country5->getProcessedData().color); - EXPECT_FALSE(country6->getProcessedData().color); - EXPECT_FALSE(country7->getProcessedData().color); - - mappers::CultureMapper culMapper; - politicalManager.convertAllCountries(clayManager, culMapper, {}, {}, {}, v3LocLoader, eu4LocLoader, false); // now we process only the 3 vanilla countries. - - EXPECT_FALSE(country1->getProcessedData().color); // these 3 eu4 countries still have no color. - EXPECT_FALSE(country2->getProcessedData().color); - EXPECT_FALSE(country3->getProcessedData().color); - EXPECT_EQ(commonItems::Color(std::array{147, 130, 110}), country4->getProcessedData().color); // however these 3 vanilla ones have their color copied over. - EXPECT_EQ(commonItems::Color(std::array{0.99f, 0.7f, 0.9f}), country5->getProcessedData().color); // since they are processed standalone. - EXPECT_EQ(commonItems::Color(std::array{62, 122, 189}), country6->getProcessedData().color); - EXPECT_EQ(commonItems::Color(std::array{62, 122, 190}), country7->getProcessedData().color); -} - -TEST(V3World_PoliticalManagerTests, PoliticalManagerCanGenerateDecentralizedCountries) -{ - auto [politicalManager, popManager, culMapper, relMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - // link = { eu4 = 4 vic3 = x000005 } # wasteland -> land - // We need to manually create an empty substate for this province so that it can spawn a country. - auto state = clayManager.getStates().at("STATE_TEST_LAND3"); - auto prov5 = state->getProvinces().at("x000005"); - auto sub5 = std::make_shared(state, V3::ProvinceMap({std::pair("x000005", prov5)})); - state->addSubState(sub5); - - politicalManager.generateDecentralizedCountries(clayManager, popManager); - - // this link will produce a decentralized state with a single substate containing 4->x5 province. - // name will be X01 as X00 is already taken by TA3 finding no mapping in country_mappings.txt. - - ASSERT_TRUE(politicalManager.getCountries().contains("X01")); - const auto& x01 = politicalManager.getCountries().at("X01"); - EXPECT_FALSE(x01->getSourceCountry()); // this country has no EU4 source. - - ASSERT_EQ(1, x01->getSubStates().size()); - const auto& substate = x01->getSubStates()[0]; - EXPECT_TRUE(substate->getProvinces().contains("x000005")); - ASSERT_TRUE(substate->getOwnerTag()); - EXPECT_EQ("X01", *substate->getOwnerTag()); - - // culture is based on original population of STATE_TEST_LAND3 in vanilla installation, thus, swedish. - EXPECT_TRUE(x01->getProcessedData().cultures.contains("swedish")); -} - -TEST(V3World_PoliticalManagerTests, DecentralizedCountriesCanBeFilled) -{ - auto [politicalManager, popManager, culMapper, relMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - // link = { eu4 = 4 vic3 = x000005 } # wasteland -> land - // We need to manually create an empty substate for this province so that it can spawn a country. - auto state = clayManager.getStates().at("STATE_TEST_LAND3"); - auto prov5 = state->getProvinces().at("x000005"); - auto sub5 = std::make_shared(state, V3::ProvinceMap({std::pair("x000005", prov5)})); - state->addSubState(sub5); - - politicalManager.generateDecentralizedCountries(clayManager, popManager); - politicalManager - .convertAllCountries(clayManager, culMapper, relMapper, cultureLoader, religionLoader, V3::LocalizationLoader(), EU4::EU4LocalizationLoader(), false); - - ASSERT_TRUE(politicalManager.getCountries().contains("X01")); - const auto& x01 = politicalManager.getCountries().at("X01"); - - // Name is "generated". Don't need locmappers for simple capitalization example. - EXPECT_EQ("Swedish Federation", x01->getName("english")); -} - -TEST(V3World_PoliticalManagerTests, MajorFormablesCanBeAltered) -{ - auto [politicalManager, popManager, culMapper, relMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - politicalManager.loadMajorFormables("TestFiles/vic3installation/game/common/country_formation/00_major_formables.txt"); - - auto ger = std::make_shared(); - V3::ProcessedData data; - data.cultures = {"some_german"}; - ger->setProcessedData(data); - politicalManager.addCountry({"GER", ger}); - - politicalManager.alterMajorFormables(); - - const auto& gerFormable = politicalManager.getMajorFormables().at("GER"); - - EXPECT_THAT(gerFormable.getCultures(), testing::UnorderedElementsAre("north_german", "south_german", "weder_german", "some_german")); -} \ No newline at end of file diff --git a/EU5ToVic3Tests/V3WorldTests/PoliticalManagerTests/TechValuesTests/TechValuesTests.cpp b/EU5ToVic3Tests/V3WorldTests/PoliticalManagerTests/TechValuesTests/TechValuesTests.cpp deleted file mode 100644 index 934107f..0000000 --- a/EU5ToVic3Tests/V3WorldTests/PoliticalManagerTests/TechValuesTests/TechValuesTests.cpp +++ /dev/null @@ -1,137 +0,0 @@ -#include "ClayManager/State/SubState.h" -#include "CountryManager/EU4Country.h" -#include "CountryManager/EU4CountryManager.h" -#include "PoliticalManager/Country/Country.h" -#include "PoliticalManager/TechValues/TechValues.h" -#include "gtest/gtest.h" - -TEST(V3World_TechValuesTests, CountryIsValidFailsForLandlessCountries) -{ - V3::Country country; - const auto eu4Country = std::make_shared(); - country.setSourceCountry(eu4Country); - - EXPECT_FALSE(V3::TechValues::isValidCountryForTechConversion(country)); - - const auto subState = std::make_shared(); - country.addSubState(subState); - - EXPECT_TRUE(V3::TechValues::isValidCountryForTechConversion(country)); -} - -TEST(V3World_TechValuesTests, CountryIsValidFailsForSourceLessCountries) -{ - V3::Country country; - const auto subState = std::make_shared(); - country.addSubState(subState); - - EXPECT_FALSE(V3::TechValues::isValidCountryForTechConversion(country)); - - const auto eu4Country = std::make_shared(); - country.setSourceCountry(eu4Country); - - EXPECT_TRUE(V3::TechValues::isValidCountryForTechConversion(country)); -} - -TEST(V3World_TechValuesTests, CountryIsValidPassesForLandedEU4ImportedCountries) -{ - V3::Country country; - const auto subState = std::make_shared(); - country.addSubState(subState); - const auto eu4Country = std::make_shared(); - country.setSourceCountry(eu4Country); - - EXPECT_TRUE(V3::TechValues::isValidCountryForTechConversion(country)); -} - -TEST(V3World_TechValuesTests, TechValuesCanBeGeneratedAndPinged) -{ - // load base eu4 countries with some tech - std::stringstream eu4input; - eu4input << "TA1 = { technology = { adm_tech = 1 dip_tech = 5 mil_tech = 7 } }\n"; - eu4input << "TA2 = { technology = { adm_tech = 5 dip_tech = 1 mil_tech = 5 } }\n"; - eu4input << "TA3 = { technology = { adm_tech = 7 dip_tech = 7 mil_tech = 1 } }\n"; - EU4::CountryManager cm; - cm.loadCountries(eu4input); - - // assign them to some vic3 countries (which must be landed, doesn't matter if land is shared) - V3::ProcessedData data; - data.civLevel = 100; - auto GA1 = std::make_shared(); - const auto subState = std::make_shared(); - GA1->addSubState(subState); - GA1->setSourceCountry(cm.getCountry("TA1")); - GA1->setProcessedData(data); - auto GA2 = std::make_shared(); - GA2->addSubState(subState); - GA2->setSourceCountry(cm.getCountry("TA2")); - GA2->setProcessedData(data); - auto GA3 = std::make_shared(); - GA3->addSubState(subState); - GA3->setSourceCountry(cm.getCountry("TA3")); - GA3->setProcessedData(data); - const std::map> countries = {{"GA1", GA1}, {"GA2", GA2}, {"GA3", GA3}}; - - // Sort them. - V3::TechValues techValues(countries); - - // and ping the ratings - EXPECT_DOUBLE_EQ(100.0 / 3.0, techValues.getSocietyTechPercentile("GA1")); - EXPECT_DOUBLE_EQ(200.0 / 3.0, techValues.getProductionTechPercentile("GA1")); - EXPECT_DOUBLE_EQ(300.0 / 3.0, techValues.getMilitaryTechPercentile("GA1")); - - EXPECT_DOUBLE_EQ(200.0 / 3.0, techValues.getSocietyTechPercentile("GA2")); - EXPECT_DOUBLE_EQ(100.0 / 3.0, techValues.getProductionTechPercentile("GA2")); - EXPECT_DOUBLE_EQ(200.0 / 3.0, techValues.getMilitaryTechPercentile("GA2")); - - EXPECT_DOUBLE_EQ(300.0 / 3.0, techValues.getSocietyTechPercentile("GA3")); - EXPECT_DOUBLE_EQ(300.0 / 3.0, techValues.getProductionTechPercentile("GA3")); - EXPECT_DOUBLE_EQ(100.0 / 3.0, techValues.getMilitaryTechPercentile("GA3")); -} - -TEST(V3World_TechValuesTests, TechValuesAreCappedByCivLevel) -{ - // load base eu4 countries with some tech - std::stringstream eu4input; - eu4input << "TA1 = { technology = { adm_tech = 7 dip_tech = 7 mil_tech = 7 } }\n"; - eu4input << "TA2 = { technology = { adm_tech = 7 dip_tech = 7 mil_tech = 7 } }\n"; - eu4input << "TA3 = { technology = { adm_tech = 7 dip_tech = 7 mil_tech = 7 } }\n"; - EU4::CountryManager cm; - cm.loadCountries(eu4input); - - // assign them to some vic3 countries (which must be landed, doesn't matter if land is shared) - V3::ProcessedData data; - auto GA1 = std::make_shared(); - const auto subState = std::make_shared(); - GA1->addSubState(subState); - GA1->setSourceCountry(cm.getCountry("TA1")); - data.civLevel = 100; // first - GA1->setProcessedData(data); - auto GA2 = std::make_shared(); - GA2->addSubState(subState); - GA2->setSourceCountry(cm.getCountry("TA2")); - data.civLevel = 10; // third - GA2->setProcessedData(data); - auto GA3 = std::make_shared(); - GA3->addSubState(subState); - GA3->setSourceCountry(cm.getCountry("TA3")); - data.civLevel = 50; // second - GA3->setProcessedData(data); - const std::map> countries = {{"GA1", GA1}, {"GA2", GA2}, {"GA3", GA3}}; - - // Sort them. - V3::TechValues techValues(countries); - - // and ping the ratings - EXPECT_DOUBLE_EQ(300.0 / 3.0, techValues.getSocietyTechPercentile("GA1")); - EXPECT_DOUBLE_EQ(300.0 / 3.0, techValues.getProductionTechPercentile("GA1")); - EXPECT_DOUBLE_EQ(300.0 / 3.0, techValues.getMilitaryTechPercentile("GA1")); - - EXPECT_DOUBLE_EQ(100.0 / 3.0, techValues.getSocietyTechPercentile("GA2")); - EXPECT_DOUBLE_EQ(100.0 / 3.0, techValues.getProductionTechPercentile("GA2")); - EXPECT_DOUBLE_EQ(100.0 / 3.0, techValues.getMilitaryTechPercentile("GA2")); - - EXPECT_DOUBLE_EQ(200.0 / 3.0, techValues.getSocietyTechPercentile("GA3")); - EXPECT_DOUBLE_EQ(200.0 / 3.0, techValues.getProductionTechPercentile("GA3")); - EXPECT_DOUBLE_EQ(200.0 / 3.0, techValues.getMilitaryTechPercentile("GA3")); -} diff --git a/EU5ToVic3Tests/V3WorldTests/PopManagerTests/PopManagerTests.cpp b/EU5ToVic3Tests/V3WorldTests/PopManagerTests/PopManagerTests.cpp deleted file mode 100644 index e05b6b8..0000000 --- a/EU5ToVic3Tests/V3WorldTests/PopManagerTests/PopManagerTests.cpp +++ /dev/null @@ -1,329 +0,0 @@ -#include "ClayManager/ClayManager.h" -#include "ClayManager/State/State.h" -#include "ClayManager/State/SubState.h" -#include "CountryManager/EU4Country.h" -#include "CountryMapper/CountryMapper.h" -#include "CultureLoader/CultureLoader.h" -#include "CultureMapper/CultureMapper.h" -#include "PoliticalManager/PoliticalManager.h" -#include "PopManager/PopManager.h" -#include "ProvinceManager/ProvinceManager.h" -#include "ProvinceMapper/ProvinceMapper.h" -#include "ReligionLoader/ReligionLoader.h" -#include "ReligionMapper/ReligionMapper.h" -#include "gtest/gtest.h" -#include - -namespace -{ -const auto eu4FS = commonItems::ModFilesystem("TestFiles/eu4installation/", {Mod("Some mod", "TestFiles/mod/themod/")}); -const auto modFS = commonItems::ModFilesystem("TestFiles/vic3installation/game/", {}); - -std::tuple prepManagers() -{ - EU4::DefaultMapParser defaults; - defaults.loadDefaultMap(eu4FS); - EU4::DefinitionScraper definitions; - definitions.loadDefinitions(eu4FS); - EU4::RegionManager regionManager; - regionManager.loadRegions(eu4FS); - - std::stringstream provinceStream; - provinceStream << "-1={}\n"; // sea, no ownership - provinceStream << "-2={ owner = TA2 base_tax=10 base_production=10 base_manpower=10 culture = culture1 religion = catholic }\n"; // substate TA-2&3 - provinceStream << "-3={ owner = TA3 base_tax=1 base_production=1 base_manpower=1 culture = culture2 religion = protestant }\n"; // substate TA-2&3 - provinceStream << "-4={}\n"; // irrelevant - provinceStream << "-5={}\n"; // irrelevant - provinceStream << "-6={}\n"; // irrelevant - provinceStream << "-7={}\n"; // irrelevant - provinceStream << "-8={}\n"; // irrelevant - provinceStream << "-9={ owner = TA9 base_tax=1 base_production=1 base_manpower=1 culture = culture3 religion = anglican }\n"; // substate TA-9 - provinceStream << "-10={}\n"; // irrelevant - EU4::ProvinceManager provinceManager; - provinceManager.loadProvinces(provinceStream); - provinceManager.loadDefaultMapParser(defaults); - provinceManager.loadDefinitionScraper(definitions); - provinceManager.classifyProvinces(regionManager); - provinceManager.buildProvinceWeights(regionManager); - provinceManager.buildPopRatios({}, false); - - mappers::ProvinceMapper provinceMapper; - provinceMapper.loadProvinceMappings("TestFiles/configurables/province_mappings_chunks.txt"); - - V3::ClayManager clayManager; - clayManager.initializeVanillaStates(modFS); - clayManager.loadTerrainsIntoProvinces(modFS); - clayManager.initializeSuperRegions(modFS); - clayManager.loadStatesIntoSuperRegions(); - - clayManager.generateChunks(provinceMapper, provinceManager); - - std::stringstream countryStream; - const auto ta2 = std::make_shared("TA2", countryStream); - const auto ta3 = std::make_shared("TA3", countryStream); - const auto ta9 = std::make_shared("TA9", countryStream); - const std::map> countries = {{"TA2", ta2}, {"TA3", ta3}, {"TA9", ta9}}; - clayManager.unDisputeChunkOwnership(countries); - clayManager.splitChunksIntoSubStates(); - - auto countryMapper = std::make_shared(); - countryMapper->loadMappingRules("TestFiles/configurables/country_mappings.txt"); - V3::PoliticalManager politicalManager; - politicalManager.loadCountryMapper(countryMapper); - politicalManager.importEU4Countries(countries); - clayManager.assignSubStateOwnership(politicalManager.getCountries(), *countryMapper); - - return {clayManager, politicalManager}; -} - -std::tuple -prepMappers() -{ - EU4::ReligionLoader religionLoader; - religionLoader.loadReligions(eu4FS); - EU4::CultureLoader cultureLoader; - cultureLoader.loadCultures(eu4FS); - - auto [clayManager, politicalManager] = prepManagers(); - mappers::ReligionMapper relMapper; - relMapper.loadMappingRules("TestFiles/configurables/religion_map.txt"); - relMapper.expandReligionMappings(religionLoader.getAllReligions()); - - mappers::CultureMapper culMapper; - culMapper.loadMappingRules("TestFiles/configurables/culture_map.txt"); - culMapper.expandCulturalMappings(clayManager, cultureLoader, religionLoader); - - V3::PopManager popManager; - popManager.initializeVanillaPops(modFS); - popManager.initializeDWPops(modFS); - popManager.convertDemographics(clayManager, culMapper, relMapper, cultureLoader, religionLoader); - clayManager.shoveRemainingProvincesIntoSubStates(); - politicalManager.generateDecentralizedCountries(clayManager, popManager); - - return std::tuple{popManager, politicalManager, culMapper, relMapper, clayManager, cultureLoader, religionLoader}; -} -} // namespace - -TEST(V3World_PopManagerTests, popManagerCanInitializeVanillaPopsAndPingThem) -{ - V3::PopManager popManager; - - std::stringstream log; - std::streambuf* cout_buffer = std::cout.rdbuf(); - std::cout.rdbuf(log.rdbuf()); - - popManager.initializeVanillaPops(modFS); - - std::cout.rdbuf(cout_buffer); - - /* - STATE_TEST_LAND1 - 600 - STATE_TEST_LAND2 - 3000 - STATE_TEST_LAND3 - 900 - STATE_TEST_LAND4 - 1000 - total: 5500 - */ - - EXPECT_THAT(log.str(), testing::HasSubstr(R"([INFO] <> Vanilla had 5500 pops.)")); - - EXPECT_FALSE(popManager.getVanillaSubStatePops("STATE_NONSENSE", "AAA")); - EXPECT_FALSE(popManager.getVanillaSubStatePops("STATE_TEST_LAND1", "NONSENSE")); - ASSERT_TRUE(popManager.getVanillaSubStatePops("STATE_TEST_LAND1", "AAA")); - - const auto& subPops = popManager.getVanillaSubStatePops("STATE_TEST_LAND1", "AAA"); - EXPECT_EQ(600, subPops->getPopCount()); - EXPECT_EQ("ashkenazi", popManager.getDominantVanillaCulture("STATE_TEST_LAND1")); // 300 pops - EXPECT_EQ("noreligion", popManager.getDominantVanillaReligion("STATE_TEST_LAND1")); // none have set religion. -} - -TEST(V3World_PopManagerTests, popManagerCanConvertDemographics) -{ - auto [popManager, politicalManager, culMapper, relMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - ASSERT_EQ(7, clayManager.getSubStates().size()); - const auto& substate1 = clayManager.getSubStates()[0]; // 2 demos inside, from provinces 2 & 3 - ASSERT_EQ(2, substate1->getDemographics().size()); - const auto& s1demo1 = substate1->getDemographics()[0]; - const auto& s1demo2 = substate1->getDemographics()[1]; - EXPECT_EQ("vculture1", s1demo1.culture); // updated demos - EXPECT_EQ("vculture2", s1demo2.culture); // updated demos - EXPECT_EQ("catholic", s1demo1.religion); - EXPECT_EQ("protestant", s1demo2.religion); - EXPECT_NEAR(0.909, s1demo1.upperRatio, 0.001); - EXPECT_NEAR(0.091, s1demo2.upperRatio, 0.001); - - const auto& substate2 = clayManager.getSubStates()[1]; // 2 demos inside, from provinces 2 & 3 - ASSERT_EQ(2, substate2->getDemographics().size()); - const auto& s2demo1 = substate2->getDemographics()[0]; - const auto& s2demo2 = substate2->getDemographics()[1]; - EXPECT_EQ("vculture1", s2demo1.culture); // updated demos - EXPECT_EQ("vculture2", s2demo2.culture); // updated demos - EXPECT_EQ("catholic", s2demo1.religion); - EXPECT_EQ("protestant", s2demo2.religion); - EXPECT_NEAR(0.909, s2demo1.upperRatio, 0.001); - EXPECT_NEAR(0.091, s2demo2.upperRatio, 0.001); - - const auto& substate3 = clayManager.getSubStates()[2]; // single demo inside, from eu4 prov 9. - ASSERT_EQ(1, substate3->getDemographics().size()); - const auto& s3demo = substate3->getDemographics()[0]; - EXPECT_EQ("vculture2", s3demo.culture); // updated demos - EXPECT_EQ("protestant", s3demo.religion); // updated demos - EXPECT_EQ(1, s3demo.upperRatio); -} - -TEST(V3World_PopManagerTests, popManagerCanGeneratePops) -{ - auto [popManager, politicalManager, culMapper, relMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - popManager.generatePops(clayManager, Configuration::POPSHAPES::Vanilla, 1); - - - /* - STATE_TEST_LAND1 - 600 - goes to GA2 - split in 2 pops for its 2 demographics - STATE_TEST_LAND2 - 3000 - goes to GA2 - split in 2 pops for its 2 demographics - STATE_TEST_LAND3 - 900 - goes to shoved X02 substate with vanilla demo - STATE_TEST_LAND4 - 1000 - goes to GA9 - single pop for single demo - total: 5500 - */ - - const auto& pop1 = clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates()[0]->getSubStatePops().getPops()[0]; - const auto& pop2 = clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates()[0]->getSubStatePops().getPops()[1]; - EXPECT_EQ(pop1, V3::Pop("vculture1", "catholic", "", 0)); - EXPECT_EQ(545, pop1.getSize()); // 545 = 0.91 * 600 - EXPECT_EQ(pop2, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(55, pop2.getSize()); // 55 = 0.09 * 600 - - const auto& pop3 = clayManager.getStates().at("STATE_TEST_LAND2")->getSubStates()[0]->getSubStatePops().getPops()[0]; - const auto& pop4 = clayManager.getStates().at("STATE_TEST_LAND2")->getSubStates()[0]->getSubStatePops().getPops()[1]; - EXPECT_EQ(pop3, V3::Pop("vculture1", "catholic", "", 0)); - EXPECT_EQ(2727, pop3.getSize()); // 2727 = 0.91 * 3000 - EXPECT_EQ(pop4, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(273, pop4.getSize()); // 273 = 0.09 * 3000 - - const auto& pop5 = clayManager.getStates().at("STATE_TEST_LAND3")->getSubStates()[0]->getSubStatePops().getPops()[0]; - EXPECT_EQ(pop5, V3::Pop("swedish", "", "", 0)); // vanilla demo - EXPECT_EQ(900, pop5.getSize()); - - const auto& pop6 = clayManager.getStates().at("STATE_TEST_LAND4")->getSubStates()[0]->getSubStatePops().getPops()[0]; - EXPECT_EQ(pop6, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(1000, pop6.getSize()); -} - -TEST(V3World_PopManagerTests, popManagerCanGenerateVanillaPopsThroughShaping) -{ - auto [popManager, politicalManager, culMapper, relMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - popManager.generatePops(clayManager, Configuration::POPSHAPES::PopShaping, 0); - - - /* - STATE_TEST_LAND1 - 600 - goes to GA2 - split in 2 pops for its 2 demographics - STATE_TEST_LAND2 - 3000 - goes to GA2 - split in 2 pops for its 2 demographics - STATE_TEST_LAND3 - 900 - goes to shoved X02 substate with vanilla demo - STATE_TEST_LAND4 - 1000 - goes to GA9 - single pop for single demo - total: 5500 - */ - - const auto& pop1 = clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates()[0]->getSubStatePops().getPops()[0]; - const auto& pop2 = clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates()[0]->getSubStatePops().getPops()[1]; - EXPECT_EQ(pop1, V3::Pop("vculture1", "catholic", "", 0)); - EXPECT_EQ(545, pop1.getSize()); // 545 = 0.91 * 600 - EXPECT_EQ(pop2, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(55, pop2.getSize()); // 55 = 0.09 * 600 - - const auto& pop3 = clayManager.getStates().at("STATE_TEST_LAND2")->getSubStates()[0]->getSubStatePops().getPops()[0]; - const auto& pop4 = clayManager.getStates().at("STATE_TEST_LAND2")->getSubStates()[0]->getSubStatePops().getPops()[1]; - EXPECT_EQ(pop3, V3::Pop("vculture1", "catholic", "", 0)); - EXPECT_EQ(2727, pop3.getSize()); // 2727 = 0.91 * 3000 - EXPECT_EQ(pop4, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(273, pop4.getSize()); // 273 = 0.09 * 3000 - - const auto& pop5 = clayManager.getStates().at("STATE_TEST_LAND3")->getSubStates()[0]->getSubStatePops().getPops()[0]; - EXPECT_EQ(pop5, V3::Pop("swedish", "", "", 0)); // vanilla demo - EXPECT_EQ(900, pop5.getSize()); - - const auto& pop6 = clayManager.getStates().at("STATE_TEST_LAND4")->getSubStates()[0]->getSubStatePops().getPops()[0]; - EXPECT_EQ(pop6, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(1000, pop6.getSize()); -} - -TEST(V3World_PopManagerTests, popManagerCanGenerateShapedPops) -{ - auto [popManager, politicalManager, culMapper, relMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - - popManager.generatePops(clayManager, Configuration::POPSHAPES::PopShaping, 1); - - /* - STATE_TEST_LAND1 - 600 -> 622: projected popcount=725 * superRegionalNormalizationFactor=0.85649 - STATE_TEST_LAND2 - 3000->3108 - STATE_TEST_LAND3 - 900->900: vanilla state, no shaping - STATE_TEST_LAND4 - 1000->1001 - total: 5500 - */ - - const auto& pop1 = clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates()[0]->getSubStatePops().getPops()[0]; - const auto& pop2 = clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates()[0]->getSubStatePops().getPops()[1]; - EXPECT_EQ(pop1, V3::Pop("vculture1", "catholic", "", 0)); - EXPECT_EQ(565, pop1.getSize()); // 565 = 0.91 * 622 - EXPECT_EQ(pop2, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(57, pop2.getSize()); // 57 = 0.091 * 622 - - const auto& pop3 = clayManager.getStates().at("STATE_TEST_LAND2")->getSubStates()[0]->getSubStatePops().getPops()[0]; - const auto& pop4 = clayManager.getStates().at("STATE_TEST_LAND2")->getSubStates()[0]->getSubStatePops().getPops()[1]; - EXPECT_EQ(pop3, V3::Pop("vculture1", "catholic", "", 0)); - EXPECT_EQ(2825, pop3.getSize()); // 2825 = 0.91 * 3108 - EXPECT_EQ(pop4, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(283, pop4.getSize()); // 283 = 0.091 * 3108 - - const auto& pop5 = clayManager.getStates().at("STATE_TEST_LAND3")->getSubStates()[0]->getSubStatePops().getPops()[0]; - EXPECT_EQ(pop5, V3::Pop("swedish", "", "", 0)); // vanilla demo - EXPECT_EQ(900, pop5.getSize()); - - const auto& pop6 = clayManager.getStates().at("STATE_TEST_LAND4")->getSubStates()[0]->getSubStatePops().getPops()[0]; - EXPECT_EQ(pop6, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(1001, pop6.getSize()); -} - -TEST(V3World_PopManagerTests, popManagerCanGenerateHomelands) -{ - auto [popManager, politicalManager, culMapper, relMapper, clayManager, cultureLoader, religionLoader] = prepMappers(); - popManager.generatePops(clayManager, Configuration::POPSHAPES::Vanilla, 1); - - - /* - STATE_TEST_LAND1 - 600 - goes to GA2 - split in 2 pops for its 2 demographics - STATE_TEST_LAND2 - 3000 - goes to GA2 - split in 2 pops for its 2 demographics - STATE_TEST_LAND3 - 900 - goes to shoved X02 substate with vanilla demo - STATE_TEST_LAND4 - 1000 - goes to GA9 - single pop for single demo - total: 5500 - */ - - const auto& pop1 = clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates()[0]->getSubStatePops().getPops()[0]; - const auto& pop2 = clayManager.getStates().at("STATE_TEST_LAND1")->getSubStates()[0]->getSubStatePops().getPops()[1]; - EXPECT_EQ(pop1, V3::Pop("vculture1", "catholic", "", 0)); - EXPECT_EQ(545, pop1.getSize()); // 545 = 0.91 * 600 <- primary culture - EXPECT_EQ(pop2, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(55, pop2.getSize()); // 55 = 0.09 * 600 - - const auto& pop3 = clayManager.getStates().at("STATE_TEST_LAND2")->getSubStates()[0]->getSubStatePops().getPops()[0]; - const auto& pop4 = clayManager.getStates().at("STATE_TEST_LAND2")->getSubStates()[0]->getSubStatePops().getPops()[1]; - EXPECT_EQ(pop3, V3::Pop("vculture1", "catholic", "", 0)); - EXPECT_EQ(2727, pop3.getSize()); // 2727 = 0.91 * 3000 <- primary culture - EXPECT_EQ(pop4, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(273, pop4.getSize()); // 273 = 0.09 * 3000 - - const auto& pop5 = clayManager.getStates().at("STATE_TEST_LAND3")->getSubStates()[0]->getSubStatePops().getPops()[0]; - EXPECT_EQ(pop5, V3::Pop("swedish", "", "", 0)); // vanilla demo - EXPECT_EQ(900, pop5.getSize()); // <- primary culture - - const auto& pop6 = clayManager.getStates().at("STATE_TEST_LAND4")->getSubStates()[0]->getSubStatePops().getPops()[0]; - EXPECT_EQ(pop6, V3::Pop("vculture2", "protestant", "", 0)); - EXPECT_EQ(1000, pop6.getSize()); // <- primary culture - - popManager.applyHomeLands(clayManager); - - EXPECT_THAT(clayManager.getStates().at("STATE_TEST_LAND1")->getHomelands(), testing::UnorderedElementsAre("vculture1")); - EXPECT_THAT(clayManager.getStates().at("STATE_TEST_LAND2")->getHomelands(), testing::UnorderedElementsAre("vculture1")); - EXPECT_THAT(clayManager.getStates().at("STATE_TEST_LAND3")->getHomelands(), testing::UnorderedElementsAre("swedish")); - EXPECT_THAT(clayManager.getStates().at("STATE_TEST_LAND4")->getHomelands(), testing::UnorderedElementsAre("vculture2")); -} \ No newline at end of file diff --git a/EU5ToVic3lib/EU5ToVic3lib.vcxproj b/EU5ToVic3lib/EU5ToVic3lib.vcxproj index ad01da7..806d30b 100644 --- a/EU5ToVic3lib/EU5ToVic3lib.vcxproj +++ b/EU5ToVic3lib/EU5ToVic3lib.vcxproj @@ -9,455 +9,21 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/EU5ToVic3lib/EU5ToVic3lib.vcxproj.filters b/EU5ToVic3lib/EU5ToVic3lib.vcxproj.filters index 54b3c3b..254f11e 100644 --- a/EU5ToVic3lib/EU5ToVic3lib.vcxproj.filters +++ b/EU5ToVic3lib/EU5ToVic3lib.vcxproj.filters @@ -4,1667 +4,68 @@ {371d4cb5-643a-4b5e-ba4f-6f177c2dfefa} - - {4aa2b128-32b2-43d8-85d7-6457732aab56} - - - {7f3012bc-0ae9-45a5-a992-f550e4575197} - - - {fae29328-2562-4d38-9daf-400330c46eef} - - - {8ad295fe-c744-49df-b2e1-27c3c5e758d6} - - - {f087f6f0-3ee8-4360-a20d-b159bc7663e5} - - - {83cd9b81-9bde-4249-836e-022916526e13} - - - {9c4a966a-7dd8-4673-8d13-b26871b66f88} - - - {b59f1f94-35b1-4569-ba37-cc6a0b9d551d} - - - {92f7ae0d-c222-43b9-9538-5e1c03b2c4f7} - - - {5184801b-1302-46b7-b604-53e6fb06a6a8} - - - {d37300f9-e25f-4f0c-9fae-6ca2fd761ee6} - - - {f6e72bda-b2ab-44a2-ada2-794ce627a42e} - - - {3116f175-df0b-4b2f-bce7-f2ccb70b7af1} - - - {5017b538-a228-4361-b5e5-347b4f4b0afe} - - - {1ca9adc8-3450-4dd6-8c9a-fa75ada33d1c} - - - {9cfc49b8-30ec-420b-9e37-2a16fade7462} - - - {5d1683f7-4c07-4eb1-8af7-6ff0773a43ba} - - - {4e260290-9c95-4967-a875-b820d32e6023} - - - {17c50b80-7915-43df-9fdb-1985dd914c49} - - - {3bdaaee1-83de-45f6-bdae-a03dec002149} - - - {20b85002-b012-4c39-8d15-fad89735e5b5} - - - {017117b9-7084-47ba-873c-808ee06dc87c} - - - {93081626-f6f4-4814-9bf9-ae289bdb1e58} - - - {f39d8d9f-5450-4728-9185-57449bd3b6e4} - {82320073-8d32-47d2-9aa5-f74f9799783a} {187b5c13-d1a0-458f-b0fe-32dd8b551682} - - {3e538e0b-e7ee-4b54-83c5-8ec3c1908282} - - - {a11c9ac0-6f26-4231-ba79-ec58733d692e} - - - {ec547f15-59c4-4712-a618-ba706fbfadb7} - - - {893d5c38-84f0-4ba8-8acb-21333746878c} - - - {ad862b0e-de62-438f-98cf-25521e35b423} - - - {40f60258-3374-426b-9cae-97e00e26117c} - - - {05bac564-8051-4950-9ef6-3afd7c953e62} - - - {bb40b25e-2d56-4371-9171-0af4f5347637} - - - {e71f8973-2549-4425-95b8-57d39825059d} - - - {837120ae-e5a8-490c-b76f-67d6f1dd729c} - - - {cad91304-0ce8-45f6-81f1-62522ae1a3e9} - - - {92729d2e-36c5-4eca-b411-6e7f13f62e8e} - - - {aebb85bf-aaf9-4640-b0d9-918f8f8c01f0} - - - {7c54f87c-3f98-40b8-803c-10761eb05760} - - - {1aca59f9-a047-495d-83e7-a78f030e3683} - - - {1c49de6d-c85a-4780-a6f5-fbf95b7e0221} - - - {478d05ca-712e-4a62-baaa-7f486dec767c} - - - {2b9d7ae9-fe58-4982-926c-31a633719e09} - - - {c817b925-7eff-494e-92b5-00d8d79699c1} - - - {04380284-8ae9-4883-9e84-75aa39a1b7f2} - - - {c4472d86-d75b-4845-b296-1f29c083a194} - - - {3671fc95-5940-404f-a545-06f0a86722a0} - - - {6ef43506-c7b8-405a-bdbb-185df3818f8c} - - - {71caf3bc-2ec2-4957-bbda-17b21b441353} - - - {f8033d95-0ad7-4b36-a78d-388cc93246c1} - - - {c3ec296f-6050-4367-89b6-b5e671e17e4f} - - - {1c4a086d-ac6f-46ac-9ca3-e9d292a48f9c} - - - {3ff53292-8872-4f27-b763-8fae79be5ba9} - - - {48b34fe9-4821-4c32-aa7f-7c09a8c65694} - - - {cbaee050-be3a-41d1-bac1-2593f38fa723} - {e226fd86-309b-4835-8a68-e47426f49359} - - {f2dcf589-ce17-4b9a-b6fe-0b29e61c6315} - - - {934696d4-3c8b-47bd-8854-9cc14a5996f6} - - - {6bdfa4f2-dd0d-45e4-8562-54fc00a74d77} - {f49d495d-2136-4302-9a08-8bcf86616b34} - - {98e550aa-26df-4ebb-a328-91a215c4ec18} - - - {36435464-bf32-4e65-855a-bbec4e31a49f} - - - {e4e7bcb9-5b76-4783-b16d-0d6c1dd5a20b} - - - {c93fef29-6219-46a1-808e-e20b870e6145} - - - {47cc933e-16eb-45b3-bf95-e289211889e0} - - - {00e7f288-c7e0-4d6d-9841-3de87f7291ae} - - - {56b0cd58-9935-4418-9059-55684d661d8a} - - - {cb1e2dcb-9001-4e1b-9e07-e64ec011fcd7} - - - {b26dc1d6-9250-448a-9aa0-6beb453dc3d9} - {664b836e-fd9c-465f-b07c-c6301efc8238} - - {ccf67a93-fbfc-4282-87b8-2ea0050b5945} - - - {b67860ba-4ab8-409b-8f3a-acc7f8c6cb96} - - - {eee34343-a26c-4b85-a834-8fa6cf785ac0} - - - {27d0cfc5-aa9d-47da-85e2-747d2ecbed1a} - - - {8036e721-7652-455b-a465-250c6d429f04} - - - {7e6b45b9-4251-4a06-ba48-34fc7a9a1d59} - - - {918ad63e-640d-47aa-8b85-9eaa443732ee} - - - {8694a07d-bf4a-4581-8e66-936f2570f074} - - - {3d566e19-9319-409d-8cc7-27bf5984c29d} - - - {55aca2ba-9010-42bd-b218-3822c632032b} - - - {b8e69b74-c352-4125-89a1-5646c33846cf} - - - {31e60ece-a380-44ff-8cae-d334432a59e8} - - - {b9d4434a-c968-4ae6-930c-62af3edbfd8a} - - - {4b13581a-2512-44f0-9556-994f417fb890} - - - {8f1cf2e6-cae8-4a78-aa6c-655a313efa36} - - - {2ded104c-144c-4341-9182-287c613c37bb} - - - {a70df1b0-30fd-44b2-bd7f-fc4a3ba59e32} - - - {875a1ea9-8bc3-4a9c-8930-9b19ef527476} - - - {ae57cfa0-b987-47dc-8bdb-83eeb3eb8482} - - - {53a1f863-9574-4156-bb76-348b3b378bfc} - - - {e79bc9e3-975f-45bf-b2a4-dc5929768208} - - - {707d5100-9296-4e00-8888-bd047d10b0c5} - - - {6e427663-8816-4a36-b639-30e5b554803d} - - - {66b78f0c-7c2e-46cf-8a68-e0d7279346f0} - - - {88b0b31e-dbea-46a4-b4d7-40e813a0d141} - - - {ab482765-1fad-443f-a57c-25be1d668a91} - - - {4297df92-6b9e-40a0-98a7-0a8f89a003bc} - - - {e397954e-2660-42e2-ab2f-af164276a67e} - - - {4c13e674-f232-4a56-af2a-2b6fb1244547} - - - {bff91238-e352-4ca1-92c9-c4ad17a0c318} - - - {81618771-6dd0-4ea5-b2fb-42f24c876c17} - - - {d6cbfe4f-3ac3-458c-ac84-095c4c159018} - - - {c3928a43-5594-40d2-aff3-03a5985ec55e} - - - {2ab0d963-13e2-4dfe-a31b-0098f1e2bfcd} - - - {eea54bb0-1120-4b6b-ab02-70cc9ba728cf} - - - {01f8082a-c1a5-46f1-bbdf-1af6f1e6d61b} - - - {b545ae91-6be8-49e1-b251-0286432ce608} - - - {15ee8f25-543f-4675-8c43-cb54e81486c7} - {ee706bf8-01ff-4bce-94b2-cbb1564e1a0d} - - {5aa9ea8c-2f74-49e7-a250-2c66e88b2463} - - - {74604a7c-f19d-4bf2-bdaa-1f5039558052} - - - {735ee16e-eb5c-469a-8043-a24df7fa7ba9} - - - {766f1433-4c6f-43fe-9650-4e9253f7731e} + + {1d4c37a6-1e56-47ef-8f62-a329edccdb39} - - {e9a649e2-1be2-4b2e-95ea-4ba4125523d3} + + {ca17ef5f-51c9-480f-be68-57812f4e6b99} EU5World - - EU5World\RegionManager - - - EU5World\RegionManager - - - EU5World\RegionManager - - - EU5World\RegionManager - - - EU5World\ProvinceManager - - - EU5World\ProvinceManager - - - EU5World\ProvinceManager - - - EU5World\ProvinceManager - - - EU5World\ProvinceManager - - - EU5World\ProvinceManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager\CountryArmy - - - EU5World\CountryManager\CountryArmy - - - EU5World\CountryManager\CountryGovernment - - - EU5World\CountryManager\CountryGovernment - - - EU5World\CountryManager\CountryHistory - - - EU5World\CountryManager\CountryHistory - - - EU5World\CountryManager\CountryRelations - - - EU5World\CountryManager\CountryRelations - - - EU5World\CountryManager\NationalSymbol - - - EU5World\CountryManager\NationalSymbol - - - EU5World\CountryManager\CountryLeader - - - EU5World\CountryManager\CountryLeader - - - EU5World\Loaders\BuildingCostLoader - - - EU5World\Loaders\BuildingCostLoader - - - EU5World\Loaders\CultureLoader - - - EU5World\Loaders\CultureLoader - - - EU5World\Loaders\CultureLoader - - - EU5World\Loaders\DefaultMapParser - - - EU5World\Loaders\DefinitionScraper - - - EU5World\Loaders\ModLoader - - - EU5World\Loaders\ReligionLoader - - - EU5World\Loaders\ReligionLoader - - - EU5World\Loaders\ReligionLoader - - - EU5World\Loaders\UnitTypeLoader - - - EU5World\Loaders\UnitTypeLoader - - - EU5World\Loaders\CommonCountryLoader - - - EU5World\Loaders\LocalizationLoader - - - EU5World\Loaders\ColonialRegionLoader - - - EU5World\Loaders\ColonialRegionLoader - - - EU5World\Loaders\TradeCompanyLoader - - - EU5World\Loaders\TradeCompanyLoader - - - EU5World\EmpireParser - - - EU5World\EmpireParser - - - EU5World\DiplomacyParser - - - EU5World\DiplomacyParser - - - EU5World\WarParser - - - EU5World\WarParser - - - Mappers\SuperGroupMapper - - - Mappers\SuperGroupMapper - - - Mappers\SuperGroupMapper - - - Mappers\NationMergeMapper - - - Mappers\NationMergeMapper - - - Mappers\ProvinceMapper - - - Mappers\ProvinceMapper - - - Mappers\ProvinceMapper - - - Mappers\CountryMapper - - - Mappers\CountryMapper - - - Mappers\ReligionMapper - - - Mappers\ReligionMapper - - - Mappers\ReligionMapper\ReligionDefinitionLoader - - - Mappers\ReligionMapper\ReligionDefinitionLoader - - - Mappers\ReligionMapper\ReligionGroupMapper - - - Mappers\ReligionMapper\ReligionGroupMapper - - - Mappers\CultureMapper - - - Mappers\CultureMapper - - - Mappers\CultureMapper\NameListLoader - - - Mappers\CultureMapper\NameListLoader - - - Mappers\CultureMapper\CultureTraitMapper - - - Mappers\CultureMapper\CultureTraitMapper - - - Mappers\CultureMapper\NameListMapper - - - Mappers\CultureMapper\NameListMapper - - - Mappers\CultureMapper\CultureDefinitionLoader - - - Mappers\CultureMapper\CultureDefinitionLoader - - - Mappers\CultureMapper\WesternizationMapper - - - Mappers\CultureMapper\WesternizationMapper - - - Mappers\ColonialRegionMapper - - - Mappers\ColonialRegionMapper - - - Mappers\PopulationSetupMapper - - - Mappers\PopulationSetupMapper - - - Mappers\IdeaEffectsMapper - - - Mappers\IdeaEffectsMapper - - - Mappers\TechSetupMapper - - - Mappers\TechSetupMapper - - - Mappers\LawMapper - - - Mappers\LawMapper - - - Mappers\LawMapper - - - Mappers\DiplomaticMapper - - - Mappers\CharacterTraitMapper - - - Mappers\CharacterTraitMapper - - - Mappers\CharacterTraitMapper - - - Mappers\ColonialTagMapper - - - Mappers\ColonialTagMapper - - - Mappers\BuildingMapper - - - Mappers\BuildingMapper - - - Mappers\BuildingMapper\ProductionMethodMapper - - - Mappers\BuildingMapper\ProductionMethodMapper - - - Mappers\BuildingMapper\ProductionMethodMapper - - - Mappers\VNColonialMapper - - - Mappers\VNColonialMapper - - - Mappers\CountryTierMapper - - - Mappers\CountryTierMapper - - - Mappers\IGIdeologiesMapper - - - Mappers\IGIdeologiesMapper - - - Mappers\MinorityPopMapper - - - Mappers\MinorityPopMapper - - - Mappers\SlaveCultureMapper - - - Mappers\SlaveCultureMapper - - - Mappers\CoastalMapper - - - Mappers\ExcludedTradeCompaniesMapper - Output - - Output\outCountries - - - Output\outStates - - - Output\outLocalizations - Output\outMetadataFile - - Output\outPops - - - Output\outReligions - - - Output\outCultures - - - Output\outDiplomacy - - - Output\outCharacters - - - Output\outFlagDefinitions - - - Output\outCoAs - - - Output\outBuildings - - - Output\outDiplomaticPlays - Vic3World - - Vic3World\ClayManager - - - Vic3World\ClayManager\State - - - Vic3World\ClayManager\State - - - Vic3World\ClayManager\State - - - Vic3World\ClayManager\State - - - Vic3World\PoliticalManager - - - Vic3World\PoliticalManager\Country - - - Vic3World\PoliticalManager\Country - - - Vic3World\PoliticalManager\TechValues - - - Vic3World\PopManager + + + Configuration - - Vic3World\PopManager\Pops - - - Vic3World\PopManager\Pops - - - Vic3World\Loaders\LocLoader - - - Vic3World\Loaders\CountryDefinitionLoader - - - Vic3World\Loaders\PopLoader - - - Vic3World\Loaders\PopLoader - - - Vic3World\Loaders\PopLoader - - - Vic3World\Loaders\PopLoader - - - Vic3World\Loaders\PopLoader - - - Vic3World\Loaders\StateLoader - - - Vic3World\Loaders\SuperRegionLoader - - - Vic3World\Loaders\SuperRegionLoader - - - Vic3World\Loaders\SuperRegionLoader - - - Vic3World\Loaders\TerrainLoader - - - Vic3World\Loaders\TerrainLoader - - - Vic3World\Loaders\BuildingLoader - - - Vic3World\Loaders\BuildingLoader - - - Vic3World\Loaders\BuildingLoader\ProductionMethodLoader - - - Vic3World\Loaders\BuildingLoader\ProductionMethodLoader - - - Vic3World\Loaders\VanillaStateLoader - - - Vic3World\Loaders\VanillaStateLoader - - - Vic3World\Loaders\VanillaStateLoader - - - Vic3World\Loaders\VanillaStateLoader - - - Vic3World\Loaders\StateModifierLoader - - - Vic3World\Loaders\LawLoader - - - Vic3World\Loaders\LawLoader - - - Vic3World\Loaders\DefinesLoader - - - Vic3World\Loaders\DefinesLoader - - - Vic3World\Loaders\NationalBudgetLoader - - - Vic3World\Loaders\NationalBudgetLoader - - - Vic3World\Loaders\NationalBudgetLoader\Script - - - Vic3World\Loaders\NationalBudgetLoader\Script - - - Vic3World\Loaders\NationalBudgetLoader\Script - - - Vic3World\Loaders\VanillaDiplomacyLoader - - - Vic3World\Loaders\VanillaDiplomacyLoader - - - Vic3World\Loaders\VanillaDiplomacyLoader - - - Vic3World\Loaders\VanillaDiplomacyLoader - - - Vic3World\Loaders\VanillaDiplomacyLoader - - - Vic3World\Loaders\VanillaCountryHistoryLoader - - - Vic3World\Loaders\VanillaCountryHistoryLoader - - - Vic3World\Loaders\VanillaPopulationHistoryLoader - - - Vic3World\Loaders\VanillaCharacterLoader - - - Vic3World\Loaders\VanillaCharacterLoader - - - Vic3World\Loaders\VanillaDiplomaticPlayLoader - - - Vic3World\Loaders\VanillaDiplomaticPlayLoader - - - Vic3World\Loaders\VanillaBuildingLoader - - - Vic3World\Loaders\VanillaBuildingLoader - - - Vic3World\Loaders\TechLoader - - - Vic3World\Loaders\TechLoader - - - Vic3World\Loaders\MajorFormablesLoader - - - Vic3World\Loaders\MajorFormablesLoader - - - Vic3World\FlagCrafter - - - Vic3World\FlagCrafter\FlagNameLoader - - - Vic3World\FlagCrafter\FlagColorLoader - - - Vic3World\EconomyManager - - - Vic3World\EconomyManager\Building - - - Vic3World\EconomyManager\Building - - - Vic3World\EconomyManager\Building - - - Vic3World\EconomyManager\Building\ProductionMethod - - - Vic3World\EconomyManager\Building\ProductionMethod - - - Vic3World\EconomyManager\NationalBudget - - - - Configuration - - - Mappers\AIStrategyMapper - - - Mappers\AIStrategyMapper - - - Output\outStrategies - - - Mappers\AISecretGoalMapper - - - Mappers\AISecretGoalMapper - - - Output\outSecretGoals - - - Mappers\CultureMapper\TraitDefinitionLoader - - - Mappers\CultureMapper\TraitDefinitionLoader + + EU5World\Loaders\ModLoader EU5World - - EU5World\RegionManager - - - EU5World\RegionManager - - - EU5World\RegionManager - - - EU5World\RegionManager - - - EU5World\ProvinceManager - - - EU5World\ProvinceManager - - - EU5World\ProvinceManager - - - EU5World\ProvinceManager - - - EU5World\ProvinceManager - - - EU5World\ProvinceManager - - - EU5World\ProvinceManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager - - - EU5World\CountryManager\CountryArmy - - - EU5World\CountryManager\CountryArmy - - - EU5World\CountryManager\CountryGovernment - - - EU5World\CountryManager\CountryGovernment - - - EU5World\CountryManager\CountryHistory - - - EU5World\CountryManager\CountryHistory - - - EU5World\CountryManager\CountryRelations - - - EU5World\CountryManager\CountryRelations - - - EU5World\CountryManager\NationalSymbol - - - EU5World\CountryManager\NationalSymbol - - - EU5World\CountryManager\NationalSymbol - - - EU5World\CountryManager\CountryLeader - - - EU5World\CountryManager\CountryLeader - - - EU5World\CountryManager\CountryLeader - - - EU5World\Loaders\BuildingCostLoader - - - EU5World\Loaders\BuildingCostLoader - - - EU5World\Loaders\CultureLoader - - - EU5World\Loaders\CultureLoader - - - EU5World\Loaders\CultureLoader - - - EU5World\Loaders\DefaultMapParser - - - EU5World\Loaders\DefinitionScraper - - - EU5World\Loaders\ModLoader - - - EU5World\Loaders\ReligionLoader - - - EU5World\Loaders\ReligionLoader - - - EU5World\Loaders\ReligionLoader - - - EU5World\Loaders\ReligionLoader - - - EU5World\Loaders\UnitTypeLoader - - - EU5World\Loaders\UnitTypeLoader - - - EU5World\Loaders\UnitTypeLoader - - - EU5World\Loaders\CommonCountryLoader - - - EU5World\Loaders\LocalizationLoader - - - EU5World\Loaders\ColonialRegionLoader - - - EU5World\Loaders\ColonialRegionLoader - - - EU5World\Loaders\TradeCompanyLoader - - - EU5World\Loaders\TradeCompanyLoader - - - EU5World\Loaders\TradeCompanyLoader - - - EU5World\EmpireParser - - - EU5World\EmpireParser - - - EU5World\DiplomacyParser - - - EU5World\DiplomacyParser - - - EU5World\WarParser - - - EU5World\WarParser - Helpers - - Mappers\SuperGroupMapper - - - Mappers\SuperGroupMapper - - - Mappers\SuperGroupMapper - - - Mappers\NationMergeMapper - - - Mappers\NationMergeMapper - - - Mappers\ProvinceMapper - - - Mappers\ProvinceMapper - - - Mappers\ProvinceMapper - - - Mappers\CountryMapper - - - Mappers\CountryMapper - - - Mappers\ReligionMapper - - - Mappers\ReligionMapper - - - Mappers\ReligionMapper\ReligionDefinitionLoader - - - Mappers\ReligionMapper\ReligionDefinitionLoader - - - Mappers\ReligionMapper\ReligionDefinitionLoader - - - Mappers\ReligionMapper\ReligionGroupMapper - - - Mappers\ReligionMapper\ReligionGroupMapper - - - Mappers\CultureMapper - - - Mappers\CultureMapper - - - Mappers\CultureMapper\NameListLoader - - - Mappers\CultureMapper\NameListLoader - - - Mappers\CultureMapper\CultureTraitMapper - - - Mappers\CultureMapper\CultureTraitMapper - - - Mappers\CultureMapper\NameListMapper - - - Mappers\CultureMapper\NameListMapper - - - Mappers\CultureMapper\CultureDefinitionLoader - - - Mappers\CultureMapper\CultureDefinitionLoader - - - Mappers\CultureMapper\CultureDefinitionLoader - - - Mappers\CultureMapper\WesternizationMapper - - - Mappers\CultureMapper\WesternizationMapper - - - Mappers\ColonialRegionMapper - - - Mappers\ColonialRegionMapper - - - Mappers\PopulationSetupMapper - - - Mappers\PopulationSetupMapper - - - Mappers\IdeaEffectsMapper - - - Mappers\IdeaEffectsMapper - - - Mappers\TechSetupMapper - - - Mappers\TechSetupMapper - - - Mappers\LawMapper - - - Mappers\LawMapper - - - Mappers\LawMapper - - - Mappers\DiplomaticMapper - - - Mappers\CharacterTraitMapper - - - Mappers\CharacterTraitMapper - - - Mappers\CharacterTraitMapper - - - Mappers\ColonialTagMapper - - - Mappers\ColonialTagMapper - - - Mappers\BuildingMapper - - - Mappers\BuildingMapper - - - Mappers\BuildingMapper\ProductionMethodMapper - - - Mappers\BuildingMapper\ProductionMethodMapper - - - Mappers\BuildingMapper\ProductionMethodMapper - - - Mappers\BuildingMapper\ProductionMethodMapper - - - Mappers\VNColonialMapper - - - Mappers\VNColonialMapper - - - Mappers\CountryTierMapper - - - Mappers\CountryTierMapper - - - Mappers\IGIdeologiesMapper - - - Mappers\IGIdeologiesMapper - - - Mappers\MinorityPopMapper - - - Mappers\MinorityPopMapper - - - Mappers\SlaveCultureMapper - - - Mappers\SlaveCultureMapper - - - Mappers\CoastalMapper - - - Mappers\ExcludedTradeCompaniesMapper - Output - - Output\outCountries - - - Output\outStates - - - Output\outLocalizations - Output\outMetadataFile - - Output\outPops - - - Output\outReligions - - - Output\outCultures - - - Output\outDiplomacy - - - Output\outCharacters - - - Output\outFlagDefinitions - - - Output\outCoAs - - - Output\outBuildings - - - Output\outDiplomaticPlays - Vic3World - - Vic3World\ClayManager - - - Vic3World\ClayManager - - - Vic3World\ClayManager\State - - - Vic3World\ClayManager\State - - - Vic3World\ClayManager\State - - - Vic3World\ClayManager\State - - - Vic3World\ClayManager\State - - - Vic3World\ClayManager\State - - - Vic3World\PoliticalManager - - - Vic3World\PoliticalManager\Country - - - Vic3World\PoliticalManager\Country - - - Vic3World\PoliticalManager\TechValues - - - Vic3World\PoliticalManager\Diplomacy - - - Vic3World\PoliticalManager\Diplomacy - - - Vic3World\PopManager - - - Vic3World\PopManager - - - Vic3World\PopManager - - - Vic3World\PopManager\Pops - - - Vic3World\PopManager\Pops - - - Vic3World\PopManager\Pops - - - Vic3World\Loaders\LocLoader - - - Vic3World\Loaders\CountryDefinitionLoader - - - Vic3World\Loaders\PopLoader - - - Vic3World\Loaders\PopLoader - - - Vic3World\Loaders\PopLoader - - - Vic3World\Loaders\PopLoader - - - Vic3World\Loaders\PopLoader - - - Vic3World\Loaders\StateLoader - - - Vic3World\Loaders\SuperRegionLoader - - - Vic3World\Loaders\SuperRegionLoader - - - Vic3World\Loaders\SuperRegionLoader - - - Vic3World\Loaders\TerrainLoader - - - Vic3World\Loaders\TerrainLoader - - - Vic3World\Loaders\BuildingLoader - - - Vic3World\Loaders\BuildingLoader - - - Vic3World\Loaders\BuildingLoader\ProductionMethodLoader - - - Vic3World\Loaders\BuildingLoader\ProductionMethodLoader - - - Vic3World\Loaders\VanillaStateLoader - - - Vic3World\Loaders\VanillaStateLoader - - - Vic3World\Loaders\VanillaStateLoader - - - Vic3World\Loaders\VanillaStateLoader - - - Vic3World\Loaders\StateModifierLoader - - - Vic3World\Loaders\LawLoader - - - Vic3World\Loaders\LawLoader - - - Vic3World\Loaders\LawLoader - - - Vic3World\Loaders\DefinesLoader - - - Vic3World\Loaders\DefinesLoader - - - Vic3World\Loaders\NationalBudgetLoader - - - Vic3World\Loaders\NationalBudgetLoader - - - Vic3World\Loaders\NationalBudgetLoader\Script - - - Vic3World\Loaders\NationalBudgetLoader\Script - - - Vic3World\Loaders\NationalBudgetLoader\Script - - - Vic3World\Loaders\VanillaDiplomacyLoader - - - Vic3World\Loaders\VanillaDiplomacyLoader - - - Vic3World\Loaders\VanillaDiplomacyLoader - - - Vic3World\Loaders\VanillaDiplomacyLoader - - - Vic3World\Loaders\VanillaDiplomacyLoader - - - Vic3World\Loaders\VanillaCountryHistoryLoader - - - Vic3World\Loaders\VanillaCountryHistoryLoader - - - Vic3World\Loaders\VanillaPopulationHistoryLoader - - - Vic3World\Loaders\VanillaCharacterLoader - - - Vic3World\Loaders\VanillaCharacterLoader - - - Vic3World\Loaders\VanillaDiplomaticPlayLoader - - - Vic3World\Loaders\VanillaDiplomaticPlayLoader - - - Vic3World\Loaders\VanillaBuildingLoader - - - Vic3World\Loaders\VanillaBuildingLoader - - - Vic3World\Loaders\TechLoader - - - Vic3World\Loaders\TechLoader - - - Vic3World\Loaders\TechLoader - - - Vic3World\Loaders\MajorFormablesLoader - - - Vic3World\Loaders\MajorFormablesLoader - - - Vic3World\FlagCrafter - - - Vic3World\FlagCrafter\FlagNameLoader - - - Vic3World\FlagCrafter\FlagColorLoader - - - Vic3World\EconomyManager - - - Vic3World\EconomyManager\Building - - - Vic3World\EconomyManager\Building - - - Vic3World\EconomyManager\Building - - - Vic3World\EconomyManager\Building\ProductionMethod - - - Vic3World\EconomyManager\Building\ProductionMethod - - - Vic3World\EconomyManager\NationalBudget - Configuration @@ -1672,32 +73,8 @@ Configuration - - Mappers\AIStrategyMapper - - - Mappers\AIStrategyMapper - - - Output\outStrategies - - - Mappers\AISecretGoalMapper - - - Mappers\AISecretGoalMapper - - - Output\outSecretGoals - - - Mappers\CultureMapper\TraitDefinitionLoader - - - Mappers\CultureMapper\TraitDefinitionLoader - - - Mappers\CultureMapper\TraitDefinitionLoader + + EU5World\Loaders\ModLoader \ No newline at end of file