• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ParadoxGameConverters / ImperatorToCK3 / 1207418278

pending completion
1207418278

Pull #305

github

GitHub
Merge 4569de198 into b486d311c
Pull Request #305: Configurable CK3 bookmark date

756 of 1804 branches covered (41.91%)

Branch coverage included in aggregate %.

88 of 88 new or added lines in 13 files covered. (100.0%)

2972 of 7983 relevant lines covered (37.23%)

168.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/ImperatorToCK3/Outputter/TitlesOutputter.cs
1
using System.Collections.Generic;
2
using System.IO;
3
using commonItems;
4
using ImperatorToCK3.CK3.Titles;
5
using ImperatorToCK3.Imperator.Countries;
6

7
namespace ImperatorToCK3.Outputter {
8
        public static class TitlesOutputter {
9
                public static void OutputTitleHistory(Title title, StreamWriter writer, Date ck3BookmarkDate) {
×
10
                        writer.WriteLine(title.Name + " = {");
×
11

12
                        writer.WriteLine($"\t{ck3BookmarkDate} = {{");
×
13

14
                        var deFactoLiege = title.DeFactoLiege;
×
15
                        if (deFactoLiege is not null) {
×
16
                                writer.WriteLine("\t\tliege = " + deFactoLiege.Name);
×
17
                        }
×
18

19
                        writer.WriteLine("\t\tholder = " + title.HolderID);
×
20

21
                        if (title.Government is not null) {
×
22
                                writer.WriteLine("\t\tgovernment = " + title.Government);
×
23
                        }
×
24

25
                        var succLaws = title.SuccessionLaws;
×
26
                        if (succLaws.Count > 0) {
×
27
                                writer.WriteLine("\t\tsuccession_laws = {");
×
28
                                foreach (var law in succLaws) {
×
29
                                        writer.WriteLine("\t\t\t" + law);
×
30
                                }
×
31
                                writer.WriteLine("\t\t}");
×
32
                        }
×
33

34
                        if (title.Rank != TitleRank.barony) {
×
35
                                var developmentLevelOpt = title.DevelopmentLevel;
×
36
                                if (developmentLevelOpt is not null) {
×
37
                                        writer.WriteLine("\t\tchange_development_level = " + developmentLevelOpt);
×
38
                                }
×
39
                        }
×
40

41
                        writer.WriteLine("\t}");
×
42

43
                        writer.WriteLine("}");
×
44
                }
×
45

46
                public static void OutputTitlesHistory(string outputModName, Dictionary<string, Title> titles, Date ck3BookmarkDate) {
×
47
                        //output title history
48
                        var alreadyOutputtedTitles = new HashSet<string>();
×
49
                        foreach (var (name, title) in titles) { // first output kindoms + their de jure vassals to files named after the kingdoms
×
50
                                if (title.Rank == TitleRank.kingdom && title.DeJureVassals.Count > 0) { // is a de jure kingdom
×
51
                                        var historyOutputPath = Path.Combine("output", outputModName, "history", "titles", name + ".txt");
×
52
                                        using var historyOutput = new StreamWriter(historyOutputPath);                      // output the kingdom's history
×
53
                                        OutputTitleHistory(title, historyOutput, ck3BookmarkDate);
×
54
                                        alreadyOutputtedTitles.Add(name);
×
55

56
                                        // output the kingdom's de jure vassals' history
57
                                        foreach (var (deJureVassalName, deJureVassal) in title.GetDeJureVassalsAndBelow()) {
×
58
                                                OutputTitleHistory(deJureVassal, historyOutput, ck3BookmarkDate);
×
59
                                                alreadyOutputtedTitles.Add(deJureVassalName);
×
60
                                        }
×
61
                                }
×
62
                        }
×
63

64
                        var otherTitlesPath = Path.Combine("output", outputModName, "history/titles/00_other_titles.txt");
×
65
                        using (var historyOutput = new StreamWriter(otherTitlesPath)) {
×
66
                                foreach (var (name, title) in titles) { // output the remaining titles
×
67
                                        if (!alreadyOutputtedTitles.Contains(name)) {
×
68
                                                OutputTitleHistory(title, historyOutput, ck3BookmarkDate);
×
69
                                                alreadyOutputtedTitles.Add(name);
×
70
                                        }
×
71
                                }
×
72
                        }
×
73
                }
×
74

75
                public static void OutputTitles(string outputModName, string ck3Path, Dictionary<string, Title> titles, IMPERATOR_DE_JURE deJure, Date ck3BookmarkDate) {
×
76
                        //output to landed_titles folder
77
                        foreach (var (name, title) in titles) {
×
78
                                var impCountry = title.ImperatorCountry;
×
79
                                if (impCountry is not null && impCountry.CountryType != CountryType.real) { // we don't need pirates, barbarians etc.
×
80
                                        continue;
×
81
                                }
82

83
                                if (title.IsImportedOrUpdatedFromImperator && name.IndexOf("IMPTOCK3") != -1) {  // title is not from CK3
×
84
                                        var outputPath = Path.Combine("output", outputModName, "common", "landed_titles", name + ".txt");
×
85
                                        using var outputStream = File.OpenWrite(outputPath);
×
86
                                        using var output = new StreamWriter(outputStream, System.Text.Encoding.UTF8);
×
87
                                        TitleOutputter.OutputTitle(output, title);
×
88
                                }
×
89
                        }
×
90
                        if (deJure == IMPERATOR_DE_JURE.REGIONS) {
×
91
                                if (!SystemUtils.TryCopyFolder("blankMod/optionalFiles/ImperatorDeJure/common/landed_titles", "output/" + outputModName + "/common/landed_titles/")) {
×
92
                                        Logger.Error("Could not copy ImperatorDeJure landed titles!");
×
93
                                }
×
94
                        }
×
95

96
                        OutputTitlesHistory(outputModName, titles, ck3BookmarkDate);
×
97
                }
×
98
        }
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc