From 8ca3ea3a3b5161017330ccf508d1b55ef055a3c1 Mon Sep 17 00:00:00 2001 From: Seweryn Presnal Date: Sun, 21 Apr 2024 10:39:10 +0200 Subject: [PATCH] Map a few I:R inventions to CK3 innovations --- .../CK3/Cultures/CultureCollection.cs | 5 +++-- ImperatorToCK3/CK3/World.cs | 2 +- .../inventions_to_innovations_map.txt | 5 +++-- .../Mappers/Technology/InnovationMapper.cs | 18 +++++++++++++++--- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ImperatorToCK3/CK3/Cultures/CultureCollection.cs b/ImperatorToCK3/CK3/Cultures/CultureCollection.cs index 1a90046b4..eced0e93a 100644 --- a/ImperatorToCK3/CK3/Cultures/CultureCollection.cs +++ b/ImperatorToCK3/CK3/Cultures/CultureCollection.cs @@ -1,6 +1,7 @@ using commonItems; using commonItems.Collections; using commonItems.Colors; +using commonItems.Localization; using commonItems.Mods; using Fernandezja.ColorHashSharp; using ImperatorToCK3.CommonUtils; @@ -175,12 +176,12 @@ public void LoadNameLists(ModFilesystem ck3ModFS) { return cultureMapper.Match(irCulture, ck3ProvinceId, irProvinceId, country.HistoricalTag); } - public void ImportTechnology(CountryCollection countries, CultureMapper cultureMapper, ProvinceMapper provinceMapper, InventionsDB inventionsDB) { // TODO: test this + public void ImportTechnology(CountryCollection countries, CultureMapper cultureMapper, ProvinceMapper provinceMapper, InventionsDB inventionsDB, LocDB irLocDB) { // TODO: add tests for this Logger.Info("Converting Imperator inventions to CK3 innovations..."); var innovationMapper = new InnovationMapper(); innovationMapper.LoadLinksAndBonuses("configurables/inventions_to_innovations_map.txt"); - innovationMapper.LogUnmappedInventions(inventionsDB); + innovationMapper.LogUnmappedInventions(inventionsDB, irLocDB); // Group I:R countries by corresponding CK3 culture. var countriesByCulture = countries.Select(c => new { diff --git a/ImperatorToCK3/CK3/World.cs b/ImperatorToCK3/CK3/World.cs index 37db493fe..46853597d 100644 --- a/ImperatorToCK3/CK3/World.cs +++ b/ImperatorToCK3/CK3/World.cs @@ -181,7 +181,7 @@ public World(Imperator.World impWorld, Configuration config) { } } - Cultures.ImportTechnology(impWorld.Countries, cultureMapper, provinceMapper, impWorld.InventionsDB); + Cultures.ImportTechnology(impWorld.Countries, cultureMapper, provinceMapper, impWorld.InventionsDB, impWorld.LocDB); var traitMapper = new TraitMapper("configurables/trait_map.txt", ModFS); diff --git a/ImperatorToCK3/Data_Files/configurables/inventions_to_innovations_map.txt b/ImperatorToCK3/Data_Files/configurables/inventions_to_innovations_map.txt index 73c76c269..056f9b6b3 100644 --- a/ImperatorToCK3/Data_Files/configurables/inventions_to_innovations_map.txt +++ b/ImperatorToCK3/Data_Files/configurables/inventions_to_innovations_map.txt @@ -25,7 +25,7 @@ bonus = { ir = gallic_chainmail_inv ck3 = innovation_quilted_armor } # TRIBAL ERA - CIVIC bonus = { ir = global_citizen_output_inv_3 ir = global_freemen_output_inv_3 ir = italic_lex_frumentaria_inv ir = global_tax_modifier_inv_3 ck3 = innovation_development_01 } link = { ir = ruler_popularity_gain_inv_4 ck3 = innovation_development_01 } # Public Works -# bonus = { ir = ck3 = innovation_currency_01 } +bonus = { ir = commerce_inv_1 ir = global_tax_modifier_inv_1 ir = commerce_inv_2 ck3 = innovation_currency_01 } # link = { ir = ck3 = innovation_currency_01 } # bonus = { ir = ck3 = innovation_gavelkind } link = { ir = oaths_of_allegiance_inv ck3 =innovation_gavelkind } # IR is Codified Succession @@ -90,7 +90,8 @@ link = { ir = global_settlement_building_slot_inv ck3 = innovation_manorialism } bonus = { ir = smear_character_cost_modifier_inv ck3 = innovation_development_02 } # 1st Town Criers # link = { ir = ck3 = innovation_development_02 } # Communal Government bonus = { ir = hold_triumph_cost_modifier_inv ck3 = innovation_currency_02 } -# link = { ir = ck3 = innovation_currency_02 } # Coinage +link = { ir = coins_inv ck3 = innovation_currency_02 } # Coinage +link = { ir = brass_coinage_inv ck3 = innovation_currency_02 } # Coinage bonus = { ir = loyalty_gain_chance_modifier_inv ir = agressive_expansion_monthly_decay_inv_4 ck3 = innovation_royal_prerogative } # link = { ir = ck3 = innovation_royal_prerogative } bonus = { ir = land_won_by_the_spear ir = religious_tech_investment_inv_1 ck3 = innovation_chronicle_writing } # 2nd Recording Tradition diff --git a/ImperatorToCK3/Mappers/Technology/InnovationMapper.cs b/ImperatorToCK3/Mappers/Technology/InnovationMapper.cs index 309255b22..a67a7b603 100644 --- a/ImperatorToCK3/Mappers/Technology/InnovationMapper.cs +++ b/ImperatorToCK3/Mappers/Technology/InnovationMapper.cs @@ -1,4 +1,5 @@ using commonItems; +using commonItems.Localization; using ImperatorToCK3.Imperator.Inventions; using System.Collections.Generic; using System.Linq; @@ -50,12 +51,23 @@ public IDictionary GetInnovationProgresses(ICollection i return progressesToReturn; } - public void LogUnmappedInventions(InventionsDB inventionsDB) { + public void LogUnmappedInventions(InventionsDB inventionsDB, LocDB irLocDB) { // Log Imperator inventions for which neither link nor bonus for CK3 innovations exists. var unmappedInventions = inventionsDB.InventionIds .Where(invention => !innovationLinks.Exists(link => link.Match(invention) is not null)) - .Where(invention => !innovationBonuses.Exists(bonus => bonus.GetProgress([invention]) is not null)); + .Where(invention => !innovationBonuses.Exists(bonus => bonus.GetProgress([invention]) is not null)) + .ToList(); - Logger.Debug($"Unmapped I:R inventions: {string.Join(", ", unmappedInventions)}"); + var inventionsWithLoc = unmappedInventions + .Select(inventionId => { + if (irLocDB.GetLocBlockForKey(inventionId) is { } locBlock) { + return $"{inventionId} ({locBlock[ConverterGlobals.PrimaryLanguage]})"; + } + return inventionId; + }); + + Logger.Debug($"Unmapped I:R inventions: {string.Join(", ", inventionsWithLoc)}"); } + + // TODO: ALSO LOG UNMAPPED CK3 MARTIAL AND CIVIC INNOVATIONS }