Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rajas of Asia support #2432

Merged
merged 171 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
6b769db
WIP TI->RoA province mappings
IhateTrains Aug 23, 2024
1c15323
TI province mapping fixes
IhateTrains Aug 23, 2024
1490716
More triangulation pairs
IhateTrains Aug 25, 2024
14fead1
Better province mappings from TI to RoA
IhateTrains Aug 29, 2024
9852e4e
Mapping for TI `confucian` religion
IhateTrains Aug 29, 2024
782df55
Some Terra Indomita to Rajas of Asia culture mappings
IhateTrains Aug 30, 2024
9c9b168
WIP TI->RoA culture mappings
IhateTrains Aug 31, 2024
5a4199c
tweak logging of unmapped I:R cultures
IhateTrains Aug 31, 2024
fad9fec
TI -> RoA culture mapping tweaks
IhateTrains Aug 31, 2024
24958b4
Mapping for chinese_unification_wargoal
IhateTrains Aug 31, 2024
5dd0b61
Mapping for japanese_clothes template
IhateTrains Aug 31, 2024
20b7bd7
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Aug 31, 2024
a545df5
Add fallback named colors for RoA
IhateTrains Aug 31, 2024
babbd33
WIP elamite_religion
IhateTrains Aug 31, 2024
4daa4ce
Adjust Elamite holy site locations for vanilla CK3 map
IhateTrains Aug 31, 2024
555b153
Add d_cult_of_humban from Bronze Age Reborn
IhateTrains Aug 31, 2024
6250a2a
Add mappings for Japanese hairstyles from TI
IhateTrains Aug 31, 2024
6942e8e
Fix history of d_cult_of_humban
IhateTrains Sep 1, 2024
b411d92
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Sep 2, 2024
4cfb3e1
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Sep 9, 2024
128d4b1
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Sep 16, 2024
a47cb0e
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Sep 16, 2024
6837c42
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Sep 16, 2024
7339430
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Sep 18, 2024
f4b4029
Post-merge cleanup
IhateTrains Sep 18, 2024
2494c6a
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Sep 22, 2024
8a6bcca
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Sep 24, 2024
5f5012e
Add TODO comments to dubious Han mappings
IhateTrains Sep 24, 2024
0022997
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Sep 26, 2024
d0df7e9
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Sep 27, 2024
9f7d95f
TI -> RoA mapping for bo and ba cultures
IhateTrains Sep 27, 2024
c373a64
TI -> RoA mapping for bekhyrian and syrbotian cultures
IhateTrains Sep 27, 2024
2867f43
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 9, 2024
460bd54
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 12, 2024
7690daa
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 14, 2024
9a53c45
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 18, 2024
b5af5fe
Don't add Updater to the dev builds
IhateTrains Oct 18, 2024
6ab4927
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 19, 2024
eea1c51
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 19, 2024
e249298
Tweak logging
IhateTrains Oct 19, 2024
a78edc8
Tweak dev build wf
IhateTrains Oct 19, 2024
98860af
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 20, 2024
369622e
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 20, 2024
ca10815
Update terra_indomita_to_rajas_of_asia.txt mappings
IhateTrains Oct 20, 2024
0333c7f
Add more info logging
IhateTrains Oct 20, 2024
75b1183
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 20, 2024
c8490ce
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 20, 2024
66c3b8a
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 20, 2024
c432f8b
Support some more CK3 character history keywords
IhateTrains Oct 20, 2024
6917ae7
Don't load CK3 characters in parallel, which could cause file order p…
IhateTrains Oct 20, 2024
6bd7c1a
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Oct 30, 2024
2859172
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Nov 4, 2024
8a8fdba
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Nov 5, 2024
ad39c7a
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Nov 5, 2024
7bb9f07
Update TI -> RoA province mappings
IhateTrains Nov 5, 2024
be1b3da
Update terra_indomita_to_rajas_of_asia.txt
IhateTrains Nov 7, 2024
d7a4e58
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Nov 10, 2024
5a84a9a
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Nov 10, 2024
ad43520
Rework the removal of unneeded file parts
IhateTrains Nov 10, 2024
7bc97f9
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Nov 21, 2024
fc45e9c
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Nov 28, 2024
4ba04a5
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Dec 2, 2024
5ca95b2
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Dec 8, 2024
a1a695a
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Dec 8, 2024
b8529fb
Update terra_indomita_to_rajas_of_asia.txt
IhateTrains Dec 9, 2024
4cc7078
Update terra_indomita_to_rajas_of_asia.txt
IhateTrains Dec 9, 2024
8439e4b
Update terra_indomita_to_rajas_of_asia.txt
IhateTrains Dec 9, 2024
2f6695a
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Dec 10, 2024
901b58c
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Dec 14, 2024
07f39ea
Fix the capitals of empire realms being moved when not needed
IhateTrains Dec 15, 2024
199aa6e
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Dec 16, 2024
4bf6f1a
Merge fix
IhateTrains Dec 16, 2024
11efc78
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Dec 28, 2024
c993c11
Create removable_file_blocks_roa.txt
IhateTrains Dec 29, 2024
e031566
Government mappings for RoA by tanner918
IhateTrains Dec 31, 2024
ce7997e
governorMappings.txt changes by tanner918
IhateTrains Dec 31, 2024
7ef6c30
TI -> RoA heritage mappings by tanner918
IhateTrains Dec 31, 2024
58f12a4
Tag->title mappings by tanner918
IhateTrains Dec 31, 2024
39c136f
TI unit type mappings by tanner918
IhateTrains Dec 31, 2024
26f2d38
TI death reason mappings by tanner918
IhateTrains Dec 31, 2024
b1d4ea7
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 3, 2025
3bcafab
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 3, 2025
1dd73e9
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 4, 2025
0b9bdd5
Remove some TI -> RoA tag mappings as recommended by tanner918
IhateTrains Jan 4, 2025
50b66ef
Give ZHO priority in mapping to e_celestia_china
IhateTrains Jan 4, 2025
a6c17d8
Use removable_file_blocks_roa.txt to FileTweaker
IhateTrains Jan 5, 2025
383762f
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 5, 2025
11b042f
Don't set subjects as de jure vassals when the static option is on
IhateTrains Jan 6, 2025
6a6dbd6
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 6, 2025
5fb5fec
Fix ck3HasRajasOfAsia variable having wrong value
IhateTrains Jan 7, 2025
0c47b98
RoA religion mappings by @tanner918
IhateTrains Jan 7, 2025
9fa7eea
Integrate removable parts of RoA by @tanner918
IhateTrains Jan 7, 2025
4e86b01
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 14, 2025
ca3301d
TI -> RoA culture mappings by @tanner918
IhateTrains Jan 15, 2025
20d1d0e
Add OutputCCULanguageParameters property to config, update comments
IhateTrains Jan 15, 2025
1eb522c
Support adding new language_group params in ccu_language_parameters.txt
IhateTrains Jan 15, 2025
8f0aba5
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 15, 2025
71b69dc
Fix exceptions
IhateTrains Jan 15, 2025
0487cef
Readd accidentally removed syriote culture mapping
IhateTrains Jan 15, 2025
701d255
Remove code duplication by adding the AddChildrenToNode method
IhateTrains Jan 15, 2025
4369b14
Fix outputting of CCU params not being aborted when expected
IhateTrains Jan 15, 2025
4823587
Extract ReadParamsIntoSet to reduce code duplication
IhateTrains Jan 16, 2025
549ca7a
Add and support the ccu_heritage_parameters.txt configurable
IhateTrains Jan 16, 2025
7e6ef81
Handle RoA names of CCU scripted effects
IhateTrains Jan 16, 2025
9ea2a37
Handle RoA not using language_branch params
IhateTrains Jan 16, 2025
4d47000
Fix heritage family and heritage group effect formats for RoA
IhateTrains Jan 16, 2025
bb030ee
Add warnings for pillars not having required CCU parameters
IhateTrains Jan 16, 2025
d7bd975
Replace FluentAssertions with AwesomeAssertions
IhateTrains Jan 16, 2025
e07588e
Make OutputCCUParameters true when TFE is enabled
IhateTrains Jan 16, 2025
98939f9
Fix false-positive warning about language params for WtWSMS
IhateTrains Jan 16, 2025
b221073
Support TFE format of ccu_scripted_effects.txt
IhateTrains Jan 17, 2025
eb266c9
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 17, 2025
04ac365
Update terra_indomita_to_rajas_of_asia.txt
IhateTrains Jan 17, 2025
509e112
Remove "autogenerated = yes" from modified province mappings
IhateTrains Jan 17, 2025
418e369
Prevent the Indomita Norway wasteland from converting to Vandilian
IhateTrains Jan 18, 2025
bfbfbbf
Remove Christian and Islamic syncretism tenets from all faiths
IhateTrains Jan 18, 2025
4ac978d
Buddhism mapping fixes (#2437)
tanner918 Jan 18, 2025
9f81818
Fix the converter creating Muslim county holders
IhateTrains Jan 18, 2025
7aabd62
Merge branch 'feature/rajas-of-asia-support' of https://github.com/Pa…
IhateTrains Jan 18, 2025
f2ac04a
Fix typo in religion_map.txt comments
IhateTrains Jan 18, 2025
7e05183
Prevent random Muslim characters being generated
IhateTrains Jan 18, 2025
b61a2b3
Prevent random Muslim characters being generated in RoA
IhateTrains Jan 18, 2025
66b5488
Prevent random Christian characters being generated in RoA
IhateTrains Jan 18, 2025
9dbcc03
Fix for GetCultureIdForGeneratedHeadOfFaith logic
IhateTrains Jan 18, 2025
02ba5d3
Make all animation_test_ characters die on 2.1.1
IhateTrains Jan 18, 2025
f0cec00
Don't generate religious heads for Christianity before 30 AD
IhateTrains Jan 18, 2025
8f36b8e
Prevent random Christian characters being generated in vanilla CK3
IhateTrains Jan 18, 2025
39a2768
[CodeFactor] Apply fixes
code-factor Jan 18, 2025
9576957
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 18, 2025
d63a07f
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 18, 2025
cc71113
Exclude c_faereyar from Eremitic handling when TI is detected
IhateTrains Jan 18, 2025
16c47f5
I'm stupid
IhateTrains Jan 18, 2025
4bfabb8
Relocalize `heritage_syriac` to "Chaldean"
IhateTrains Jan 19, 2025
18cca46
Fix cultural pillar parameters not being outputted
IhateTrains Jan 19, 2025
aa334a4
Move form_bosporan_kingdom_decision overwrite to replaceable_file_blocks
IhateTrains Jan 19, 2025
ff29662
CCU updates (#2443)
tanner918 Jan 19, 2025
7bd79d7
Handle replaceable_file_blocks_roa.txt
IhateTrains Jan 19, 2025
622c476
Roa ccu language fix (#2446)
tanner918 Jan 20, 2025
940fedc
Fix for governors not becoming administrative
IhateTrains Jan 20, 2025
6dca697
Merge branch 'feature/rajas-of-asia-support' of https://github.com/Pa…
IhateTrains Jan 20, 2025
1f4c970
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 20, 2025
489a089
Move ir=lalasian to mapping for ck3=cilician
IhateTrains Jan 20, 2025
d0f986d
Move pamphylian culture to Greek mappings
IhateTrains Jan 20, 2025
20ee5bf
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 20, 2025
1e3412d
Comment tweaks
IhateTrains Jan 20, 2025
8216eb9
Use appointment_succession_law for admin governors
IhateTrains Jan 20, 2025
b713452
Support Liquid syntax in succession_law_map
IhateTrains Jan 20, 2025
e75daa8
Support has_ck3_dlc parameter in succession law mappings
IhateTrains Jan 20, 2025
2a051e0
[CodeFactor] Apply fixes to commit e75daa8
code-factor Jan 20, 2025
c99e448
Support ir_government parameter in succession law mappings
IhateTrains Jan 20, 2025
4e3ee28
Merge branch 'feature/rajas-of-asia-support' of https://github.com/Pa…
IhateTrains Jan 20, 2025
3e3ddee
Support ck3_title_rank parameter in government mappings
IhateTrains Jan 20, 2025
6412969
Fix bookmark character name not being outputted
IhateTrains Jan 20, 2025
5c9786d
Fix tests
IhateTrains Jan 21, 2025
da36649
Setup succession laws (#2453)
tanner918 Jan 21, 2025
7ce8359
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 21, 2025
aa28cc4
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 21, 2025
75f700b
Changed yuezhi to map to tocharian (#2458)
tanner918 Jan 21, 2025
7b2add8
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 21, 2025
16d0575
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 21, 2025
0e6d715
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 22, 2025
6cf54e5
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 22, 2025
89e0960
Fix typo in marital_custom_male_only
IhateTrains Jan 22, 2025
a566fb8
tradition_seafarers -> tradition_seafaring
IhateTrains Jan 22, 2025
2ace7a6
Replace invalid tradition_beacon_of_learning entry
IhateTrains Jan 22, 2025
64fcc10
Remove problematic tradition_ep3_imperial_tagmata from Neo-Minoan
IhateTrains Jan 22, 2025
ce57de0
Formatting fixes
IhateTrains Jan 22, 2025
e8b6ead
Formatting and tradition fixes
IhateTrains Jan 22, 2025
cc0166d
Add mapping for Antiquitas greek_pantheon religion
IhateTrains Jan 22, 2025
5590e9e
Fix spelling issues reported by reviewdog
IhateTrains Jan 22, 2025
ac41843
Merge branch 'master' into feature/rajas-of-asia-support
IhateTrains Jan 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build_dev_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ jobs:
# global-json-file: global.json
- name: "Build backend"
working-directory: ImperatorToCK3
# Make sure it builds self-contained, because for the dev build we're not building the InnoSetup installer.
run: |
dotnet publish -p:PublishProfile=${{ matrix.build }} -c:Release --output:"../Publish/ImperatorToCK3"
dotnet publish -p:PublishProfile=${{ matrix.build }} -c:Release --output:"../Publish/ImperatorToCK3" -p:SelfContained=true
- name: Archive Publish folder
uses: thedoctor0/zip-release@master
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CultureCollectionTests {
private static readonly ModFilesystem ck3ModFS = new("TestFiles/CK3/game", Array.Empty<Mod>());
private static readonly PillarCollection pillars;
private static readonly ColorFactory colorFactory = new();
private static readonly OrderedDictionary<string, bool> ck3ModFlags = [];
private static readonly OrderedDictionary<string, bool> ck3ModFlags = new() {{"tfe", false}, {"wtwsms", false}, {"roa", false}};

static CultureCollectionTests() {
pillars = new PillarCollection(colorFactory, []) {
Expand Down Expand Up @@ -51,7 +51,7 @@ public void ConverterHeritageCanBeMergedIntoExistingHeritage() {
Assert.Single(cultures);

cultures.AddNameList(new NameList("name_list_albanian", new BufferedReader()));
cultures.LoadConverterPillars("TestFiles/CK3/CultureCollectionTests/configurables/converter_pillars");
cultures.LoadConverterPillars("TestFiles/CK3/CultureCollectionTests/configurables/converter_pillars", ck3ModFlags);
cultures.LoadConverterCultures("TestFiles/CK3/CultureCollectionTests/configurables/converter_cultures.txt");

Assert.Equal(2, cultures.Count);
Expand All @@ -71,7 +71,7 @@ public void ConverterLanguageCanBeMergedIntoExistingLanguage() {
cultures.AddPillar(new("language_illyrian", new() {Type = "language"}));

cultures.AddNameList(new NameList("name_list_albanian", new BufferedReader()));
cultures.LoadConverterPillars("TestFiles/CK3/CultureCollectionTests/configurables/converter_pillars");
cultures.LoadConverterPillars("TestFiles/CK3/CultureCollectionTests/configurables/converter_pillars", ck3ModFlags);
cultures.LoadConverterCultures("TestFiles/CK3/CultureCollectionTests/configurables/converter_cultures.txt");

Assert.Equal(2, cultures.Count);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using commonItems.Mods;
using ImperatorToCK3.CK3.Cultures;
using System;
using System.Collections.Generic;
using System.IO;
using Xunit;

Expand All @@ -18,13 +19,14 @@ public void WarningIsLoggedWhenPillarDataIsMissingType() {
var pillarsFile = File.CreateText("pillars_test/common/culture/pillars/test_pillars.txt");
pillarsFile.WriteLine("pillar_without_type = {}");
pillarsFile.Close();


OrderedDictionary<string, bool> ck3ModFlags = [];
var modFS = new ModFilesystem("pillars_test", Array.Empty<Mod>());
var collection = new PillarCollection(new commonItems.Colors.ColorFactory(), []);
var collection = new PillarCollection(new commonItems.Colors.ColorFactory(), ck3ModFlags);

var consoleOut = new StringWriter();
Console.SetOut(consoleOut);
collection.LoadPillars(modFS);
collection.LoadPillars(modFS, ck3ModFlags);
Assert.Contains("[WARN] Pillar pillar_without_type has no type defined! Skipping.", consoleOut.ToString());
}
}
2 changes: 1 addition & 1 deletion ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private class TitleBuilder {
"TestFiles/configurables/governorMappings.txt",
"TestFiles/configurables/country_rank_map.txt");
private GovernmentMapper governmentMapper = new(ck3GovernmentIds: Array.Empty<string>());
private SuccessionLawMapper successionLawMapper = new("TestFiles/configurables/succession_law_map.txt");
private SuccessionLawMapper successionLawMapper = new("TestFiles/configurables/succession_law_map.liquid", ck3ModFlags: []);
private DefiniteFormMapper definiteFormMapper = new("TestFiles/configurables/definite_form_names.txt");

private readonly ReligionMapper religionMapper;
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3.UnitTests/ImperatorToCK3.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AwesomeAssertions" Version="8.0.0-rc.3" />
<PackageReference Include="coverlet.msbuild" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="8.0.0-rc.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using commonItems;
using ImperatorToCK3.CK3.Titles;
using ImperatorToCK3.Mappers.Government;
using System.Collections.Generic;
using Xunit;
Expand All @@ -10,22 +11,22 @@ public class GovernmentMapperTests {
public void NonMatchGivesNull() {
var reader = new BufferedReader("link = { ck3 = ck3Government ir = irGovernment }");
var mapper = new GovernmentMapper(reader, ck3GovernmentIds: new List<string> { "ck3Government" });
var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("nonMatchingGovernment", null, []);
var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("nonMatchingGovernment", rank: null, irCultureId: 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<string> { "ck3Government" });
var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", null, []);
var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", rank: null, irCultureId: 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<string> { "ck3Government" });
var ck3Gov1 = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", null, []);
var ck3Gov2 = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment2", null, []);
var ck3Gov1 = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", rank: null, irCultureId: null, []);
var ck3Gov2 = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment2", rank: null, irCultureId: null, []);
Assert.Equal("ck3Government", ck3Gov1);
Assert.Equal("ck3Government", ck3Gov2);
}
Expand All @@ -36,7 +37,7 @@ public void CorrectRuleMatches() {
"link = { ck3 = ck3Government2 ir = irGovernment2 }"
);
var mapper = new GovernmentMapper(reader, ck3GovernmentIds: new List<string> { "ck3Government", "ck3Government2" });
var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment2", null, []);
var ck3Gov = mapper.GetCK3GovernmentForImperatorGovernment("irGovernment2", rank: null, irCultureId: null, []);
Assert.Equal("ck3Government2", ck3Gov);
}

Expand All @@ -48,10 +49,32 @@ public void CultureCanBeUsedToMatch() {
"link = { ck3 = govC ir = irGovernment }"
);
var mapper = new GovernmentMapper(reader, ck3GovernmentIds: new List<string> { "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", rank: null, "roman", []));
Assert.Equal("govB", mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", rank: null, "greek", []));
Assert.Equal("govC", mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", rank: null, "thracian", []));
Assert.Equal("govC", mapper.GetCK3GovernmentForImperatorGovernment("irGovernment", rank: null, irCultureId: null, []));
}

[Fact]
public void CK3TitleRankCanBeUsedToMatch() {
var reader = new BufferedReader(
"""
link = { ck3 = administrative_government ir = imperium ck3_title_rank = ke } # only for kingdoms and empires
link = { ck3 = feudal_government ir = imperium }
"""
);
var mapper = new GovernmentMapper(reader, ck3GovernmentIds: [ "administrative_government", "feudal_government" ]);

foreach (var rank in new List<TitleRank> { TitleRank.empire, TitleRank.kingdom }) {
Assert.Equal("administrative_government",
mapper.GetCK3GovernmentForImperatorGovernment(
irGovernmentId: "imperium", rank, irCultureId: null, enabledCK3Dlcs: []));
}
foreach (var rank in new List<TitleRank> { TitleRank.duchy, TitleRank.county, TitleRank.barony }) {
Assert.Equal("feudal_government",
mapper.GetCK3GovernmentForImperatorGovernment(
irGovernmentId: "imperium", rank, irCultureId: null, enabledCK3Dlcs: []));
}
}

[Fact]
Expand All @@ -70,7 +93,7 @@ public void CK3DlcCanBeUsedToMatch() {
""");
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: []));
Assert.Equal("administrative_government", mapper.GetCK3GovernmentForImperatorGovernment("imperium", rank: null, irCultureId: null, enabledCK3Dlcs: ["roads_to_power"]));
Assert.Equal("feudal_government", mapper.GetCK3GovernmentForImperatorGovernment("imperium", rank: null, irCultureId: null, enabledCK3Dlcs: []));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,25 @@ namespace ImperatorToCK3.UnitTests.Mappers.SuccessionLaw;
[Collection("Sequential")]
[CollectionDefinition("Sequential", DisableParallelization = true)]
public class SuccessionLawMapperTests {
private static readonly OrderedDictionary<string, bool> ck3ModFlags = [];
private static readonly string[] enabledCK3Dlcs = [];

[Fact]
public void NonMatchGivesEmptySet() {
var reader = new BufferedReader("link = { ir=implaw ck3 = ck3law }");
var mapper = new SuccessionLawMapper(reader);

var ck3Laws = mapper.GetCK3LawsForImperatorLaws(new SortedSet<string> { "madeUpLaw" });
var ck3Laws = mapper.GetCK3LawsForImperatorLaws(impLaws: ["madeUpLaw"], irGovernment: null, enabledCK3Dlcs);
Assert.Empty(ck3Laws);
}

[Fact]
public void Ck3LawCanBeFound() {
public void CK3LawCanBeFound() {
var reader = new BufferedReader("link = { ir=implaw ck3 = ck3law }");
var mapper = new SuccessionLawMapper(reader);

var ck3Laws = mapper.GetCK3LawsForImperatorLaws(new SortedSet<string> { "implaw" });
Assert.Equal(new SortedSet<string> { "ck3law" }, ck3Laws);
var ck3Laws = mapper.GetCK3LawsForImperatorLaws(impLaws: ["implaw"], irGovernment: null, enabledCK3Dlcs);
Assert.Equal(["ck3law"], ck3Laws);
}

[Fact]
Expand All @@ -42,28 +45,82 @@ public void LinkWithNoCK3LawResultsInWarning() {
[Fact]
public void MultipleLawsCanBeReturned() {
var reader = new BufferedReader(
"link = { ir=implaw ck3 = ck3law ck3 = ck3law2 }\n" +
"link = { ir=implaw ck3 = ck3law3 }\n" +
"link = { ir=implaw2 ck3 = ck3law4 }\n" +
"link = { ir=implaw3 ck3 = ck3law5 }\n"
"""
link = { ir=implaw ck3 = ck3law ck3 = ck3law2 }
link = { ir=implaw ck3 = ck3law3 } # Will not be used because the first link matches implaw
link = { ir=implaw2 ck3 = ck3law4 }
link = { ir=implaw3 ck3 = ck3law5 }
"""
);
var mapper = new SuccessionLawMapper(reader);

var ck3Laws = mapper.GetCK3LawsForImperatorLaws(new SortedSet<string> { "implaw", "implaw3" });
var expectedReturnedLaws = new SortedSet<string> { "ck3law", "ck3law2", "ck3law3", "ck3law5" };
var ck3Laws = mapper.GetCK3LawsForImperatorLaws(impLaws: ["implaw", "implaw3"], irGovernment: null, enabledCK3Dlcs);
var expectedReturnedLaws = new SortedSet<string> { "ck3law", "ck3law2", "ck3law5" };
Assert.Equal(expectedReturnedLaws, ck3Laws);
}

[Fact]
public void EnabledCK3DlcsCanBeUsedInMappings() {
var reader = new BufferedReader(
"""
link = { ir=implaw ck3=ck3lawForDLC has_ck3_dlc=roads_to_power }
link = { ir=implaw ck3=ck3law }
"""
);
var mapper = new SuccessionLawMapper(reader);

var ck3LawsWithDlc = mapper.GetCK3LawsForImperatorLaws(
impLaws: ["implaw"],
irGovernment: null,
enabledCK3Dlcs:["roads_to_power"]);
Assert.Equal(["ck3lawForDLC"], ck3LawsWithDlc);

var ck3LawsWithoutDlc = mapper.GetCK3LawsForImperatorLaws(
impLaws: ["implaw"],
irGovernment: null,
enabledCK3Dlcs: []);
Assert.Equal(["ck3law"], ck3LawsWithoutDlc);
}

[Fact]
public void ImperatorGovernmentCanBeUsedInMappings() {
var reader = new BufferedReader(
"""
link = { ir=implaw ck3=ck3law1 ir_government=imperium ir_government=imperial_cult }
link = { ir=implaw ck3=ck3law2 }
"""
);
var mapper = new SuccessionLawMapper(reader);

var ck3LawsWithImperialGov = mapper.GetCK3LawsForImperatorLaws(
impLaws: ["implaw"],
irGovernment: "imperium",
enabledCK3Dlcs: enabledCK3Dlcs);
Assert.Equal(["ck3law1"], ck3LawsWithImperialGov);

var ck3LawsWithoutImperialGov = mapper.GetCK3LawsForImperatorLaws(
impLaws: ["implaw"],
irGovernment: "imperial_cult",
enabledCK3Dlcs: enabledCK3Dlcs);
Assert.Equal(["ck3law1"], ck3LawsWithoutImperialGov);

var ck3LawsWithoutImperatorGov = mapper.GetCK3LawsForImperatorLaws(
impLaws: ["implaw"],
irGovernment: "madeUpGov",
enabledCK3Dlcs: enabledCK3Dlcs);
Assert.Equal(["ck3law2"], ck3LawsWithoutImperatorGov);
}

[Fact]
public void MappingsAreReadFromFile() {
var mapper = new SuccessionLawMapper("TestFiles/configurables/succession_law_map.txt");
var mapper = new SuccessionLawMapper("TestFiles/configurables/succession_law_map.liquid", ck3ModFlags);
Assert.Equal(
new SortedSet<string> { "ck3law1", "ck3law2" },
mapper.GetCK3LawsForImperatorLaws(new() { "implaw1" })
["ck3law1", "ck3law2"],
mapper.GetCK3LawsForImperatorLaws(impLaws: ["implaw1"], irGovernment: null, enabledCK3Dlcs)
);
Assert.Equal(
new SortedSet<string> { "ck3law3" },
mapper.GetCK3LawsForImperatorLaws(new() { "implaw2" })
["ck3law3"],
mapper.GetCK3LawsForImperatorLaws(impLaws: ["implaw2"], irGovernment: null, enabledCK3Dlcs)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace ImperatorToCK3.UnitTests.TestHelpers;
private static readonly ColorFactory colorFactory = new();
private static readonly OrderedDictionary<string, bool> ck3ModFlags = [];

public void LoadConverterPillars(string filePath) {
PillarCollection.LoadConverterPillars(filePath);
public void LoadConverterPillars(string filePath, OrderedDictionary<string, bool> ck3ModFlags) {
PillarCollection.LoadConverterPillars(filePath, ck3ModFlags);
}

public void AddNameList(NameList nameList) {
Expand Down
1 change: 1 addition & 0 deletions ImperatorToCK3.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=pontifex/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Provs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Qahtanite/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=rajas/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=rakaly/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=rankless/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Rechtabra/@EntryIndexedValue">True</s:Boolean>
Expand Down
4 changes: 4 additions & 0 deletions ImperatorToCK3/CK3/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@
.WithLiteralField("if", "if")
.WithSimpleField("sexuality", "sexuality", null)
.WithLiteralField("domicile", "domicile")
.WithLiteralField("create_maa_regiment", "create_maa_regiment")
.WithSimpleField("add_gold", "add_gold", null)
.WithSimpleField("add_piety_level", "add_piety_level", null)
.WithSimpleField("add_prestige_level", "add_prestige_level", null)
.Build();

public History History { get; } = historyFactory.GetHistory();
Expand Down Expand Up @@ -355,174 +359,174 @@
}
}

internal Character(
Imperator.Characters.Character impCharacter,
CharacterCollection characters,
ReligionMapper religionMapper,
CultureMapper cultureMapper,
TraitMapper traitMapper,
NicknameMapper nicknameMapper,
LocDB irLocDB,
CK3LocDB ck3LocDB,
MapData irMapData,
ProvinceMapper provinceMapper, // used to determine ck3 province for religion mapper
DeathReasonMapper deathReasonMapper,
DNAFactory dnaFactory,
Date dateOnConversion,
Configuration config,
ISet<string> unlocalizedImperatorNames
) {
this.characters = characters;

ImperatorCharacter = impCharacter;
ImperatorCharacter.CK3Character = this;
Id = "imperator" + ImperatorCharacter.Id;
FromImperator = true;

if (!string.IsNullOrEmpty(ImperatorCharacter.CustomName)) {
var loc = ImperatorCharacter.CustomName;
var locKey = CommonFunctions.NormalizeUTF8Path(loc.FoldToASCII().Replace(' ', '_'));
var name = $"IRTOCK3_CUSTOM_NAME_{locKey}";
SetName(name, null);

var ck3NameLocBlock = ck3LocDB.GetOrCreateLocBlock(name);
foreach (var language in ConverterGlobals.SupportedLanguages) {
ck3NameLocBlock[language] = loc;
}
} else {
var nameLoc = ImperatorCharacter.Name;
var name = nameLoc.Replace(' ', '_');
SetName(name, null);
if (!string.IsNullOrEmpty(name)) {
var ck3NameLocBlock = ck3LocDB.GetOrCreateLocBlock(name);
var matchedLocBlock = irLocDB.GetLocBlockForKey(name);
if (matchedLocBlock is not null) {
ck3NameLocBlock.CopyFrom(matchedLocBlock);
} else { // fallback: use unlocalized name as displayed name
unlocalizedImperatorNames.Add(name);
ck3NameLocBlock[ConverterGlobals.PrimaryLanguage] = nameLoc;
}
}
}

Female = ImperatorCharacter.Female;

// Determine valid (not dropped in province mappings) "source I:R province" and "source CK3 province"
// to be used by religion mapper. Don't give up without a fight.
ulong? irProvinceId = ImperatorCharacter.GetSourceLandProvince(irMapData);

var impProvForProvinceMapper = irProvinceId;
if ((!impProvForProvinceMapper.HasValue || provinceMapper.GetCK3ProvinceNumbers(impProvForProvinceMapper.Value).Count == 0) && ImperatorCharacter.Father is not null) {
impProvForProvinceMapper = ImperatorCharacter.Father.ProvinceId;
}
if ((!impProvForProvinceMapper.HasValue || provinceMapper.GetCK3ProvinceNumbers(impProvForProvinceMapper.Value).Count == 0) && ImperatorCharacter.Mother is not null) {
impProvForProvinceMapper = ImperatorCharacter.Mother.ProvinceId;
}
if ((!impProvForProvinceMapper.HasValue || provinceMapper.GetCK3ProvinceNumbers(impProvForProvinceMapper.Value).Count == 0) && ImperatorCharacter.Spouses.Count > 0) {
var firstSpouse = ImperatorCharacter.Spouses.First().Value;
impProvForProvinceMapper = firstSpouse.ProvinceId;
}

var ck3ProvinceNumbers = impProvForProvinceMapper.HasValue ? provinceMapper.GetCK3ProvinceNumbers(impProvForProvinceMapper.Value) : [];
ulong? ck3ProvinceId = ck3ProvinceNumbers.Count > 0 ? ck3ProvinceNumbers[0] : null;

var cultureMatch = cultureMapper.Match(
ImperatorCharacter.Culture,
ck3ProvinceId,
irProvinceId,
ImperatorCharacter.Country?.HistoricalTag
);
if (cultureMatch is null) {
Logger.Warn($"Could not determine CK3 culture for Imperator character {ImperatorCharacter.Id}" +
$" with culture {ImperatorCharacter.Culture}!");
} else {
SetCultureId(cultureMatch, null);
}

var faithMatch = religionMapper.Match(
ImperatorCharacter.Religion,
GetCultureId(dateOnConversion),
ck3ProvinceId,
irProvinceId,
ImperatorCharacter.HomeCountry?.HistoricalTag,
config
);
if (faithMatch is not null) {
SetFaithId(faithMatch, null);
}

// Determine character attributes.
History.AddFieldValue(null, "diplomacy", "diplomacy", ImperatorCharacter.Attributes.Charisma);
History.AddFieldValue(null, "martial", "martial", ImperatorCharacter.Attributes.Martial);
History.AddFieldValue(null, "stewardship", "stewardship", ImperatorCharacter.Attributes.Finesse);
var intrigue = (ImperatorCharacter.Attributes.Finesse + ImperatorCharacter.Attributes.Charisma) / 2;
History.AddFieldValue(null, "intrigue", "intrigue", intrigue);
History.AddFieldValue(null, "learning", "learning", ImperatorCharacter.Attributes.Zeal);

if (impCharacter.Fertility.HasValue) {
History.AddFieldValue(null, "fertility", "fertility", impCharacter.Fertility.Value);
}

if (impCharacter.Health is not null) {
// In I:R, health is a value between 0 and 100, with 100 being the best.
// In CK3, 0 means near death, ≥ 7 means excellent health.
// https://imperator.paradoxwikis.com/Characters#Secondary
// https://ck3.paradoxwikis.com/Attributes#Health
var ck3Health = impCharacter.Health.Value / 10;
History.AddFieldValue(null, "health", "health", ck3Health);
}

foreach (var traitId in traitMapper.GetCK3TraitsForImperatorTraits(ImperatorCharacter.Traits)) {
AddBaseTrait(traitId);
}

BirthDate = ImperatorCharacter.BirthDate;
DeathDate = ImperatorCharacter.DeathDate;
var impDeathReason = ImperatorCharacter.DeathReason;
if (impDeathReason is not null) {
DeathReason = deathReasonMapper.GetCK3ReasonForImperatorReason(impDeathReason);
}

var nicknameMatch = nicknameMapper.GetCK3NicknameForImperatorNickname(ImperatorCharacter.Nickname);
if (nicknameMatch is not null) {
var nicknameDate = ImperatorCharacter.DeathDate ?? dateOnConversion;
SetNickname(nicknameMatch, nicknameDate);
}

if (ImperatorCharacter.Wealth != 0) {
Gold = ImperatorCharacter.Wealth * config.ImperatorCurrencyRate;
}

// If character is imprisoned, set jailor.
SetJailor();
SetEmployerFromImperator();

void SetJailor() {
if (ImperatorCharacter.PrisonerHome is null) {
return;
}

var prisonCountry = ImperatorCharacter.Country;
if (prisonCountry is null) {
Logger.Warn($"Imperator character {ImperatorCharacter.Id} is imprisoned but has no country!");
} else if (prisonCountry.CK3Title is null) {
Logger.Debug($"Imperator character {ImperatorCharacter.Id}'s prison country does not exist in CK3!");
} else {
jailorId = prisonCountry.CK3Title.GetHolderId(dateOnConversion);
}
}

void SetEmployerFromImperator() {
var prisonerHome = ImperatorCharacter.PrisonerHome;
var homeCountry = ImperatorCharacter.HomeCountry;
if (prisonerHome?.CK3Title is not null) { // is imprisoned
SetEmployerId(prisonerHome.CK3Title.GetHolderId(dateOnConversion), null);
} else if (homeCountry?.CK3Title is not null) {
SetEmployerId(homeCountry.CK3Title.GetHolderId(dateOnConversion), null);
}
}
}

Check notice on line 529 in ImperatorToCK3/CK3/Characters/Character.cs

View check run for this annotation

codefactor.io / CodeFactor

ImperatorToCK3/CK3/Characters/Character.cs#L362-L529

Complex Method
public void SetCultureId(string cultureId, Date? date) {
History.AddFieldValue(date, "culture", "culture", cultureId);
}
Expand Down
15 changes: 14 additions & 1 deletion ImperatorToCK3/CK3/Characters/CharactersLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ public void LoadCK3Characters(ModFilesystem ck3ModFS, Date bookmarkDate) {
loadedCharacters.Add(character);
});
parser.IgnoreAndLogUnregisteredItems();
parser.ParseGameFolder("history/characters", ck3ModFS, "txt", recursive: true, parallel: true);
parser.ParseGameFolder("history/characters", ck3ModFS, "txt", recursive: true);

// Make all animation_test_ characters die on 2.1.1.
foreach (var character in loadedCharacters) {
if (!character.Id.StartsWith("animation_test_")) {
continue;
}

var deathField = character.History.Fields["death"];
deathField.RemoveAllEntries();
deathField.AddEntryToHistory(new Date(2, 1, 1), "death", value: true);
}

string[] irrelevantEffects = ["set_relation_rival", "set_relation_potential_rival", "set_relation_nemesis",
"set_relation_lover", "set_relation_soulmate",
Expand Down Expand Up @@ -86,6 +97,8 @@ public void LoadCK3Characters(ModFilesystem ck3ModFS, Date bookmarkDate) {
character.InitConcubinesCache();
character.UpdateChildrenCacheOfParents();
}

Logger.Info("Loaded CK3 characters.");
}

private static void RemoveInvalidMotherAndFatherEntries(Character character, HashSet<string> femaleCharacterIds, HashSet<string> maleCharacterIds) {
Expand Down
7 changes: 7 additions & 0 deletions ImperatorToCK3/CK3/Cultures/Pillar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ internal sealed class Pillar : IIdentifiable<string>, IPDXSerializable {
public string Id { get; }
public string Type { get; }
public Color? Color { get; }
private readonly Dictionary<string, string> parameters;
public IReadOnlyDictionary<string, string> Parameters => parameters;
private readonly List<KeyValuePair<string, StringOfItem>> attributes;
public IReadOnlyCollection<KeyValuePair<string, StringOfItem>> Attributes => attributes;

Expand All @@ -19,6 +21,7 @@ public Pillar(string id, PillarData pillarData) {

Type = pillarData.Type!;
Color = pillarData.Color;
parameters = new(pillarData.Parameters);
attributes = new List<KeyValuePair<string, StringOfItem>>(pillarData.Attributes);
}

Expand All @@ -37,6 +40,10 @@ public string Serialize(string indent, bool withBraces) {
if (Color is not null) {
sb.Append(contentIndent).AppendLine($"color={Color}");
}
if (parameters.Count > 0) {
sb.Append(contentIndent).Append("parameters=")
.AppendLine(PDXSerializer.Serialize(parameters, indent: contentIndent, withBraces: true));
}
sb.AppendLine(PDXSerializer.Serialize(Attributes, indent: contentIndent, withBraces: false));

if (withBraces) {
Expand Down
Loading
Loading