private SniperInfo Map(PokewatchersResult result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            sniperInfo.Id = pokemonId;
            var geoCoordinates = GeoCoordinatesParser.ParseGeoCoordinates(result.coords);

            if (geoCoordinates == null)
            {
                return(null);
            }
            sniperInfo.Latitude  = Math.Round(geoCoordinates.Latitude, 7);
            sniperInfo.Longitude = Math.Round(geoCoordinates.Longitude, 7);

            var timeStamp = DateTime.Now.AddTicks(result.until);

            sniperInfo.ExpirationTimestamp = DateTime.Now.AddMinutes(Constants.MaxExpirationInTheFuture) < timeStamp?
                                             DateTime.Now.AddMinutes(Constants.MaxExpirationInTheFuture) : timeStamp;

            sniperInfo.ChannelInfo = new ChannelInfo {
                server = Channel
            };

            return(sniperInfo);
        }
        public static List <string> LoadFilter()
        {
            if (File.Exists(FilterPath))
            {
                var input        = File.ReadAllText(FilterPath);
                var jsonSettings = new JsonSerializerSettings();
                jsonSettings.Converters.Add(new StringEnumConverter {
                    CamelCaseText = true
                });
                jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace;
                jsonSettings.DefaultValueHandling   = DefaultValueHandling.Populate;
                return(JsonConvert.DeserializeObject <List <string> >(input, jsonSettings).
                       GroupBy(x => PokemonParser.ParsePokemon(x)).
                       Select(y => y.FirstOrDefault()).ToList());
            }
            else
            {
                var output = JsonConvert.SerializeObject(DefaultPokemonsToFeed, Formatting.Indented,
                                                         new StringEnumConverter {
                    CamelCaseText = true
                });

                var folder = Path.GetDirectoryName(FilterPath);
                if (folder != null && !Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                File.WriteAllText(FilterPath, output);
                return(new List <string>());
            }
        }
        private async void SnipeMe_Click(object sender, EventArgs e)
        {
            var           array    = SnipeInfo.Text.Split('|');
            PokemonId     idPoke   = PokemonParser.ParsePokemon(array[0]);
            GeoCoordinate geocoord = new GeoCoordinate(double.Parse(array[1]), double.Parse(array[2]));
            var           success  = await Logic.Logic._instance.Snipe(idPoke, geocoord);

            SnipeInfo.Text = "";
        }
        private static SniperInfo Map(PokemongoivclubPokemon result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            sniperInfo.Id        = pokemonId;
            sniperInfo.Latitude  = result.lat;
            sniperInfo.Longitude = result.lon;
            return(sniperInfo);
        }
        private static SniperInfo Map(PokemongoivclubPokemon result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            sniperInfo.Id          = pokemonId;
            sniperInfo.Latitude    = Math.Round(result.lat, 7);
            sniperInfo.Longitude   = Math.Round(result.lon, 7);
            sniperInfo.ChannelInfo = new ChannelInfo {
                server = Channel
            };
            return(sniperInfo);
        }
Exemple #6
0
        private SniperInfo Map(PokeSpawnsPokemon result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            if (!_pokemonIdsToFind.Contains(pokemonId))
            {
                return(null);
            }
            sniperInfo.Id        = pokemonId;
            sniperInfo.Latitude  = result.lat;
            sniperInfo.Longitude = result.lon;
            return(sniperInfo);
        }
Exemple #7
0
        private SniperInfo Map(PokeSnipeResult result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            sniperInfo.Id        = pokemonId;
            sniperInfo.Latitude  = result.lat;
            sniperInfo.Longitude = result.lon;

            sniperInfo.ChannelInfo = new ChannelInfo {
                server = Channel
            };
            return(sniperInfo);
        }
        private SniperInfo Map(Result result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            sniperInfo.Id = pokemonId;
            var geoCoordinates = GeoCoordinatesParser.ParseGeoCoordinates(result.coords);

            if (geoCoordinates == null)
            {
                return(null);
            }
            sniperInfo.Latitude  = geoCoordinates.Latitude;
            sniperInfo.Longitude = geoCoordinates.Longitude;

            sniperInfo.ExpirationTimestamp = Convert.ToDateTime(result.until);
            return(sniperInfo);
        }
        private SniperInfo Map(PokewatchersResult result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            sniperInfo.Id = pokemonId;
            var geoCoordinates = GeoCoordinatesParser.ParseGeoCoordinates(result.coords);

            if (geoCoordinates == null)
            {
                return(null);
            }
            sniperInfo.Latitude  = geoCoordinates.Latitude;
            sniperInfo.Longitude = geoCoordinates.Longitude;

            var untilTime = DateTime.Now.AddTicks(result.until);

            sniperInfo.ExpirationTimestamp = untilTime;
            return(sniperInfo);
        }
Exemple #10
0
        public static void Load()
        {
            if (!File.Exists(ConfigFile))
            {
                var output = JsonConvert.SerializeObject(GlobalSettings.DefaultPokemonsToFeed, Formatting.Indented,
                                                         new StringEnumConverter {
                    CamelCaseText = true
                });

                var folder = Path.GetDirectoryName(ConfigFile);
                if (folder != null && !Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                File.WriteAllText(ConfigFile, output);
            }
            GlobalSettings.PokekomsToFeedFilter = GlobalSettings.LoadFilter();
            var set = GlobalSettings.PokekomsToFeedFilter.OrderBy(x => PokemonParser.ParsePokemon(x));

            foreach (var s in set)
            {
                try
                {
                    var id  = PokemonParser.ParsePokemon(s, false);
                    var img = new BitmapImage(
                        new Uri(
                            $"pack://application:,,,/PogoLocationFeeder.GUI;component/Assets/icons/{(int)id}.png",
                            UriKind.Absolute));
                    img.Freeze();
                    GlobalVariables.PokemonToFeedFilterInternal.Add(new PokemonFilterModel(id, img));
                    GlobalVariables.AllPokemonsInternal.Remove(GlobalVariables.AllPokemonsInternal.Single(x => x.Id == id));
                }
                catch (Exception e)
                {
                    Log.Warn("Could not add pokemon to the filter", e);
                }
            }
        }
 private void testPokemonParsing(string text, PokemonId expectedPokemonId)
 {
     Assert.AreEqual(expectedPokemonId, PokemonParser.ParsePokemon(text));
 }