diff --git a/.github/workflows/Publish.yml b/.github/workflows/Publish.yml index e2130f17..f0505d0f 100644 --- a/.github/workflows/Publish.yml +++ b/.github/workflows/Publish.yml @@ -22,7 +22,7 @@ jobs: mod_description: ${{ steps.changelog.outputs.mod_description }} steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup .NET Core uses: actions/setup-dotnet@master @@ -31,15 +31,26 @@ jobs: - name: Build Diplomacy Module run: | - $impl = $PWD.Path + '/bannerlord-implementations'; $path = $PWD.Path + '/bannerlord'; - $final = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/'; + + $implFX = $PWD.Path + '/bannerlord-implementationsFX'; + $implCore = $PWD.Path + '/bannerlord-implementationsCore'; + + $finalFX = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/'; + $finalCore = $path + '/Modules/Bannerlord.Diplomacy/bin/Gaming.Desktop.x64_Shipping_Client/'; + $proj = 'src/Bannerlord.Diplomacy/Bannerlord.Diplomacy.csproj'; - $pdll = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/Bannerlord.Diplomacy*.dll'; - $ppdb = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/Bannerlord.Diplomacy*.pdb'; + + $pdllFX = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/Bannerlord.Diplomacy*.dll'; + $ppdbFX = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/Bannerlord.Diplomacy*.pdb'; + $pdllCore = $path + '/Modules/Bannerlord.Diplomacy/bin/Gaming.Desktop.x64_Shipping_Client/Bannerlord.Diplomacy*.dll'; + $ppdbCore = $path + '/Modules/Bannerlord.Diplomacy/bin/Gaming.Desktop.x64_Shipping_Client/Bannerlord.Diplomacy*.pdb'; + # The folders are required to be created before executing the script - New-Item -ItemType directory -Force -Path $impl; New-Item -ItemType directory -Force -Path $path; + New-Item -ItemType directory -Force -Path $implFX; + New-Item -ItemType directory -Force -Path $implCore; + [string[]]$gameversions = Get-Content -Path supported-game-versions.txt; # Process all implementations For ($i = 0; $i -le $gameversions.Length - 1; $i++) @@ -51,15 +62,22 @@ jobs: echo "Start building for gameversion = $gameversion" dotnet clean $proj --configuration Release; dotnet build $proj --configuration Release -p:OverrideGameVersion=$gameversion -p:GameFolder="$path" -p:ConstGameVersionWithPrefix="$constgameversion"; + # Copy Implementations to the Implementations folder - Copy-Item $pdll $impl/; - Copy-Item $ppdb $impl/; + Copy-Item $pdllFX $implFX/; + Copy-Item $ppdbFX $implFX/; + Copy-Item $pdllCore $implCore/; + Copy-Item $ppdbCore $implCore/; + echo "::endgroup::" } # Copy Implementations to the Module - Copy-Item $impl/* $final; + Copy-Item $implFX/* $finalFX; + Copy-Item $implCore/* $finalCore; + # Delete Implementations folder - Remove-Item -Recurse $impl; + Remove-Item -Recurse $implFX; + Remove-Item -Recurse $implCore; shell: pwsh - name: Install and Run ChangelogParser diff --git a/.github/workflows/TestBuild.yml b/.github/workflows/TestBuild.yml index 43386e91..fc5d713a 100644 --- a/.github/workflows/TestBuild.yml +++ b/.github/workflows/TestBuild.yml @@ -27,7 +27,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v4 - name: Setup .NET Core uses: actions/setup-dotnet@master @@ -36,15 +36,26 @@ jobs: - name: Build Diplomacy Module for testing run: | - $impl = $PWD.Path + '/bannerlord-implementations'; $path = $PWD.Path + '/bannerlord'; - $final = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/'; + + $implFX = $PWD.Path + '/bannerlord-implementationsFX'; + $implCore = $PWD.Path + '/bannerlord-implementationsCore'; + + $finalFX = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/'; + $finalCore = $path + '/Modules/Bannerlord.Diplomacy/bin/Gaming.Desktop.x64_Shipping_Client/'; + $proj = 'src/Bannerlord.Diplomacy/Bannerlord.Diplomacy.csproj'; - $pdll = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/Bannerlord.Diplomacy*.dll'; - $ppdb = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/Bannerlord.Diplomacy*.pdb'; + + $pdllFX = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/Bannerlord.Diplomacy*.dll'; + $ppdbFX = $path + '/Modules/Bannerlord.Diplomacy/bin/Win64_Shipping_Client/Bannerlord.Diplomacy*.pdb'; + $pdllCore = $path + '/Modules/Bannerlord.Diplomacy/bin/Gaming.Desktop.x64_Shipping_Client/Bannerlord.Diplomacy*.dll'; + $ppdbCore = $path + '/Modules/Bannerlord.Diplomacy/bin/Gaming.Desktop.x64_Shipping_Client/Bannerlord.Diplomacy*.pdb'; + # The folders are required to be created before executing the script - New-Item -ItemType directory -Force -Path $impl; New-Item -ItemType directory -Force -Path $path; + New-Item -ItemType directory -Force -Path $implFX; + New-Item -ItemType directory -Force -Path $implCore; + [string[]]$gameversions = Get-Content -Path supported-game-versions.txt; # Process all implementations For ($i = 0; $i -le $gameversions.Length - 1; $i++) @@ -56,13 +67,20 @@ jobs: echo "Start building for gameversion = $gameversion" dotnet clean $proj --configuration Release; dotnet build $proj --configuration Release -p:OverrideGameVersion=$gameversion -p:GameFolder="$path" -p:ConstGameVersionWithPrefix="$constgameversion"; + # Copy Implementations to the Implementations folder - Copy-Item $pdll $impl/; - Copy-Item $ppdb $impl/; + Copy-Item $pdllFX $implFX/; + Copy-Item $ppdbFX $implFX/; + Copy-Item $pdllCore $implCore/; + Copy-Item $ppdbCore $implCore/; + echo "::endgroup::" } # Copy Implementations to the Module - Copy-Item $impl/* $final; + Copy-Item $implFX/* $finalFX; + Copy-Item $implCore/* $finalCore; + # Delete Implementations folder - Remove-Item -Recurse $impl; + Remove-Item -Recurse $implFX; + Remove-Item -Recurse $implCore; shell: pwsh diff --git a/LICENSE b/LICENSE index 9163e0e3..af1ffccc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright © 2020-2023 Diplomacy Team +Copyright © 2020-2024 Diplomacy Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/build/common.props b/build/common.props index 685dee91..984c7ed6 100644 --- a/build/common.props +++ b/build/common.props @@ -2,7 +2,7 @@ - 1.2.11 + 1.2.12 1.0.0 @@ -11,27 +11,24 @@ 1.1.0.104 - 2.2.2 + 2.3.3 - 2.8.16 + 2.9.7 5.9.2 2.11.0 - 3.0.0.138 + 3.0.0.139 - 5.0.209 + 5.0.222 1.0.1.44 3.2.0.77 + - net472 - x64 - 9.0 - enable Bannerlord.Diplomacy $(ModuleId) Diplomacy @@ -42,7 +39,7 @@ Diplomacy Team Diplomacy Library mod for Bannerlord false - Copyright © 2020-2022 Diplomacy Team + Copyright © 2020-2024 Diplomacy Team Diplomacy system overhaul for Mount & Blade II: Bannerlord @@ -117,4 +114,4 @@ - \ No newline at end of file + diff --git a/changelog.txt b/changelog.txt index 3b105973..beba7324 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 1.2.12 +Game Versions: v1.0.x, v1.1.x, v1.2.x +* Added Xbox support +* Restored version support +--------------------------------------------------------------------------------------------------- Version: 1.2.11 Game Versions: v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.1.6,v1.2.0,v1.2.1,v1.2.2,v1.2.3,v1.2.4,v1.2.5,v1.2.6,v1.2.7,v1.2.8,1.2.9 * Add support for v1.2.9 diff --git a/src/Bannerlord.Diplomacy.sln b/src/Bannerlord.Diplomacy.sln index 9bdbf4b9..fbcded38 100644 --- a/src/Bannerlord.Diplomacy.sln +++ b/src/Bannerlord.Diplomacy.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31005.135 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34728.123 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bannerlord.Diplomacy", "Bannerlord.Diplomacy\Bannerlord.Diplomacy.csproj", "{AD3695A8-2BDD-44AF-A115-54F839A9EC2A}" EndProject @@ -24,8 +24,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{AE56 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{8CBC023C-EB40-415D-8A78-B6B7F82523E9}" ProjectSection(SolutionItems) = preProject - ..\.github\workflows\build.yml = ..\.github\workflows\build.yml ..\.github\workflows\dotnet-format-daily.yml = ..\.github\workflows\dotnet-format-daily.yml + ..\.github\workflows\Publish.yml = ..\.github\workflows\Publish.yml ..\.github\workflows\TestBuild.yml = ..\.github\workflows\TestBuild.yml EndProjectSection EndProject @@ -33,8 +33,10 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Beta_Debug|x64 = Beta_Debug|x64 Beta_Release|x64 = Beta_Release|x64 + Debug|x64 = Debug|x64 Minimal_Debug|x64 = Minimal_Debug|x64 Minimal_Release|x64 = Minimal_Release|x64 + Release|x64 = Release|x64 Stable_Debug|x64 = Stable_Debug|x64 Stable_Release|x64 = Stable_Release|x64 EndGlobalSection @@ -43,10 +45,14 @@ Global {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Beta_Debug|x64.Build.0 = Beta_Debug|x64 {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Beta_Release|x64.ActiveCfg = Beta_Release|x64 {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Beta_Release|x64.Build.0 = Beta_Release|x64 - {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Minimal_Debug|x64.ActiveCfg = Stable_Debug|x64 - {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Minimal_Debug|x64.Build.0 = Stable_Debug|x64 - {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Minimal_Release|x64.ActiveCfg = Stable_Release|x64 - {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Minimal_Release|x64.Build.0 = Stable_Release|x64 + {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Debug|x64.ActiveCfg = Debug|x64 + {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Debug|x64.Build.0 = Debug|x64 + {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Minimal_Debug|x64.ActiveCfg = Debug|x64 + {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Minimal_Debug|x64.Build.0 = Debug|x64 + {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Minimal_Release|x64.ActiveCfg = Release|x64 + {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Minimal_Release|x64.Build.0 = Release|x64 + {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Release|x64.ActiveCfg = Release|x64 + {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Release|x64.Build.0 = Release|x64 {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Stable_Debug|x64.ActiveCfg = Stable_Debug|x64 {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Stable_Debug|x64.Build.0 = Stable_Debug|x64 {AD3695A8-2BDD-44AF-A115-54F839A9EC2A}.Stable_Release|x64.ActiveCfg = Stable_Release|x64 diff --git a/src/Bannerlord.Diplomacy/Bannerlord.Diplomacy.csproj b/src/Bannerlord.Diplomacy/Bannerlord.Diplomacy.csproj index 2715d3da..525d5bbd 100644 --- a/src/Bannerlord.Diplomacy/Bannerlord.Diplomacy.csproj +++ b/src/Bannerlord.Diplomacy/Bannerlord.Diplomacy.csproj @@ -1,8 +1,26 @@  + + net472;net6 + latest + enable + x64 + false + false + + + + true + + + true + true + true + + $(ModuleName).$(GameVersion) - Stable_Debug;Stable_Release;Beta_Debug;Beta_Release + Stable_Debug;Stable_Release;Beta_Debug;Beta_Release;Debug;Release @@ -26,7 +44,7 @@ - + diff --git a/src/Bannerlord.Diplomacy/CampaignBehaviors/CivilWarBehavior.cs b/src/Bannerlord.Diplomacy/CampaignBehaviors/CivilWarBehavior.cs index f6561e42..2d982679 100644 --- a/src/Bannerlord.Diplomacy/CampaignBehaviors/CivilWarBehavior.cs +++ b/src/Bannerlord.Diplomacy/CampaignBehaviors/CivilWarBehavior.cs @@ -60,12 +60,13 @@ private void DailyTick() foreach (var kingdom in KingdomExtensions.AllActiveKingdoms.Where(x => (x.IsRebelKingdom() || x.HasRebellion()) && x.Fiefs.IsEmpty()).ToList()) { var rebelFaction = RebelFactionManager.GetRebelFactionForRebelKingdom(kingdom) ?? kingdom.GetRebelFactions().FirstOrDefault(); - - var otherKingdom = kingdom.IsRebelKingdom() ? rebelFaction.ParentKingdom : rebelFaction.RebelKingdom!; - if (rebelFaction != null) + if (rebelFaction is null) { - KingdomPeaceAction.ApplyPeace(kingdom, otherKingdom); + continue; } + + var otherKingdom = kingdom.IsRebelKingdom() ? rebelFaction.ParentKingdom : rebelFaction.RebelKingdom!; + KingdomPeaceAction.ApplyPeace(kingdom, otherKingdom); } } } diff --git a/src/Bannerlord.Diplomacy/CampaignBehaviors/WarExhaustionBehavior.cs b/src/Bannerlord.Diplomacy/CampaignBehaviors/WarExhaustionBehavior.cs index 8189cba1..ba42b289 100644 --- a/src/Bannerlord.Diplomacy/CampaignBehaviors/WarExhaustionBehavior.cs +++ b/src/Bannerlord.Diplomacy/CampaignBehaviors/WarExhaustionBehavior.cs @@ -172,7 +172,6 @@ private void OnHeroKilled(Hero victim, Hero killer, KillCharacterAction.KillChar _warExhaustionManager.AddHeroPerishedWarExhaustion(kingdoms, victim, killer.PartyBelongedTo?.Name ?? effector!.Name, detail); } - private static bool VerifyEventSides(PartyBase attackerSideLeaderParty, PartyBase defenderSideLeaderParty, out Kingdom? attacker, out Kingdom? defender) { if ((attackerSideLeaderParty.IsMobile && (attackerSideLeaderParty.MobileParty?.IsBandit ?? false)) || (defenderSideLeaderParty.IsMobile && (defenderSideLeaderParty.MobileParty?.IsBandit ?? false)) @@ -195,7 +194,7 @@ private static bool VerifyEventSides(PartyBase attackerSideLeaderParty, PartyBas private static bool VerifyEventSides(PartyBase effectorSideParty, Hero effectedSideHero, out Kingdom? effector, out Kingdom? effected) { - if (effectorSideParty.IsMobile && (effectorSideParty.MobileParty?.IsBandit ?? false) + if ((effectorSideParty.IsMobile && (effectorSideParty.MobileParty?.IsBandit ?? false)) || effectorSideParty.MapFaction == null || effectorSideParty.MapFaction.IsBanditFaction || effectedSideHero.MapFaction == null || effectedSideHero.MapFaction.IsBanditFaction || effectorSideParty.MapFaction is not Kingdom effectorKingdom || effectedSideHero.MapFaction is not Kingdom effectedKingdom @@ -251,4 +250,4 @@ public override void SyncData(IDataStore dataStore) } } } -} +} \ No newline at end of file diff --git a/src/Bannerlord.Diplomacy/CivilWar/Actions/ChangeKingdomBannerAction.cs b/src/Bannerlord.Diplomacy/CivilWar/Actions/ChangeKingdomBannerAction.cs index 07f3ed1d..e6caa308 100644 --- a/src/Bannerlord.Diplomacy/CivilWar/Actions/ChangeKingdomBannerAction.cs +++ b/src/Bannerlord.Diplomacy/CivilWar/Actions/ChangeKingdomBannerAction.cs @@ -153,7 +153,7 @@ private static uint GetUniqueSigilColor(uint backgroundColor) .Where(x => !currentSigilColors.Contains(x)) .ToList(); - if (colors.Any()) + if (colors.Count > 0) selectedColor = colors.GetRandomElementInefficiently(); } diff --git a/src/Bannerlord.Diplomacy/CivilWar/FactionNameGenerator.cs b/src/Bannerlord.Diplomacy/CivilWar/FactionNameGenerator.cs index f3c4aaf7..f0495b43 100644 --- a/src/Bannerlord.Diplomacy/CivilWar/FactionNameGenerator.cs +++ b/src/Bannerlord.Diplomacy/CivilWar/FactionNameGenerator.cs @@ -290,7 +290,7 @@ public static TextObject GenerateKingdomName(RebelFaction rebelFaction) string? kingdomTitle; var culture = rebelFaction.Clans.Where(x => !x.IsEliminated).Select(x => x.Culture.StringId).GroupBy(x => x).OrderByDescending(x => x.Count()).First().Key; CultureToKingdomTitles.TryGetValue(culture, out var cultureTitles); - if (cultureTitles is not null && cultureTitles.Any() && MBRandom.RandomFloat < 0.5) + if (cultureTitles is not null && cultureTitles.Count > 0 && MBRandom.RandomFloat < 0.5) { kingdomTitle = ResolveTitle(cultureTitles); } @@ -299,7 +299,7 @@ public static TextObject GenerateKingdomName(RebelFaction rebelFaction) kingdomTitle = ResolveTitle(CommonKingdomTitles); } - var kingdomName = CultureToKingdomNames.TryGetValue(culture, out var value) && value.Any() ? new TextObject(value.GetRandomElement()) : rebelFaction.SponsorClan.Name; + var kingdomName = CultureToKingdomNames.TryGetValue(culture, out var value) && value.Count > 0 ? new TextObject(value.GetRandomElement()) : rebelFaction.SponsorClan.Name; return new TextObject(kingdomTitle, new Dictionary { { "CLAN_NAME", kingdomName } }); } diff --git a/src/Bannerlord.Diplomacy/CivilWar/Factions/RebelFaction.cs b/src/Bannerlord.Diplomacy/CivilWar/Factions/RebelFaction.cs index cc63dd3d..e926264d 100644 --- a/src/Bannerlord.Diplomacy/CivilWar/Factions/RebelFaction.cs +++ b/src/Bannerlord.Diplomacy/CivilWar/Factions/RebelFaction.cs @@ -138,7 +138,7 @@ public void RemoveClan(Clan clan) if (_participatingClans.Contains(clan)) { var remainingClanList = _participatingClans.Where(x => x != clan && !x.IsEliminated).ToList(); - if (!remainingClanList.Any()) + if (remainingClanList.Count <= 0) { RebelFactionManager.DestroyRebelFaction(this); return; diff --git a/src/Bannerlord.Diplomacy/CivilWar/RebelFactionManager.cs b/src/Bannerlord.Diplomacy/CivilWar/RebelFactionManager.cs index d7b782c4..50db30d1 100644 --- a/src/Bannerlord.Diplomacy/CivilWar/RebelFactionManager.cs +++ b/src/Bannerlord.Diplomacy/CivilWar/RebelFactionManager.cs @@ -109,7 +109,7 @@ public static Kingdom GetCivilWarLoser(Kingdom kingdomMakingPeace, Kingdom other { return (WarExhaustionManager.Instance?.GetWarResult(kingdomMakingPeace, otherKingdom) ?? WarExhaustionManager.WarResult.None) switch { - WarExhaustionManager.WarResult.Tie when kingdomMakingPeace.Fiefs.Any() => TributeHelper.GetBaseValueForTrubute(kingdomMakingPeace, otherKingdom) < 0 ? otherKingdom : kingdomMakingPeace, + WarExhaustionManager.WarResult.Tie when kingdomMakingPeace.Fiefs.Count > 0 => TributeHelper.GetBaseValueForTrubute(kingdomMakingPeace, otherKingdom) < 0 ? otherKingdom : kingdomMakingPeace, >= WarExhaustionManager.WarResult.PyrrhicVictory => otherKingdom, _ => kingdomMakingPeace, }; diff --git a/src/Bannerlord.Diplomacy/DiplomaticAction/WarPeace/DeclareWarConditions.cs b/src/Bannerlord.Diplomacy/DiplomaticAction/WarPeace/DeclareWarConditions.cs index f87619ef..360527ac 100644 --- a/src/Bannerlord.Diplomacy/DiplomaticAction/WarPeace/DeclareWarConditions.cs +++ b/src/Bannerlord.Diplomacy/DiplomaticAction/WarPeace/DeclareWarConditions.cs @@ -17,7 +17,7 @@ internal sealed class DeclareWarConditions : AbstractConditionEvaluator { @@ -105,7 +105,6 @@ private static void GetNotificationInquiryTitleAndBody(Kingdom kingdomMakingPeac return; } - var strArgs = new Dictionary { {"ORGANIZATIONAL_EXPENSES", diplomacyCost.GoldCost.Value}, @@ -208,7 +207,7 @@ private static string GetPeaceInquiryText(Kingdom kingdomMakingPeace, Kingdom ot var rebelIsMakingPeace = kingdomMakingPeace.IsRebelKingdomOf(otherKingdom); var originalIsMakingPeace = otherKingdom.IsRebelKingdomOf(kingdomMakingPeace); - if (!isATie && rebelIsMakingPeace || originalIsMakingPeace) + if ((!isATie && rebelIsMakingPeace) || originalIsMakingPeace) { var strRebelArgs = new Dictionary { @@ -336,7 +335,7 @@ private static bool ShouldAnyFiefsBeReturned(Kingdom kingdomMakingPeace, Kingdom if (!Settings.Instance!.EnableWarExhaustion || !Settings.Instance!.EnableFiefRepatriation || !WarExhaustionManager.Instance!.HasMaxWarExhaustion(kingdomMakingPeace, otherKingdom)) return false; - if (!kingdomMakingPeace.Fiefs.Any()) + if (kingdomMakingPeace.Fiefs.Count <= 0) return false; if (kingdomMakingPeace.IsRebelKingdomOf(otherKingdom) || (otherKingdom.IsRebelKingdomOf(kingdomMakingPeace) && kingdomMakingPeace.GetRebelFactions().Any(x => x.RebelKingdom == otherKingdom && x is not SecessionFaction))) diff --git a/src/Bannerlord.Diplomacy/Extensions/ClanExtensions.cs b/src/Bannerlord.Diplomacy/Extensions/ClanExtensions.cs index 97d5ca37..7237c140 100644 --- a/src/Bannerlord.Diplomacy/Extensions/ClanExtensions.cs +++ b/src/Bannerlord.Diplomacy/Extensions/ClanExtensions.cs @@ -58,8 +58,8 @@ public static IEnumerable GetRebelFactions(this Clan clan) return default; } } - - public static bool HasMarriedClanLeaderRelation(this Clan clan, Clan other) + + public static bool HasMarriedClanLeaderRelation(this Clan clan, Clan other) { // if any relatives are alive and married to other clan => "related by marriage" return clan.Leader.Spouse?.AllRelatedHeroes().Any(ownSpouseFamMember => ownSpouseFamMember.Clan == other) ?? false diff --git a/src/Bannerlord.Diplomacy/Extensions/HeroExtensions.cs b/src/Bannerlord.Diplomacy/Extensions/HeroExtensions.cs index 49477f74..e4029a57 100644 --- a/src/Bannerlord.Diplomacy/Extensions/HeroExtensions.cs +++ b/src/Bannerlord.Diplomacy/Extensions/HeroExtensions.cs @@ -14,8 +14,8 @@ public static float GetNormalizedTraitValue(this Hero hero, TraitObject trait) var zeroMinTraitLevel = hero.GetTraitLevel(trait) + Math.Abs(trait.MinValue); return zeroMinTraitLevel / zeroMinMaxTraitLevel; } - - public static IEnumerable AllRelatedHeroes(this Hero inHero, bool includeExSpouses = false) + + public static IEnumerable AllRelatedHeroes(this Hero inHero, bool includeExSpouses = false) { if (inHero.Father != null) { diff --git a/src/Bannerlord.Diplomacy/FactionPair.cs b/src/Bannerlord.Diplomacy/FactionPair.cs index c7a0945d..ad2cd988 100644 --- a/src/Bannerlord.Diplomacy/FactionPair.cs +++ b/src/Bannerlord.Diplomacy/FactionPair.cs @@ -40,7 +40,7 @@ internal FactionPair(FactionPair other) _hashCode = other._hashCode; } - public override bool Equals(object obj) => obj is FactionPair p && Equals(p); + public override bool Equals(object? obj) => obj is FactionPair p && Equals(p); public bool Equals(FactionPair p) => Faction1 == p.Faction1 && Faction2 == p.Faction2; diff --git a/src/Bannerlord.Diplomacy/Helpers/MessageHelper.cs b/src/Bannerlord.Diplomacy/Helpers/MessageHelper.cs index a9bb1c6d..76bad4a1 100644 --- a/src/Bannerlord.Diplomacy/Helpers/MessageHelper.cs +++ b/src/Bannerlord.Diplomacy/Helpers/MessageHelper.cs @@ -13,7 +13,7 @@ public static void SendFailedActionMessage(string action, List exception { var sb = new StringBuilder(); sb.Append(action); - if (exceptions.Any()) sb.Append(exceptions.First()); + if (exceptions.Count > 0) sb.Append(exceptions.First()); InformationManager.DisplayMessage(new InformationMessage(sb.ToString())); } @@ -22,7 +22,7 @@ public static void SendFailedActionMessage(string action, List excep { var sb = new StringBuilder(); sb.Append(action); - if (exceptions.Any()) sb.Append(exceptions.First()); + if (exceptions.Count > 0) sb.Append(exceptions.First()); InformationManager.DisplayMessage(new InformationMessage(sb.ToString())); } diff --git a/src/Bannerlord.Diplomacy/Messengers/MessengerManager.cs b/src/Bannerlord.Diplomacy/Messengers/MessengerManager.cs index 5c4d753e..59d7d560 100644 --- a/src/Bannerlord.Diplomacy/Messengers/MessengerManager.cs +++ b/src/Bannerlord.Diplomacy/Messengers/MessengerManager.cs @@ -344,7 +344,7 @@ public void SendMessengerWithCost(Hero targetHero, GoldCost diplomacyCost) public static bool IsTargetHeroAvailable(Hero targetHero) { - var available = targetHero.IsActive || targetHero.IsWanderer && targetHero.HeroState == Hero.CharacterStates.NotSpawned; + var available = targetHero.IsActive || (targetHero.IsWanderer && targetHero.HeroState == Hero.CharacterStates.NotSpawned); return available && !targetHero.IsHumanPlayerCharacter; } @@ -362,7 +362,7 @@ public static bool IsTargetHeroAvailable(Hero targetHero, out TextObject excepti return false; } - var available = targetHero.IsActive || targetHero.IsWanderer && targetHero.HeroState == Hero.CharacterStates.NotSpawned; + var available = targetHero.IsActive || (targetHero.IsWanderer && targetHero.HeroState == Hero.CharacterStates.NotSpawned); if (!available) { exception = new("{=bLR91Eob}{REASON}The messenger won't be able to reach the addressee."); diff --git a/src/Bannerlord.Diplomacy/Models/DiplomacyKingdomDecisionPermissionModel.cs b/src/Bannerlord.Diplomacy/Models/DiplomacyKingdomDecisionPermissionModel.cs index 28c19a59..5c6d9754 100644 --- a/src/Bannerlord.Diplomacy/Models/DiplomacyKingdomDecisionPermissionModel.cs +++ b/src/Bannerlord.Diplomacy/Models/DiplomacyKingdomDecisionPermissionModel.cs @@ -32,9 +32,9 @@ public override bool IsWarDecisionAllowedBetweenKingdoms(Kingdom kingdom1, Kingd if (isWarDecisionAllowed) { var listExceptions = DeclareWarConditions.Instance.CanApplyExceptions(kingdom1, kingdom2, bypassCosts: true); - if (listExceptions is not null && listExceptions.Any()) + if (listExceptions is not null && listExceptions.Count > 0) { - reason = listExceptions.FirstOrDefault(); + reason = listExceptions.FirstOrDefault() ?? TextObject.Empty; isWarDecisionAllowed = false; } } @@ -56,9 +56,9 @@ public override bool IsPeaceDecisionAllowedBetweenKingdoms(Kingdom kingdom1, Kin if (isPeaceDecisionAllowed) { var listExceptions = MakePeaceConditions.Instance.CanApplyExceptions(kingdom1, kingdom2, bypassCosts: true); - if (listExceptions is not null && listExceptions.Any()) + if (listExceptions is not null && listExceptions.Count > 0) { - reason = listExceptions.FirstOrDefault(); + reason = listExceptions.FirstOrDefault() ?? TextObject.Empty; isPeaceDecisionAllowed = false; } } diff --git a/src/Bannerlord.Diplomacy/PatchTools/PatchClass.cs b/src/Bannerlord.Diplomacy/PatchTools/PatchClass.cs index a928a964..067f065f 100644 --- a/src/Bannerlord.Diplomacy/PatchTools/PatchClass.cs +++ b/src/Bannerlord.Diplomacy/PatchTools/PatchClass.cs @@ -65,7 +65,7 @@ public void Apply(Harmony harmony) public void Remove(Harmony harmony) => harmony.Unpatch(_targetMethod, _patchMethod.MethodInfo); public override string ToString() => $"{Enum.GetName(typeof(HarmonyPatchType), _type)} patch of " - + $"{_targetMethod.Name} in type {_targetMethod.DeclaringType.Name} ({_targetMethod.DeclaringType.FullName})"; + + $"{_targetMethod.Name} in type {_targetMethod.DeclaringType!.Name} ({_targetMethod.DeclaringType.FullName})"; private sealed class PatchCreationException : Exception { diff --git a/src/Bannerlord.Diplomacy/Settings.cs b/src/Bannerlord.Diplomacy/Settings.cs index 0fcf9c3e..478c5e85 100644 --- a/src/Bannerlord.Diplomacy/Settings.cs +++ b/src/Bannerlord.Diplomacy/Settings.cs @@ -99,7 +99,7 @@ class Settings : AttributeGlobalSettings [SettingPropertyInteger("{=jwNKk8P7}No Wars When Married", 0, 100, Order = 1004, RequireRestart = false, HintText = "{=xcMzKH48}If active, kingdom leader clans that have a marriage between each other will not start wars. Default value is active.")] [SettingPropertyGroup(HeadingKingdomDiplomacy)] public bool NoWarWhenMarriedLeaderClans { get; set; } = true; - + // Messengers [SettingPropertyBool("{=nwTyegdV}Enable Messengers Accidents", Order = 0, RequireRestart = false, HintText = "{=T7yybpw3}If enabled, adds a small chance of failure for messengers. The longer the journey, the higher the chance of an accident on the road. Default value is enabled.")] diff --git a/src/Bannerlord.Diplomacy/SubModule.cs b/src/Bannerlord.Diplomacy/SubModule.cs index d855d3a3..725f6ab0 100644 --- a/src/Bannerlord.Diplomacy/SubModule.cs +++ b/src/Bannerlord.Diplomacy/SubModule.cs @@ -1,5 +1,4 @@ using Bannerlord.ButterLib.Common.Extensions; - using Bannerlord.UIExtenderEx; using Bannerlord.UIExtenderEx.ResourceManager; @@ -19,16 +18,16 @@ using TaleWorlds.CampaignSystem.ComponentInterfaces; using TaleWorlds.Core; using TaleWorlds.Library; -using TaleWorlds.MountAndBlade; using TaleWorlds.Localization; +using TaleWorlds.MountAndBlade; namespace Diplomacy { public sealed class SubModule : MBSubModuleBase { - public static readonly string Version = $"v{typeof(SubModule).Assembly.GetName().Version.ToString(3)}"; + public static readonly string Version = $"v{typeof(SubModule).Assembly.GetName().Version!.ToString(3)}"; - public static readonly string Name = typeof(SubModule).Namespace; + public static readonly string Name = typeof(SubModule).Namespace!; public static readonly string DisplayName = new TextObject($"{{=MYz8nKqq}}{Name}").ToString(); public static readonly string MainHarmonyDomain = "bannerlord." + Name.ToLower(); public static readonly string CampaignHarmonyDomain = MainHarmonyDomain + ".campaign"; @@ -47,11 +46,7 @@ protected override void OnSubModuleLoad() base.OnSubModuleLoad(); Instance = this; -#if v129 var extender = UIExtender.Create(Name); -#else - var extender = new UIExtender(Name); -#endif extender.Register(typeof(SubModule).Assembly); extender.Enable(); diff --git a/src/Bannerlord.Diplomacy/ViewModel/DiplomacyFactionRelationshipVM.cs b/src/Bannerlord.Diplomacy/ViewModel/DiplomacyFactionRelationshipVM.cs index f38a5bdb..a9caa89f 100644 --- a/src/Bannerlord.Diplomacy/ViewModel/DiplomacyFactionRelationshipVM.cs +++ b/src/Bannerlord.Diplomacy/ViewModel/DiplomacyFactionRelationshipVM.cs @@ -24,7 +24,7 @@ public DiplomacyFactionRelationshipVM(IFaction faction, HintViewModel? hint = nu [UsedImplicitly] private void ExecuteLink() => Campaign.Current.EncyclopediaManager.GoToLink(Faction.EncyclopediaLink); - public override bool Equals(object obj) => obj is DiplomacyFactionRelationshipVM vm && Equals(vm); + public override bool Equals(object? obj) => obj is DiplomacyFactionRelationshipVM vm && Equals(vm); public bool Equals(DiplomacyFactionRelationshipVM vm) => EqualityComparer.Default.Equals(Faction, vm.Faction); diff --git a/src/Bannerlord.Diplomacy/ViewModel/DonateGoldVM.cs b/src/Bannerlord.Diplomacy/ViewModel/DonateGoldVM.cs index 93536733..fbcf46a4 100644 --- a/src/Bannerlord.Diplomacy/ViewModel/DonateGoldVM.cs +++ b/src/Bannerlord.Diplomacy/ViewModel/DonateGoldVM.cs @@ -91,7 +91,7 @@ private void ExecutePropose() _onFinalize(); } - private void HandlePropertyChanged(object sender, PropertyChangedEventArgs e) + private void HandlePropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(IntValue)) Refresh(); diff --git a/src/Bannerlord.Diplomacy/ViewModel/GrantFiefSortControllerVM.cs b/src/Bannerlord.Diplomacy/ViewModel/GrantFiefSortControllerVM.cs index 1a2ee6b0..bf302b42 100644 --- a/src/Bannerlord.Diplomacy/ViewModel/GrantFiefSortControllerVM.cs +++ b/src/Bannerlord.Diplomacy/ViewModel/GrantFiefSortControllerVM.cs @@ -177,77 +177,77 @@ public void SetSortMode(bool isAcending) _isAcending = isAcending; } - public abstract int Compare(GrantFiefItemVM x, GrantFiefItemVM y); + public abstract int Compare(GrantFiefItemVM? x, GrantFiefItemVM? y); protected bool _isAcending; } private class ItemNameComparer : ItemComparerBase { - public override int Compare(GrantFiefItemVM x, GrantFiefItemVM y) + public override int Compare(GrantFiefItemVM? x, GrantFiefItemVM? y) { if (_isAcending) { - return y.Settlement.Name.ToString().CompareTo(x.Settlement.Name.ToString()) * -1; + return Comparer.Default.Compare(x?.Settlement.Name.ToString(), y?.Settlement.Name.ToString()); } - return y.Settlement.Name.ToString().CompareTo(x.Settlement.Name.ToString()); + return Comparer.Default.Compare(y?.Settlement.Name.ToString(), x?.Settlement.Name.ToString()); } } private class ItemClanComparer : ItemComparerBase { - public override int Compare(GrantFiefItemVM x, GrantFiefItemVM y) + public override int Compare(GrantFiefItemVM? x, GrantFiefItemVM? y) { if (_isAcending) { - return y.Settlement.OwnerClan.Name.ToString().CompareTo(x.Settlement.OwnerClan.Name.ToString()) * -1; + return Comparer.Default.Compare(x?.Settlement.OwnerClan?.Name.ToString(), y?.Settlement.OwnerClan?.Name.ToString()); } - return y.Settlement.OwnerClan.Name.ToString().CompareTo(x.Settlement.OwnerClan.Name.ToString()); + return Comparer.Default.Compare(y?.Settlement.OwnerClan?.Name.ToString(), x?.Settlement.OwnerClan?.Name.ToString()); } } private class ItemTypeComparer : ItemComparerBase { - public override int Compare(GrantFiefItemVM x, GrantFiefItemVM y) + public override int Compare(GrantFiefItemVM? x, GrantFiefItemVM? y) { if (_isAcending) { - return x.Settlement.IsCastle.CompareTo(y.Settlement.IsCastle); + return Comparer.Default.Compare(x?.Settlement.IsCastle, y?.Settlement.IsCastle); } - return x.Settlement.IsCastle.CompareTo(y.Settlement.IsCastle) * -1; + return Comparer.Default.Compare(y?.Settlement.IsCastle, x?.Settlement.IsCastle); } } private class ItemProsperityComparer : ItemComparerBase { - public override int Compare(GrantFiefItemVM x, GrantFiefItemVM y) + public override int Compare(GrantFiefItemVM? x, GrantFiefItemVM? y) { if (_isAcending) { - return y.Prosperity.CompareTo(x.Prosperity) * -1; + return Comparer.Default.Compare(x?.Prosperity, y?.Prosperity); } - return y.Prosperity.CompareTo(x.Prosperity); + return Comparer.Default.Compare(y?.Prosperity, x?.Prosperity); } } private class ItemRelationComparer : ItemComparerBase { - public override int Compare(GrantFiefItemVM x, GrantFiefItemVM y) + public override int Compare(GrantFiefItemVM? x, GrantFiefItemVM? y) { if (_isAcending) { - return y.RelationBonus.CompareTo(x.RelationBonus) * -1; + return Comparer.Default.Compare(x?.RelationBonus, y?.RelationBonus); } - return y.RelationBonus.CompareTo(x.RelationBonus); + return Comparer.Default.Compare(y?.RelationBonus, x?.RelationBonus); } } private class ItemFoodComparer : ItemComparerBase { - public override int Compare(GrantFiefItemVM x, GrantFiefItemVM y) + public override int Compare(GrantFiefItemVM? x, GrantFiefItemVM? y) { - var num = y.Settlement.Town?.FoodStocks ?? 0f; - var value = x.Settlement.Town?.FoodStocks ?? 0f; + var num = y?.Settlement.Town?.FoodStocks ?? 0f; + var value = x?.Settlement.Town?.FoodStocks ?? 0f; if (_isAcending) { return num.CompareTo(value) * -1; @@ -256,27 +256,15 @@ public override int Compare(GrantFiefItemVM x, GrantFiefItemVM y) } } - private class ItemGarrisonComparer : ItemComparerBase - { - public override int Compare(GrantFiefItemVM x, GrantFiefItemVM y) - { - if (_isAcending) - { - return y.Garrison.CompareTo(x.Garrison) * -1; - } - return y.Garrison.CompareTo(x.Garrison); - } - } - private class ItemDefendersComparer : ItemComparerBase { - public override int Compare(GrantFiefItemVM x, GrantFiefItemVM y) + public override int Compare(GrantFiefItemVM? x, GrantFiefItemVM? y) { if (_isAcending) { - return y.Garrison.CompareTo(x.Garrison) * -1; + return Comparer.Default.Compare(x?.Garrison, y?.Garrison); } - return y.Garrison.CompareTo(x.Garrison); + return Comparer.Default.Compare(y?.Garrison, x?.Garrison); } } } diff --git a/src/Bannerlord.Diplomacy/ViewModel/WarExhaustionBreakdownVM.cs b/src/Bannerlord.Diplomacy/ViewModel/WarExhaustionBreakdownVM.cs index 64b9e388..ec285dcf 100644 --- a/src/Bannerlord.Diplomacy/ViewModel/WarExhaustionBreakdownVM.cs +++ b/src/Bannerlord.Diplomacy/ViewModel/WarExhaustionBreakdownVM.cs @@ -69,7 +69,7 @@ private BasicTooltipViewModel UpdateValueHint(int factionIndex, WarExhaustionBre }; var list = new List(); - if (factionEventRecords is not null && factionEventRecords.Any()) + if (factionEventRecords is not null && factionEventRecords.Count > 0) { list.Add(new TooltipProperty(Text, factionValue > 0 ? factionValue.ToString() : string.Empty, 0, false, TooltipProperty.TooltipPropertyFlags.Title)); foreach (var (eventDescription, exhaustionValue) in factionEventRecords) diff --git a/src/Bannerlord.Diplomacy/ViewModelMixin/DiplomacyPanelPrefabExtension.cs b/src/Bannerlord.Diplomacy/ViewModelMixin/DiplomacyPanelPrefabExtension.cs index a1717091..42c15abd 100644 --- a/src/Bannerlord.Diplomacy/ViewModelMixin/DiplomacyPanelPrefabExtension.cs +++ b/src/Bannerlord.Diplomacy/ViewModelMixin/DiplomacyPanelPrefabExtension.cs @@ -35,6 +35,5 @@ public DiplomacyPanelPrefabExtension() [PrefabExtensionXmlDocument] [UsedImplicitly] public XmlDocument GetPrefabExtension() => _document; - } } \ No newline at end of file diff --git a/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomClanVMMixin.cs b/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomClanVMMixin.cs index c2f054a8..aa45a938 100644 --- a/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomClanVMMixin.cs +++ b/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomClanVMMixin.cs @@ -20,7 +20,6 @@ namespace Diplomacy.ViewModelMixin [UsedImplicitly] internal sealed class KingdomClanVMMixin : BaseViewModelMixin { - private bool _canGrantFiefToClan; private readonly GrantFiefInterface _grantFiefInterface; private readonly DonateGoldInterface _donateGoldInterface; @@ -46,7 +45,6 @@ public KingdomClanVMMixin(KingdomClanVM vm) : base(vm) RefreshCanGrantFief(); } - public override void OnFinalize() { base.OnFinalize(); diff --git a/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomDiplomacyVMMixin.cs b/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomDiplomacyVMMixin.cs index dcaba0aa..15e2e6f3 100644 --- a/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomDiplomacyVMMixin.cs +++ b/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomDiplomacyVMMixin.cs @@ -27,10 +27,8 @@ internal sealed class KingdomDiplomacyVMMixin : BaseViewModelMixin _playerAlliances; private bool _showOverview; private bool _showStats; diff --git a/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomWarItemVMMixin.cs b/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomWarItemVMMixin.cs index d1d84687..d9bf6ca4 100644 --- a/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomWarItemVMMixin.cs +++ b/src/Bannerlord.Diplomacy/ViewModelMixin/KingdomWarItemVMMixin.cs @@ -150,7 +150,7 @@ private void UpdateActionAvailability() ["TRIBUTE_GET"] = tributeValue < 0 ? 1 : 0, ["TRIBUTE"] = Math.Abs(tributeValue), }), - ["FIEFS_TO_RETURN"] = new TextObject(_TFiefs, new() { ["FIEFS_ANY"] = KingdomPeaceAction.GetFiefsSuitableToBeReturned(_faction1, _faction2).Any() ? 1 : 0 }), + ["FIEFS_TO_RETURN"] = new TextObject(_TFiefs, new() { ["FIEFS_ANY"] = KingdomPeaceAction.GetFiefsSuitableToBeReturned(_faction1, _faction2).Count > 0 ? 1 : 0 }), }).ToString(); } else diff --git a/src/Bannerlord.Diplomacy/WarExhaustion/EventRecords/WarExhaustionEventRecord.cs b/src/Bannerlord.Diplomacy/WarExhaustion/EventRecords/WarExhaustionEventRecord.cs index 2768e47b..fb0b603f 100644 --- a/src/Bannerlord.Diplomacy/WarExhaustion/EventRecords/WarExhaustionEventRecord.cs +++ b/src/Bannerlord.Diplomacy/WarExhaustion/EventRecords/WarExhaustionEventRecord.cs @@ -46,7 +46,7 @@ public WarExhaustionEventRecord(CampaignTime eventDate, int faction1Value, float protected static TextObject? FindTextWithVariation(string textToFind) { - int variationSeparatorIdx = textToFind.LastIndexOf("."); + int variationSeparatorIdx = textToFind.LastIndexOf('.'); if (variationSeparatorIdx > 0) { var id = textToFind.Substring(0, variationSeparatorIdx); diff --git a/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionBreakdown.cs b/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionBreakdown.cs index 692f7045..56dc0770 100644 --- a/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionBreakdown.cs +++ b/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionBreakdown.cs @@ -75,7 +75,7 @@ internal List GetWarExhaustionBreakdown(Kingdom kingdom1 private static void GetBreakdownByEventType(WarExhaustionType warExhaustionType, List result, List warExhaustionEventRecords, bool reversedKeyOrder, bool useValue = false, bool addIfEmpty = true) { var eventRecords = warExhaustionEventRecords.Where(r => r.WarExhaustionType == warExhaustionType).OrderBy(r => r.EventDate).ToList(); - if (!eventRecords.Any() && !addIfEmpty) + if (eventRecords.Count <= 0 && !addIfEmpty) return; int valueFaction1 = 0, valueFaction2 = 0; @@ -127,7 +127,7 @@ private static void GetBreakdownByEventType(WarExhaustionType warExhaustionType, var recordsToShow = originalList.OrderByDescending(rec => rec.EventDate).Take(Settings.Instance!.MaxShownBreakdownEntries).OrderBy(rec => rec.EventDate).ToList(); var recordsToSummarize = originalList.Except(recordsToShow).OrderBy(rec => rec.EventDate).ToList(); - if (!recordsToSummarize.Any()) + if (recordsToSummarize.Count <= 0) return recordsToShow.Select(x => (x.EventDescription, x.ExhaustionValue)).ToList(); CampaignTime minDate = CampaignTime.Never, maxDate = CampaignTime.Zero; float totalValue = 0f; int recordCount = 0; diff --git a/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionManager.EventHandling.cs b/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionManager.EventHandling.cs index 5f2ba172..288aea4a 100644 --- a/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionManager.EventHandling.cs +++ b/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionManager.EventHandling.cs @@ -188,8 +188,8 @@ private WarExhaustionRecord GetDailyWarExhaustionDelta(Kingdoms kingdoms, Campai GetWarExhaustionPerDay(out var warExhaustionPerDay, out var warExhaustionPerDayOccupied); var faction1 = kingdoms.ReversedKeyOrder ? kingdoms.Kingdom2 : kingdoms.Kingdom1; var faction2 = kingdoms.ReversedKeyOrder ? kingdoms.Kingdom1 : kingdoms.Kingdom2; - var faction1IsOccupied = !faction1.Fiefs.Any(); - var faction2IsOccupied = !faction2.Fiefs.Any(); + var faction1IsOccupied = faction1.Fiefs.Count <= 0; + var faction2IsOccupied = faction2.Fiefs.Count <= 0; var faction1WarExhaustion = faction1IsOccupied ? warExhaustionPerDayOccupied : warExhaustionPerDay; var faction2WarExhaustion = faction2IsOccupied ? warExhaustionPerDayOccupied : warExhaustionPerDay; var hasActiveQuest = !IsValidQuestState(kingdoms.Kingdom1, kingdoms.Kingdom2); @@ -708,7 +708,7 @@ private static void AddOccupationEventForFaction(IFaction faction, CampaignTime private CampaignTime GetLastOccupationDate(Kingdom kingdom, out IFaction? effector) { - if (!kingdom.Fiefs.Any()) + if (kingdom.Fiefs.Count <= 0) { for (int index = Campaign.Current.LogEntryHistory.GameActionLogs.Count - 1; index >= 0; --index) { diff --git a/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionRecord.cs b/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionRecord.cs index 8f908f8e..0579cf9e 100644 --- a/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionRecord.cs +++ b/src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionRecord.cs @@ -71,7 +71,7 @@ private static VictoriousFactionType CalculateVictorIfApplicable(float faction1V private static ActiveQuestState GetAppropriateQuestState(ActiveQuestState a, ActiveQuestState b) => (a > ActiveQuestState.None) ? Max(b, ActiveQuestState.HadActiveQuest) : b; public override string ToString() => string.Format("({0},{1})", Faction1Value.ToString("F2"), Faction2Value.ToString("F2")); - public override bool Equals(object obj) => obj is WarExhaustionRecord warExhaustionRecord && Equals(warExhaustionRecord); + public override bool Equals(object? obj) => obj is WarExhaustionRecord warExhaustionRecord && Equals(warExhaustionRecord); public bool Equals(WarExhaustionRecord warExhaustionRecord) => Faction1Value == warExhaustionRecord.Faction1Value && Faction2Value == warExhaustionRecord.Faction2Value; public override int GetHashCode() => Faction1Value.GetHashCode() ^ Faction2Value.GetHashCode(); public static WarExhaustionRecord operator +(WarExhaustionRecord a) => a; diff --git a/supported-game-versions.txt b/supported-game-versions.txt index f0b0f727..1224bbcb 100644 --- a/supported-game-versions.txt +++ b/supported-game-versions.txt @@ -9,4 +9,13 @@ v1.2.2 v1.2.1 v1.2.0 v1.1.6 -v1.1.5 \ No newline at end of file +v1.1.5 +v1.1.4 +v1.1.3 +v1.1.2 +v1.1.1 +v1.1.0 +v1.0.3 +v1.0.2 +v1.0.1 +v1.0.0 \ No newline at end of file