From 01b79e1250e4d7e2b68877a7446d592622d17fe5 Mon Sep 17 00:00:00 2001 From: Alexey Chernyshov <65975574+artifixer@users.noreply.github.com> Date: Wed, 15 May 2024 03:00:30 +0300 Subject: [PATCH] Codestyle fixes --- .../CampaignBehaviors/WarExhaustionBehavior.cs | 3 +-- .../CivilWar/Actions/ChangeKingdomBannerAction.cs | 2 +- src/Bannerlord.Diplomacy/CivilWar/FactionNameGenerator.cs | 4 ++-- src/Bannerlord.Diplomacy/CivilWar/Factions/RebelFaction.cs | 2 +- src/Bannerlord.Diplomacy/CivilWar/RebelFactionManager.cs | 2 +- .../DiplomaticAction/WarPeace/KingdomPeaceAction.cs | 7 +++---- src/Bannerlord.Diplomacy/Helpers/MessageHelper.cs | 4 ++-- src/Bannerlord.Diplomacy/Messengers/MessengerManager.cs | 4 ++-- .../Models/DiplomacyKingdomDecisionPermissionModel.cs | 4 ++-- .../ViewModel/GrantFiefSortControllerVM.cs | 2 -- .../ViewModel/WarExhaustionBreakdownVM.cs | 2 +- .../ViewModelMixin/DiplomacyPanelPrefabExtension.cs | 1 - .../ViewModelMixin/KingdomClanVMMixin.cs | 2 -- .../ViewModelMixin/KingdomDiplomacyVMMixin.cs | 2 -- .../ViewModelMixin/KingdomWarItemVMMixin.cs | 2 +- .../WarExhaustion/EventRecords/WarExhaustionEventRecord.cs | 2 +- .../WarExhaustion/WarExhaustionBreakdown.cs | 4 ++-- .../WarExhaustion/WarExhaustionManager.EventHandling.cs | 6 +++--- 18 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/Bannerlord.Diplomacy/CampaignBehaviors/WarExhaustionBehavior.cs b/src/Bannerlord.Diplomacy/CampaignBehaviors/WarExhaustionBehavior.cs index 6a7a3782..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 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/KingdomPeaceAction.cs b/src/Bannerlord.Diplomacy/DiplomaticAction/WarPeace/KingdomPeaceAction.cs index 7b3ded98..ce33aa53 100644 --- a/src/Bannerlord.Diplomacy/DiplomaticAction/WarPeace/KingdomPeaceAction.cs +++ b/src/Bannerlord.Diplomacy/DiplomaticAction/WarPeace/KingdomPeaceAction.cs @@ -89,7 +89,7 @@ private static void GetNotificationInquiryTitleAndBody(Kingdom kingdomMakingPeac var rebelIsMakingPeace = kingdomMakingPeace.IsRebelKingdomOf(otherKingdom); var originalIsMakingPeace = otherKingdom.IsRebelKingdomOf(kingdomMakingPeace); - if (!isATie && rebelIsMakingPeace || originalIsMakingPeace) + if ((!isATie && rebelIsMakingPeace) || originalIsMakingPeace) { var strRebelArgs = new Dictionary { @@ -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/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 7354f1c0..5c6d9754 100644 --- a/src/Bannerlord.Diplomacy/Models/DiplomacyKingdomDecisionPermissionModel.cs +++ b/src/Bannerlord.Diplomacy/Models/DiplomacyKingdomDecisionPermissionModel.cs @@ -32,7 +32,7 @@ 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() ?? TextObject.Empty; isWarDecisionAllowed = false; @@ -56,7 +56,7 @@ 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() ?? TextObject.Empty; isPeaceDecisionAllowed = false; diff --git a/src/Bannerlord.Diplomacy/ViewModel/GrantFiefSortControllerVM.cs b/src/Bannerlord.Diplomacy/ViewModel/GrantFiefSortControllerVM.cs index e36bbbe6..bf302b42 100644 --- a/src/Bannerlord.Diplomacy/ViewModel/GrantFiefSortControllerVM.cs +++ b/src/Bannerlord.Diplomacy/ViewModel/GrantFiefSortControllerVM.cs @@ -188,7 +188,6 @@ public override int Compare(GrantFiefItemVM? x, GrantFiefItemVM? y) { if (_isAcending) { - return Comparer.Default.Compare(x?.Settlement.Name.ToString(), y?.Settlement.Name.ToString()); } return Comparer.Default.Compare(y?.Settlement.Name.ToString(), x?.Settlement.Name.ToString()); @@ -201,7 +200,6 @@ public override int Compare(GrantFiefItemVM? x, GrantFiefItemVM? y) { if (_isAcending) { - return Comparer.Default.Compare(x?.Settlement.OwnerClan?.Name.ToString(), y?.Settlement.OwnerClan?.Name.ToString()); } return Comparer.Default.Compare(y?.Settlement.OwnerClan?.Name.ToString(), x?.Settlement.OwnerClan?.Name.ToString()); 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) {