From 674a51cf2799c1b30c9373c4576e4edae7d495c6 Mon Sep 17 00:00:00 2001 From: IhateTrains Date: Thu, 26 Sep 2024 20:27:33 +0100 Subject: [PATCH] Don't convert to Administrative government if Roads to Power is missing (#2234) #patch --- .../Characters/CharacterCollectionTests.cs | 3 +- .../CK3/Titles/LandedTitlesTests.cs | 20 ++++++++- .../CK3/Titles/RulerTermTests.cs | 6 ++- .../CK3/Titles/TitleTests.cs | 3 +- .../Government/GovernmentMapperTests.cs | 38 +++++++++++++---- .../Mappers/TagTitle/TagTitleMapperTests.cs | 9 ++-- .../Outputter/CoatOfArmsOutputterTests.cs | 6 ++- ImperatorToCK3/CK3/Titles/LandedTitles.cs | 24 +++++++---- ImperatorToCK3/CK3/Titles/RulerTerm.cs | 7 ++-- ImperatorToCK3/CK3/Titles/Title.cs | 19 +++++---- ImperatorToCK3/CK3/World.cs | 41 ++++++++++++++++++- .../configurables/government_map.txt | 6 ++- ImperatorToCK3/ImperatorToCK3.csproj | 2 +- .../Mappers/Government/GovernmentMapper.cs | 4 +- .../Mappers/Government/GovernmentMapping.cs | 13 +++++- ImperatorToCK3/Outputter/BookmarkOutputter.cs | 5 +++ 16 files changed, 163 insertions(+), 43 deletions(-) diff --git a/ImperatorToCK3.UnitTests/CK3/Characters/CharacterCollectionTests.cs b/ImperatorToCK3.UnitTests/CK3/Characters/CharacterCollectionTests.cs index 3b6afe952..a890d7443 100644 --- a/ImperatorToCK3.UnitTests/CK3/Characters/CharacterCollectionTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Characters/CharacterCollectionTests.cs @@ -337,7 +337,8 @@ public void ImperatorCountriesGoldCanBeDistributedAmongRulerAndVassals() { characters, conversionDate, config, - new List>()); + new List>(), + enabledCK3Dlcs: []); var provinces = new ProvinceCollection(ck3ModFS); var ck3MapData = new MapData(ck3ModFS); diff --git a/ImperatorToCK3.UnitTests/CK3/Titles/LandedTitlesTests.cs b/ImperatorToCK3.UnitTests/CK3/Titles/LandedTitlesTests.cs index ad785dad8..bd12ba1a8 100644 --- a/ImperatorToCK3.UnitTests/CK3/Titles/LandedTitlesTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Titles/LandedTitlesTests.cs @@ -301,7 +301,25 @@ public void GovernorshipsCanBeRecognizedAsCountyLevel() { var ck3LocDB = new TestCK3LocDB(); // Import country 589. - titles.ImportImperatorCountries(imperatorWorld.Countries, imperatorWorld.Dependencies, tagTitleMapper, irLocDB, ck3LocDB, provinceMapper, coaMapper, new GovernmentMapper(ck3GovernmentIds: Array.Empty()), new SuccessionLawMapper(), definiteFormMapper, religionMapper, cultureMapper, nicknameMapper, characters, conversionDate, config, new List>()); + titles.ImportImperatorCountries( + imperatorWorld.Countries, + imperatorWorld.Dependencies, + tagTitleMapper, + irLocDB, + ck3LocDB, + provinceMapper, + coaMapper, + new GovernmentMapper(ck3GovernmentIds: Array.Empty()), + new SuccessionLawMapper(), + definiteFormMapper, + religionMapper, + cultureMapper, + nicknameMapper, + characters, + conversionDate, + config, + new List>(), + enabledCK3Dlcs: []); Assert.Collection(titles, title => Assert.Equal("c_county1", title.Id), title => Assert.Equal("b_barony1", title.Id), diff --git a/ImperatorToCK3.UnitTests/CK3/Titles/RulerTermTests.cs b/ImperatorToCK3.UnitTests/CK3/Titles/RulerTermTests.cs index c5423be08..a8b19c2f0 100644 --- a/ImperatorToCK3.UnitTests/CK3/Titles/RulerTermTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Titles/RulerTermTests.cs @@ -62,7 +62,8 @@ public void ImperatorRulerTermIsCorrectlyConverted() { new CultureMapper(irRegionMapper, ck3RegionMapper, new CultureCollection(new ColorFactory(), new PillarCollection(new ColorFactory(), []), [])), new NicknameMapper("TestFiles/configurables/nickname_map.txt"), new ProvinceMapper(), - new Configuration() + new Configuration(), + enabledCK3Dlcs: [] ); Assert.Equal("imperator69", ck3RulerTerm.CharacterId); Assert.Equal(new Date(500, 2, 3, AUC: true), ck3RulerTerm.StartDate); @@ -104,7 +105,8 @@ public void PreImperatorTermIsCorrectlyConverted() { new CultureMapper(new BufferedReader("link = { ir=spartan ck3=greek }"), irRegionMapper, ck3RegionMapper, cultures), new NicknameMapper("TestFiles/configurables/nickname_map.txt"), new ProvinceMapper(), - new Configuration() + new Configuration(), + enabledCK3Dlcs: [] ); Assert.Equal("imperatorRegnalSPAAlexander504_1_1BC", ck3RulerTerm.CharacterId); Assert.Equal(new Date(250, 1, 1, AUC: true), ck3RulerTerm.StartDate); diff --git a/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs b/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs index 1c9c73c16..9def27d0f 100644 --- a/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs @@ -90,7 +90,8 @@ public Title BuildFromTag() { nicknameMapper, characters, ck3BookmarkDate, - config + config, + enabledCK3Dlcs: [] ); } public TitleBuilder WithCountry(Country country) { diff --git a/ImperatorToCK3.UnitTests/Mappers/Government/GovernmentMapperTests.cs b/ImperatorToCK3.UnitTests/Mappers/Government/GovernmentMapperTests.cs index efa46b2ff..7ea627501 100644 --- a/ImperatorToCK3.UnitTests/Mappers/Government/GovernmentMapperTests.cs +++ b/ImperatorToCK3.UnitTests/Mappers/Government/GovernmentMapperTests.cs @@ -10,22 +10,22 @@ public class GovernmentMapperTests { public void NonMatchGivesNull() { var reader = new BufferedReader("link = { ck3 = ck3Government ir = irGovernment }"); var mapper = new GovernmentMapper(reader, ck3GovernmentIds: new List { "ck3Government" }); - var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("nonMatchingGovernment", null); + var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("nonMatchingGovernment", null, []); Assert.Null(ck3Gov); } [Fact] public void CK3GovernmentCanBeFound() { var reader = new BufferedReader("link = { ck3 = ck3Government ir = irGovernment }"); var mapper = new GovernmentMapper(reader, ck3GovernmentIds: new List { "ck3Government" }); - var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", null); + var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", null, []); Assert.Equal("ck3Government", ck3Gov); } [Fact] public void MultipleImperatorGovernmentsCanBeInARule() { var reader = new BufferedReader("link = { ck3 = ck3Government ir = irGovernment ir = irGovernment2 }"); var mapper = new GovernmentMapper(reader, ck3GovernmentIds: new List { "ck3Government" }); - var ck3Gov1 = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", null); - var ck3Gov2 = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment2", null); + var ck3Gov1 = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", null, []); + var ck3Gov2 = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment2", null, []); Assert.Equal("ck3Government", ck3Gov1); Assert.Equal("ck3Government", ck3Gov2); } @@ -36,7 +36,7 @@ public void CorrectRuleMatches() { "link = { ck3 = ck3Government2 ir = irGovernment2 }" ); var mapper = new GovernmentMapper(reader, ck3GovernmentIds: new List { "ck3Government", "ck3Government2" }); - var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment2", null); + var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment2", null, []); Assert.Equal("ck3Government2", ck3Gov); } @@ -48,9 +48,29 @@ public void CultureCanBeUsedToMatch() { "link = { ck3 = govC ir = irGovernment }" ); var mapper = new GovernmentMapper(reader, ck3GovernmentIds: new List { "govA", "govB", "govC" }); - Assert.Equal("govA", mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", "roman")); - Assert.Equal("govB", mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", "greek")); - Assert.Equal("govC", mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", "thracian")); - Assert.Equal("govC", mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", null)); + Assert.Equal("govA", mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", "roman", [])); + Assert.Equal("govB", mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", "greek", [])); + Assert.Equal("govC", mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", "thracian", [])); + Assert.Equal("govC", mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", null, [])); + } + + [Fact] + public void CK3DlcCanBeUsedToMatch() { + var reader = new BufferedReader( + """ + link = { ck3 = administrative_government + has_ck3_dlc = roads_to_power + ir = imperium + ir = imperial_cult + } + link = { ck3 = feudal_government + ir = imperium # When the user doesn't have the Roads to Power DLC. + ir = imperial_cult # When the user doesn't have the Roads to Power DLC. + } + """); + var mapper = new GovernmentMapper(reader, ck3GovernmentIds: [ "administrative_government", "feudal_government" ]); + + Assert.Equal("administrative_government", mapper.GetCK3GovernmentForImperatorGovernment("imperium", null, enabledCK3Dlcs: ["roads_to_power"])); + Assert.Equal("feudal_government", mapper.GetCK3GovernmentForImperatorGovernment("imperium", null, enabledCK3Dlcs: [])); } } \ No newline at end of file diff --git a/ImperatorToCK3.UnitTests/Mappers/TagTitle/TagTitleMapperTests.cs b/ImperatorToCK3.UnitTests/Mappers/TagTitle/TagTitleMapperTests.cs index c210ce006..63cd5f2c9 100644 --- a/ImperatorToCK3.UnitTests/Mappers/TagTitle/TagTitleMapperTests.cs +++ b/ImperatorToCK3.UnitTests/Mappers/TagTitle/TagTitleMapperTests.cs @@ -93,7 +93,8 @@ public void TitleCanBeMatchedFromGovernorship() { new CharacterCollection(), new Date(), new Configuration(), - new List>() + new List>(), + enabledCK3Dlcs: [] ); irRegionMapper.Regions.Add(new ImperatorRegion("central_italy_region", new BufferedReader(), Areas, ColorFactory)); @@ -168,7 +169,8 @@ public void TitleCanBeGeneratedFromGovernorship() { new CharacterCollection(), new Date(), new Configuration(), - new List>() + new List>(), + enabledCK3Dlcs: [] ); irRegionMapper.Regions.Add(new ImperatorRegion("apulia_region", new BufferedReader(), Areas, ColorFactory)); @@ -262,7 +264,8 @@ public void GovernorshipCanBeRegistered() { new CharacterCollection(), new Date(), new Configuration(), - new List>() + new List>(), + enabledCK3Dlcs: [] ); var ck3Provinces = new ProvinceCollection(); diff --git a/ImperatorToCK3.UnitTests/Outputter/CoatOfArmsOutputterTests.cs b/ImperatorToCK3.UnitTests/Outputter/CoatOfArmsOutputterTests.cs index 936fde69a..9845ff7bc 100644 --- a/ImperatorToCK3.UnitTests/Outputter/CoatOfArmsOutputterTests.cs +++ b/ImperatorToCK3.UnitTests/Outputter/CoatOfArmsOutputterTests.cs @@ -73,7 +73,8 @@ public async Task CoaIsOutputtedForCountryWithFlagSet() { new CharacterCollection(), new Date(400, 1, 1), new Configuration(), - new List>() + new List>(), + enabledCK3Dlcs: [] ); await CoatOfArmsOutputter.OutputCoas(outputModPath, titles, new List(), new CoaMapper()); @@ -119,7 +120,8 @@ public async Task CoaIsNotOutputtedForCountryWithoutFlagSet() { new CharacterCollection(), new Date(400, 1, 1), new Configuration(), - new List>() + new List>(), + enabledCK3Dlcs: [] ); await CoatOfArmsOutputter.OutputCoas(outputModPath, titles, new List(), new CoaMapper()); diff --git a/ImperatorToCK3/CK3/Titles/LandedTitles.cs b/ImperatorToCK3/CK3/Titles/LandedTitles.cs index 6bb66af54..7134e9827 100644 --- a/ImperatorToCK3/CK3/Titles/LandedTitles.cs +++ b/ImperatorToCK3/CK3/Titles/LandedTitles.cs @@ -159,7 +159,8 @@ public Title Add( NicknameMapper nicknameMapper, CharacterCollection characters, Date conversionDate, - Configuration config + Configuration config, + IReadOnlyCollection enabledCK3Dlcs ) { var newTitle = new Title(this, country, @@ -178,7 +179,8 @@ Configuration config nicknameMapper, characters, conversionDate, - config + config, + enabledCK3Dlcs ); dict[newTitle.Id] = newTitle; return newTitle; @@ -338,7 +340,8 @@ public void ImportImperatorCountries( CharacterCollection characters, Date conversionDate, Configuration config, - List> countyLevelCountries + List> countyLevelCountries, + IReadOnlyCollection enabledCK3Dlcs ) { Logger.Info("Importing Imperator countries..."); @@ -372,7 +375,8 @@ public void ImportImperatorCountries( characters, conversionDate, config, - countyLevelCountries + countyLevelCountries, + enabledCK3Dlcs ); ++counter; } @@ -395,7 +399,8 @@ public void ImportImperatorCountries( characters, conversionDate, config, - countyLevelCountries + countyLevelCountries, + enabledCK3Dlcs ); ++counter; } @@ -420,7 +425,8 @@ private void ImportImperatorCountry( CharacterCollection characters, Date conversionDate, Configuration config, - List> countyLevelCountries) { + List> countyLevelCountries, + IReadOnlyCollection enabledCK3Dlcs) { // Create a new title or update existing title. var titleId = DetermineId(country, dependency, imperatorCountries, tagTitleMapper, irLocDB); @@ -447,7 +453,8 @@ private void ImportImperatorCountry( nicknameMapper, characters, conversionDate, - config + config, + enabledCK3Dlcs ); } else { Add( @@ -467,7 +474,8 @@ private void ImportImperatorCountry( nicknameMapper, characters, conversionDate, - config + config, + enabledCK3Dlcs ); } } diff --git a/ImperatorToCK3/CK3/Titles/RulerTerm.cs b/ImperatorToCK3/CK3/Titles/RulerTerm.cs index f9b547f2b..8beda95f5 100644 --- a/ImperatorToCK3/CK3/Titles/RulerTerm.cs +++ b/ImperatorToCK3/CK3/Titles/RulerTerm.cs @@ -6,6 +6,7 @@ using ImperatorToCK3.Mappers.Nickname; using ImperatorToCK3.Mappers.Province; using ImperatorToCK3.Mappers.Religion; +using System.Collections.Generic; namespace ImperatorToCK3.CK3.Titles; @@ -25,14 +26,14 @@ public RulerTerm( CultureMapper cultureMapper, NicknameMapper nicknameMapper, ProvinceMapper provinceMapper, - Configuration config - ) { + Configuration config, + IReadOnlyCollection enabledCK3Dlcs) { if (imperatorRulerTerm.CharacterId is not null) { CharacterId = $"imperator{imperatorRulerTerm.CharacterId}"; } StartDate = imperatorRulerTerm.StartDate; if (imperatorRulerTerm.Government is not null) { - Government = governmentMapper.GetCK3GovernmentForImperatorGovernment(imperatorRulerTerm.Government, null); + Government = governmentMapper.GetCK3GovernmentForImperatorGovernment(imperatorRulerTerm.Government, null, enabledCK3Dlcs); } PreImperatorRuler = imperatorRulerTerm.PreImperatorRuler; diff --git a/ImperatorToCK3/CK3/Titles/Title.cs b/ImperatorToCK3/CK3/Titles/Title.cs index cc6a0bc4f..fe677d370 100644 --- a/ImperatorToCK3/CK3/Titles/Title.cs +++ b/ImperatorToCK3/CK3/Titles/Title.cs @@ -62,7 +62,8 @@ private Title(LandedTitles parentCollection, NicknameMapper nicknameMapper, CharacterCollection characters, Date conversionDate, - Configuration config + Configuration config, + IReadOnlyCollection enabledCK3Dlcs ) { IsCreatedFromImperator = true; this.parentCollection = parentCollection; @@ -84,7 +85,8 @@ Configuration config nicknameMapper, characters, conversionDate, - config + config, + enabledCK3Dlcs ); } private Title(LandedTitles parentCollection, @@ -188,7 +190,8 @@ public void InitializeFromTag( NicknameMapper nicknameMapper, CharacterCollection characters, Date conversionDate, - Configuration config + Configuration config, + IReadOnlyCollection enabledCK3Dlcs ) { ImperatorCountry = country; ImperatorCountry.CK3Title = this; @@ -202,7 +205,7 @@ Configuration config ClearHolderSpecificHistory(); - FillHolderAndGovernmentHistory(country, characters, governmentMapper, irLocDB, ck3LocDB, religionMapper, cultureMapper, nicknameMapper, provinceMapper, config, conversionDate); + FillHolderAndGovernmentHistory(country, characters, governmentMapper, irLocDB, ck3LocDB, religionMapper, cultureMapper, nicknameMapper, provinceMapper, config, conversionDate, enabledCK3Dlcs); // Determine color. var color1Opt = ImperatorCountry.Color1; @@ -299,7 +302,8 @@ private void FillHolderAndGovernmentHistory(Country imperatorCountry, NicknameMapper nicknameMapper, ProvinceMapper provinceMapper, Configuration config, - Date conversionDate) { + Date conversionDate, + IReadOnlyCollection enabledCK3Dlcs) { // ------------------ determine previous and current holders foreach (var impRulerTerm in imperatorCountry.RulerTerms) { @@ -313,7 +317,8 @@ private void FillHolderAndGovernmentHistory(Country imperatorCountry, cultureMapper, nicknameMapper, provinceMapper, - config + config, + enabledCK3Dlcs ); var characterId = rulerTerm.CharacterId; @@ -337,7 +342,7 @@ private void FillHolderAndGovernmentHistory(Country imperatorCountry, if (imperatorCountry.Government is not null) { var lastCK3TermGov = GetGovernment(conversionDate); - var ck3CountryGov = governmentMapper.GetCK3GovernmentForImperatorGovernment(imperatorCountry.Government, imperatorCountry.PrimaryCulture); + var ck3CountryGov = governmentMapper.GetCK3GovernmentForImperatorGovernment(imperatorCountry.Government, imperatorCountry.PrimaryCulture, enabledCK3Dlcs); if (lastCK3TermGov != ck3CountryGov && ck3CountryGov is not null) { History.AddFieldValue(conversionDate, "government", "government", ck3CountryGov); } diff --git a/ImperatorToCK3/CK3/World.cs b/ImperatorToCK3/CK3/World.cs index ebf0440ca..cbd987c5e 100644 --- a/ImperatorToCK3/CK3/World.cs +++ b/ImperatorToCK3/CK3/World.cs @@ -60,6 +60,7 @@ public sealed class World { public IList Wars { get; } = new List(); public LegendSeedCollection LegendSeeds { get; } = []; public CoaMapper CK3CoaMapper { get; private set; } = null!; + private readonly List enabledDlcFlags = []; /// /// Date based on I:R save date, but normalized for CK3 purposes. @@ -68,6 +69,8 @@ public sealed class World { public World(Imperator.World impWorld, Configuration config, Thread? irCoaExtractThread) { Logger.Info("*** Hello CK3, let's get painting. ***"); + + DetermineCK3Dlcs(config); warMapper.DetectUnmappedWarGoals(impWorld.ModFS); @@ -288,7 +291,8 @@ public World(Imperator.World impWorld, Configuration config, Thread? irCoaExtrac Characters, CorrectedDate, config, - countyLevelCountries + countyLevelCountries, + enabledDlcFlags ); // Now we can deal with provinces since we know to whom to assign them. We first import vanilla province data. @@ -1040,6 +1044,41 @@ private void GenerateFillerHoldersForUnownedLands(CultureCollection cultures, Co } } + private void DetermineCK3Dlcs(Configuration config) { + var dlcFolderPath = Path.Join(config.CK3Path, "game/dlc"); + if (!Directory.Exists(dlcFolderPath)) { + Logger.Warn($"CK3 DLC folder not found: {dlcFolderPath}"); + return; + } + + OrderedDictionary dlcFileToDlcFlagDict = new() { + {"dlc001.dlc", "garments_of_hre"}, + {"dlc002.dlc", "fashion_of_abbasid_court"}, + {"dlc003.dlc", "northern_lords"}, + {"dlc004.dlc", "royal_court"}, + {"dlc005.dlc", "fate_of_iberia"}, + {"dlc006.dlc", "friends_and_foes"}, + {"dlc007.dlc", "tours_and_tournaments"}, + {"dlc008.dlc", "elegance_of_empire"}, + {"dlc009.dlc", "wards_and_wardens"}, + {"dlc010.dlc", "legacy_of_persia"}, + {"dlc011.dlc", "legends_of_the_dead"}, + {"dlc012.dlc", "north_african_attire"}, + {"dlc013.dlc", "couture_of_capets"}, + {"dlc014.dlc", "roads_to_power"}, + }; + + var dlcFiles = Directory.GetFiles(dlcFolderPath, "*.dlc", SearchOption.AllDirectories); + foreach (var dlcFile in dlcFiles) { + var dlcFileName = Path.GetFileName(dlcFile); + if (dlcFileToDlcFlagDict.TryGetValue(dlcFileName, out var dlcFlag)) { + enabledDlcFlags.Add(dlcFlag); + } else { + Logger.Warn($"Unknown DLC file: {dlcFileName}"); + } + } + } + private readonly DeathReasonMapper deathReasonMapper = new(); private readonly DefiniteFormMapper definiteFormMapper = new(Path.Combine("configurables", "definite_form_names.txt")); private readonly NicknameMapper nicknameMapper = new(Path.Combine("configurables", "nickname_map.txt")); diff --git a/ImperatorToCK3/Data_Files/configurables/government_map.txt b/ImperatorToCK3/Data_Files/configurables/government_map.txt index c3944d7cf..c7cabd7e4 100644 --- a/ImperatorToCK3/Data_Files/configurables/government_map.txt +++ b/ImperatorToCK3/Data_Files/configurables/government_map.txt @@ -7,8 +7,9 @@ # ck3 = CK3 government ID # ir = Imperator government ID # irCulture = Imperator culture ID (optional) +# has_ck3_dlc = CK3 DLC ID (optional, supported IDs: roads_to_power) #} -# multiple entries allowed for: ir, irCulture +# multiple entries allowed for: ir, irCulture, has_ck3_dlc # multiple entries not allowed for: ck3 ## TFE @@ -34,6 +35,7 @@ link = { ck3 = theocracy_government ir = theocratic_republic } link = { ck3 = administrative_government + has_ck3_dlc = roads_to_power ir = imperium ir = imperial_cult } @@ -44,6 +46,8 @@ link = { ck3 = feudal_government ir = stratocratic_monarchy ir = theocratic_monarchy ir = plutocratic_monarchy + ir = imperium # When the user doesn't have the Roads to Power DLC. + ir = imperial_cult # When the user doesn't have the Roads to Power DLC. } link = { ck3 = tribal_government ir = tribal_chiefdom diff --git a/ImperatorToCK3/ImperatorToCK3.csproj b/ImperatorToCK3/ImperatorToCK3.csproj index 122e6024e..79c0a3ddf 100644 --- a/ImperatorToCK3/ImperatorToCK3.csproj +++ b/ImperatorToCK3/ImperatorToCK3.csproj @@ -44,7 +44,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ImperatorToCK3/Mappers/Government/GovernmentMapper.cs b/ImperatorToCK3/Mappers/Government/GovernmentMapper.cs index 07a2fc561..66eb863f6 100644 --- a/ImperatorToCK3/Mappers/Government/GovernmentMapper.cs +++ b/ImperatorToCK3/Mappers/Government/GovernmentMapper.cs @@ -48,9 +48,9 @@ private void RemoveInvalidLinks(ICollection ck3GovernmentIds) { } } - public string? GetCK3GovernmentForImperatorGovernment(string irGovernmentId, string? irCultureId) { + public string? GetCK3GovernmentForImperatorGovernment(string irGovernmentId, string? irCultureId, IReadOnlyCollection enabledCK3Dlcs) { foreach (var mapping in mappings) { - var match = mapping.Match(irGovernmentId, irCultureId); + var match = mapping.Match(irGovernmentId, irCultureId, enabledCK3Dlcs); if (match is not null) { return match; } diff --git a/ImperatorToCK3/Mappers/Government/GovernmentMapping.cs b/ImperatorToCK3/Mappers/Government/GovernmentMapping.cs index 05088c260..c59734bbf 100644 --- a/ImperatorToCK3/Mappers/Government/GovernmentMapping.cs +++ b/ImperatorToCK3/Mappers/Government/GovernmentMapping.cs @@ -7,18 +7,20 @@ internal sealed class GovernmentMapping { public string CK3GovernmentId { get; private set; } = ""; public SortedSet ImperatorGovernmentIds { get; } = []; public SortedSet ImperatorCultureIds { get; } = []; + public HashSet RequiredCK3Dlcs { get; } = []; public GovernmentMapping(BufferedReader mappingReader) { var parser = new Parser(); parser.RegisterKeyword("ck3", reader => CK3GovernmentId = reader.GetString()); parser.RegisterKeyword("ir", reader => ImperatorGovernmentIds.Add(reader.GetString())); parser.RegisterKeyword("irCulture", reader => ImperatorCultureIds.Add(reader.GetString())); + parser.RegisterKeyword("has_ck3_dlc", reader => RequiredCK3Dlcs.Add(reader.GetString())); parser.IgnoreAndLogUnregisteredItems(); parser.ParseStream(mappingReader); } - public string? Match(string irGovernmentId, string? irCultureId) { + public string? Match(string irGovernmentId, string? irCultureId, IReadOnlyCollection enabledCK3Dlcs) { if (!ImperatorGovernmentIds.Contains(irGovernmentId)) { return null; } @@ -31,6 +33,15 @@ public GovernmentMapping(BufferedReader mappingReader) { return null; } } + + if (RequiredCK3Dlcs.Count != 0) { + if (enabledCK3Dlcs.Count == 0) { + return null; + } + if (!RequiredCK3Dlcs.IsSubsetOf(enabledCK3Dlcs)) { + return null; + } + } return CK3GovernmentId; } diff --git a/ImperatorToCK3/Outputter/BookmarkOutputter.cs b/ImperatorToCK3/Outputter/BookmarkOutputter.cs index 63d71a8bc..cf6151c3f 100644 --- a/ImperatorToCK3/Outputter/BookmarkOutputter.cs +++ b/ImperatorToCK3/Outputter/BookmarkOutputter.cs @@ -79,6 +79,11 @@ Configuration config if (holder.GetName(config.CK3BookmarkDate) is {} holderName) { if (ck3LocDB.TryGetValue(holderName, out var holderNameLoc)) { holderLoc.CopyFrom(holderNameLoc); + } else { + // Use the raw name. + foreach (var language in ConverterGlobals.SupportedLanguages) { + holderLoc[language] = holderName; + } } } var holderDescLoc = ck3LocDB.GetOrCreateLocBlock($"bm_converted_{holder.Id}_desc");