public void MultipleDuchiesCanBeLoaded() { var reader = new BufferedReader("duchies = { d_ivrea d_athens d_oppo }"); var region = CK3Region.Parse("region1", reader); Assert.Empty(region.Duchies); // not linked yet var titles = new Title.LandedTitles(); region.LinkDuchy(titles.Add("d_ivrea")); region.LinkDuchy(titles.Add("d_athens")); region.LinkDuchy(titles.Add("d_oppo")); Assert.Equal(3, region.Duchies.Count); }
public void PrimogenitureAndSeniorityTriggersAreOutputted() { const string outputModName = "outputMod"; var outputFilePath = Path.Combine( "output", outputModName, "common", "scripted_triggers", "IRToCK3_succession_triggers.txt" ); var date = new Date(476, 1, 1); var titles = new Title.LandedTitles(); var kingdomPrimogeniture = titles.Add("k_kingdom1"); kingdomPrimogeniture.SuccessionLaws.Add("single_heir_succession_law"); var kingdomSeniority = titles.Add("k_kingdom2"); kingdomSeniority.SuccessionLaws.Add("single_heir_dynasty_house"); var vassal = titles.Add("d_vassal"); vassal.SuccessionLaws.Add("single_heir_succession_law"); vassal.SetDeFactoLiege(kingdomPrimogeniture, date); // has de facto liege, will not be added to the trigger SystemUtils.TryCreateFolder(CommonFunctions.GetPath(outputFilePath)); SuccessionTriggersOutputter.OutputSuccessionTriggers(outputModName, titles, date); using var file = File.OpenRead(outputFilePath); var reader = new StreamReader(file); Assert.Equal("historical_succession_access_single_heir_succession_law_trigger={", reader.ReadLine()); Assert.Equal("\tOR={", reader.ReadLine()); Assert.Equal($"\t\thas_title=title:{kingdomPrimogeniture.Id}", reader.ReadLine()); Assert.Equal("\t}", reader.ReadLine()); Assert.Equal("}", reader.ReadLine()); Assert.Equal("historical_succession_access_single_heir_dynasty_house_trigger={", reader.ReadLine()); Assert.Equal("\tOR={", reader.ReadLine()); Assert.Equal($"\t\thas_title=title:{kingdomSeniority.Id}", reader.ReadLine()); Assert.Equal("\t}", reader.ReadLine()); Assert.Equal("}", reader.ReadLine()); Assert.True(reader.EndOfStream); }
public void DuchyCanBeLoaded() { var reader = new BufferedReader("duchies = { d_duchy }"); var region = CK3Region.Parse("region1", reader); Assert.Empty(region.Duchies); // not linked yet var titles = new Title.LandedTitles(); region.LinkDuchy(titles.Add("d_duchy")); Assert.Collection(region.Duchies, item => Assert.Equal("d_duchy", item.Key) ); }
public void RegionCanBeLinkedToDuchy() { var reader = new BufferedReader("duchies = { d_ivrea d_athens d_oppo }"); var region = CK3Region.Parse("region1", reader); var titles = new Title.LandedTitles(); var reader2 = new BufferedReader( "{ c_athens = { b_athens = { province = 79 } b_newbarony = { province = 56 } } }" ); var duchy2 = titles.Add("d_athens"); duchy2.LoadTitles(reader2); Assert.False(region.Duchies.ContainsKey("d_athens")); // not linked yet region.LinkDuchy(duchy2); Assert.NotNull(region.Duchies["d_athens"]); }
public void LinkedRegionWillFailForProvinceMismatch() { var reader = new BufferedReader("duchies = { d_ivrea d_athens d_oppo }"); var region = CK3Region.Parse("region1", reader); var titles = new Title.LandedTitles(); var reader2 = new BufferedReader( "{ c_athens = { b_athens = { province = 79 } b_newbarony = { province = 56 } } }" ); var duchy2 = titles.Add("d_athens"); duchy2.LoadTitles(reader2); region.LinkDuchy(duchy2); Assert.False(region.ContainsProvince(7)); }
public void LinkedRegionCanLocateProvince() { var reader = new BufferedReader("duchies = { d_ivrea d_athens d_oppo }"); var region = CK3Region.Parse("region1", reader); var titles = new Title.LandedTitles(); var reader2 = new BufferedReader( "= { c_athens = { b_athens = { province = 79 } b_newbarony = { province = 56 } } }" ); var duchy2 = titles.Add("d_athens"); duchy2.LoadTitles(reader2); region.LinkDuchy(duchy2); Assert.True(region.ContainsProvince(79)); Assert.True(region.ContainsProvince(56)); }
public void TitlesAreOutputted() { const string outputModName = "outputMod"; var titles = new Title.LandedTitles(); var kingdom = titles.Add("k_kingdom"); var history = new History(); history.AddFieldValue("liege", 0, new Date(20, 1, 1), "liege"); var kingdomHistory = new TitleHistory(history); kingdom.AddHistory(kingdomHistory); var duchy = titles.Add("d_duchy"); duchy.DeJureLiege = kingdom; var county = titles.Add("c_county"); county.DeJureLiege = duchy; var barony = titles.Add("b_barony"); barony.DeJureLiege = county; var specialTitle = titles.Add("k_special_title"); var specialHistory = new History(); specialHistory.AddFieldValue("holder", "bob_42", new Date(20, 1, 1), "holder"); var specialTitleHistory = new TitleHistory(specialHistory); specialTitle.AddHistory(specialTitleHistory); var titleHistoryPath = Path.Combine("output", outputModName, "history", "titles"); var kingdomHistoryPath = Path.Combine(titleHistoryPath, "k_kingdom.txt"); var otherTitlesHistoryPath = Path.Combine(titleHistoryPath, "00_other_titles.txt"); SystemUtils.TryCreateFolder(titleHistoryPath); var landedTitlesPath = Path.Combine("output", outputModName, "common", "landed_titles", "00_landed_titles.txt"); SystemUtils.TryCreateFolder(CommonFunctions.GetPath(landedTitlesPath)); TitlesOutputter.OutputTitles(outputModName, titles, IMPERATOR_DE_JURE.NO); Assert.True(File.Exists(kingdomHistoryPath)); using var kingdomHistoryFile = File.OpenRead(kingdomHistoryPath); var reader = new StreamReader(kingdomHistoryFile); Assert.Equal("k_kingdom={", reader.ReadLine()); Assert.Equal("\t20.1.1={", reader.ReadLine()); Assert.Equal("\t\tliege=0", reader.ReadLine()); Assert.Equal("\t}", reader.ReadLine()); Assert.Equal("}", reader.ReadLine()); Assert.True(reader.EndOfStream); Assert.True(File.Exists(otherTitlesHistoryPath)); using var otherTitlesHistoryFile = File.OpenRead(otherTitlesHistoryPath); reader = new StreamReader(otherTitlesHistoryFile); Assert.Equal("k_special_title={", reader.ReadLine()); Assert.Equal("\t20.1.1={", reader.ReadLine()); Assert.Equal("\t\tholder=\"bob_42\"", reader.ReadLine()); Assert.Equal("\t}", reader.ReadLine()); Assert.Equal("}", reader.ReadLine()); Assert.True(reader.EndOfStream); Assert.True(File.Exists(landedTitlesPath)); using var landedTitlesFile = File.OpenRead(landedTitlesPath); reader = new StreamReader(landedTitlesFile); Assert.Equal("k_kingdom={", reader.ReadLine()); Assert.Equal("\td_duchy={", reader.ReadLine()); Assert.Equal("\t\tc_county={", reader.ReadLine()); Assert.Equal("\t\t\tb_barony={", reader.ReadLine()); Assert.Equal("\t\t\t\tlandless=no", reader.ReadLine()); Assert.Equal("\t\t\t\tdefinite_form=no", reader.ReadLine()); Assert.Equal("\t\t\t\truler_uses_title_name=no", reader.ReadLine()); Assert.Equal("\t\t\t}", reader.ReadLine()); Assert.Equal("\t\t\tlandless=no", reader.ReadLine()); Assert.Equal("\t\t\tdefinite_form=no", reader.ReadLine()); Assert.Equal("\t\t\truler_uses_title_name=no", reader.ReadLine()); Assert.Equal("\t\t}", reader.ReadLine()); Assert.Equal("\t\tlandless=no", reader.ReadLine()); Assert.Equal("\t\tdefinite_form=no", reader.ReadLine()); Assert.Equal("\t\truler_uses_title_name=no", reader.ReadLine()); Assert.Equal("\t}", reader.ReadLine()); Assert.Equal("\tlandless=no", reader.ReadLine()); Assert.Equal("\tdefinite_form=no", reader.ReadLine()); Assert.Equal("\truler_uses_title_name=no", reader.ReadLine()); Assert.Equal("}", reader.ReadLine()); Assert.Equal("k_special_title={", reader.ReadLine()); Assert.Equal("\tlandless=no", reader.ReadLine()); Assert.Equal("\tdefinite_form=no", reader.ReadLine()); Assert.Equal("\truler_uses_title_name=no", reader.ReadLine()); Assert.Equal("}", reader.ReadLine()); Assert.True(reader.EndOfStream); }