private async Task <bool> FarmHours(IReadOnlyCollection <Game> games) { if ((games == null) || (games.Count == 0)) { Bot.ArchiLogger.LogNullError(nameof(games)); return(false); } float maxHour = games.Max(game => game.HoursPlayed); if (maxHour < 0) { Bot.ArchiLogger.LogNullError(nameof(maxHour)); return(false); } if (maxHour >= Bot.BotConfig.HoursUntilCardDrops) { Bot.ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsInvalid, nameof(maxHour))); return(true); } await Bot.IdleGames(games).ConfigureAwait(false); bool success = true; while (maxHour < Bot.BotConfig.HoursUntilCardDrops) { Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.StillIdlingList, string.Join(", ", games.Select(game => game.AppID)))); DateTime startFarmingPeriod = DateTime.UtcNow; if (await FarmingResetSemaphore.WaitAsync((ASF.GlobalConfig.FarmingDelay * 60 * 1000) + (ExtraFarmingDelaySeconds * 1000)).ConfigureAwait(false)) { success = KeepFarming; } // Don't forget to update our GamesToFarm hours float timePlayed = (float)DateTime.UtcNow.Subtract(startFarmingPeriod).TotalHours; foreach (Game game in games) { game.HoursPlayed += timePlayed; } if (!success) { break; } maxHour += timePlayed; } Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.StoppedIdlingList, string.Join(", ", games.Select(game => game.AppID)))); return(success); }