Ejemplo n.º 1
0
        public List <SniperInfo> parseMessage(string message)
        {
            var snipeList = new List <SniperInfo>();
            var lines     = message.Split('\r', '\n');

            foreach (var input in lines)
            {
                sniperInfo = new SniperInfo();
                var geoCoordinates = GeoCoordinatesParser.ParseGeoCoordinates(input);
                if (geoCoordinates == null)
                {
                    Log.Debug($"Can't get coords from line: {input}");
                    continue;
                }
                sniperInfo.Latitude  = geoCoordinates.Latitude;
                sniperInfo.Longitude = geoCoordinates.Longitude;
                var iv = IVParser.ParseIV(input);
                sniperInfo.IV = iv;
                parseTimestamp(input);
                var pokemon = PokemonParser.ParsePokemon(input);
                sniperInfo.Id = pokemon;
                snipeList.Add(sniperInfo);
            }

            return(snipeList);
        }
Ejemplo n.º 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);
        }