Example #1
0
        public List <SniperInfo> parseMessage(string message)
        {
            var snipeList = new List <SniperInfo>();
            var lines     = message.Split(new[] { '\r', '\n' });

            foreach (var input in lines)
            {
                sniperInfo = new SniperInfo();
                GeoCoordinates geoCoordinates = GeoCoordinatesParser.parseGeoCoordinates(input);
                if (geoCoordinates == null)
                {
                    Log.Debug($"Can't get coords from line: {input}");
                    continue;
                }
                else
                {
                    sniperInfo.Latitude  = geoCoordinates.latitude;
                    sniperInfo.Longitude = geoCoordinates.longitude;
                }
                double iv = IVParser.parseIV(input);
                sniperInfo.IV = iv;
                parseTimestamp(input);
                PokemonId pokemon = PokemonParser.parsePokemon(input);
                sniperInfo.Id = pokemon;
                snipeList.Add(sniperInfo);
            }

            return(snipeList);
        }
Example #2
0
        private static List <SniperInfo> ParseMultiLine(string[] lines)
        {
            var        sniperInfos = new List <SniperInfo>();
            SniperInfo current     = null;

            foreach (var line in lines)
            {
                var pokemon = PokemonParser.ParsePokemon(line);
                if (pokemon != PokemonId.Missingno)
                {
                    if (IsValid(current))
                    {
                        sniperInfos.Add(current);
                    }
                    current    = new SniperInfo();
                    current.Id = pokemon;
                }
                if (current != null)
                {
                    var geoCoordinates = GeoCoordinatesParser.ParseGeoCoordinates(line);
                    if (geoCoordinates != null)
                    {
                        current.Latitude  = Math.Round(geoCoordinates.Latitude, 7);
                        current.Longitude = Math.Round(geoCoordinates.Longitude, 7);
                    }
                    var iv = IVParser.ParseIV(line);
                    current.IV = iv;
                    var timeStamp = ParseTimestamp(line);
                    if (timeStamp != default(DateTime))
                    {
                        current.ExpirationTimestamp = DateTime.Now.AddMinutes(Constants.MaxExpirationInTheFuture) < timeStamp?
                                                      DateTime.Now.AddMinutes(Constants.MaxExpirationInTheFuture) :
                                                          timeStamp;
                    }
                }
            }
            if (IsValid(current))
            {
                sniperInfos.Add(current);
            }
            return(sniperInfos);
        }