diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7a796e5bd..d213ccc19 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,6 +13,11 @@ updates: schedule: interval: "weekly" + - package-ecosystem: "dotnet-sdk" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "github-actions" # Workflow files stored in the # default location of `.github/workflows` diff --git a/Fronter.NET b/Fronter.NET index 2a69dd89f..709e908c9 160000 --- a/Fronter.NET +++ b/Fronter.NET @@ -1 +1 @@ -Subproject commit 2a69dd89fe480965fbbee49feb470a84750b8806 +Subproject commit 709e908c97d0f6fbf59d36fe2bb304c3cb786c96 diff --git a/ImperatorToCK3.UnitTests/CK3/Cultures/NameListTests.cs b/ImperatorToCK3.UnitTests/CK3/Cultures/NameListTests.cs new file mode 100644 index 000000000..4dc3edfbc --- /dev/null +++ b/ImperatorToCK3.UnitTests/CK3/Cultures/NameListTests.cs @@ -0,0 +1,38 @@ +using commonItems; +using Xunit; + +namespace ImperatorToCK3.UnitTests.CK3.Cultures; + +public class NameListTests { + [Fact] + public void NameListIsCorrectlyLoaded() { + var reader = new BufferedReader(""" + { + male_names = { + John + "Alexander" + 2 = { Tom "Mark" } + } + female_names = { + Jane + "Alexandra" + 2 = { Sandra "Maria" } + } + """); + var nameList = new ImperatorToCK3.CK3.Cultures.NameList("test", reader); + + Assert.Equal("test", nameList.Id); + Assert.Collection(nameList.MaleNames, + item => Assert.Equal("John", item), + item => Assert.Equal("Alexander", item), + item => Assert.Equal("Tom", item), + item => Assert.Equal("Mark", item) + ); + Assert.Collection(nameList.FemaleNames, + item => Assert.Equal("Jane", item), + item => Assert.Equal("Alexandra", item), + item => Assert.Equal("Sandra", item), + item => Assert.Equal("Maria", item) + ); + } +} \ No newline at end of file diff --git a/ImperatorToCK3.UnitTests/Imperator/Diplomacy/DiplomacyDBTests.cs b/ImperatorToCK3.UnitTests/Imperator/Diplomacy/DiplomacyDBTests.cs new file mode 100644 index 000000000..b475874fc --- /dev/null +++ b/ImperatorToCK3.UnitTests/Imperator/Diplomacy/DiplomacyDBTests.cs @@ -0,0 +1,102 @@ +using commonItems; +using System; +using System.IO; +using Xunit; + +namespace ImperatorToCK3.UnitTests.Imperator.Diplomacy; + +[Collection("Sequential")] +[CollectionDefinition("Sequential", DisableParallelization = true)] +public class DiplomacyDBTests { + [Fact] + public void WarWithNoAttackersIsSkipped() { + var output = new StringWriter(); + Console.SetOut(output); + + var reader = new BufferedReader(""" + database = { + 1 = { previous=no } + 2 = { previous=no defender=1 } + } + """); + var diplomacy = new ImperatorToCK3.Imperator.Diplomacy.DiplomacyDB(reader); + + Assert.Empty(diplomacy.Wars); + var logStr = output.ToString(); + Assert.Contains("[DEBUG] Skipping war 1 has no attackers!", logStr); + Assert.Contains("[DEBUG] Skipping war 2 has no attackers!", logStr); + } + + [Fact] + public void WarWithNoDefendersIsSkipped() { + var output = new StringWriter(); + Console.SetOut(output); + + var reader = new BufferedReader(""" + database = { + 1 = { previous=no attacker=1 } + } + """); + var diplomacy = new ImperatorToCK3.Imperator.Diplomacy.DiplomacyDB(reader); + + Assert.Empty(diplomacy.Wars); + var logStr = output.ToString(); + Assert.Contains("[DEBUG] Skipping war 1 has no defenders!", logStr); + } + + [Fact] + public void WarWithNoWarGoalIsSkipped() { + var output = new StringWriter(); + Console.SetOut(output); + + var reader = new BufferedReader(""" + database = { + 1 = { previous=no attacker=1 defender=2 } + } + """); + var diplomacy = new ImperatorToCK3.Imperator.Diplomacy.DiplomacyDB(reader); + + Assert.Empty(diplomacy.Wars); + var logStr = output.ToString(); + Assert.Contains("[WARN] Skipping war 1 with no wargoal!", logStr); + } + + [Fact] + public void PreviousWarsAreSkipped() { + var reader = new BufferedReader("database = { 1 = { previous=yes } }"); + var diplomacy = new ImperatorToCK3.Imperator.Diplomacy.DiplomacyDB(reader); + + Assert.Empty(diplomacy.Wars); + } + + [Fact] + public void WarCanBeLoaded() { + var reader = new BufferedReader(""" + database = { + 1 = { + attacker=1 defender=2 start_date=1.1.1 take_province={ type="conquer_wargoal" state=3 } + } + } + """); + var diplomacy = new ImperatorToCK3.Imperator.Diplomacy.DiplomacyDB(reader); + + Assert.Single(diplomacy.Wars); + Assert.Equal(new Date("1.1.1", AUC: true), diplomacy.Wars[0].StartDate); + Assert.Equal((ulong)1, diplomacy.Wars[0].AttackerCountryIds[0]); + Assert.Equal((ulong)2, diplomacy.Wars[0].DefenderCountryIds[0]); + Assert.Equal("conquer_wargoal", diplomacy.Wars[0].WarGoal); + Assert.Equal((ulong)3, diplomacy.Wars[0].TargetedStateId); + } + + [Fact] + public void DependencyCanBeLoaded() { + var reader = new BufferedReader("dependency = { first=1 second=2 start_date=1.1.1 subject_type=tributary }"); + var diplomacy = new ImperatorToCK3.Imperator.Diplomacy.DiplomacyDB(reader); + + Assert.Single(diplomacy.Dependencies); + Assert.Equal((ulong)1, diplomacy.Dependencies[0].OverlordId); + Assert.Equal((ulong)2, diplomacy.Dependencies[0].SubjectId); + Assert.Equal(new Date("1.1.1", AUC: true), diplomacy.Dependencies[0].StartDate); + Assert.Equal("tributary", diplomacy.Dependencies[0].SubjectType); + } +} \ No newline at end of file diff --git a/ImperatorToCK3.UnitTests/Imperator/Diplomacy/DiplomacyTests.cs b/ImperatorToCK3.UnitTests/Imperator/Diplomacy/DiplomacyTests.cs deleted file mode 100644 index 9acf888de..000000000 --- a/ImperatorToCK3.UnitTests/Imperator/Diplomacy/DiplomacyTests.cs +++ /dev/null @@ -1,31 +0,0 @@ -using commonItems; -using System; -using System.IO; -using Xunit; - -namespace ImperatorToCK3.UnitTests.Imperator.Diplomacy; - -[Collection("Sequential")] -[CollectionDefinition("Sequential", DisableParallelization = true)] -public class DiplomacyTests { - [Fact] - public void WarWithNoDefendersIsSkipped() { - var output = new StringWriter(); - Console.SetOut(output); - - var reader = new BufferedReader(""" - database = { - 1 = { previous=no } - 2 = { previous=no attacker=1 } - 3 = { previous=no defender=1 } - } - """); - var diplomacy = new ImperatorToCK3.Imperator.Diplomacy.DiplomacyDB(reader); - - Assert.Empty(diplomacy.Wars); - var logStr = output.ToString(); - Assert.Contains("[DEBUG] Skipping war 1 has no attackers!", logStr); - Assert.Contains("[DEBUG] Skipping war 2 has no defenders!", logStr); - Assert.Contains("[DEBUG] Skipping war 3 has no attackers!", logStr); - } -} \ No newline at end of file diff --git a/ImperatorToCK3.UnitTests/ImperatorToCK3.UnitTests.csproj b/ImperatorToCK3.UnitTests/ImperatorToCK3.UnitTests.csproj index e12304355..3d48c7542 100644 --- a/ImperatorToCK3.UnitTests/ImperatorToCK3.UnitTests.csproj +++ b/ImperatorToCK3.UnitTests/ImperatorToCK3.UnitTests.csproj @@ -17,7 +17,7 @@ all - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ImperatorToCK3/CK3/Cultures/NameList.cs b/ImperatorToCK3/CK3/Cultures/NameList.cs index 5858fc71f..8a753c61f 100644 --- a/ImperatorToCK3/CK3/Cultures/NameList.cs +++ b/ImperatorToCK3/CK3/Cultures/NameList.cs @@ -1,17 +1,16 @@ using commonItems; using commonItems.Collections; using System.Collections.Generic; -using System.Collections.Immutable; using System.Text.RegularExpressions; namespace ImperatorToCK3.CK3.Cultures; public sealed partial class NameList : IIdentifiable { public string Id { get; } - private readonly OrderedSet maleNames = new(); - private readonly OrderedSet femaleNames = new(); - public IReadOnlyCollection MaleNames => maleNames.ToImmutableList(); - public IReadOnlyCollection FemaleNames => femaleNames.ToImmutableList(); + private readonly OrderedSet maleNames = []; + private readonly OrderedSet femaleNames = []; + public IReadOnlyCollection MaleNames => maleNames; + public IReadOnlyCollection FemaleNames => femaleNames; public NameList(string id, BufferedReader nameListReader) { Id = id; @@ -25,8 +24,8 @@ public NameList(string id, BufferedReader nameListReader) { maleNamesBlockParser.RegisterRegex(CommonRegexes.String, (_, nameStr) => { maleNames.Add(nameStr); }); - maleNamesBlockParser.RegisterRegex(CommonRegexes.QuotedString, (_, nameStr) => { - maleNames.Add(nameStr); + maleNamesBlockParser.RegisterRegex(CommonRegexes.QuotedString, (_, quotedNameStr) => { + maleNames.Add(quotedNameStr.RemQuotes()); }); maleNamesBlockParser.IgnoreAndLogUnregisteredItems(); maleNamesBlockParser.ParseStream(maleNamesReader); @@ -39,8 +38,8 @@ public NameList(string id, BufferedReader nameListReader) { femaleNamesBlockParser.RegisterRegex(CommonRegexes.String, (_, nameStr) => { femaleNames.Add(nameStr); }); - femaleNamesBlockParser.RegisterRegex(CommonRegexes.QuotedString, (_, nameStr) => { - femaleNames.Add(nameStr); + femaleNamesBlockParser.RegisterRegex(CommonRegexes.QuotedString, (_, quotedNameStr) => { + femaleNames.Add(quotedNameStr.RemQuotes()); }); femaleNamesBlockParser.IgnoreAndLogUnregisteredItems(); femaleNamesBlockParser.ParseStream(reader); diff --git a/ImperatorToCK3/Helpers/RakalyCaller.cs b/ImperatorToCK3/Helpers/RakalyCaller.cs index 4bc27ad9f..7db566149 100644 --- a/ImperatorToCK3/Helpers/RakalyCaller.cs +++ b/ImperatorToCK3/Helpers/RakalyCaller.cs @@ -10,7 +10,7 @@ namespace ImperatorToCK3.Helpers; public static class RakalyCaller { - private const string RakalyVersion = "0.5.3"; + private const string RakalyVersion = "0.5.4"; private static readonly string RelativeRakalyPath; static RakalyCaller() { diff --git a/ImperatorToCK3/Imperator/Diplomacy/DiplomacyDB.cs b/ImperatorToCK3/Imperator/Diplomacy/DiplomacyDB.cs index 9effadd91..159988479 100644 --- a/ImperatorToCK3/Imperator/Diplomacy/DiplomacyDB.cs +++ b/ImperatorToCK3/Imperator/Diplomacy/DiplomacyDB.cs @@ -79,6 +79,6 @@ private void LoadDependency(BufferedReader dependencyReader) { dependencies.Add(new(overlordId, subjectId, startDate, subjectType)); } - private readonly IgnoredKeywordsSet ignoredTokens = new(); + private readonly IgnoredKeywordsSet ignoredTokens = []; private readonly IgnoredKeywordsSet ignoredDatabaseTokens = new(); } \ No newline at end of file diff --git a/ImperatorToCK3/ImperatorToCK3.csproj b/ImperatorToCK3/ImperatorToCK3.csproj index 4eff25cd3..cafda7cf9 100644 --- a/ImperatorToCK3/ImperatorToCK3.csproj +++ b/ImperatorToCK3/ImperatorToCK3.csproj @@ -35,21 +35,21 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/ImperatorToCK3/Resources/rakaly/rakaly-0.5.3-aarch64-apple-darwin/rakaly b/ImperatorToCK3/Resources/rakaly/rakaly-0.5.4-aarch64-apple-darwin/rakaly similarity index 58% rename from ImperatorToCK3/Resources/rakaly/rakaly-0.5.3-aarch64-apple-darwin/rakaly rename to ImperatorToCK3/Resources/rakaly/rakaly-0.5.4-aarch64-apple-darwin/rakaly index 224e61eb7..d5d3d6cef 100644 Binary files a/ImperatorToCK3/Resources/rakaly/rakaly-0.5.3-aarch64-apple-darwin/rakaly and b/ImperatorToCK3/Resources/rakaly/rakaly-0.5.4-aarch64-apple-darwin/rakaly differ diff --git a/ImperatorToCK3/Resources/rakaly/rakaly-0.5.3-x86_64-pc-windows-msvc/rakaly.exe b/ImperatorToCK3/Resources/rakaly/rakaly-0.5.4-x86_64-pc-windows-msvc/rakaly.exe similarity index 57% rename from ImperatorToCK3/Resources/rakaly/rakaly-0.5.3-x86_64-pc-windows-msvc/rakaly.exe rename to ImperatorToCK3/Resources/rakaly/rakaly-0.5.4-x86_64-pc-windows-msvc/rakaly.exe index f1974a6c1..ef71230f6 100644 Binary files a/ImperatorToCK3/Resources/rakaly/rakaly-0.5.3-x86_64-pc-windows-msvc/rakaly.exe and b/ImperatorToCK3/Resources/rakaly/rakaly-0.5.4-x86_64-pc-windows-msvc/rakaly.exe differ diff --git a/ImperatorToCK3/Resources/rakaly/rakaly-0.5.3-x86_64-unknown-linux-musl/rakaly b/ImperatorToCK3/Resources/rakaly/rakaly-0.5.4-x86_64-unknown-linux-musl/rakaly similarity index 57% rename from ImperatorToCK3/Resources/rakaly/rakaly-0.5.3-x86_64-unknown-linux-musl/rakaly rename to ImperatorToCK3/Resources/rakaly/rakaly-0.5.4-x86_64-unknown-linux-musl/rakaly index 42875fd1e..ffb87efec 100644 Binary files a/ImperatorToCK3/Resources/rakaly/rakaly-0.5.3-x86_64-unknown-linux-musl/rakaly and b/ImperatorToCK3/Resources/rakaly/rakaly-0.5.4-x86_64-unknown-linux-musl/rakaly differ diff --git a/InnoDependencyInstaller b/InnoDependencyInstaller index 79f64dee4..0c7655462 160000 --- a/InnoDependencyInstaller +++ b/InnoDependencyInstaller @@ -1 +1 @@ -Subproject commit 79f64dee4ce01b045a4fbcee6695e87c3dba9818 +Subproject commit 0c7655462dc99f8f63c30c78db13c5af1482d19b diff --git a/global.json b/global.json index 1ca30c7e2..e2cedb46b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.100-rc.2.24474.11", + "version": "9.0.100", "allowPrerelease": true, "rollForward": "disable" }