diff --git a/ArchiSteamFarm/Statistics.cs b/ArchiSteamFarm/Statistics.cs index d65fa499e..c49df1442 100644 --- a/ArchiSteamFarm/Statistics.cs +++ b/ArchiSteamFarm/Statistics.cs @@ -34,6 +34,7 @@ using Newtonsoft.Json; namespace ArchiSteamFarm { internal sealed class Statistics : IAsyncDisposable { + private const ushort MaxItemsForFairBots = 30000; // Determines which fair bots we'll skip when matching due to excessive number of inventory requests they need to make, which are likely to fail in the process or cause excessive delays private const byte MaxMatchedBotsHard = 40; // Determines how many bots we can attempt to match in total, where match attempt is equal to analyzing bot's inventory private const byte MaxMatchedBotsSoft = MaxMatchedBotsHard / 2; // Determines how many consecutive empty matches we need to get before we decide to skip bots from the same category private const byte MaxMatchingRounds = 10; // Determines maximum amount of matching rounds we're going to consider before leaving the rest of work for the next batch @@ -400,7 +401,7 @@ namespace ArchiSteamFarm { HashSet<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)> skippedSetsThisRound = new HashSet<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)>(); - foreach (ListedUser listedUser in listedUsers.Where(listedUser => (listedUser.SteamID != Bot.SteamID) && acceptedMatchableTypes.Any(listedUser.MatchableTypes.Contains) && (!triedSteamIDs.TryGetValue(listedUser.SteamID, out (byte Tries, ISet GivenAssetIDs, ISet ReceivedAssetIDs) attempt) || (attempt.Tries < byte.MaxValue)) && !Bot.IsBlacklistedFromTrades(listedUser.SteamID)).OrderBy(listedUser => triedSteamIDs.TryGetValue(listedUser.SteamID, out (byte Tries, ISet GivenAssetIDs, ISet ReceivedAssetIDs) attempt) ? attempt.Tries : 0).ThenByDescending(listedUser => listedUser.MatchEverything).ThenByDescending(listedUser => listedUser.Score)) { + foreach (ListedUser listedUser in listedUsers.Where(listedUser => (listedUser.SteamID != Bot.SteamID) && (listedUser.MatchEverything || (listedUser.ItemsCount < MaxItemsForFairBots)) && acceptedMatchableTypes.Any(listedUser.MatchableTypes.Contains) && (!triedSteamIDs.TryGetValue(listedUser.SteamID, out (byte Tries, ISet GivenAssetIDs, ISet ReceivedAssetIDs) attempt) || (attempt.Tries < byte.MaxValue)) && !Bot.IsBlacklistedFromTrades(listedUser.SteamID)).OrderBy(listedUser => triedSteamIDs.TryGetValue(listedUser.SteamID, out (byte Tries, ISet GivenAssetIDs, ISet ReceivedAssetIDs) attempt) ? attempt.Tries : 0).ThenByDescending(listedUser => listedUser.MatchEverything).ThenByDescending(listedUser => listedUser.Score)) { if (listedUser.MatchEverything && skipAnyBots) { continue; } @@ -696,6 +697,11 @@ namespace ArchiSteamFarm { [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] private sealed class ListedUser { +#pragma warning disable 649 + [JsonProperty(PropertyName = "items_count", Required = Required.Always)] + internal readonly ushort ItemsCount; +#pragma warning restore 649 + internal readonly HashSet MatchableTypes = new HashSet(); #pragma warning disable 649 @@ -715,11 +721,6 @@ namespace ArchiSteamFarm { private readonly ushort GamesCount; #pragma warning restore 649 -#pragma warning disable 649 - [JsonProperty(PropertyName = "items_count", Required = Required.Always)] - private readonly ushort ItemsCount; -#pragma warning restore 649 - internal bool MatchEverything { get; private set; } #pragma warning disable IDE0051