From 6a5ce0a9045548769d2cbee56e202ea1f98b3bdd Mon Sep 17 00:00:00 2001 From: panthernet Date: Wed, 27 Jul 2016 15:16:12 +0300 Subject: [PATCH 1/2] + Added new translation strings and russian lang file --- .../Translations/translation.ru_RU.json | 120 ++++++++++++++++++ PoGo.NecroBot.CLI/ConsoleEventListener.cs | 12 +- PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj | 3 + PoGo.NecroBot.Logic/Common/Translations.cs | 23 +++- .../State/PositionCheckState.cs | 3 +- .../Tasks/DisplayPokemonStatsTask.cs | 19 +-- .../Tasks/FarmPokestopsGPXTask.cs | 2 +- PoGo.NecroBot.Logic/Utils/GPXReader.cs | 9 +- 8 files changed, 173 insertions(+), 18 deletions(-) create mode 100644 PoGo.NecroBot.CLI/Config/Translations/translation.ru_RU.json diff --git a/PoGo.NecroBot.CLI/Config/Translations/translation.ru_RU.json b/PoGo.NecroBot.CLI/Config/Translations/translation.ru_RU.json new file mode 100644 index 000000000..1a9a93fae --- /dev/null +++ b/PoGo.NecroBot.CLI/Config/Translations/translation.ru_RU.json @@ -0,0 +1,120 @@ +{ + "TranslationStrings": [ + { + "Key": "pokeball", + "Value": "PokeBall" + }, + { + "Key": "greatPokeball", + "Value": "GreatBall" + }, + { + "Key": "ultraPokeball", + "Value": "UltraBall" + }, + { + "Key": "masterPokeball", + "Value": "MasterBall" + }, + { + "Key": "wrongAuthType", + "Value": "Неизвестный AuthType в config.json" + }, + { + "Key": "farmPokestopsOutsideRadius", + "Value": "Вы находитесь вне указанного радиуса! Идем кк точке старта ({0}m away) через 5 сек. Ваш Coords.ini файл корректен?" + }, + { + "Key": "farmPokestopsNoUsableFound", + "Value": "Не найдено активных PokeStops в вашей зоне. Может указана слишком мальенькая максимальная дистанция поиска в настройках?" + }, + { + "Key": "eventFortUsed", + "Value": "XP: {0}, Gems: {1}, Предметов: {2}" + }, + { + "Key": "eventFortTargeted", + "Value": "{0} через ({1}m)" + }, + { + "Key": "eventProfileLogin", + "Value": "Играем за {0}" + }, + { + "Key": "eventUsedLuckyEgg", + "Value": "Использовано Lucky Egg, осталось: {0}" + }, + { + "Key": "eventPokemonEvolvedSuccess", + "Value": "{0} успешно за {1}xp" + }, + { + "Key": "eventPokemonEvolvedFailed", + "Value": "Не удалось {0}. Результат: {1}, прекращаем эволюционирование {2}" + }, + { + "Key": "eventPokemonTransferred", + "Value": "{0}\t- CP: {1} IV: {2}% [Лучший CP: {3} IV: {4}%] (Конфеток: {5})" + }, + { + "Key": "eventItemRecycled", + "Value": "{0}x {1}" + }, + { + "Key": "eventPokemonCapture", + "Value": "({0}) | ({1}) {2} Lvl: {3} CP: ({4}/{5}) IV: {6}% | Шанс: {7}% | {8}m дист | с {9} ({10} осталось). | {11}" + }, + { + "Key": "eventNoPokeballs", + "Value": "Нет Pokeball'ов - Мы упустили {0} с CP {1}" + }, + { + "Key": "catchStatusAttempt", + "Value": "{0} Попытка #{1}" + }, + { + "Key": "catchStatus", + "Value": "{0}" + }, + { + "Key": "candies", + "Value": "Конфеток: {0}" + }, + { + "Key": "unhandledGPXData", + "Value": "Неизвестные данные в GPX файле, пробуем пропустить." + }, + { + "Key": "displayHighestsHeader", + "Value": "ТОП покемонов" + }, + { + "Key": "commonWordPerfect", + "Value": "идеальный" + }, + { + "Key": "commonWordName", + "Value": "имя" + }, + { + "Key": "displayHighestsCPHeader", + "Value": "ТОП по CP" + }, + { + "Key": "displayHighestsPerfectHeader", + "Value": "ТОП по идеальным статам" + }, + { + "Key": "welcomeWarning", + "Value": "Убедитесь, что Широта и Долгота верны! Закройте программу если это не так! Широта: {0} Долгота: {1}" + }, + { + "Key": "incubatorPuttingEgg", + "Value": "Кладем яйцо в инкубатор: {0:0.00}км осталось" + }, + { + "Key": "incubatorStatusUpdate", + "Value": "Статус инкубатора: {0:0.00}км осталось" + } + ] +} \ No newline at end of file diff --git a/PoGo.NecroBot.CLI/ConsoleEventListener.cs b/PoGo.NecroBot.CLI/ConsoleEventListener.cs index 070f2c18f..966203a60 100644 --- a/PoGo.NecroBot.CLI/ConsoleEventListener.cs +++ b/PoGo.NecroBot.CLI/ConsoleEventListener.cs @@ -60,9 +60,9 @@ public void HandleEvent(ItemRecycledEvent evt, Context ctx) public void HandleEvent(EggIncubatorStatusEvent evt, Context ctx) { if (evt.WasAddedNow) - Logger.Write($"Putting egg in incubator: {evt.KmRemaining:0.00}km left"); + Logger.Write(ctx.Translations.GetTranslation(TranslationString.IncubatorPuttingEgg, evt.KmRemaining)); else - Logger.Write($"Incubator status update: {evt.KmRemaining:0.00}km left"); + Logger.Write(ctx.Translations.GetTranslation(TranslationString.IncubatorStatusUpdate, evt.KmRemaining)); } public void HandleEvent(FortUsedEvent evt, Context ctx) @@ -121,10 +121,14 @@ public void HandleEvent(UseBerryEvent evt, Context ctx) public void HandleEvent(DisplayHighestsPokemonEvent evt, Context ctx) { - Logger.Write($"====== DisplayHighests{evt.SortedBy} ======", LogLevel.Info, ConsoleColor.Yellow); + var strHeader = ctx.Translations.GetTranslation(TranslationString.DisplayHighestsHeader); + var strPerfect = ctx.Translations.GetTranslation(TranslationString.CommonWordPerfect); + var strName = ctx.Translations.GetTranslation(TranslationString.CommonWordName).ToUpper(); + + Logger.Write($"====== {strHeader}{evt.SortedBy} ======", LogLevel.Info, ConsoleColor.Yellow); foreach (var pokemon in evt.PokemonList) Logger.Write( - $"# CP {pokemon.Item1.Cp.ToString().PadLeft(4, ' ')}/{pokemon.Item2.ToString().PadLeft(4, ' ')} | ({pokemon.Item3.ToString("0.00")}% perfect)\t| Lvl {pokemon.Item4.ToString("00")}\t NAME: '{pokemon.Item1.PokemonId}'", + $"# CP {pokemon.Item1.Cp.ToString().PadLeft(4, ' ')}/{pokemon.Item2.ToString().PadLeft(4, ' ')} | ({pokemon.Item3.ToString("0.00")}% {strPerfect})\t| Lvl {pokemon.Item4.ToString("00")}\t {strName}: '{pokemon.Item1.PokemonId}'", LogLevel.Info, ConsoleColor.Yellow); } diff --git a/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj b/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj index 12f8c543b..3997c92ca 100644 --- a/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj +++ b/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj @@ -125,6 +125,9 @@ + + Always + Always diff --git a/PoGo.NecroBot.Logic/Common/Translations.cs b/PoGo.NecroBot.Logic/Common/Translations.cs index 8fd2bea0c..6016c3cf2 100644 --- a/PoGo.NecroBot.Logic/Common/Translations.cs +++ b/PoGo.NecroBot.Logic/Common/Translations.cs @@ -91,7 +91,19 @@ public string GetTranslation(TranslationString translationString) new KeyValuePair(Common.TranslationString.EventNoPokeballs, "No Pokeballs - We missed a {0} with CP {1}"), new KeyValuePair(Common.TranslationString.CatchStatusAttempt, "{0} Attempt #{1}"), new KeyValuePair(Common.TranslationString.CatchStatus, "{0}"), - new KeyValuePair(Common.TranslationString.Candies, "Candies: {0}") + new KeyValuePair(Common.TranslationString.Candies, "Candies: {0}"), + new KeyValuePair(Common.TranslationString.UnhandledGPXData, "Unhandled data in GPX file, attempting to skip."), + new KeyValuePair(Common.TranslationString.DisplayHighestsHeader, "DisplayHighests"), + new KeyValuePair(Common.TranslationString.CommonWordPerfect, "perfect"), + new KeyValuePair(Common.TranslationString.CommonWordName, "name"), + new KeyValuePair(Common.TranslationString.DisplayHighestsCPHeader, "DisplayHighestsCP"), + new KeyValuePair(Common.TranslationString.DisplayHighestsPerfectHeader, "DisplayHighestsPerfect"), + new KeyValuePair(Common.TranslationString.WelcomeWarning, "Make sure Lat & Lng are right. Exit Program if not! Lat: {0} Lng: {1}"), + new KeyValuePair(Common.TranslationString.IncubatorPuttingEgg, "Putting egg in incubator: {0:0.00}km left"), + new KeyValuePair(Common.TranslationString.IncubatorStatusUpdate, "Incubator status update: {0:0.00}km left"), + // + // + }; } @@ -119,5 +131,14 @@ public enum TranslationString CatchStatusAttempt, CatchStatus, Candies, + UnhandledGPXData, + DisplayHighestsHeader, + CommonWordPerfect, + CommonWordName, + DisplayHighestsCPHeader, + DisplayHighestsPerfectHeader, + WelcomeWarning, + IncubatorPuttingEgg, + IncubatorStatusUpdate, } } diff --git a/PoGo.NecroBot.Logic/State/PositionCheckState.cs b/PoGo.NecroBot.Logic/State/PositionCheckState.cs index ccf300be7..b73bb2a54 100644 --- a/PoGo.NecroBot.Logic/State/PositionCheckState.cs +++ b/PoGo.NecroBot.Logic/State/PositionCheckState.cs @@ -53,8 +53,7 @@ public async Task Execute(Context ctx, StateMachine machine) machine.Fire(new WarnEvent { - Message = - $"Make sure Lat & Lng are right. Exit Program if not! Lat: {ctx.Client.CurrentLatitude} Lng: {ctx.Client.CurrentLongitude}" + Message = ctx.Translations.GetTranslation(Common.TranslationString.WelcomeWarning, ctx.Client.CurrentLatitude, ctx.Client.CurrentLongitude) }); await Task.Delay(3000); diff --git a/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs b/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs index a86ff9943..9a3a2a25c 100644 --- a/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs @@ -1,10 +1,8 @@ -using PoGo.NecroBot.Logic.Logging; +using PoGo.NecroBot.Logic.Common; +using PoGo.NecroBot.Logic.Logging; using PoGo.NecroBot.Logic.PoGoUtils; using PoGo.NecroBot.Logic.State; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; namespace PoGo.NecroBot.Logic.Tasks @@ -13,18 +11,23 @@ public class DisplayPokemonStatsTask { public static async Task Execute(Context ctx, StateMachine machine) { - Logger.Write("====== DisplayHighestsCP ======", LogLevel.Info, ConsoleColor.Yellow); + var strHeader = ctx.Translations.GetTranslation(TranslationString.DisplayHighestsCPHeader); + var strPerfect = ctx.Translations.GetTranslation(TranslationString.CommonWordPerfect); + var strName = ctx.Translations.GetTranslation(TranslationString.CommonWordName).ToUpper(); + + Logger.Write($"====== {strHeader} ======", LogLevel.Info, ConsoleColor.Yellow); var highestsPokemonCp = await ctx.Inventory.GetHighestsCp(20); foreach (var pokemon in highestsPokemonCp) Logger.Write( - $"# CP {pokemon.Cp.ToString().PadLeft(4, ' ')}/{PokemonInfo.CalculateMaxCp(pokemon).ToString().PadLeft(4, ' ')} | ({PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% perfect)\t| Lvl {PokemonInfo.GetLevel(pokemon).ToString("00")}\t NAME: '{pokemon.PokemonId}'", + $"# CP {pokemon.Cp.ToString().PadLeft(4, ' ')}/{PokemonInfo.CalculateMaxCp(pokemon).ToString().PadLeft(4, ' ')} | ({PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% {strPerfect})\t| Lvl {PokemonInfo.GetLevel(pokemon).ToString("00")}\t {strName}: '{pokemon.PokemonId}'", LogLevel.Info, ConsoleColor.Yellow); - Logger.Write("====== DisplayHighestsPerfect ======", LogLevel.Info, ConsoleColor.Yellow); + strHeader = ctx.Translations.GetTranslation(TranslationString.DisplayHighestsPerfectHeader); + Logger.Write($"====== {strHeader} ======", LogLevel.Info, ConsoleColor.Yellow); var highestsPokemonPerfect = await ctx.Inventory.GetHighestsPerfect(20); foreach (var pokemon in highestsPokemonPerfect) { Logger.Write( - $"# CP {pokemon.Cp.ToString().PadLeft(4, ' ')}/{PokemonInfo.CalculateMaxCp(pokemon).ToString().PadLeft(4, ' ')} | ({PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% perfect)\t| Lvl {PokemonInfo.GetLevel(pokemon).ToString("00")}\t NAME: '{pokemon.PokemonId}'", + $"# CP {pokemon.Cp.ToString().PadLeft(4, ' ')}/{PokemonInfo.CalculateMaxCp(pokemon).ToString().PadLeft(4, ' ')} | ({PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% {strPerfect})\t| Lvl {PokemonInfo.GetLevel(pokemon).ToString("00")}\t {strName}: '{pokemon.PokemonId}'", LogLevel.Info, ConsoleColor.Yellow); } } diff --git a/PoGo.NecroBot.Logic/Tasks/FarmPokestopsGPXTask.cs b/PoGo.NecroBot.Logic/Tasks/FarmPokestopsGPXTask.cs index 3b669dd86..32b158e09 100644 --- a/PoGo.NecroBot.Logic/Tasks/FarmPokestopsGPXTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/FarmPokestopsGPXTask.cs @@ -135,7 +135,7 @@ await ctx.Navigation.HumanPathWalking(trackPoints.ElementAt(curTrkPt), private static List GetGpxTracks(Context ctx) { var xmlString = File.ReadAllText(ctx.LogicSettings.GpxFile); - var readgpx = new GpxReader(xmlString); + var readgpx = new GpxReader(xmlString, ctx); return readgpx.Tracks; } diff --git a/PoGo.NecroBot.Logic/Utils/GPXReader.cs b/PoGo.NecroBot.Logic/Utils/GPXReader.cs index cab03fa3f..4eef58222 100644 --- a/PoGo.NecroBot.Logic/Utils/GPXReader.cs +++ b/PoGo.NecroBot.Logic/Utils/GPXReader.cs @@ -6,6 +6,8 @@ using System.Collections.Generic; using System.Xml; using PoGo.NecroBot.Logic.Logging; +using PoGo.NecroBot.Logic.Common; +using PoGo.NecroBot.Logic.State; #endregion @@ -32,8 +34,11 @@ public class GpxReader public string UrlName = ""; public List WayPoints = new List(); - public GpxReader(string xml) + private Context _ctx; + + public GpxReader(string xml, Context ctx) { + _ctx = ctx; if (xml.Equals("")) return; _gpx.LoadXml(xml); if (_gpx.DocumentElement == null || !_gpx.DocumentElement.Name.Equals("gpx")) return; @@ -104,7 +109,7 @@ public GpxReader(string xml) case "topografix:map": break; default: - Logger.Write("Unhandled data in GPX file, attempting to skip.", LogLevel.Info); + Logger.Write(ctx.Translations.GetTranslation(TranslationString.UnhandledGPXData), LogLevel.Info); break; } } From 33d955cefbfa5e91a75b2e1e38439a2530f94d68 Mon Sep 17 00:00:00 2001 From: panthernet Date: Wed, 27 Jul 2016 15:41:14 +0300 Subject: [PATCH 2/2] + Translations fix --- .../Translations/translation.ru_RU.json | 4 ++++ PoGo.NecroBot.CLI/ConsoleEventListener.cs | 20 +++++++++++++++++-- PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj | 3 --- PoGo.NecroBot.Logic/Common/Translations.cs | 5 ++--- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/PoGo.NecroBot.CLI/Config/Translations/translation.ru_RU.json b/PoGo.NecroBot.CLI/Config/Translations/translation.ru_RU.json index 1a9a93fae..dc6f182b0 100644 --- a/PoGo.NecroBot.CLI/Config/Translations/translation.ru_RU.json +++ b/PoGo.NecroBot.CLI/Config/Translations/translation.ru_RU.json @@ -115,6 +115,10 @@ { "Key": "incubatorStatusUpdate", "Value": "Статус инкубатора: {0:0.00}км осталось" + }, + { + "Key": "displayHighestsLevelHeader", + "Value": "ТОП по уровню" } ] } \ No newline at end of file diff --git a/PoGo.NecroBot.CLI/ConsoleEventListener.cs b/PoGo.NecroBot.CLI/ConsoleEventListener.cs index 966203a60..3561a5bd8 100644 --- a/PoGo.NecroBot.CLI/ConsoleEventListener.cs +++ b/PoGo.NecroBot.CLI/ConsoleEventListener.cs @@ -121,11 +121,27 @@ public void HandleEvent(UseBerryEvent evt, Context ctx) public void HandleEvent(DisplayHighestsPokemonEvent evt, Context ctx) { - var strHeader = ctx.Translations.GetTranslation(TranslationString.DisplayHighestsHeader); + string strHeader; + //PokemonData | CP | IV | Level + switch (evt.SortedBy) + { + case "Level": + strHeader = ctx.Translations.GetTranslation(TranslationString.DisplayHighestsLevelHeader); + break; + case "IV": + strHeader = ctx.Translations.GetTranslation(TranslationString.DisplayHighestsPerfectHeader); + break; + case "CP": + strHeader = ctx.Translations.GetTranslation(TranslationString.DisplayHighestsCPHeader); + break; + default: + strHeader = ctx.Translations.GetTranslation(TranslationString.DisplayHighestsHeader); + break; + } var strPerfect = ctx.Translations.GetTranslation(TranslationString.CommonWordPerfect); var strName = ctx.Translations.GetTranslation(TranslationString.CommonWordName).ToUpper(); - Logger.Write($"====== {strHeader}{evt.SortedBy} ======", LogLevel.Info, ConsoleColor.Yellow); + Logger.Write($"====== {strHeader} ======", LogLevel.Info, ConsoleColor.Yellow); foreach (var pokemon in evt.PokemonList) Logger.Write( $"# CP {pokemon.Item1.Cp.ToString().PadLeft(4, ' ')}/{pokemon.Item2.ToString().PadLeft(4, ' ')} | ({pokemon.Item3.ToString("0.00")}% {strPerfect})\t| Lvl {pokemon.Item4.ToString("00")}\t {strName}: '{pokemon.Item1.PokemonId}'", diff --git a/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj b/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj index e0b0a97b9..b58e0e65c 100644 --- a/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj +++ b/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj @@ -105,9 +105,6 @@ - - Always - Always diff --git a/PoGo.NecroBot.Logic/Common/Translations.cs b/PoGo.NecroBot.Logic/Common/Translations.cs index 92eef5906..a4f996d18 100644 --- a/PoGo.NecroBot.Logic/Common/Translations.cs +++ b/PoGo.NecroBot.Logic/Common/Translations.cs @@ -98,12 +98,10 @@ public string GetTranslation(TranslationString translationString) new KeyValuePair(Common.TranslationString.CommonWordName, "name"), new KeyValuePair(Common.TranslationString.DisplayHighestsCPHeader, "DisplayHighestsCP"), new KeyValuePair(Common.TranslationString.DisplayHighestsPerfectHeader, "DisplayHighestsPerfect"), + new KeyValuePair(Common.TranslationString.DisplayHighestsLevelHeader, "DisplayHighestsLevel"), new KeyValuePair(Common.TranslationString.WelcomeWarning, "Make sure Lat & Lng are right. Exit Program if not! Lat: {0} Lng: {1}"), new KeyValuePair(Common.TranslationString.IncubatorPuttingEgg, "Putting egg in incubator: {0:0.00}km left"), new KeyValuePair(Common.TranslationString.IncubatorStatusUpdate, "Incubator status update: {0:0.00}km left"), - // - // - }; } @@ -140,5 +138,6 @@ public enum TranslationString WelcomeWarning, IncubatorPuttingEgg, IncubatorStatusUpdate, + DisplayHighestsLevelHeader, } }