-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make country rank conversion configurable through `configurables/coun…
…try_rank_map.txt` (#1834) #minor
- Loading branch information
1 parent
d17b4a3
commit 7ce613f
Showing
13 changed files
with
203 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
ImperatorToCK3.UnitTests/TestFiles/configurables/country_rank_map.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Some words specific to empires, kingdoms and duchies override the mappings based on rank. | ||
empire_keywords = { "empire" "imperium" } | ||
kingdom_keywords = { "kingdom" "regnum" } | ||
duchy_keywords = { "duchy" "principality" "dukedom" "ducatus" } | ||
|
||
# Every Imperator country rank should be mapped to CK3 title rank. | ||
# d - duchy, k - kingdom, e - empire | ||
# Mapping to county and barony level is not supported. | ||
|
||
# A mapping can contain optional required_territories field. | ||
# Use it if you want to base the CK3 rank on the number of owned I:R territories. | ||
|
||
# First matching mapping is used. | ||
|
||
link = { ir=migrant_horde ck3=d } | ||
link = { ir=city_power ck3=d } | ||
link = { ir=local_power ck3=k } | ||
link = { ir=regional_power ck3=k } | ||
link = { ir=major_power required_territories=300 ck3=e } | ||
link = { ir=major_power ck3=k } | ||
link = { ir=great_power ck3=e } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace ImperatorToCK3.CK3.Titles; | ||
|
||
public enum TitleRank { barony, county, duchy, kingdom, empire } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
|
||
namespace ImperatorToCK3.CK3.Titles; | ||
|
||
public static class TitleRankUtils { | ||
public static TitleRank CharToTitleRank(char c) { | ||
return c switch { | ||
'e' => TitleRank.empire, | ||
'k' => TitleRank.kingdom, | ||
'd' => TitleRank.duchy, | ||
'c' => TitleRank.county, | ||
'b' => TitleRank.barony, | ||
_ => throw new ArgumentOutOfRangeException(nameof(c)) | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
ImperatorToCK3/Data_Files/configurables/country_rank_map.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Some words specific to empires, kingdoms and duchies override the mappings based on rank. | ||
empire_keywords = { "empire" "imperium" } | ||
kingdom_keywords = { "kingdom" "regnum" } | ||
duchy_keywords = { "duchy" "principality" "dukedom" "ducatus" } | ||
|
||
# Every Imperator country rank should be mapped to CK3 title rank. | ||
# d - duchy, k - kingdom, e - empire | ||
# Mapping to county and barony level is not supported. | ||
|
||
# A mapping can contain optional required_territories field. | ||
# Use it if you want to base the CK3 rank on the number of owned I:R territories. | ||
|
||
# First matching mapping is used. | ||
|
||
link = { ir=migrant_horde ck3=d } | ||
link = { ir=city_power ck3=d } | ||
link = { ir=local_power ck3=k } | ||
link = { ir=regional_power ck3=k } | ||
link = { ir=major_power required_territories=300 ck3=e } | ||
link = { ir=major_power ck3=k } | ||
link = { ir=great_power ck3=e } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using commonItems; | ||
using ImperatorToCK3.CK3.Titles; | ||
|
||
namespace ImperatorToCK3.Mappers.TagTitle; | ||
|
||
public class RankMapping { | ||
public RankMapping(BufferedReader mappingReader) { | ||
var parser = new Parser(); | ||
parser.RegisterKeyword("ir", reader => irRank = reader.GetString()); | ||
parser.RegisterKeyword("required_territories", reader => requiredTerritories = reader.GetInt()); | ||
parser.RegisterKeyword("ck3", reader => ck3Rank = TitleRankUtils.CharToTitleRank(reader.GetChar())); | ||
parser.IgnoreAndLogUnregisteredItems(); | ||
parser.ParseStream(mappingReader); | ||
} | ||
|
||
public TitleRank? Match(string imperatorRank, int territoriesCount) { | ||
if (irRank is not null && imperatorRank != irRank) { | ||
return null; | ||
} | ||
|
||
if (requiredTerritories > 0 && territoriesCount < requiredTerritories) { | ||
return null; | ||
} | ||
|
||
return ck3Rank; | ||
} | ||
|
||
private string? irRank; | ||
private int requiredTerritories = 0; | ||
private TitleRank? ck3Rank; | ||
} |
Oops, something went wrong.