Skip to content

Commit

Permalink
Merge branch 'master' into pr/2440
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains committed Jan 22, 2025
2 parents f4a2910 + de2e775 commit e4e648c
Show file tree
Hide file tree
Showing 12 changed files with 602 additions and 390 deletions.
4 changes: 2 additions & 2 deletions ImperatorToCK3.UnitTests/ImperatorToCK3.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.3">
<PackageReference Include="coverlet.msbuild" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -23,7 +23,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.3">
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
6 changes: 5 additions & 1 deletion ImperatorToCK3/CK3/Religions/Faith.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ public string Serialize(string indent, bool withBraces) {
}

public OrderedSet<string> GetDoctrineIdsForDoctrineCategoryId(string doctrineCategoryId) {
var category = Religion.ReligionCollection.DoctrineCategories[doctrineCategoryId];
if (!Religion.ReligionCollection.DoctrineCategories.TryGetValue(doctrineCategoryId, out var category)) {
Logger.Warn($"Doctrine category {doctrineCategoryId} not found.");
return [];
}

return GetDoctrineIdsForDoctrineCategory(category);
}

Expand Down
21 changes: 21 additions & 0 deletions ImperatorToCK3/CK3/Religions/ReligionCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ public void LoadReligions(ModFilesystem ck3ModFS, ColorFactory colorFactory) {
}

public void LoadConverterFaiths(string converterFaithsPath, ColorFactory colorFactory) {
OrderedSet<Faith> loadedConverterFaiths = [];

var parser = new Parser();
parser.RegisterRegex(CommonRegexes.String, (religionReader, religionId) => {
var optReligion = new Religion(religionId, religionReader, this, colorFactory);

// For validation, store all faiths loaded inside the converter religion.
loadedConverterFaiths.UnionWith(optReligion.Faiths);

// Check if religion already exists. If it does, add converter faiths to it.
// Otherwise, add the converter faith's religion.
Expand All @@ -55,6 +60,22 @@ public void LoadConverterFaiths(string converterFaithsPath, ColorFactory colorFa
});
parser.RegisterRegex(CommonRegexes.Catchall, ParserHelpers.IgnoreAndLogItem);
parser.ParseFile(converterFaithsPath);

// Validation: every faith should have a pilgrimage doctrine.
string? pilgrimageFallback = DoctrineCategories.TryGetValue("doctrine_pilgrimage", out var pilgrimageCategory)
? pilgrimageCategory.DoctrineIds.FirstOrDefault(d => d == "doctrine_pilgrimage_encouraged")
: null;
foreach (var converterFaith in loadedConverterFaiths) {
var pilgrimageDoctrine = converterFaith.GetDoctrineIdsForDoctrineCategoryId("doctrine_pilgrimage");
if (pilgrimageDoctrine.Count == 0) {
if (pilgrimageFallback is not null) {
Logger.Warn($"Faith {converterFaith.Id} has no pilgrimage doctrine! Setting {pilgrimageFallback}");
converterFaith.DoctrineIds.Add(pilgrimageFallback);
} else {
Logger.Warn($"Faith {converterFaith.Id} has no pilgrimage doctrine!");
}
}
}
}

private void RegisterHolySitesKeywords(Parser parser, bool areSitesFromConverter) {
Expand Down
15 changes: 12 additions & 3 deletions ImperatorToCK3/CK3/Titles/LandedTitles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@ public void LoadTitles(ModFilesystem ck3ModFS, CK3LocDB ck3LocDB) {
continue;
}
// Try to use the first valid capital of a de jure vassal.
var newCapitalId = title.DeJureVassals
.Select(v => v.CapitalCountyId)
.FirstOrDefault(vassalCapitalId => vassalCapitalId is not null && validTitleIds.Contains(vassalCapitalId));
string? newCapitalId;
if (title.Rank >= TitleRank.kingdom) {
newCapitalId = title.DeJureVassals
.Select(v => v.CapitalCountyId)
.FirstOrDefault(vassalCapitalId => vassalCapitalId is not null && validTitleIds.Contains(vassalCapitalId));
} else {
newCapitalId = title.DeJureVassals
.Where(v => v.Rank == TitleRank.county)
.Select(c => c.Id)
.FirstOrDefault();
}

// If not found, for landless titles try using capital of de jure liege.
if (newCapitalId is null && title.Landless) {
newCapitalId = title.DeJureLiege?.CapitalCountyId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@
unlock_final_hasan_decisions_1_tt: ""
unlock_final_hasan_decisions_2_tt: ""
unlock_final_hasan_decisions_3_tt: ""

# "Ancient Egyptian" is weird as a name for a culture that exists in the megacampaign timeline.
ancient_egyptian: "Kemetic"
ancient_egyptian_collective_noun: "Kemetics"
ancient_egyptian_prefix: "Egypto"
# "Egyptian" should not be used for the later Arabic-speaking population of Egypt.
# Instead, base the name on "Misr", the Arabic name for Egypt.
egyptian: "Misri"
egyptian_collective_noun: "Misris"
egyptian_prefix: "Egypto"
39 changes: 39 additions & 0 deletions ImperatorToCK3/Data_Files/configurables/converter_faiths.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ scythian_religion = {
doctrine = doctrine_clerical_gender_either
doctrine = doctrine_clerical_marriage_allowed
doctrine = doctrine_clerical_succession_temporal_appointment

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

traits = {
virtues = { brave just honest }
Expand Down Expand Up @@ -468,6 +471,9 @@ arabic_religion = {
doctrine = doctrine_clerical_gender_either
doctrine = doctrine_clerical_marriage_allowed
doctrine = doctrine_clerical_succession_temporal_appointment

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

traits = {
virtues = { brave just honest }
Expand Down Expand Up @@ -700,6 +706,9 @@ burmic_religion = { # Folk religions of Burmese peoples
doctrine = doctrine_clerical_gender_female_only
doctrine = doctrine_clerical_marriage_disallowed
doctrine = doctrine_clerical_succession_spiritual_appointment

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

traits = {
virtues = { brave compassionate content diligent lifestyle_mystic } # IRToCK3: missing "transgender" trait excluded
Expand Down Expand Up @@ -1916,6 +1925,9 @@ anatolian_religion = {
doctrine = doctrine_clerical_gender_male_only
doctrine = doctrine_clerical_marriage_disallowed # They're eunuchs...
doctrine = doctrine_clerical_succession_temporal_appointment

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

traits = {
virtues = { just honest eunuch }
Expand Down Expand Up @@ -2148,6 +2160,9 @@ armenian_religion = {
doctrine = doctrine_clerical_gender_either
doctrine = doctrine_clerical_marriage_allowed
doctrine = doctrine_clerical_succession_temporal_appointment

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

traits = {
virtues = { brave just honest }
Expand Down Expand Up @@ -2386,6 +2401,9 @@ canaanite_religion = {
doctrine = doctrine_clerical_gender_either
doctrine = doctrine_clerical_marriage_allowed
doctrine = doctrine_clerical_succession_temporal_appointment

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

traits = {
virtues = { brave just honest }
Expand Down Expand Up @@ -2617,6 +2635,9 @@ caucasian_religion = {
doctrine = doctrine_clerical_gender_either
doctrine = doctrine_clerical_marriage_allowed
doctrine = doctrine_clerical_succession_temporal_appointment

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

traits = {
virtues = { brave just honest }
Expand Down Expand Up @@ -2854,6 +2875,9 @@ celtic_religion = {
doctrine = doctrine_clerical_gender_either
doctrine = doctrine_clerical_marriage_allowed
doctrine = doctrine_clerical_succession_temporal_appointment

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

traits = {
virtues = { brave just honest }
Expand Down Expand Up @@ -3780,6 +3804,9 @@ iberic_religion = {
doctrine = doctrine_clerical_gender_either
doctrine = doctrine_clerical_marriage_allowed
doctrine = doctrine_clerical_succession_temporal_appointment

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

traits = {
virtues = { brave just honest }
Expand Down Expand Up @@ -3983,6 +4010,9 @@ ajivika_religion = { # credits to Izn from Invictus team for listing the doctrin
family = rf_eastern
graphical_faith = dharmic_gfx
doctrine = eastern_hostility_doctrine

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

custom_faith_icons = { # copied from Hinduism
custom_faith_1 custom_faith_2 custom_faith_3 custom_faith_4 custom_faith_5 custom_faith_6 custom_faith_7 custom_faith_8 custom_faith_9 custom_faith_10 dualism_custom_1 zoroastrian_custom_1 zoroastrian_custom_2 buddhism_custom_1 buddhism_custom_2 buddhism_custom_3 buddhism_custom_4 taoism_custom_1 yazidi_custom_1 sunni_custom_2 sunni_custom_3 sunni_custom_4 muhakkima_1 muhakkima_2 muhakkima_4 muhakkima_5 muhakkima_6 judaism_custom_1 custom_faith_fp1_fenrir custom_faith_fp1_irminsul custom_faith_fp1_jormungandr custom_faith_fp1_odins_ravens custom_faith_fp1_runestone_moon custom_faith_fp1_thors_hammer custom_faith_fp1_valknut custom_faith_fp1_yggdrasil custom_faith_boromian_circles custom_faith_lotus custom_faith_aum_tibetan custom_faith_pentagram custom_faith_pentagram_inverted custom_faith_burning_bush custom_faith_allah custom_faith_gankyil custom_faith_eye_of_providence custom_faith_dove custom_faith_ichthys custom_faith_lamb custom_faith_black_sheep custom_faith_ankh custom_faith_chi_rho custom_faith_hamsa custom_faith_cool_s
Expand Down Expand Up @@ -4337,6 +4367,9 @@ mesopotamian_religion = {
doctrine = doctrine_clerical_gender_either
doctrine = doctrine_clerical_marriage_allowed
doctrine = doctrine_clerical_succession_temporal_appointment

# Pilgrimage
doctrine = doctrine_pilgrimage_mandatory # chat.deepseek.com: "The Babylonian nobility (awilu), as part of the upper class, were expected to participate in the Akitu festival, but their involvement was not enforced through legal penalties. Instead, their participation was driven by social and religious expectations"

traits = {
virtues = { brave just honest }
Expand Down Expand Up @@ -4568,6 +4601,9 @@ paleo_balkan_religion = {
doctrine = doctrine_clerical_gender_either
doctrine = doctrine_clerical_marriage_allowed
doctrine = doctrine_clerical_succession_temporal_appointment

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

traits = {
virtues = { brave just honest }
Expand Down Expand Up @@ -4912,6 +4948,9 @@ hurrian_religion_group = {
#Clerical Functions
doctrine = doctrine_clerical_gender_either
doctrine = doctrine_clerical_marriage_allowed

# Pilgrimage
doctrine = doctrine_pilgrimage_encouraged

traits = {
virtues = { brave just humble }
Expand Down
Loading

0 comments on commit e4e648c

Please sign in to comment.