diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index 560b3d6b0..eb2a1a66b 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -29,6 +29,7 @@ using System.Linq; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using ArchiSteamFarm.Localization; using HtmlAgilityPack; using Newtonsoft.Json; @@ -134,7 +135,7 @@ namespace ArchiSteamFarm { internal void Resume(bool userAction) { if (StickyPause) { if (!userAction) { - Bot.ArchiLogger.LogGenericInfo("Not honoring this request, as sticky pause is enabled!"); + Bot.ArchiLogger.LogGenericInfo(Strings.IgnoredStickyPauseEnabled); return; } @@ -167,7 +168,7 @@ namespace ArchiSteamFarm { } if (!await IsAnythingToFarm().ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericInfo("We don't have anything to farm on this account!"); + Bot.ArchiLogger.LogGenericInfo(Strings.NothingToIdle); await Bot.OnFarmingFinished(false).ConfigureAwait(false); return; } @@ -177,11 +178,11 @@ namespace ArchiSteamFarm { return; } - Bot.ArchiLogger.LogGenericInfo("We have a total of " + GamesToFarm.Count + " games (" + GamesToFarm.Sum(game => game.CardsRemaining) + " cards) left to farm (~" + TimeRemaining.ToHumanReadable() + " remaining)..."); + Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.GamesToIdle, GamesToFarm.Count, GamesToFarm.Sum(game => game.CardsRemaining), TimeRemaining.ToHumanReadable())); // This is the last moment for final check if we can farm if (!Bot.IsPlayingPossible) { - Bot.ArchiLogger.LogGenericInfo("But farming is currently unavailable, we'll try later!"); + Bot.ArchiLogger.LogGenericInfo(Strings.PlayingNotAvailable); return; } @@ -193,7 +194,7 @@ namespace ArchiSteamFarm { 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 - Bot.ArchiLogger.LogGenericInfo("Chosen farming algorithm: Complex"); + Bot.ArchiLogger.LogGenericInfo(string.Join(Strings.ChosenFarmingAlgorithm, "Complex")); while (GamesToFarm.Count > 0) { HashSet gamesToFarmSolo = GamesToFarm.Count > 1 ? new HashSet(GamesToFarm.Where(game => game.HoursPlayed >= HoursToBump)) : new HashSet(GamesToFarm); if (gamesToFarmSolo.Count > 0) { @@ -208,7 +209,7 @@ namespace ArchiSteamFarm { } } else { if (FarmMultiple(GamesToFarm.OrderByDescending(game => game.HoursPlayed).Take(ArchiHandler.MaxGamesPlayedConcurrently))) { - Bot.ArchiLogger.LogGenericInfo("Done farming: " + string.Join(", ", GamesToFarm.Select(game => game.AppID))); + Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.IdlingFinishedForGames, string.Join(", ", GamesToFarm.Select(game => game.AppID)))); } else { NowFarming = false; return; @@ -216,7 +217,7 @@ namespace ArchiSteamFarm { } } } else { // If we have unrestricted card drops, we use simple algorithm - Bot.ArchiLogger.LogGenericInfo("Chosen farming algorithm: Simple"); + Bot.ArchiLogger.LogGenericInfo(string.Join(Strings.ChosenFarmingAlgorithm, "Simple")); while (GamesToFarm.Count > 0) { Game game = GamesToFarm.First(); if (await FarmSolo(game).ConfigureAwait(false)) { @@ -232,7 +233,7 @@ namespace ArchiSteamFarm { CurrentGamesFarming.ClearAndTrim(); NowFarming = false; - Bot.ArchiLogger.LogGenericInfo("Farming finished!"); + Bot.ArchiLogger.LogGenericInfo(Strings.IdlingFinished); await Bot.OnFarmingFinished(true).ConfigureAwait(false); } @@ -248,21 +249,18 @@ namespace ArchiSteamFarm { return; } - Bot.ArchiLogger.LogGenericInfo("Sending signal to stop farming"); KeepFarming = false; FarmResetEvent.Set(); - Bot.ArchiLogger.LogGenericInfo("Waiting for reaction..."); for (byte i = 0; (i < 5) && NowFarming; i++) { await Task.Delay(1000).ConfigureAwait(false); } if (NowFarming) { - Bot.ArchiLogger.LogGenericWarning("Timed out!"); NowFarming = false; } - Bot.ArchiLogger.LogGenericInfo("Farming stopped!"); + Bot.ArchiLogger.LogGenericInfo(Strings.IdlingStopped); Bot.OnFarmingStopped(); } finally { FarmingSemaphore.Release(); @@ -277,7 +275,7 @@ namespace ArchiSteamFarm { ushort? cardsRemaining = await GetCardsRemaining(appID).ConfigureAwait(false); if (!cardsRemaining.HasValue) { - Bot.ArchiLogger.LogGenericWarning("Could not check cards status for " + appID + " (" + name + "), will try again later!"); + Bot.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningCouldNotCheckCardsStatus, appID, name)); return; } @@ -511,7 +509,7 @@ namespace ArchiSteamFarm { bool? keepFarming = await ShouldFarm(game).ConfigureAwait(false); while (keepFarming.GetValueOrDefault(true) && (DateTime.Now < endFarmingDate)) { - Bot.ArchiLogger.LogGenericInfo("Still farming: " + game.AppID + " (" + game.GameName + ")"); + Bot.ArchiLogger.LogGenericInfo(string.Join(Strings.StillIdling, game.AppID, game.GameName)); DateTime startFarmingPeriod = DateTime.Now; if (FarmResetEvent.Wait(60 * 1000 * Program.GlobalConfig.FarmingDelay)) { @@ -529,7 +527,7 @@ namespace ArchiSteamFarm { keepFarming = await ShouldFarm(game).ConfigureAwait(false); } - Bot.ArchiLogger.LogGenericInfo("Stopped farming: " + game.AppID + " (" + game.GameName + ")"); + Bot.ArchiLogger.LogGenericInfo(string.Join(Strings.StoppedIdling, game.AppID, game.GameName)); return success; } @@ -546,7 +544,7 @@ namespace ArchiSteamFarm { } if (maxHour >= HoursToBump) { - Bot.ArchiLogger.LogGenericError("Received request for already boosted games!"); + Bot.ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsInvalid, nameof(maxHour))); return true; } @@ -554,7 +552,7 @@ namespace ArchiSteamFarm { bool success = true; while (maxHour < 2) { - Bot.ArchiLogger.LogGenericInfo("Still farming: " + string.Join(", ", games.Select(game => game.AppID))); + Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.StillIdlingList, string.Join(", ", games.Select(game => game.AppID)))); DateTime startFarmingPeriod = DateTime.Now; if (FarmResetEvent.Wait(60 * 1000 * Program.GlobalConfig.FarmingDelay)) { @@ -575,7 +573,7 @@ namespace ArchiSteamFarm { maxHour += timePlayed; } - Bot.ArchiLogger.LogGenericInfo("Stopped farming: " + string.Join(", ", games.Select(game => game.AppID))); + Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.StoppedIdlingList, string.Join(", ", games.Select(game => game.AppID)))); return success; } @@ -587,7 +585,7 @@ namespace ArchiSteamFarm { CurrentGamesFarming.ReplaceWith(games); - Bot.ArchiLogger.LogGenericInfo("Now farming: " + string.Join(", ", CurrentGamesFarming.Select(game => game.AppID))); + Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.NowIdlingList, string.Join(", ", CurrentGamesFarming.Select(game => game.AppID)))); bool result = FarmHours(CurrentGamesFarming); CurrentGamesFarming.ClearAndTrim(); @@ -602,7 +600,7 @@ namespace ArchiSteamFarm { CurrentGamesFarming.Add(game); - Bot.ArchiLogger.LogGenericInfo("Now farming: " + game.AppID + " (" + game.GameName + ")"); + Bot.ArchiLogger.LogGenericInfo(string.Join(Strings.NowIdling, game.AppID, game.GameName)); bool result = await Farm(game).ConfigureAwait(false); CurrentGamesFarming.ClearAndTrim(); @@ -613,7 +611,7 @@ namespace ArchiSteamFarm { GamesToFarm.Remove(game); - Bot.ArchiLogger.LogGenericInfo("Done farming: " + game.AppID + " (" + game.GameName + ")" + (game.HoursPlayed > 0 ? " after " + TimeSpan.FromHours(game.HoursPlayed).ToHumanReadable() + " of playtime!" : "")); + Bot.ArchiLogger.LogGenericInfo(string.Join(Strings.IdlingFinishedForGame, game.AppID, game.GameName, TimeSpan.FromHours(game.HoursPlayed).ToHumanReadable())); return true; } @@ -651,13 +649,11 @@ namespace ArchiSteamFarm { } private async Task IsAnythingToFarm() { - Bot.ArchiLogger.LogGenericInfo("Checking badges..."); - // Find the number of badge pages - Bot.ArchiLogger.LogGenericInfo("Checking first page..."); + Bot.ArchiLogger.LogGenericInfo(Strings.CheckingFirstBadgePage); HtmlDocument htmlDocument = await Bot.ArchiWebHandler.GetBadgePage(1).ConfigureAwait(false); if (htmlDocument == null) { - Bot.ArchiLogger.LogGenericWarning("Could not get badges information, will try again later!"); + Bot.ArchiLogger.LogGenericWarning(Strings.WarningCouldNotCheckBadges); return false; } @@ -682,7 +678,7 @@ namespace ArchiSteamFarm { List tasks = new List(maxPages - 1) { CheckPage(htmlDocument) }; if (maxPages > 1) { - Bot.ArchiLogger.LogGenericInfo("Checking other pages..."); + Bot.ArchiLogger.LogGenericInfo(Strings.CheckingOtherBadgePages); for (byte page = 2; page <= maxPages; page++) { byte currentPage = page; // We need a copy of variable being passed when in for loops, as loop will proceed before task is launched @@ -703,13 +699,13 @@ namespace ArchiSteamFarm { ushort? cardsRemaining = await GetCardsRemaining(game.AppID).ConfigureAwait(false); if (!cardsRemaining.HasValue) { - Bot.ArchiLogger.LogGenericWarning("Could not check cards status for " + game.AppID + " (" + game.GameName + "), will try again later!"); + Bot.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningCouldNotCheckCardsStatus, game.AppID, game.GameName)); return null; } game.CardsRemaining = cardsRemaining.Value; - Bot.ArchiLogger.LogGenericInfo("Status for " + game.AppID + " (" + game.GameName + "): " + game.CardsRemaining + " cards remaining"); + Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.IdlingStatusForGame, game.AppID, game.GameName, game.CardsRemaining)); return game.CardsRemaining > 0; } @@ -743,7 +739,7 @@ namespace ArchiSteamFarm { gamesToFarm = GamesToFarm.OrderByDescending(game => game.GameName); break; default: - Bot.ArchiLogger.LogGenericError("Unhandled case: " + Bot.BotConfig.FarmingOrder); + Bot.ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsInvalid, nameof(Bot.BotConfig.FarmingOrder))); return; } diff --git a/ArchiSteamFarm/Localization/Strings.Designer.cs b/ArchiSteamFarm/Localization/Strings.Designer.cs index edb452352..7c78b8720 100644 --- a/ArchiSteamFarm/Localization/Strings.Designer.cs +++ b/ArchiSteamFarm/Localization/Strings.Designer.cs @@ -78,6 +78,33 @@ namespace ArchiSteamFarm.Localization { } } + /// + /// Looks up a localized string similar to Checking first badge page.... + /// + internal static string CheckingFirstBadgePage { + get { + return ResourceManager.GetString("CheckingFirstBadgePage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Checking other badge pages.... + /// + internal static string CheckingOtherBadgePages { + get { + return ResourceManager.GetString("CheckingOtherBadgePages", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Chosen farming algorithm: {0}. + /// + internal static string ChosenFarmingAlgorithm { + get { + return ResourceManager.GetString("ChosenFarmingAlgorithm", resourceCulture); + } + } + /// /// Looks up a localized string similar to Content: ///{0}. @@ -288,6 +315,15 @@ namespace ArchiSteamFarm.Localization { } } + /// + /// Looks up a localized string similar to We have a total of {0} games ({1} cards) left to idle (~{3} remaining).... + /// + internal static string GamesToIdle { + get { + return ResourceManager.GetString("GamesToIdle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Global config file has been changed!. /// @@ -297,6 +333,60 @@ namespace ArchiSteamFarm.Localization { } } + /// + /// Looks up a localized string similar to Idling finished!. + /// + internal static string IdlingFinished { + get { + return ResourceManager.GetString("IdlingFinished", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finished idling: {0} ({1}) after {2} of playtime!. + /// + internal static string IdlingFinishedForGame { + get { + return ResourceManager.GetString("IdlingFinishedForGame", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finished idling games: {0}. + /// + internal static string IdlingFinishedForGames { + get { + return ResourceManager.GetString("IdlingFinishedForGames", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Idling status for {0} ({1}): {2} cards remaining. + /// + internal static string IdlingStatusForGame { + get { + return ResourceManager.GetString("IdlingStatusForGame", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Idling stopped!. + /// + internal static string IdlingStopped { + get { + return ResourceManager.GetString("IdlingStopped", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Not honoring this request, as sticky pause is enabled!. + /// + internal static string IgnoredStickyPauseEnabled { + get { + return ResourceManager.GetString("IgnoredStickyPauseEnabled", resourceCulture); + } + } + /// /// Looks up a localized string similar to Ignoring trade: {0}. /// @@ -324,6 +414,42 @@ namespace ArchiSteamFarm.Localization { } } + /// + /// Looks up a localized string similar to We don't have anything to idle on this account!. + /// + internal static string NothingToIdle { + get { + return ResourceManager.GetString("NothingToIdle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Now idling: {0} ({1}). + /// + internal static string NowIdling { + get { + return ResourceManager.GetString("NowIdling", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Now idling: {0}. + /// + internal static string NowIdlingList { + get { + return ResourceManager.GetString("NowIdlingList", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Playing is currently unavailable, we'll try again later!. + /// + internal static string PlayingNotAvailable { + get { + return ResourceManager.GetString("PlayingNotAvailable", resourceCulture); + } + } + /// /// Looks up a localized string similar to Refreshing our session!. /// @@ -387,6 +513,42 @@ namespace ArchiSteamFarm.Localization { } } + /// + /// Looks up a localized string similar to Still idling: {0} ({1}). + /// + internal static string StillIdling { + get { + return ResourceManager.GetString("StillIdling", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Still idling: {0}. + /// + internal static string StillIdlingList { + get { + return ResourceManager.GetString("StillIdlingList", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Stopped idling: {0} ({1}). + /// + internal static string StoppedIdling { + get { + return ResourceManager.GetString("StoppedIdling", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Stopped idling: {0}. + /// + internal static string StoppedIdlingList { + get { + return ResourceManager.GetString("StoppedIdlingList", resourceCulture); + } + } + /// /// Looks up a localized string similar to Success!. /// @@ -594,6 +756,24 @@ namespace ArchiSteamFarm.Localization { } } + /// + /// Looks up a localized string similar to Could not get badges information, we will try again later!. + /// + internal static string WarningCouldNotCheckBadges { + get { + return ResourceManager.GetString("WarningCouldNotCheckBadges", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Could not check cards status for: {0} ({1}), we will try again later!. + /// + internal static string WarningCouldNotCheckCardsStatus { + get { + return ResourceManager.GetString("WarningCouldNotCheckCardsStatus", resourceCulture); + } + } + /// /// Looks up a localized string similar to Failed!. /// diff --git a/ArchiSteamFarm/Localization/Strings.resx b/ArchiSteamFarm/Localization/Strings.resx index 506c67bfe..d36d9da32 100644 --- a/ArchiSteamFarm/Localization/Strings.resx +++ b/ArchiSteamFarm/Localization/Strings.resx @@ -371,4 +371,76 @@ StackTrace: Starting WCF server on {0}... {0} will be replaced by WCF hostname + + Checking first badge page... + + + Checking other badge pages... + + + Chosen farming algorithm: {0} + {0} will be replaced by the name of chosen farming algorithm + + + We have a total of {0} games ({1} cards) left to idle (~{3} remaining)... + {0} will be replaced by number of games, {1} will be replaced by number of cards, {2} will be replaced by translated TimeSpan string built from TimeSpan* translation parts + + + Idling finished! + + + Finished idling: {0} ({1}) after {2} of playtime! + {0} will be replaced by game's appID (number), {1} will be replaced by game's name, {2} will be replaced by translated TimeSpan string built from TimeSpan* translation parts + + + Finished idling games: {0} + {0} will be replaced by list of the games (appIDs, numbers), separated by a comma + + + Idling status for {0} ({1}): {2} cards remaining + {0} will be replaced by game's appID (number), {1} will be replaced by game's name, {2} will be replaced by number of cards left to idle + + + Idling stopped! + + + Not honoring this request, as sticky pause is enabled! + + + We don't have anything to idle on this account! + + + Now idling: {0} ({1}) + {0} will be replaced by game's appID (number), {1} will be replaced by game's name + + + Now idling: {0} + {0} will be replaced by list of the games (appIDs, numbers), separated by a comma + + + Playing is currently unavailable, we'll try again later! + + + Still idling: {0} ({1}) + {0} will be replaced by game's appID (number), {1} will be replaced by game's name + + + Still idling: {0} + {0} will be replaced by list of the games (appIDs, numbers), separated by a comma + + + Stopped idling: {0} ({1}) + {0} will be replaced by game's appID (number), {1} will be replaced by game's name + + + Stopped idling: {0} + {0} will be replaced by list of the games (appIDs, numbers), separated by a comma + + + Could not get badges information, we will try again later! + + + Could not check cards status for: {0} ({1}), we will try again later! + {0} will be replaced by game's appID (number), {1} will be replaced by game's name + \ No newline at end of file diff --git a/ArchiSteamFarm/Utilities.cs b/ArchiSteamFarm/Utilities.cs index 28b0fb0db..a5295aa77 100644 --- a/ArchiSteamFarm/Utilities.cs +++ b/ArchiSteamFarm/Utilities.cs @@ -100,7 +100,7 @@ namespace ArchiSteamFarm { } if (result.Length == 0) { - return ""; + return string.Format(Strings.TimeSpanSeconds, 0); } // Get rid of last comma + space