diff --git a/PoGo.PokeMobBot.CLI/Config/Translations/translation.de.json b/PoGo.PokeMobBot.CLI/Config/Translations/translation.de.json index 9138918..1d08931 100644 --- a/PoGo.PokeMobBot.CLI/Config/Translations/translation.de.json +++ b/PoGo.PokeMobBot.CLI/Config/Translations/translation.de.json @@ -83,7 +83,7 @@ }, { "Key": "eventUseLuckyEggMinPokemonCheck", - "Value": "Not enough Pokemon to trigger a lucky egg. Waiting for {0} more. ({1}/{2})" + "Value": "Nicht genug Pokemon vorhanden um Glücks-Ei zu benutzen. Warte auf {0} mehr. ({1}/{2})" }, { "Key": "eventPokemonEvolvedSuccess", @@ -325,7 +325,7 @@ }, { "Key": "UseBerry", - "Value": "Benutze Himbeere. Verbleibend: {0}" + "Value": "Benutze Himmihbeere. Verbleibend: {0}" } ], "pokemon": [ diff --git a/PoGo.PokeMobBot.Logic/DataDumper/Dumper.cs b/PoGo.PokeMobBot.Logic/DataDumper/Dumper.cs index dd1f0e8..a0bde3a 100644 --- a/PoGo.PokeMobBot.Logic/DataDumper/Dumper.cs +++ b/PoGo.PokeMobBot.Logic/DataDumper/Dumper.cs @@ -60,7 +60,7 @@ public static void Dump(ISession session, string data, string filename, string e private static void DumpToFile(ISession session, string data, string filename, string extension = "txt") { var path = Path.Combine(session.LogicSettings.ProfilePath, "Dumps", - $"PokeMobBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}"); + $"PokeMobBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH:mm:ss")}.{extension}"); try { diff --git a/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs index c48bbbe..1e39aa1 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs @@ -1,10 +1,13 @@ #region using directives +using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using PoGo.PokeMobBot.Logic.Common; using PoGo.PokeMobBot.Logic.Event; using PoGo.PokeMobBot.Logic.Logging; +using PoGo.PokeMobBot.Logic.PoGoUtils; using PoGo.PokeMobBot.Logic.State; using POGOProtos.Map.Fort; using POGOProtos.Networking.Responses; @@ -15,6 +18,8 @@ namespace PoGo.PokeMobBot.Logic.Tasks { public static class CatchLurePokemonsTask { + private static HashSet cache; + public static async Task Execute(ISession session, FortData currentFortData, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -41,6 +46,21 @@ public static async Task Execute(ISession session, FortData currentFortData, Can var encounterId = currentFortData.LureInfo.EncounterId; var encounter = await session.Client.Encounter.EncounterLurePokemon(encounterId, fortId); + // Feed this encounter back to the snipe server + if (session.LogicSettings.UseSnipeLocationServer) + { + var payload = new SniperInfo + { + Latitude = currentFortData.Latitude, + Longitude = currentFortData.Longitude, + Iv = PokemonInfo.CalculatePokemonPerfection(encounter.PokemonData), + Id = encounter.PokemonData.PokemonId, + Move1 = encounter.PokemonData.Move1, + Move2 = encounter.PokemonData.Move2, + }; + SnipePokemonTask.Feedback(payload); + } + if (encounter.Result == DiskEncounterResponse.Types.Result.Success) { await CatchPokemonTask.Execute(session, encounter, null, currentFortData, encounterId); diff --git a/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs index 23eb9a5..bcece0e 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs @@ -1,11 +1,14 @@ #region using directives +using System; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Newtonsoft.Json; using PoGo.PokeMobBot.Logic.Common; using PoGo.PokeMobBot.Logic.Event; using PoGo.PokeMobBot.Logic.Logging; +using PoGo.PokeMobBot.Logic.PoGoUtils; using PoGo.PokeMobBot.Logic.State; using PoGo.PokeMobBot.Logic.Utils; using POGOProtos.Inventory.Item; @@ -57,6 +60,21 @@ public static async Task Execute(ISession session, CancellationToken cancellatio var encounter = await session.Client.Encounter.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnPointId); + // Feed this encounter back to the snipe server + if (session.LogicSettings.UseSnipeLocationServer) + { + var payload = new SniperInfo + { + Latitude = encounter.WildPokemon.Latitude, + Longitude = encounter.WildPokemon.Longitude, + Iv = PokemonInfo.CalculatePokemonPerfection(encounter.WildPokemon.PokemonData), + Id = encounter.WildPokemon.PokemonData.PokemonId, + Move1 = encounter.WildPokemon.PokemonData.Move1, + Move2 = encounter.WildPokemon.PokemonData.Move2, + }; + SnipePokemonTask.Feedback(payload); + } + if (encounter.Status == EncounterResponse.Types.Status.EncounterSuccess) { await CatchPokemonTask.Execute(session, encounter, pokemon); diff --git a/PoGo.PokeMobBot.Logic/Tasks/RecycleItemsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/RecycleItemsTask.cs index 3ecfc23..a415e8e 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/RecycleItemsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/RecycleItemsTask.cs @@ -263,28 +263,6 @@ private static async Task OptimizedRecycleRevives(ISession session, Cancellation await DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500); } } - - if (diff > 0) - { - int maxRevivesToKeep = maxReviveCount - diff; - if (maxRevivesToKeep < 0) - { - maxRevivesToKeep = 0; - } - maxRevivesToRecycle = maxReviveCount - maxRevivesToKeep; - - if (maxRevivesToRecycle != 0) - { - diff -= maxRevivesToRecycle; - cancellationToken.ThrowIfCancellationRequested(); - await session.Client.Inventory.RecycleItem(ItemId.ItemMaxRevive, maxRevivesToRecycle); - session.EventDispatcher.Send(new ItemRecycledEvent { Id = ItemId.ItemMaxRevive, Count = maxRevivesToRecycle }); - if (session.LogicSettings.Teleport) - await Task.Delay(session.LogicSettings.DelayRecyleItem); - else - await DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500); - } - } } } } diff --git a/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs b/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs index 16d32ea..5b34603 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs @@ -12,6 +12,7 @@ using Newtonsoft.Json; using PoGo.PokeMobBot.Logic.Common; using PoGo.PokeMobBot.Logic.Event; +using PoGo.PokeMobBot.Logic.Logging; using PoGo.PokeMobBot.Logic.State; using PoGo.PokeMobBot.Logic.PoGoUtils; using POGOProtos.Enums; @@ -30,6 +31,8 @@ public class SniperInfo public double Iv { get; set; } public DateTime TimeStamp { get; set; } public PokemonId Id { get; set; } + public PokemonMove Move1 { get; set; } + public PokemonMove Move2 { get; set; } [JsonIgnore] public DateTime TimeStampAdded { get; set; } = DateTime.Now; @@ -88,6 +91,8 @@ public static class SnipePokemonTask public static List LocsVisited = new List(); private static readonly List SnipeLocations = new List(); private static DateTime _lastSnipe = DateTime.MinValue; + private static StreamReader Reader; + private static StreamWriter Writer; public static Task AsyncStart(Session session, CancellationToken cancellationToken = default(CancellationToken)) { @@ -516,7 +521,7 @@ public static async Task Start(Session session, CancellationToken cancellationTo var currentTimestamp = t.TotalMilliseconds; var pokemonIds = session.LogicSettings.PokemonToSnipe.Pokemon; - var formatter = new NumberFormatInfo { NumberDecimalSeparator = "." }; + var formatter = new NumberFormatInfo {NumberDecimalSeparator = "."}; var offset = session.LogicSettings.SnipingScanOffset; // 0.003 = half a mile; maximum 0.06 is 10 miles @@ -636,11 +641,13 @@ public static async Task Start(Session session, CancellationToken cancellationTo lClient.Connect(session.LogicSettings.SnipeLocationServer, session.LogicSettings.SnipeLocationServerPort); - var sr = new StreamReader(lClient.GetStream()); + NetworkStream stream = lClient.GetStream(); + Reader = new StreamReader(stream); + Writer = new StreamWriter(stream); while (lClient.Connected) { - var line = sr.ReadLine(); + var line = Reader.ReadLine(); if (line == null) throw new Exception("Unable to ReadLine from sniper socket"); @@ -655,6 +662,12 @@ public static async Task Start(Session session, CancellationToken cancellationTo SnipeLocations.RemoveAll(x => DateTime.Now > x.TimeStampAdded.AddMinutes(15)); SnipeLocations.Add(info); } + + Reader.Close(); + Writer.Close(); + stream.Close(); + Reader = null; + Writer = null; } catch (SocketException) { @@ -663,11 +676,23 @@ public static async Task Start(Session session, CancellationToken cancellationTo catch (Exception ex) { // most likely System.IO.IOException - session.EventDispatcher.Send(new ErrorEvent { Message = ex.ToString() }); + session.EventDispatcher.Send(new ErrorEvent {Message = ex.ToString()}); } + await Task.Delay(5000, cancellationToken); } - await Task.Delay(5000, cancellationToken); } } + + /// + /// Sends a communication back to the feeder server. + /// + /// Message to send. + public static void Feedback(SniperInfo info) + { + if (Writer == null) + return; + Writer.WriteLine(JsonConvert.SerializeObject(info)); + Writer.Flush(); + } } } \ No newline at end of file diff --git a/Pokemon-Go-Rocket-API b/Pokemon-Go-Rocket-API deleted file mode 160000 index 1505165..0000000 --- a/Pokemon-Go-Rocket-API +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 15051653138aa5a521f2523057ebb855e30701e3