From 4a9e6f6cc6d766e9e26e57eface23d28d5476cb2 Mon Sep 17 00:00:00 2001 From: Archi Date: Thu, 11 Jan 2024 16:46:45 +0100 Subject: [PATCH] Deprioritize bots with 1-game inventory Those are usually stash accounts, and while we still want to match them, we can leave them only as a last resort if no other bots are available. This decreases chance of hitting a bot that was just recently turned off or had its items traded away, as what usually happens with such accounts. --- .../Data/ListedUser.cs | 5 +++++ .../RemoteCommunication.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Data/ListedUser.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Data/ListedUser.cs index c6f71c56f..50b914b55 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Data/ListedUser.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Data/ListedUser.cs @@ -55,6 +55,11 @@ internal sealed class ListedUser { internal readonly ulong SteamID; #pragma warning restore CS0649 // False positive, the field is used during json deserialization +#pragma warning disable CS0649 // False positive, the field is used during json deserialization + [JsonProperty(Required = Required.Always)] + internal readonly uint TotalGamesCount; +#pragma warning restore CS0649 // False positive, the field is used during json deserialization + #pragma warning disable CS0649 // False positive, the field is used during json deserialization [JsonProperty(Required = Required.Always)] internal readonly uint TotalInventoryCount; diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs index a81495001..cb496feff 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs @@ -1226,7 +1226,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { byte failuresInRow = 0; uint matchedSets = 0; - foreach (ListedUser listedUser in listedUsers.Where(listedUser => (listedUser.SteamID != Bot.SteamID) && acceptedMatchableTypes.Any(listedUser.MatchableTypes.Contains) && !Bot.IsBlacklistedFromTrades(listedUser.SteamID)).OrderBy(listedUser => deprioritizedSteamIDs.Contains(listedUser.SteamID)).ThenByDescending(static listedUser => listedUser.MatchEverything).ThenBy(static listedUser => listedUser.TotalInventoryCount)) { + foreach (ListedUser listedUser in listedUsers.Where(listedUser => (listedUser.SteamID != Bot.SteamID) && acceptedMatchableTypes.Any(listedUser.MatchableTypes.Contains) && !Bot.IsBlacklistedFromTrades(listedUser.SteamID)).OrderByDescending(listedUser => !deprioritizedSteamIDs.Contains(listedUser.SteamID)).ThenByDescending(static listedUser => listedUser.TotalGamesCount > 1).ThenByDescending(static listedUser => listedUser.MatchEverything).ThenBy(static listedUser => listedUser.TotalInventoryCount)) { if (failuresInRow >= WebBrowser.MaxTries) { Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(failuresInRow)} >= {WebBrowser.MaxTries}"));