Esempio n. 1
0
        public static void CheckVersion()
        {
            try
            {
                var match =
                    new Regex(
                        @"\[assembly\: AssemblyVersion\(""(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})""\)\]")
                    .Match(DownloadServerVersion());

                if (!match.Success)
                {
                    return;
                }
                var gitVersion =
                    new Version(
                        $"{match.Groups[1]}.{match.Groups[2]}.{match.Groups[3]}.{match.Groups[4]}");

                if (gitVersion <= Assembly.GetExecutingAssembly().GetName().Version)
                {
                    Logger.Write(
                        "Awesome! You have already got the newest version! " +
                        Assembly.GetExecutingAssembly().GetName().Version, LogLevel.Info);
                    return;
                }

                Logger.Write("There is a new Version available: https://github.com/Spegeli/PokemoGoBot-GottaCatchEmAll", LogLevel.Info);
                Logger.Write($"GitHub Version: {gitVersion} | Local Version: {CurrentVersion}", LogLevel.Info);
                Thread.Sleep(1000);
            }
            catch (Exception)
            {
                // ignored
            }
        }
Esempio n. 2
0
        private async Task DisplayHighests()
        {
            Logger.Write("====== DisplayHighestsCP ======", LogLevel.Info, ConsoleColor.Yellow);
            var highestsPokemonCp = await Inventory.GetHighestsCp(15);

            string space = " ";

            foreach (var pokemon in highestsPokemonCp)
            {
                if (PokemonInfo.CalculatePokemonPerfection(pokemon) > 100)
                {
                    space = "\t";
                }

                Logger.Write(
                    $"# CP {pokemon.Cp.ToString().PadLeft(4, ' ')}/{PokemonInfo.CalculateMaxCp(pokemon).ToString().PadLeft(4, ' ')} | ({PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% perfect){space}| Lvl {PokemonInfo.GetLevel(pokemon).ToString("00")}\t NAME: '{pokemon.PokemonId}'",
                    LogLevel.Info, ConsoleColor.Yellow);
            }

            Logger.Write("====== DisplayHighestsPerfect ======", LogLevel.Info, ConsoleColor.Yellow);
            var highestsPokemonPerfect = await Inventory.GetHighestsIv(15);

            foreach (var pokemon in highestsPokemonPerfect)
            {
                if (PokemonInfo.CalculatePokemonPerfection(pokemon) > 100)
                {
                    space = "\t";
                }

                Logger.Write(
                    $"# CP {pokemon.Cp.ToString().PadLeft(4, ' ')}/{PokemonInfo.CalculateMaxCp(pokemon).ToString().PadLeft(4, ' ')} | ({PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% perfect){space}| Lvl {PokemonInfo.GetLevel(pokemon).ToString("00")}\t NAME: '{pokemon.PokemonId}'",
                    LogLevel.Info, ConsoleColor.Yellow);
            }
        }
        public static async Task Execute()
        {
            await Inventory.GetCachedInventory(true);

            var pokemonToEvolve = await Inventory.GetPokemonToEvolve(Logic._client.Settings.PrioritizeIVOverCP, Logic._client.Settings.PokemonsToEvolve);

            if (pokemonToEvolve == null || !pokemonToEvolve.Any())
            {
                return;
            }

            Logger.Write($"Found {pokemonToEvolve.Count()} Pokemon for Evolve:", LogLevel.Debug);
            foreach (var pokemon in pokemonToEvolve)
            {
                var evolvePokemonOutProto = await Logic._client.Inventory.EvolvePokemon(pokemon.Id);

                await Inventory.GetCachedInventory(true);

                Logger.Write(evolvePokemonOutProto.Result == EvolvePokemonResponse.Types.Result.Success
                        ? $"{pokemon.PokemonId} [CP: {pokemon.Cp}/{PokemonInfo.CalculateMaxCp(pokemon)} | IV: { PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% perfect] | received XP {evolvePokemonOutProto.ExperienceAwarded}"
                        : $"Failed: {pokemon.PokemonId}. EvolvePokemonOutProto.Result was {evolvePokemonOutProto.Result}, stopping evolving {pokemon.PokemonId}"
                             , LogLevel.Evolve);

                if (evolvePokemonOutProto.Result == EvolvePokemonResponse.Types.Result.Success)
                {
                    BotStats.ExperienceThisSession += evolvePokemonOutProto.ExperienceAwarded;
                }
            }
            await BotStats.GetPokeDexCount();

            BotStats.UpdateConsoleTitle();
        }
Esempio n. 4
0
        public static async Task Execute()
        {
            var tracks = GetGpxTracks();

            for (var curTrk = 0; curTrk < tracks.Count; curTrk++)
            {
                var track         = tracks.ElementAt(curTrk);
                var trackSegments = track.Segments;
                for (var curTrkSeg = 0; curTrkSeg < trackSegments.Count; curTrkSeg++)
                {
                    var trackPoints = track.Segments.ElementAt(curTrkSeg).TrackPoints;
                    for (var curTrkPt = 0; curTrkPt < trackPoints.Count; curTrkPt++)
                    {
                        var nextPoint     = trackPoints.ElementAt(curTrkPt);
                        var distanceCheck = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude,
                                                                                    Logic._client.CurrentLongitude, Convert.ToDouble(nextPoint.Lat, CultureInfo.InvariantCulture),
                                                                                    Convert.ToDouble(nextPoint.Lon, CultureInfo.InvariantCulture));

                        if (distanceCheck > 5000)
                        {
                            Logger.Write(
                                $"Your Target destination of {nextPoint.Lat}, {nextPoint.Lon} is too far from your current position of {Logic._client.CurrentLatitude}, {Logic._client.CurrentLongitude} - Distance: {distanceCheck:0.##}",
                                LogLevel.Error);
                            break;
                        }

                        Logger.Write($"Your Target destination is {nextPoint.Lat}, {nextPoint.Lon} your location is {Logic._client.CurrentLatitude}, {Logic._client.CurrentLongitude} - Distance: {distanceCheck:0.##}", LogLevel.Debug);

                        if (Logic._client.Settings.ExportPokemonToCsvEveryMinutes > 0 && ExportPokemonToCsv._lastExportTime.AddMinutes(Logic._client.Settings.ExportPokemonToCsvEveryMinutes).Ticks < DateTime.Now.Ticks)
                        {
                            var _playerProfile = await Logic._client.Player.GetPlayer();

                            await ExportPokemonToCsv.Execute(_playerProfile.PlayerData);
                        }
                        if (Logic._client.Settings.UseLuckyEggs)
                        {
                            await UseLuckyEggTask.Execute();
                        }
                        if (Logic._client.Settings.CatchIncensePokemon)
                        {
                            await UseIncenseTask.Execute();
                        }

                        await
                        Navigation.HumanPathWalking(trackPoints.ElementAt(curTrkPt),
                                                    async() =>
                        {
                            //await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                            // Catch normal map Pokemon
                            await CatchMapPokemonsTask.Execute();
                            //Catch Pokestops on the Way
                            await UseNearbyPokestopsTask.Execute();
                            //Catch Incense Pokemon
                            await CatchIncensePokemonsTask.Execute();
                            return(true);
                        });
                    } //end trkpts
                }     //end trksegs
            }         //end tracks
        }
        public static async Task Execute()
        {
            var currentAmountOfIncense = await Inventory.GetItemAmountByType(ItemId.ItemIncenseOrdinary);

            if (currentAmountOfIncense <= 0 || _lastIncenseTime.AddMinutes(30).Ticks > DateTime.Now.Ticks)
            {
                return;
            }

            var UseIncense = await Logic._client.Inventory.UseIncense(ItemId.ItemIncenseOrdinary);

            if (UseIncense.Result == UseIncenseResponse.Types.Result.IncenseAlreadyActive)
            {
                return;
            }

            if (UseIncense.Result == UseIncenseResponse.Types.Result.Success)
            {
                _lastIncenseTime = DateTime.Now;
                Logger.Write($"Used Incense [Remaining: {currentAmountOfIncense - 1}]", LogLevel.Incense);
            }
            else if (UseIncense.Result == UseIncenseResponse.Types.Result.NoneInInventory)
            {
                Logger.Write($"No Incense Available", LogLevel.Debug);
            }
            else if (UseIncense.Result == UseIncenseResponse.Types.Result.IncenseAlreadyActive || (UseIncense.AppliedIncense == null))
            {
                Logger.Write($"Incense Already Active", LogLevel.Debug);
            }
        }
Esempio n. 6
0
        public static async Task Execute()
        {
            var currentAmountOfLuckyEggs = await Inventory.GetItemAmountByType(ItemId.ItemLuckyEgg);

            if (currentAmountOfLuckyEggs <= 0 || _lastLuckyEggTime.AddMinutes(30).Ticks > DateTime.Now.Ticks)
            {
                return;
            }

            var UseEgg = await Logic._client.Inventory.UseItemXpBoost();

            if (UseEgg.Result == UseItemXpBoostResponse.Types.Result.ErrorXpBoostAlreadyActive)
            {
                return;
            }

            if (UseEgg.Result == UseItemXpBoostResponse.Types.Result.Success)
            {
                _lastLuckyEggTime = DateTime.Now;
                Logger.Write($"Used Lucky Egg [Remaining: {currentAmountOfLuckyEggs - 1}]", LogLevel.Egg);
            }
            else if (UseEgg.Result == UseItemXpBoostResponse.Types.Result.ErrorNoItemsRemaining)
            {
                Logger.Write($"No Eggs Available", LogLevel.Debug);
            }
            else if (UseEgg.Result == UseItemXpBoostResponse.Types.Result.ErrorXpBoostAlreadyActive || (UseEgg.AppliedItems == null))
            {
                Logger.Write($"Lucky Egg Already Active", LogLevel.Debug);
            }
        }
        public static async Task Execute()
        {
            if (!Logic._client.Settings.CatchIncensePokemon)
            {
                return;
            }

            var incensePokemon = await Logic._client.Map.GetIncensePokemons();

            if (incensePokemon.Result == GetIncensePokemonResponse.Types.Result.IncenseEncounterAvailable)
            {
                var pokemon = new MapPokemon
                {
                    EncounterId           = incensePokemon.EncounterId,
                    ExpirationTimestampMs = incensePokemon.DisappearTimestampMs,
                    Latitude     = incensePokemon.Latitude,
                    Longitude    = incensePokemon.Longitude,
                    PokemonId    = incensePokemon.PokemonId,
                    SpawnPointId = incensePokemon.EncounterLocation
                };

                if (Logic._client.Settings.UsePokemonDoNotCatchList &&
                    Logic._client.Settings.PokemonsToNotCatch.Contains(pokemon.PokemonId))
                {
                    Logger.Write($"Ignore Pokemon - {pokemon.PokemonId} - is on ToNotCatch List", LogLevel.Debug);
                    return;
                }

                var encounter =
                    await Logic._client.Encounter.EncounterIncensePokemon(pokemon.EncounterId, pokemon.SpawnPointId);

                if (encounter.Result == IncenseEncounterResponse.Types.Result.IncenseEncounterSuccess)
                {
                    await CatchPokemonTask.Execute(encounter, pokemon);
                }
                else
                {
                    Logger.Write($"Encounter problem: {encounter.Result}", LogLevel.Warning);
                }
            }

            if (Logic._client.Settings.EvolvePokemon || Logic._client.Settings.EvolvePokemonAboveIV)
            {
                await EvolvePokemonTask.Execute();
            }
            if (Logic._client.Settings.TransferPokemon)
            {
                await TransferPokemonTask.Execute();
            }
        }
Esempio n. 8
0
        public static async Task <PlayerUpdateResponse> HumanPathWalking(GpxReader.Trkpt trk, Func <Task <bool> > functionExecutedWhileWalking)
        {
            var targetLocation = new GeoUtils(Convert.ToDouble(trk.Lat), Convert.ToDouble(trk.Lon));

            double walkingSpeedInKilometersPerHour = Logic._client.Settings.WalkingSpeedInKilometerPerHour;
            var    speedInMetersPerSecond          = walkingSpeedInKilometersPerHour / 3.6;

            var sourceLocation   = new GeoUtils(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude);
            var distanceToTarget = LocationUtils.CalculateDistanceInMeters(sourceLocation, targetLocation);

            Logger.Write($"Distance to target location: {distanceToTarget:0.##} meters. Will take {distanceToTarget/speedInMetersPerSecond:0.##} seconds!", LogLevel.Navigation);

            var nextWaypointBearing  = LocationUtils.DegreeBearing(sourceLocation, targetLocation);
            var nextWaypointDistance = speedInMetersPerSecond;
            var waypoint             = LocationUtils.CreateWaypoint(sourceLocation, nextWaypointDistance, nextWaypointBearing, Convert.ToDouble(trk.Ele));

            //Initial walking
            var requestSendDateTime = DateTime.Now;
            PlayerUpdateResponse result;
            await Logic._client.Player.UpdatePlayerLocation(waypoint.Latitude, waypoint.Longitude, Logic._client.Settings.DefaultAltitude);

            do
            {
                var millisecondsUntilGetUpdatePlayerLocationResponse = (DateTime.Now - requestSendDateTime).TotalMilliseconds;

                sourceLocation = new GeoUtils(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude);
                var currentDistanceToTarget = LocationUtils.CalculateDistanceInMeters(sourceLocation, targetLocation);
                Logger.Write($"Distance to target location: {currentDistanceToTarget:0.##} meters. Will take {currentDistanceToTarget / speedInMetersPerSecond:0.##} seconds!", LogLevel.Debug);

                nextWaypointDistance = Math.Min(currentDistanceToTarget,
                                                millisecondsUntilGetUpdatePlayerLocationResponse / 1000 * speedInMetersPerSecond);
                nextWaypointBearing = LocationUtils.DegreeBearing(sourceLocation, targetLocation);
                waypoint            = LocationUtils.CreateWaypoint(sourceLocation, nextWaypointDistance, nextWaypointBearing);

                requestSendDateTime = DateTime.Now;
                result =
                    await
                    Logic._client.Player.UpdatePlayerLocation(waypoint.Latitude, waypoint.Longitude,
                                                              waypoint.Altitude);

                if (functionExecutedWhileWalking != null)
                {
                    await functionExecutedWhileWalking();// look for pokemon
                }
            } while (LocationUtils.CalculateDistanceInMeters(sourceLocation, targetLocation) >= 35);

            return(result);
        }
Esempio n. 9
0
        public static async Task Execute()
        {
            await Inventory.GetCachedInventory(true);

            var pokemonToTransfer = await Inventory.GetPokemonToTransfer(Logic._clientSettings.NotTransferPokemonsThatCanEvolve, Logic._clientSettings.PrioritizeIVOverCP, Logic._clientSettings.PokemonsToNotTransfer);

            if (pokemonToTransfer == null || !pokemonToTransfer.Any())
            {
                return;
            }

            Logger.Write($"Found {pokemonToTransfer.Count()} Pokemon for Transfer:", LogLevel.Debug);
            foreach (var pokemon in pokemonToTransfer)
            {
                await Logic._client.Inventory.TransferPokemon(pokemon.Id);

                await Inventory.GetCachedInventory(true);

                var myPokemonSettings = await Inventory.GetPokemonSettings();

                var pokemonSettings   = myPokemonSettings.ToList();
                var myPokemonFamilies = await Inventory.GetPokemonFamilies();

                var pokemonFamilies = myPokemonFamilies.ToArray();
                var settings        = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId);
                var familyCandy     = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);
                var familyCandies   = $"{familyCandy.Candy_}";

                BotStats.PokemonTransferedThisSession += 1;

                var bestPokemonOfType = Logic._client.Settings.PrioritizeIVOverCP
                    ? await Inventory.GetHighestPokemonOfTypeByIv(pokemon)
                    : await Inventory.GetHighestPokemonOfTypeByCp(pokemon);

                var bestPokemonInfo = "NONE";
                if (bestPokemonOfType != null)
                {
                    bestPokemonInfo = $"CP: {bestPokemonOfType.Cp}/{PokemonInfo.CalculateMaxCp(bestPokemonOfType)} | IV: {PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType).ToString("0.00")}% perfect";
                }

                Logger.Write($"{pokemon.PokemonId} [CP: {pokemon.Cp}/{PokemonInfo.CalculateMaxCp(pokemon)} | IV: { PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% perfect] | Best: [{bestPokemonInfo}] | Family Candies: {familyCandies}", LogLevel.Transfer);
            }

            await BotStats.GetPokemonCount();

            BotStats.UpdateConsoleTitle();
        }
Esempio n. 10
0
        private static async Task UseBerry(ulong encounterId, string spawnPointId)
        {
            await Inventory.GetCachedInventory(true);

            var inventoryitems = await Inventory.GetItems();

            var berry = inventoryitems.FirstOrDefault(p => p.ItemId == ItemId.ItemRazzBerry);

            if (berry == null || berry.Count <= 0)
            {
                return;
            }

            await Logic._client.Encounter.UseCaptureItem(encounterId, ItemId.ItemRazzBerry, spawnPointId);

            berry.Count -= 1;
            Logger.Write($"Used Razz Berry [Remaining: {berry.Count}]", LogLevel.Berry);
        }
Esempio n. 11
0
        public static async Task Execute()
        {
            if (!Logic._client.Settings.CatchPokemon)
            {
                return;
            }

            var pokemons = await GetNearbyPokemons();

            if (pokemons == null || !pokemons.Any())
            {
                return;
            }

            Logger.Write($"Found {pokemons.Count} catchable Pokemon", LogLevel.Debug);
            foreach (var pokemon in pokemons)
            {
                if (Logic._client.Settings.UsePokemonToNotCatchList && Logic._client.Settings.PokemonsToNotCatch.Contains(pokemon.PokemonId))
                {
                    Logger.Write($"Ignore Pokemon - {pokemon.PokemonId} - is on ToNotCatch List", LogLevel.Debug);
                    continue;
                }

                var encounter = await Logic._client.Encounter.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnPointId);

                if (encounter.Status == EncounterResponse.Types.Status.EncounterSuccess)
                {
                    await CatchPokemonTask.Execute(encounter, pokemon);
                }
                else
                {
                    Logger.Write($"Encounter problem: {encounter.Status}", LogLevel.Warning);
                }
            }

            if (Logic._client.Settings.EvolvePokemon || Logic._client.Settings.EvolveOnlyPokemonAboveIV)
            {
                await EvolvePokemonTask.Execute();
            }
            if (Logic._client.Settings.TransferPokemon)
            {
                await TransferPokemonTask.Execute();
            }
        }
Esempio n. 12
0
        public static async Task Execute()
        {
            await Inventory.GetCachedInventory(true);

            var items = await Inventory.GetItemsToRecycle(Logic._clientSettings);

            if (items == null || !items.Any())
            {
                return;
            }

            Logger.Write($"Found {items.Count()} Recyclable {(items.Count() == 1 ? "Item" : "Items")}:", LogLevel.Debug);
            foreach (var item in items)
            {
                await Logic._client.Inventory.RecycleItem(item.ItemId, item.Count);

                Logger.Write($"{item.Count}x {item.ItemId}", LogLevel.Recycling);

                BotStats.ItemsRemovedThisSession += item.Count;
            }

            BotStats.UpdateConsoleTitle();
            _recycleCounter = 0;
        }
        public static async Task Execute(FortData currentFortData)
        {
            Logger.Write("Looking for lured Pokemon...", LogLevel.Debug);

            var fortId    = currentFortData.Id;
            var pokemonId = currentFortData.LureInfo.ActivePokemonId;

            if (Logic._client.Settings.UsePokemonDoNotCatchList &&
                Logic._client.Settings.PokemonsToNotCatch.Contains(pokemonId))
            {
                Logger.Write($"Ignore Pokemon - {pokemonId} - is on ToNotCatch List", LogLevel.Debug);
                return;
            }

            var encounterId = currentFortData.LureInfo.EncounterId;

            var encounter = await Logic._client.Encounter.EncounterLurePokemon(encounterId, fortId);

            Logger.Write($"fortId: {fortId}", LogLevel.Debug);
            Logger.Write($"pokemonId: {pokemonId}", LogLevel.Debug);
            Logger.Write($"encounterId: {encounterId}", LogLevel.Debug);
            Logger.Write($"encounter: {encounter}", LogLevel.Debug);

            if (encounter.Result == DiskEncounterResponse.Types.Result.Success)
            {
                await CatchPokemonTask.Execute(encounter, null, currentFortData, encounterId);
            }
            else
            {
                if (encounter.Result.ToString().Contains("NotAvailable"))
                {
                    return;
                }
                Logger.Write($"Encounter problem: Lure Pokemon {encounter.Result}", LogLevel.Warning);
            }
        }
        public static async Task Execute()
        {
            var distanceFromStart = LocationUtils.CalculateDistanceInMeters(
                Logic._client.Settings.DefaultLatitude, Logic._client.Settings.DefaultLongitude,
                Logic._client.CurrentLatitude, Logic._client.CurrentLongitude);

            // Edge case for when the client somehow ends up outside the defined radius
            if (Logic._client.Settings.MaxTravelDistanceInMeters != 0 &&
                distanceFromStart > Logic._client.Settings.MaxTravelDistanceInMeters)
            {
                Logger.Write(
                    $"You're outside of your defined radius! Walking to Default Coords ({distanceFromStart:0.##}m away). Is your LastCoords.ini file correct?",
                    LogLevel.Warning);
                await Navigation.HumanLikeWalking(
                    new GeoUtils(Logic._client.Settings.DefaultLatitude, Logic._client.Settings.DefaultLongitude),
                    async() =>
                {
                    // Catch normal map Pokemon
                    await CatchMapPokemonsTask.Execute();
                    //Catch Incense Pokemon
                    await CatchIncensePokemonsTask.Execute();
                    return(true);
                });
            }

            var pokestops = await Inventory.GetPokestops();

            if (pokestops == null || !pokestops.Any())
            {
                Logger.Write("No usable PokeStops found in your area. Reasons: Softbanned - Server Issues - MaxTravelDistanceInMeters too small",
                             LogLevel.Warning);
            }
            else
            {
                Logger.Write($"Found {pokestops.Count()} {(pokestops.Count() == 1 ? "Pokestop" : "Pokestops")}", LogLevel.Info);
            }

            while (pokestops.Any())
            {
                if (Logic._client.Settings.ExportPokemonToCsvEveryMinutes > 0 && ExportPokemonToCsv._lastExportTime.AddMinutes(Logic._client.Settings.ExportPokemonToCsvEveryMinutes).Ticks < DateTime.Now.Ticks)
                {
                    var _playerProfile = await Logic._client.Player.GetPlayer();

                    await ExportPokemonToCsv.Execute(_playerProfile.PlayerData);
                }
                if (Logic._client.Settings.UseLuckyEggs)
                {
                    await UseLuckyEggTask.Execute();
                }
                if (Logic._client.Settings.CatchIncensePokemon)
                {
                    await UseIncenseTask.Execute();
                }

                var pokestopwithcooldown = pokestops.Where(p => p.CooldownCompleteTimestampMs > DateTime.UtcNow.ToUnixTime()).FirstOrDefault();
                if (pokestopwithcooldown != null)
                {
                    pokestops.Remove(pokestopwithcooldown);
                }

                var pokestop =
                    pokestops.Where(p => p.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime())
                    .OrderBy(
                        i =>
                        LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude,
                                                                Logic._client.CurrentLongitude, i.Latitude, i.Longitude)).First();

                var lured    = string.Empty;
                var distance = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, pokestop.Latitude, pokestop.Longitude);
                if (distance > 100)
                {
                    var lurePokestop = pokestops.FirstOrDefault(x => x.LureInfo != null);
                    if (lurePokestop != null)
                    {
                        distance = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, pokestop.Latitude, pokestop.Longitude);
                        if (distance < 200)
                        {
                            lured    = " is Lured";
                            pokestop = lurePokestop;
                        }
                        else
                        {
                            pokestops.Remove(pokestop);
                        }
                    }
                }
                else
                {
                    pokestops.Remove(pokestop);
                }

                var fortInfo = await Logic._client.Fort.GetFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);

                var latlngDebug = string.Empty;
                if (Logic._client.Settings.DebugMode)
                {
                    latlngDebug = $" | Latitude: {pokestop.Latitude} - Longitude: {pokestop.Longitude}";
                }
                Logger.Write($"Name: {fortInfo.Name} in {distance:0.##} m distance{lured}{latlngDebug}", LogLevel.Pokestop);

                if (Logic._client.Settings.UseTeleportInsteadOfWalking)
                {
                    await
                    Logic._client.Player.UpdatePlayerLocation(pokestop.Latitude, pokestop.Longitude,
                                                              Logic._client.Settings.DefaultAltitude);

                    await RandomHelper.RandomDelay(500);

                    Logger.Write($"Using Teleport instead of Walking!", LogLevel.Navigation);
                }
                else
                {
                    await
                    Navigation.HumanLikeWalking(new GeoUtils(pokestop.Latitude, pokestop.Longitude),
                                                async() =>
                    {
                        // Catch normal map Pokemon
                        await CatchMapPokemonsTask.Execute();
                        //Catch Incense Pokemon
                        await CatchIncensePokemonsTask.Execute();
                        return(true);
                    });
                }

                //Catch Lure Pokemon
                if (pokestop.LureInfo != null && Logic._client.Settings.CatchLuredPokemon)
                {
                    await CatchLurePokemonsTask.Execute(pokestop);
                }

                var       timesZeroXPawarded = 0;
                var       fortTry            = 0;  //Current check
                const int retryNumber        = 45; //How many times it needs to check to clear softban
                const int zeroCheck          = 5;  //How many times it checks fort before it thinks it's softban
                do
                {
                    var fortSearch = await Logic._client.Fort.SearchFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);

                    if (fortSearch.ExperienceAwarded > 0 && timesZeroXPawarded > 0)
                    {
                        timesZeroXPawarded = 0;
                    }
                    if (fortSearch.ExperienceAwarded == 0)
                    {
                        if (fortSearch.Result == FortSearchResponse.Types.Result.InCooldownPeriod)
                        {
                            Logger.Write("Pokestop is on Cooldown", LogLevel.Debug);
                            break;
                        }

                        timesZeroXPawarded++;
                        if (timesZeroXPawarded > zeroCheck)
                        {
                            fortTry += 1;

                            if (Logic._client.Settings.DebugMode)
                            {
                                Logger.Write(
                                    $"Seems your Soft-Banned. Trying to Unban via Pokestop Spins. Retry {fortTry} of {retryNumber - zeroCheck}",
                                    LogLevel.Warning);
                            }

                            await RandomHelper.RandomDelay(450);
                        }
                    }
                    else if (fortSearch.ExperienceAwarded != 0)
                    {
                        BotStats.ExperienceThisSession += fortSearch.ExperienceAwarded;
                        BotStats.UpdateConsoleTitle();
                        Logger.Write($"XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Items: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}", LogLevel.Pokestop);
                        RecycleItemsTask._recycleCounter++;
                        HatchEggsTask._hatchUpdateDelay++;
                        break;                               //Continue with program as loot was succesfull.
                    }
                } while (fortTry < retryNumber - zeroCheck); //Stop trying if softban is cleaned earlier or if 40 times fort looting failed.

                if (RecycleItemsTask._recycleCounter >= 5)
                {
                    await RecycleItemsTask.Execute();
                }
                if (HatchEggsTask._hatchUpdateDelay >= 15)
                {
                    await HatchEggsTask.Execute();
                }
            }
        }
        public static async Task Execute(PlayerData player, string filename = "PokeList.csv")
        {
            if (player == null)
            {
                return;
            }
            var stats = await Inventory.GetPlayerStats();

            var stat = stats.FirstOrDefault();

            if (stat == null)
            {
                return;
            }

            if (!Directory.Exists(_exportPath))
            {
                Directory.CreateDirectory(_exportPath);
            }
            if (Directory.Exists(_exportPath))
            {
                try
                {
                    var pokelistFile = Path.Combine(_exportPath, $"Profile_{player.Username}_{filename}");
                    if (File.Exists(pokelistFile))
                    {
                        File.Delete(pokelistFile);
                    }

                    CsvExport myExport   = new CsvExport();
                    var       allPokemon = await Inventory.GetHighestsIv();

                    var myPokemonSettings = await Inventory.GetPokemonSettings();

                    var pokemonSettings   = myPokemonSettings.ToList();
                    var myPokemonFamilies = await Inventory.GetPokemonFamilies();

                    var pokemonFamilies = myPokemonFamilies.ToArray();
                    var trainerLevel    = stat.Level;
                    foreach (var pokemon in allPokemon)
                    {
                        var toEncode = $"{(int)pokemon.PokemonId}" + "," + trainerLevel + "," + PokemonInfo.GetLevel(pokemon) + "," + pokemon.Cp + "," + pokemon.Stamina;
                        //Generate base64 code to make it viewable here http://poke.isitin.org/#MTUwLDIzLDE3LDE5MDIsMTE4
                        var encoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(toEncode));

                        var settings       = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId);
                        var familiecandies = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId).Candy_;

                        myExport.AddRow();
                        myExport["PokemonID"]          = (int)pokemon.PokemonId;
                        myExport["Name"]               = pokemon.PokemonId;
                        myExport["NickName"]           = pokemon.Nickname;
                        myExport["Level"]              = PokemonInfo.GetLevel(pokemon).ToString("0.0");
                        myExport["CP"]                 = pokemon.Cp;
                        myExport["MaxCP"]              = PokemonInfo.CalculateMaxCp(pokemon);
                        myExport["IV Perfection in %"] = PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00");
                        myExport["Attack 1"]           = pokemon.Move1;
                        myExport["Attack 2"]           = pokemon.Move2;
                        myExport["HP"]                 = pokemon.Stamina;
                        myExport["Attk"]               = pokemon.IndividualAttack;
                        myExport["Def"]                = pokemon.IndividualDefense;
                        myExport["Stamina"]            = pokemon.IndividualStamina;
                        myExport["Familie Candies"]    = familiecandies;
                        myExport["IsInGym"]            = pokemon.DeployedFortId != string.Empty ? "Yes" : "No";
                        myExport["IsFavorite"]         = pokemon.Favorite != 0 ? "Yes" : "No";
                        myExport["previewLink"]        = $"http://poke.isitin.org/#{encoded}";
                    }
                    myExport.ExportToFile(pokelistFile);
                    Logger.Write($"Export Player Infos and all Pokemon to \"\\Export\\Profile_{player.Username}_{filename}\"", LogLevel.Info);
                }
                catch
                {
                    Logger.Write("Export Player Infos and all Pokemons to CSV not possible. File seems be in use!", LogLevel.Warning);
                }
                _lastExportTime = DateTime.Now;
                if (Logic._client.Settings.ExportPokemonToCsvEveryMinutes > 0)
                {
                    Logger.Write($"Next Export in {Logic._client.Settings.ExportPokemonToCsvEveryMinutes} Minutes", LogLevel.Info);
                }
            }
        }
Esempio n. 16
0
        //Please do not change GetPokeStops() in this file, it's specifically set
        //to only find stops within 40 meters
        //this is for gpx pathing, we are not going to the pokestops,
        //so do not make it more than 40 because it will never get close to those stops.
        public static async Task Execute()
        {
            if (Logic._client.Settings.GPXIgnorePokestops)
            {
                return;
            }

            var pokestops = await Inventory.GetPokestops(true);

            while (pokestops.Any())
            {
                var pokestop =
                    pokestops.OrderBy(
                        i =>
                        LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude,
                                                                Logic._client.CurrentLongitude, i.Latitude, i.Longitude)).First();
                pokestops.Remove(pokestop);

                var distance = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, pokestop.Latitude, pokestop.Longitude);

                var fortInfo = await Logic._client.Fort.GetFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);

                var latlngDebug = string.Empty;
                if (Logic._client.Settings.DebugMode)
                {
                    latlngDebug = $"| Latitude: {pokestop.Latitude} - Longitude: {pokestop.Longitude}";
                }
                Logger.Write($"Name: {fortInfo.Name} in {distance:0.##} m distance {latlngDebug}", LogLevel.Pokestop);

                //Catch Lure Pokemon
                if (pokestop.LureInfo != null && Logic._client.Settings.CatchLuredPokemon)
                {
                    await CatchLurePokemonsTask.Execute(pokestop);
                }

                var       timesZeroXPawarded = 0;
                var       fortTry            = 0;  //Current check
                const int retryNumber        = 50; //How many times it needs to check to clear softban
                const int zeroCheck          = 5;  //How many times it checks fort before it thinks it's softban
                do
                {
                    var fortSearch = await Logic._client.Fort.SearchFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);

                    if (fortSearch.ExperienceAwarded > 0 && timesZeroXPawarded > 0)
                    {
                        timesZeroXPawarded = 0;
                    }
                    if (fortSearch.ExperienceAwarded == 0)
                    {
                        timesZeroXPawarded++;

                        if (timesZeroXPawarded <= zeroCheck)
                        {
                            continue;
                        }
                        if ((int)fortSearch.CooldownCompleteTimestampMs != 0)
                        {
                            break; // Check if successfully looted, if so program can continue as this was "false alarm".
                        }
                        fortTry += 1;

                        if (Logic._client.Settings.DebugMode)
                        {
                            Logger.Write($"Seems your Soft-Banned. Trying to Unban via Pokestop Spins. Retry {fortTry} of {retryNumber - zeroCheck}", LogLevel.Warning);
                        }

                        await RandomHelper.RandomDelay(75, 100);
                    }
                    else
                    {
                        BotStats.ExperienceThisSession += fortSearch.ExperienceAwarded;
                        BotStats.UpdateConsoleTitle();
                        Logger.Write($"XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Items: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}", LogLevel.Pokestop);
                        RecycleItemsTask._recycleCounter++;
                        HatchEggsTask._hatchUpdateDelayGPX++;
                        break; //Continue with program as loot was succesfull.
                    }
                } while (fortTry < retryNumber - zeroCheck);
                //Stop trying if softban is cleaned earlier or if 40 times fort looting failed.

                if (RecycleItemsTask._recycleCounter >= 5)
                {
                    await RecycleItemsTask.Execute();
                }
                if (HatchEggsTask._hatchUpdateDelayGPX >= 5)
                {
                    await HatchEggsTask.Execute();
                }
            }
        }
Esempio n. 17
0
        public async Task PostLoginExecute()
        {
            Logger.Write($"Client logged in", LogLevel.Info);

            while (true)
            {
                if (!_isInitialized)
                {
                    await Inventory.GetCachedInventory();

                    _playerProfile = await _client.Player.GetPlayer();

                    BotStats.UpdateConsoleTitle();

                    var stats = await Inventory.GetPlayerStats();

                    var stat = stats.FirstOrDefault();
                    if (stat != null)
                    {
                        BotStats.KmWalkedOnStart = stat.KmWalked;
                    }

                    Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);
                    if (_clientSettings.AuthType == AuthType.Ptc)
                    {
                        Logger.Write($"PTC Account: {BotStats.GetUsername(_playerProfile)}\n", LogLevel.None, ConsoleColor.Cyan);
                    }
                    Logger.Write($"Latitude: {_clientSettings.DefaultLatitude}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write($"Longitude: {_clientSettings.DefaultLongitude}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);
                    Logger.Write("Your Account:\n");
                    Logger.Write($"Name: {BotStats.GetUsername(_playerProfile)}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write($"Team: {_playerProfile.PlayerData.Team}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write($"Level: {BotStats.GetCurrentInfo()}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write($"Stardust: {_playerProfile.PlayerData.Currencies.ToArray()[1].Amount}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);
                    await DisplayHighests();

                    Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);

                    var pokemonsToNotTransfer = _clientSettings.PokemonsToNotTransfer;
                    var pokemonsToNotCatch    = _clientSettings.PokemonsToNotCatch;
                    var pokemonsToEvolve      = _clientSettings.PokemonsToEvolve;

                    await RecycleItemsTask.Execute();

                    if (_client.Settings.UseLuckyEggs)
                    {
                        await UseLuckyEggTask.Execute();
                    }
                    if (_client.Settings.EvolvePokemon || _client.Settings.EvolvePokemonAboveIV)
                    {
                        await EvolvePokemonTask.Execute();
                    }
                    if (_client.Settings.TransferPokemon)
                    {
                        await TransferPokemonTask.Execute();
                    }
                    await ExportPokemonToCsv.Execute(_playerProfile.PlayerData);

                    if (_clientSettings.HatchEggs)
                    {
                        await HatchEggsTask.Execute();
                    }
                }
                _isInitialized = true;
                await Main();

                await RefreshTokens();

                /*
                 * Example calls below
                 *
                 * var profile = await _client.GetProfile();
                 * var settings = await _client.GetSettings();
                 * var mapObjects = await _client.GetMapObjects();
                 * var inventory = await _client.GetInventory();
                 * var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon).Where(p => p != null && p?.PokemonId > 0);
                 */

                await Task.Delay(10000);
            }
        }
Esempio n. 18
0
        public static async Task Execute(dynamic encounter, MapPokemon pokemon, FortData currentFortData = null, ulong encounterId = 0)
        {
            // If the encounter is null nothing will work below, so exit now
            if (encounter == null)
            {
                return;
            }
            float probability = encounter.CaptureProbability?.CaptureProbability_[0];

            var catchType   = encounter is EncounterResponse ? "Normal" : encounter is DiskEncounterResponse ? "Lure" : "Incense";
            var Id          = encounter is EncounterResponse ? pokemon.PokemonId : encounter?.PokemonData.PokemonId;
            var Level       = PokemonInfo.GetLevel(encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData : encounter?.PokemonData);
            var Cp          = encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData?.Cp : encounter?.PokemonData?.Cp ?? 0;
            var MaxCp       = PokemonInfo.CalculateMaxCp(encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData : encounter?.PokemonData);
            var Iv          = PokemonInfo.CalculatePokemonPerfection(encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData : encounter?.PokemonData);
            var Probability = Math.Round(probability * 100, 2);
            var distance    = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude,
                                                                      Logic._client.CurrentLongitude,
                                                                      encounter is EncounterResponse || encounter is IncenseEncounterResponse ? pokemon.Latitude : currentFortData.Latitude,
                                                                      encounter is EncounterResponse || encounter is IncenseEncounterResponse ? pokemon.Longitude : currentFortData.Longitude);

            if (!float.IsNaN(probability) && probability < 0.35)
            {
                await
                UseBerry(encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.EncounterId : encounterId,
                         encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.SpawnPointId : currentFortData?.Id);
            }

            CatchPokemonResponse caughtPokemonResponse;
            var attemptCounter = 1;

            do
            {
                var pokeball = await GetBestBall(encounter, probability);

                if (pokeball == ItemId.ItemUnknown)
                {
                    Logger.Write($"You don't own any Pokeballs :( - We missed a {Id} with CP {Cp}", LogLevel.Warning);
                    return;
                }

                caughtPokemonResponse =
                    await Logic._client.Encounter.CatchPokemon(
                        encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.EncounterId : encounterId,
                        encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.SpawnPointId : currentFortData.Id, pokeball);

                if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess)
                {
                    BotStats.ExperienceThisSession    += caughtPokemonResponse.CaptureAward.Xp.Sum();
                    BotStats.PokemonCaughtThisSession += 1;
                    await BotStats.GetPokeDexCount();

                    await BotStats.GetPokemonCount();

                    var profile = await Logic._client.Player.GetPlayer();

                    BotStats.TotalStardust = profile.PlayerData.Currencies.ToArray()[1].Amount;
                    BotStats.UpdateConsoleTitle();
                }

                if (encounter?.CaptureProbability?.CaptureProbability_ != null)
                {
                    Func <ItemId, string> returnRealBallName = a =>
                    {
                        switch (a)
                        {
                        case ItemId.ItemPokeBall:
                            return("Poke");

                        case ItemId.ItemGreatBall:
                            return("Great");

                        case ItemId.ItemUltraBall:
                            return("Ultra");

                        case ItemId.ItemMasterBall:
                            return("Master");

                        default:
                            return("Unknown");
                        }
                    };

                    var catchStatus = attemptCounter > 1
                        ? $"{caughtPokemonResponse.Status} Attempt #{attemptCounter}"
                        : $"{caughtPokemonResponse.Status}";

                    var receivedXp = caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess
                        ? $"and received XP {caughtPokemonResponse.CaptureAward.Xp.Sum()}"
                        : $"";

                    await Inventory.GetCachedInventory(true);

                    var BallAmount = await Inventory.GetItemAmountByType(pokeball);

                    Logger.Write($"({catchStatus} / {catchType}) | {Id} - Lvl {Level} [CP {Cp}/{MaxCp} | IV: {Iv.ToString("0.00")}% perfect] | Chance: {Probability} | {distance:0.##}m dist | with a {returnRealBallName(pokeball)}Ball [Remaining: {BallAmount}] {receivedXp}", LogLevel.Pokemon);
                }

                attemptCounter++;
            }while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed || caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);
        }
Esempio n. 19
0
        public async Task Execute()
        {
            if (!_isInitialized)
            {
                GitChecker.CheckVersion();

                var latLngFromFile = PositionCheckState.LoadPositionFromDisk();
                if (latLngFromFile != null && Math.Abs(latLngFromFile.Item1) > 0 && Math.Abs(latLngFromFile.Item2) > 0)
                {
                    _client.Player.SetCoordinates(latLngFromFile.Item1, latLngFromFile.Item2,
                                                  _client.Settings.DefaultAltitude);
                }
                else
                {
                    _client.Player.SetCoordinates(_client.Settings.DefaultLatitude, _client.Settings.DefaultLongitude,
                                                  _client.Settings.DefaultAltitude);
                }

                if (Math.Abs(_clientSettings.DefaultLatitude) <= 0 || Math.Abs(_clientSettings.DefaultLongitude) <= 0)
                {
                    Logger.Write($"Please change first Latitude and/or Longitude because currently your using default values!", LogLevel.Error);
                    for (int i = 3; i > 0; i--)
                    {
                        Logger.Write($"Bot will close in {i * 5} seconds!", LogLevel.Warning);
                        await Task.Delay(5000);
                    }
                    Environment.Exit(1);
                }
                else
                {
                    Logger.Write($"Make sure Lat & Lng is right. Exit Program if not! Lat: {_client.CurrentLatitude} Lng: {_client.CurrentLongitude}", LogLevel.Warning);
                    for (int i = 3; i > 0; i--)
                    {
                        Logger.Write($"Bot will continue in {i * 5} seconds!", LogLevel.Warning);
                        await Task.Delay(5000);
                    }
                }
            }
            Logger.Write($"Logging in via: {_clientSettings.AuthType}", LogLevel.Info);
            while (true)
            {
                try
                {
                    switch (_clientSettings.AuthType)
                    {
                    case AuthType.Ptc:
                        await _client.Login.DoLogin();

                        break;

                    case AuthType.Google:
                        await _client.Login.DoLogin();

                        break;

                    default:
                        Logger.Write("wrong AuthType");
                        Environment.Exit(0);
                        break;
                    }
                    await PostLoginExecute();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.Write("Account not verified! Exiting...", LogLevel.Error);
                    await Task.Delay(5000);

                    Environment.Exit(0);
                }
                catch (GoogleException e)
                {
                    if (e.Message.Contains("NeedsBrowser"))
                    {
                        Logger.Write("As you have Google Two Factor Auth enabled, you will need to insert an App Specific Password into the UserSettings.", LogLevel.Error);
                        Logger.Write("Opening Google App-Passwords. Please make a new App Password (use Other as Device)", LogLevel.Error);
                        await Task.Delay(7000);

                        try
                        {
                            Process.Start("https://security.google.com/settings/security/apppasswords");
                        }
                        catch (Exception)
                        {
                            Logger.Write("https://security.google.com/settings/security/apppasswords");
                            throw;
                        }
                    }
                    Logger.Write("Make sure you have entered the right Email & Password.", LogLevel.Error);
                    await Task.Delay(5000);

                    Environment.Exit(0);
                }
                catch (InvalidProtocolBufferException ex) when(ex.Message.Contains("SkipLastField"))
                {
                    Logger.Write("Connection refused. Your IP might have been Blacklisted by Niantic. Exiting..", LogLevel.Error);
                    await Task.Delay(5000);

                    Environment.Exit(0);
                }
                catch (Exception e)
                {
                    Logger.Write(e.Message + " from " + e.Source);
                    Logger.Write("Error, trying automatic restart..", LogLevel.Error);
                    await Execute();
                }
                await Task.Delay(10000);
            }
        }
Esempio n. 20
0
        public GpxReader(string xml)
        {
            if (xml.Equals(""))
            {
                return;
            }
            _gpx.LoadXml(xml);
            if (_gpx.DocumentElement == null || !_gpx.DocumentElement.Name.Equals("gpx"))
            {
                return;
            }
            var gpxNodes = _gpx.GetElementsByTagName("gpx")[0].ChildNodes;

            foreach (XmlNode node in gpxNodes)
            {
                switch (node.Name)
                {
                case "name":
                    Name = node.InnerText;
                    break;

                case "desc":
                    Description = node.InnerText;
                    break;

                case "author":
                    Author = node.InnerText;
                    break;

                case "email":
                    EMail = node.InnerText;
                    break;

                case "time":
                    Time = node.InnerText;
                    break;

                case "keywords":
                    KeyWords = node.InnerText;
                    break;

                case "bounds":
                    Bounds = new GpsBoundary();
                    if (node.Attributes != null)
                    {
                        foreach (XmlAttribute att in node.Attributes)
                        {
                            switch (att.Name)
                            {
                            case "minlat":
                                Bounds.Min.Lat = att.Value;
                                break;

                            case "minlon":
                                Bounds.Min.Lon = att.Value;
                                break;

                            case "maxlat":
                                Bounds.Max.Lat = att.Value;
                                break;

                            case "maxlon":
                                Bounds.Max.Lon = att.Value;
                                break;
                            }
                        }
                    }
                    break;

                case "wpt":
                    var newWayPoint = new Wpt(node);
                    WayPoints.Add(newWayPoint);
                    break;

                case "rte":
                    var newRoute = new Rte(node);
                    Routes.Add(newRoute);
                    break;

                case "trk":
                    var track = new Trk(node);
                    Tracks.Add(track);
                    break;

                case "url":
                    Url = node.InnerText;
                    break;

                case "urlname":
                    UrlName = node.InnerText;
                    break;

                case "topografix:active_point":
                case "topografix:map":
                    break;

                default:
                    Logger.Write("Unhandled data in GPX file, attempting to skip.", LogLevel.Info);
                    break;
                }
            }
        }