diff --git a/PoGo.NecroBot.Logic/Tasks/SnipePokemonTask.cs b/PoGo.NecroBot.Logic/Tasks/SnipePokemonTask.cs index ec8cbae..a24c7e4 100644 --- a/PoGo.NecroBot.Logic/Tasks/SnipePokemonTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/SnipePokemonTask.cs @@ -29,11 +29,11 @@ public class SniperInfo public class PokemonLocation { - public long id { get; set; } - public double expiration_time { get; set; } + public long expires { get; set; } public double latitude { get; set; } public double longitude { get; set; } - public int pokemonId { get; set; } + public int pokemon_id { get; set; } + public string pokemon_name { get; set; } public PokemonLocation(double _latitude, double _longitude) { @@ -73,15 +73,14 @@ public override bool Equals(Object obj) // contains calls this here public class ScanResult { - public string status { get; set; } - public List pokemon { get; set; } + public List pokemons { get; set; } } public static class SnipePokemonTask { public static List locsVisited = new List(); private static List snipeLocations = new List(); - private static DateTime lastSnipe = DateTime.Now; + private static DateTime lastSnipe = DateTime.MinValue; public static Task AsyncStart(Session session, CancellationToken cancellationToken = default(CancellationToken)) { @@ -242,6 +241,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio } } else + { foreach (var location in session.LogicSettings.PokemonToSnipe.Locations) { @@ -250,11 +250,11 @@ public static async Task Execute(ISession session, CancellationToken cancellatio var scanResult = SnipeScanForPokemon(location); var locationsToSnipe = new List(); - if (scanResult.pokemon != null) + if (scanResult.pokemons != null) { - var filteredPokemon = scanResult.pokemon.Where(q => pokemonIds.Contains((PokemonId)q.pokemonId)); + var filteredPokemon = scanResult.pokemons.Where(q => pokemonIds.Contains((PokemonId)q.pokemon_id)); var notVisitedPokemon = filteredPokemon.Where(q => !locsVisited.Contains(q)); - var notExpiredPokemon = notVisitedPokemon.Where(q => q.expiration_time < currentTimestamp); + var notExpiredPokemon = notVisitedPokemon.Where(q => q.expires < currentTimestamp); locationsToSnipe.AddRange(notExpiredPokemon); } @@ -285,6 +285,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio });*/ } } + } } } @@ -292,8 +293,11 @@ public static async Task Execute(ISession session, CancellationToken cancellatio private static ScanResult SnipeScanForPokemon(Location location) { var formatter = new System.Globalization.NumberFormatInfo() { NumberDecimalSeparator = "." }; - var uri = $"https://pokevision.com/map/data/{location.Latitude.ToString(formatter)}/{location.Longitude.ToString(formatter)}"; - + //We have to use this new API because Pokevision is shutdown indefinitely. Thanks to the guys at Skiplagged for providing this API!! + //You need to sepcify a lower and upper bounds for the coordinate you want to search. + Location upperBounds = new Location { Latitude = location.Latitude + 0.04, Longitude = location.Longitude + 0.01 }; + Location lowerBounds = new Location { Latitude = location.Latitude - 0.04, Longitude = location.Longitude - 0.01 }; + var uri = $"http://skiplagged.com/api/pokemon.php?bounds={lowerBounds.Latitude.ToString(formatter)},{lowerBounds.Longitude.ToString(formatter)},{upperBounds.Latitude.ToString(formatter)},{upperBounds.Longitude.ToString(formatter)}"; ScanResult scanResult; try { @@ -311,8 +315,7 @@ private static ScanResult SnipeScanForPokemon(Location location) { scanResult = new ScanResult() { - status = "fail", - pokemon = new List() + pokemons = new List() }; } return scanResult;