From 5c121bee755d31e22c9060904a3819dd656e91d7 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Tue, 22 Aug 2017 20:54:27 +0200 Subject: [PATCH] Misc complex algorithm optimization --- ArchiSteamFarm/CardsFarmer.cs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index 84920e740..fe11f43b4 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -582,20 +582,24 @@ namespace ArchiSteamFarm { // If we have restricted card drops, we use complex algorithm Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.ChosenFarmingAlgorithm, "Complex")); while (GamesToFarm.Count > 0) { - HashSet gamesToCheck = new HashSet(GamesToFarm.Where(game => game.HoursPlayed >= HoursToBump)); + HashSet gamesToCheck = new HashSet(GamesToFarm.Count > 1 ? GamesToFarm.Where(game => game.HoursPlayed >= HoursToBump) : GamesToFarm); - foreach (Game game in gamesToCheck) { - if (!await IsPlayableGame(game).ConfigureAwait(false)) { - GamesToFarm.Remove(game); - continue; + if (gamesToCheck.Count > 0) { + foreach (Game game in gamesToCheck) { + if (!await IsPlayableGame(game).ConfigureAwait(false)) { + GamesToFarm.Remove(game); + continue; + } + + if (await FarmSolo(game).ConfigureAwait(false)) { + continue; + } + + NowFarming = false; + return; } - if (await FarmSolo(game).ConfigureAwait(false)) { - continue; - } - - NowFarming = false; - return; + continue; } gamesToCheck = new HashSet(GamesToFarm.OrderByDescending(game => game.HoursPlayed)); @@ -713,7 +717,7 @@ namespace ArchiSteamFarm { Bot.IdleGames(games.Select(game => game.PlayableAppID)); bool success = true; - while (maxHour < 2) { + while (maxHour < HoursToBump) { Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.StillIdlingList, string.Join(", ", games.Select(game => game.AppID)))); DateTime startFarmingPeriod = DateTime.UtcNow;