From 2ab5e6013de7b6e66b4e6a63a88a5a33b3e298e7 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Tue, 12 Apr 2016 16:36:09 +0200 Subject: [PATCH] Misc --- ArchiSteamFarm/CardsFarmer.cs | 63 ++++++++++++++++------------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index d23e9490d..cd86852a5 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -103,56 +103,51 @@ namespace ArchiSteamFarm { bool farmedSomething = false; - // Now the algorithm used for farming depends on whether account is restricted or not - if (Bot.BotConfig.CardDropsRestricted) { // If we have restricted card drops, we use complex algorithm - Logging.LogGenericInfo("Chosen farming algorithm: Complex", Bot.BotName); - while (GamesToFarm.Count > 0) { - HashSet gamesToFarmSolo = GetGamesToFarmSolo(GamesToFarm); - if (gamesToFarmSolo.Count > 0) { - while (gamesToFarmSolo.Count > 0) { - uint appID = gamesToFarmSolo.First(); - if (await FarmSolo(appID).ConfigureAwait(false)) { - farmedSomething = true; - gamesToFarmSolo.Remove(appID); - gamesToFarmSolo.TrimExcess(); + do { + // Now the algorithm used for farming depends on whether account is restricted or not + if (Bot.BotConfig.CardDropsRestricted) { // If we have restricted card drops, we use complex algorithm + Logging.LogGenericInfo("Chosen farming algorithm: Complex", Bot.BotName); + while (GamesToFarm.Count > 0) { + HashSet gamesToFarmSolo = GetGamesToFarmSolo(GamesToFarm); + if (gamesToFarmSolo.Count > 0) { + while (gamesToFarmSolo.Count > 0) { + uint appID = gamesToFarmSolo.First(); + if (await FarmSolo(appID).ConfigureAwait(false)) { + farmedSomething = true; + gamesToFarmSolo.Remove(appID); + gamesToFarmSolo.TrimExcess(); + } else { + NowFarming = false; + return; + } + } + } else { + if (FarmMultiple()) { + Logging.LogGenericInfo("Done farming: " + string.Join(", ", GamesToFarm.Keys), Bot.BotName); } else { NowFarming = false; return; } } - } else { - if (FarmMultiple()) { - Logging.LogGenericInfo("Done farming: " + string.Join(", ", GamesToFarm.Keys), Bot.BotName); + } + } else { // If we have unrestricted card drops, we use simple algorithm + Logging.LogGenericInfo("Chosen farming algorithm: Simple", Bot.BotName); + while (GamesToFarm.Count > 0) { + uint appID = GamesToFarm.Keys.FirstOrDefault(); + if (await FarmSolo(appID).ConfigureAwait(false)) { + farmedSomething = true; } else { NowFarming = false; return; } } } - } else { // If we have unrestricted card drops, we use simple algorithm - Logging.LogGenericInfo("Chosen farming algorithm: Simple", Bot.BotName); - while (GamesToFarm.Count > 0) { - uint appID = GamesToFarm.Keys.FirstOrDefault(); - if (await FarmSolo(appID).ConfigureAwait(false)) { - farmedSomething = true; - } else { - NowFarming = false; - return; - } - } - } + } while (await IsAnythingToFarm().ConfigureAwait(false)); CurrentGamesFarming.Clear(); CurrentGamesFarming.TrimExcess(); NowFarming = false; - // We finished our queue for now, make sure that everything is indeed farmed before proceeding further - // Some games could be added in the meantime - if (await IsAnythingToFarm().ConfigureAwait(false)) { - StartFarming().Forget(); - return; - } - Logging.LogGenericInfo("Farming finished!", Bot.BotName); await Bot.OnFarmingFinished(farmedSomething).ConfigureAwait(false); }