From f4e600a3cf0624588d9a62308fe5293d2e7f0f74 Mon Sep 17 00:00:00 2001 From: PocketMobsters Date: Wed, 3 Aug 2016 13:40:08 -0500 Subject: [PATCH] Better pokestop grabbing logic --- .../Tasks/FarmPokestopsTask.cs | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsTask.cs index fef92a0..c36aa02 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsTask.cs @@ -439,17 +439,34 @@ private static async Task> GetPokeStops(ISession session) session.EventDispatcher.Send(new PokeStopListEvent { Forts = pokeStops.ToList() }); // Wasn't sure how to make this pretty. Edit as needed. - pokeStops = pokeStops - .Where( - i => - i.Type == FortType.Checkpoint && - i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime() && - ( // Make sure PokeStop is within max travel distance, unless it's set to 0. - LocationUtils.CalculateDistanceInMeters( - session.Settings.DefaultLatitude, session.Settings.DefaultLongitude, - i.Latitude, i.Longitude) < session.LogicSettings.MaxTravelDistanceInMeters) || - session.LogicSettings.MaxTravelDistanceInMeters == 0 - ); + if (session.LogicSettings.Teleport) + { + pokeStops = mapObjects.MapCells.SelectMany(i => i.Forts) + .Where( + i => + i.Type == FortType.Checkpoint && + i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime() && + ( // Make sure PokeStop is within max travel distance, unless it's set to 0. + LocationUtils.CalculateDistanceInMeters( + session.Settings.DefaultLatitude, session.Settings.DefaultLongitude, + i.Latitude, i.Longitude) < session.LogicSettings.MaxTravelDistanceInMeters) || + session.LogicSettings.MaxTravelDistanceInMeters == 0 + ); + } + else + { + pokeStops = mapObjects.MapCells.SelectMany(i => i.Forts) + .Where( + i => + i.Type == FortType.Checkpoint && + i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime() && + ( // Make sure PokeStop is within max travel distance, unless it's set to 0. + LocationUtils.CalculateDistanceInMeters( + session.Client.CurrentLatitude, session.Client.CurrentLongitude, + i.Latitude, i.Longitude) < session.LogicSettings.MaxTravelDistanceInMeters) || + session.LogicSettings.MaxTravelDistanceInMeters == 0 + ); + } return pokeStops.ToList(); } @@ -460,4 +477,4 @@ private static async Task DownloadProfile(ISession session) session.Profile = await session.Client.Player.GetPlayer(); } } -} \ No newline at end of file +}