Exemple #1
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            // Looking for any lure pokestop neaby

            var mapObjects = await session.Client.Map.GetMapObjects();

            var pokeStops = mapObjects.MapCells.SelectMany(i => i.Forts)
                            .Where(
                i =>
                (i.Type == FortType.Checkpoint) &&
                i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime()
                );

            session.AddForts(pokeStops.ToList());

            var             forts       = session.Forts.Where(p => p.Type == FortType.Checkpoint);
            List <FortData> luredNearBy = new List <FortData>();

            foreach (FortData fort in forts)
            {
                var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                       session.Client.CurrentLongitude, fort.Latitude, fort.Longitude);
                if (distance < 40 && fort.LureInfo != null)
                {
                    luredNearBy.Add(fort);
                    await Execute(session, fort, cancellationToken);
                }
            }
            ;
        }
Exemple #2
0
        public static async Task SpinPokestopNearBy(ISession session, CancellationToken cancellationToken, FortData destinationFort = null)
        {
            var allForts = session.Forts.Where(p => p.Type == FortType.Checkpoint).ToList();

            if (allForts.Count > 1)
            {
                var spinablePokestops = allForts.Where(
                    i =>
                    (
                        LocationUtils.CalculateDistanceInMeters(
                            session.Client.CurrentLatitude, session.Client.CurrentLongitude,
                            i.Latitude, i.Longitude) < 40 &&
                        i.CooldownCompleteTimestampMs == 0 &&
                        (destinationFort == null || destinationFort.Id != i.Id))
                    ).ToList();

                List <FortData> spinedPokeStops = new List <FortData>();
                if (spinablePokestops.Count >= 1)
                {
                    foreach (var pokeStop in spinablePokestops)
                    {
                        var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
                        await FarmPokestop(session, pokeStop, fortInfo, cancellationToken, true);

                        pokeStop.CooldownCompleteTimestampMs = DateTime.UtcNow.ToUnixTime() + 5 * 60 * 1000;
                        spinedPokeStops.Add(pokeStop);
                        if (spinablePokestops.Count > 1)
                        {
                            await Task.Delay(1000);
                        }
                    }
                }
                session.AddForts(spinablePokestops);
            }
        }
Exemple #3
0
        public static async Task SpinPokestopNearBy(ISession session, CancellationToken cancellationToken, FortData destinationFort = null)
        {
            if (session.Forts.Count() > 0)
            {
                var spinablePokestops = session.Forts.Where(
                    i =>
                    (
                        LocationUtils.CalculateDistanceInMeters(
                            session.Client.CurrentLatitude, session.Client.CurrentLongitude,
                            i.Latitude, i.Longitude) < 40 &&
                        i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime() &&
                        (destinationFort == null || destinationFort.Id != i.Id))
                    ).ToList();

                if (spinablePokestops.Count() > 0)
                {
                    foreach (var pokeStop in spinablePokestops)
                    {
                        var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude).ConfigureAwait(false);
                        await FarmPokestop(session, pokeStop, fortInfo, cancellationToken, true).ConfigureAwait(false);
                    }
                }
                session.AddForts(spinablePokestops);
            }
        }
Exemple #4
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            TinyIoC.TinyIoCContainer.Current.Resolve <MultiAccountManager>().ThrowIfSwitchAccountRequested();
            //request map objects to referesh data. keep all fort in session

            var mapObjectTupe = await GetPokeStops(session).ConfigureAwait(false);

            var pokeStop = await GetNextPokeStop(session).ConfigureAwait(false);

            while (pokeStop != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                // Exit this task if both catching and looting has reached its limits
                await CheckLimit(session).ConfigureAwait(false);

                var fortInfo = pokeStop.Id.StartsWith(SetMoveToTargetTask.TARGET_ID) ? SetMoveToTargetTask.FakeFortInfo(pokeStop) : await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude).ConfigureAwait(false);

                await WalkingToPokeStop(session, cancellationToken, pokeStop, fortInfo).ConfigureAwait(false);

                await DoActionAtPokeStop(session, cancellationToken, pokeStop, fortInfo).ConfigureAwait(false);

                await UseGymBattleTask.Execute(session, cancellationToken, pokeStop, fortInfo).ConfigureAwait(false);

                if (fortInfo.Type == FortType.Gym &&
                    (session.GymState.getGymDetails(session, pokeStop).GymState.FortData.OwnedByTeam == session.Profile.PlayerData.Team || session.GymState.capturedGymId.Equals(fortInfo.FortId)) &&
                    session.LogicSettings.GymConfig.Enable &&
                    session.LogicSettings.GymConfig.EnableGymTraining)
                {
                    if (string.IsNullOrEmpty(session.GymState.trainingGymId) || !session.GymState.trainingGymId.Equals(fortInfo.FortId))
                    {
                        session.GymState.trainingGymId = fortInfo.FortId;
                        session.GymState.trainingRound = 0;
                    }
                    session.GymState.trainingRound++;
                    if (session.GymState.trainingRound <= session.LogicSettings.GymConfig.MaxTrainingRoundsOnOneGym)
                    {
                        continue;
                    }
                }

                if (!await SetMoveToTargetTask.IsReachedDestination(pokeStop, session, cancellationToken).ConfigureAwait(false))
                {
                    pokeStop.CooldownCompleteTimestampMs = DateTime.UtcNow.ToUnixTime() + (pokeStop.Type == FortType.Gym ? session.LogicSettings.GymConfig.VisitTimeout : 5) * 60 * 1000; //5 minutes to cooldown
                    session.AddForts(new List <FortData>()
                    {
                        pokeStop
                    });                                                  //replace object in memory.
                }

                await MSniperServiceTask.Execute(session, cancellationToken).ConfigureAwait(false);

                if (session.LogicSettings.EnableHumanWalkingSnipe)
                {
                    await HumanWalkSnipeTask.Execute(session, cancellationToken, pokeStop, fortInfo).ConfigureAwait(false);
                }

                pokeStop = await GetNextPokeStop(session).ConfigureAwait(false);
            }
        }
Exemple #5
0
        //Please do not change GetPokeStops() in this file, it's specifically set
        //to only find stops within 40 meters for GPX pathing, as we are not going to the pokestops,
        //so do not make it more than 40 because it will never get close to those stops.
        //For non GPX pathing, it returns all pokestops in range.
        private static async Task <Tuple <List <FortData>, List <FortData> > > GetPokeStops(ISession session)
        {
            var             manager    = TinyIoC.TinyIoCContainer.Current.Resolve <MultiAccountManager>();
            List <FortData> mapObjects = await UpdateFortsData(session).ConfigureAwait(false);

            session.AddForts(mapObjects);

            if (!session.LogicSettings.UseGpxPathing)
            {
                if (mapObjects.Count <= 0)
                {
                    // only send this for non GPX because otherwise we generate false positives
                    session.EventDispatcher.Send(new WarnEvent
                    {
                        Message = session.Translation.GetTranslation(TranslationString.FarmPokestopsNoUsableFound)
                    });
                    mapEmptyCount++;
                    if (mapEmptyCount == 30 &&
                        manager.AllowMultipleBot() &&
                        TinyIoCContainer.Current.Resolve <MultiAccountManager>().AllowSwitch())
                    {
                        throw new ActiveSwitchByRuleException()
                              {
                                  MatchedRule = SwitchRules.EmptyMap, ReachedValue = 30
                              };
                    }
                }
                else
                {
                    mapEmptyCount = 0;
                }

                var pokeStops = mapObjects.Where(p => p.Type == FortType.Checkpoint).ToList();
                session.AddVisibleForts(pokeStops);
                session.EventDispatcher.Send(new PokeStopListEvent(mapObjects));

                var gyms = mapObjects.Where(p => p.Type == FortType.Gym).ToList();
                return(Tuple.Create(pokeStops, gyms));
            }

            if (mapObjects.Count > 0)
            {
                // only send when there are stops for GPX because otherwise we send empty arrays often
                session.EventDispatcher.Send(new PokeStopListEvent(mapObjects));
            }
            // Wasn't sure how to make this pretty. Edit as needed.
            return(Tuple.Create(
                       mapObjects.Where(
                           i => i.Type == FortType.Checkpoint &&
                           ( // Make sure PokeStop is within 40 meters or else it is pointless to hit it
                               LocationUtils.CalculateDistanceInMeters(
                                   session.Client.CurrentLatitude, session.Client.CurrentLongitude,
                                   i.Latitude, i.Longitude) <= 40)
                           ).ToList(),
                       mapObjects.Where(p => p.Type == FortType.Gym && LocationUtils.CalculateDistanceInMeters(
                                            session.Client.CurrentLatitude, session.Client.CurrentLongitude,
                                            p.Latitude, p.Longitude) <= 40).ToList()
                       ));
        }
        private static async Task <List <MapPokemon> > GetPokemons(ISession session)
        {
            var mapObjects = await session.Client.Map.GetMapObjects();

            session.AddForts(mapObjects.Item1.MapCells.SelectMany(p => p.Forts).ToList());
            var pokemons = mapObjects.Item1.MapCells.SelectMany(i => i.CatchablePokemons).ToList();

            return(pokemons);
        }
Exemple #7
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            //request map objects to referesh data. keep all fort in session

            var mapObjectTupe = await GetPokeStops(session);

            _pokestopList = mapObjectTupe.Item2;
            var pokeStop = await GetNextPokeStop(session);

            while (pokeStop != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                // Exit this task if both catching and looting has reached its limits
                if ((UseNearbyPokestopsTask._pokestopLimitReached || UseNearbyPokestopsTask._pokestopTimerReached) &&
                    (CatchPokemonTask._catchPokemonLimitReached || CatchPokemonTask._catchPokemonTimerReached))
                {
                    return;
                }
                if (session.LogicSettings.ActivateMSniper)
                {
                    await MSniperServiceTask.CheckMSniper(session, cancellationToken);
                }
                var fortInfo = pokeStop.Id == SetMoveToTargetTask.TARGET_ID ? SetMoveToTargetTask.FortInfo : await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                await WalkingToPokeStop(session, cancellationToken, pokeStop, fortInfo);

                await DoActionAtPokeStop(session, cancellationToken, pokeStop, fortInfo);

                await UseGymBattleTask.Execute(session, cancellationToken, pokeStop, fortInfo);

                if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
                {
                    await SnipePokemonTask.Execute(session, cancellationToken);
                }

                if (!await SetMoveToTargetTask.IsReachedDestination(pokeStop, session, cancellationToken))
                {
                    pokeStop.CooldownCompleteTimestampMs = DateTime.UtcNow.ToUnixTime() + (pokeStop.Type == FortType.Gym ? session.LogicSettings.GymVisitTimeout : 5) * 60 * 1000; //5 minutes to cooldown
                    session.AddForts(new List <FortData>()
                    {
                        pokeStop
                    });                                                  //replace object in memory.
                }

                if (session.LogicSettings.EnableHumanWalkingSnipe)
                {
                    await HumanWalkSnipeTask.Execute(session, cancellationToken, pokeStop);
                }
                pokeStop = await GetNextPokeStop(session);
            }
        }
Exemple #8
0
        //Please do not change GetPokeStops() in this file, it's specifically set
        //to only find stops within 40 meters for GPX pathing, as we are not going to the pokestops,
        //so do not make it more than 40 because it will never get close to those stops.
        //For non GPX pathing, it returns all pokestops in range.
        private static async Task <Tuple <List <FortData>, List <FortData> > > GetPokeStops(ISession session)
        {
            List <FortData> mapObjects = await UpdateFortsData(session);

            session.AddForts(mapObjects);

            if (!session.LogicSettings.UseGpxPathing)
            {
                if (mapObjects.Count <= 0)
                {
                    // only send this for non GPX because otherwise we generate false positives
                    session.EventDispatcher.Send(new WarnEvent
                    {
                        Message = session.Translation.GetTranslation(TranslationString.FarmPokestopsNoUsableFound)
                    });
                }

                var pokeStops = mapObjects.Where(p => p.Type == FortType.Checkpoint).ToList();
                session.AddVisibleForts(pokeStops);
                session.EventDispatcher.Send(new PokeStopListEvent {
                    Forts = mapObjects
                });

                var gyms = mapObjects.Where(p => p.Type == FortType.Gym).ToList();
                //   session.EventDispatcher.Send(new PokeStopListEvent { Forts = mapObjects });
                return(Tuple.Create(pokeStops, gyms));
            }

            if (mapObjects.Count > 0)
            {
                // only send when there are stops for GPX because otherwise we send empty arrays often
                session.EventDispatcher.Send(new PokeStopListEvent {
                    Forts = mapObjects
                });
            }
            // Wasn't sure how to make this pretty. Edit as needed.
            return(Tuple.Create(
                       mapObjects.Where(
                           i => i.Type == FortType.Checkpoint &&
                           ( // Make sure PokeStop is within 40 meters or else it is pointless to hit it
                               LocationUtils.CalculateDistanceInMeters(
                                   session.Client.CurrentLatitude, session.Client.CurrentLongitude,
                                   i.Latitude, i.Longitude) < 40) ||
                           session.LogicSettings.MaxTravelDistanceInMeters == 0
                           ).ToList(),
                       mapObjects.Where(p => p.Type == FortType.Gym && LocationUtils.CalculateDistanceInMeters(
                                            session.Client.CurrentLatitude, session.Client.CurrentLongitude,
                                            p.Latitude, p.Longitude) < 40).ToList()
                       ));
        }
Exemple #9
0
        public static async Task <IOrderedEnumerable <MapPokemon> > GetNearbyPokemons(ISession session)
        {
            var mapObjects = await session.Client.Map.GetMapObjects();

            session.AddForts(mapObjects.Item1.MapCells.SelectMany(p => p.Forts).ToList());
            var pokemons = mapObjects.Item1.MapCells.SelectMany(i => i.CatchablePokemons)
                           .OrderBy(
                i =>
                LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                        session.Client.CurrentLongitude,
                                                        i.Latitude, i.Longitude));

            return(pokemons);
        }
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            TinyIoC.TinyIoCContainer.Current.Resolve <MultiAccountManager>().ThrowIfSwitchAccountRequested();
            //request map objects to referesh data. keep all fort in session

            var mapObjectTupe = await GetPokeStops(session).ConfigureAwait(false);

            var pokeStop = await GetNextPokeStop(session).ConfigureAwait(false);

            while (pokeStop != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                // Exit this task if both catching and looting has reached its limits
                await CheckLimit(session).ConfigureAwait(false);

                var fortInfo = pokeStop.Id.StartsWith(SetMoveToTargetTask.TARGET_ID) ? SetMoveToTargetTask.FakeFortInfo(pokeStop) : await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude).ConfigureAwait(false);
                await WalkingToPokeStop(session, cancellationToken, pokeStop, fortInfo).ConfigureAwait(false);
                await DoActionAtPokeStop(session, cancellationToken, pokeStop, fortInfo).ConfigureAwait(false);

                if (pokeStop.Type == FortType.Gym)
                {
                    var fortDetails = await session.Client.Fort.GymGetInfo(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude).ConfigureAwait(false);

                    if (fortDetails.Result == GymGetInfoResponse.Types.Result.Success)
                    {
                        await UseGymBattleTask.Execute(session, cancellationToken, pokeStop, fortInfo, fortDetails).ConfigureAwait(false);
                    }
                }

                if (!await SetMoveToTargetTask.IsReachedDestination(pokeStop, session, cancellationToken).ConfigureAwait(false))
                {
                    pokeStop.CooldownCompleteTimestampMs = DateTime.UtcNow.ToUnixTime() + 5 * 60 * 1000; //5 minutes to cooldown
                    session.AddForts(new List <FortData>()
                    {
                        pokeStop
                    });                                                  //replace object in memory.
                }

                if (session.LogicSettings.EnableHumanWalkingSnipe)
                {
                    await MSniperServiceTask.Execute(session, cancellationToken).ConfigureAwait(false);

                    await HumanWalkSnipeTask.Execute(session, cancellationToken, pokeStop, fortInfo).ConfigureAwait(false);
                }

                pokeStop = await GetNextPokeStop(session).ConfigureAwait(false);
            }
        }
Exemple #11
0
        public static async Task <List <FortData> > UpdateFortsData(ISession session)
        {
            var mapObjects = await session.Client.Map.GetMapObjects().ConfigureAwait(false);

            session.AddForts(mapObjects.MapCells.SelectMany(p => p.Forts).ToList());

            var pokeStops = mapObjects.MapCells.SelectMany(i => i.Forts)
                            .Where(
                i =>
                (i.Type == FortType.Checkpoint || i.Type == FortType.Gym) &&
                i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime() &&
                (
                    LocationUtils.CalculateDistanceInMeters(
                        session.Settings.DefaultLatitude, session.Settings.DefaultLongitude,
                        i.Latitude, i.Longitude) <= session.LogicSettings.MaxTravelDistanceInMeters)
                );

            return(pokeStops.ToList());
        }
Exemple #12
0
        public static async Task SpinPokestopNearBy(ISession session, CancellationToken cancellationToken, FortData destinationFort = null)
        {
            var allForts = session.Forts.Where(p => p.Type == FortType.Checkpoint).ToList();

            if (allForts.Count > 1)
            {
                var spinablePokestops = allForts.Where(
                    i =>
                    (
                        LocationUtils.CalculateDistanceInMeters(
                            session.Client.CurrentLatitude, session.Client.CurrentLongitude,
                            i.Latitude, i.Longitude) < 40 &&
                        i.CooldownCompleteTimestampMs == 0 &&
                        (destinationFort == null || destinationFort.Id != i.Id))
                    ).ToList();

                List <FortData> spinedPokeStops = new List <FortData>();
                if (spinablePokestops.Count >= 1)
                {
                    foreach (var pokeStop in spinablePokestops)
                    {
                        var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
                        await FarmPokestop(session, pokeStop, fortInfo, cancellationToken, true);

                        // Synchronize cooldown with map
                        var mapFort = (await session.Client.Map.GetMapObjects()).MapCells.SelectMany(x => x.Forts).Where(y => y.Id == pokeStop.Id).FirstOrDefault();
                        if (mapFort != pokeStop)
                        {
                            pokeStop.CooldownCompleteTimestampMs = mapFort.CooldownCompleteTimestampMs;
                        }
                        spinedPokeStops.Add(pokeStop);
                        if (spinablePokestops.Count > 1)
                        {
                            await Task.Delay(1000);
                        }
                    }
                }
                session.AddForts(spinablePokestops);
            }
        }
        public static async Task Snipe(ISession session, IEnumerable <PokemonId> pokemonIds, double latitude,
                                       double longitude, CancellationToken cancellationToken)
        {
            if (LocsVisited.Contains(new PokemonLocation(latitude, longitude)))
            {
                return;
            }

            var currentLatitude  = session.Client.CurrentLatitude;
            var currentLongitude = session.Client.CurrentLongitude;
            var catchedPokemon   = false;

            session.EventDispatcher.Send(new SnipeModeEvent {
                Active = true
            });

            List <MapPokemon> catchablePokemon;

            try
            {
                await
                LocationUtils.UpdatePlayerLocationWithAltitude(session,
                                                               new GeoCoordinate(latitude, longitude, session.Client.CurrentAltitude), 0); // Set speed to 0 for random speed.

                session.EventDispatcher.Send(new UpdatePositionEvent
                {
                    Longitude = longitude,
                    Latitude  = latitude
                });

                var mapObjects = session.Client.Map.GetMapObjects().Result;
                session.AddForts(mapObjects.Item1.MapCells.SelectMany(p => p.Forts).ToList());
                catchablePokemon =
                    mapObjects.Item1.MapCells.SelectMany(q => q.CatchablePokemons)
                    .Where(q => pokemonIds.Contains(q.PokemonId))
                    .OrderByDescending(pokemon => PokemonInfo.CalculateMaxCpMultiplier(pokemon.PokemonId))
                    .ToList();
            }
            finally
            {
                await
                LocationUtils.UpdatePlayerLocationWithAltitude(session,
                                                               new GeoCoordinate(currentLatitude, currentLongitude, session.Client.CurrentAltitude), 0); // Set speed to 0 for random speed.
            }

            if (catchablePokemon.Count == 0)
            {
                // Pokemon not found but we still add to the locations visited, so we don't keep sniping
                // locations with no pokemon.
                if (!LocsVisited.Contains(new PokemonLocation(latitude, longitude)))
                {
                    LocsVisited.Add(new PokemonLocation(latitude, longitude));
                }
            }

            foreach (var pokemon in catchablePokemon)
            {
                EncounterResponse encounter;
                try
                {
                    await
                    LocationUtils.UpdatePlayerLocationWithAltitude(session,
                                                                   new GeoCoordinate(latitude, longitude, session.Client.CurrentAltitude), 0); // Set speed to 0 for random speed.

                    encounter =
                        session.Client.Encounter.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnPointId).Result;
                }
                finally
                {
                    await
                    LocationUtils.UpdatePlayerLocationWithAltitude(session,
                                                                   new GeoCoordinate(currentLatitude, currentLongitude, session.Client.CurrentAltitude), 0); // Set speed to 0 for random speed.
                }

                switch (encounter.Status)
                {
                case EncounterResponse.Types.Status.EncounterSuccess:

                    if (!LocsVisited.Contains(new PokemonLocation(latitude, longitude)))
                    {
                        LocsVisited.Add(new PokemonLocation(latitude, longitude));
                    }

                    //Also add exact pokemon location to LocsVisited, some times the server one differ a little.
                    if (!LocsVisited.Contains(new PokemonLocation(pokemon.Latitude, pokemon.Longitude)))
                    {
                        LocsVisited.Add(new PokemonLocation(pokemon.Latitude, pokemon.Longitude));
                    }

                    session.EventDispatcher.Send(new UpdatePositionEvent
                    {
                        Latitude  = currentLatitude,
                        Longitude = currentLongitude
                    });

                    await CatchPokemonTask.Execute(session, cancellationToken, encounter, pokemon,
                                                   currentFortData : null, sessionAllowTransfer : true);

                    catchedPokemon = true;
                    break;

                case EncounterResponse.Types.Status.PokemonInventoryFull:
                    if (session.LogicSettings.EvolveAllPokemonAboveIv ||
                        session.LogicSettings.EvolveAllPokemonWithEnoughCandy ||
                        session.LogicSettings.UseLuckyEggsWhileEvolving ||
                        session.LogicSettings.KeepPokemonsThatCanEvolve)
                    {
                        await EvolvePokemonTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.TransferDuplicatePokemon)
                    {
                        await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
                    }
                    else
                    {
                        session.EventDispatcher.Send(new WarnEvent
                        {
                            Message = session.Translation.GetTranslation(TranslationString.InvFullTransferManually)
                        });
                    }
                    break;

                default:
                    session.EventDispatcher.Send(new WarnEvent
                    {
                        Message =
                            session.Translation.GetTranslation(
                                TranslationString.EncounterProblem, encounter.Status)
                    });
                    break;
                }

                if (!Equals(catchablePokemon.ElementAtOrDefault(catchablePokemon.Count - 1), pokemon))
                {
                    await Task.Delay(session.LogicSettings.DelayBetweenPokemonUpgrade, cancellationToken);
                }
            }

            if (!catchedPokemon)
            {
                session.EventDispatcher.Send(new SnipeEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.NoPokemonToSnipe)
                });
            }

            _lastSnipe = DateTime.Now;

            if (catchedPokemon)
            {
                session.Stats.SnipeCount++;
                session.Stats.LastSnipeTime = _lastSnipe;
            }
            session.EventDispatcher.Send(new SnipeModeEvent {
                Active = false
            });
            await Task.Delay(session.LogicSettings.DelayBetweenPlayerActions, cancellationToken);
        }
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            //request map objects to referesh data. keep all fort in session

            var mapObjectTupe = await GetPokeStops(session);

            _pokestopList = mapObjectTupe.Item2;
            var pokeStop = await GetNextPokeStop(session);

            while (pokeStop != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await SnipeMSniperTask.CheckMSniperLocation(session, cancellationToken);

                var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                await WalkingToPokeStop(session, cancellationToken, pokeStop, fortInfo);

                await DoActionAtPokeStop(session, cancellationToken, pokeStop, fortInfo);

                await UseGymBattleTask.Execute(session, cancellationToken, pokeStop, fortInfo);

                if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
                {
                    await SnipePokemonTask.Execute(session, cancellationToken);
                }

                await SnipeMSniperTask.CheckMSniperLocation(session, cancellationToken);

                if (session.LogicSettings.EnableHumanWalkingSnipe)
                {
                    await HumanWalkSnipeTask.Execute(session, cancellationToken, pokeStop);
                }
                pokeStop.CooldownCompleteTimestampMs = DateTime.UtcNow.ToUnixTime() + (pokeStop.Type == FortType.Gym ? session.LogicSettings.GymVisitTimeout : 5) * 60 * 1000; //5 minutes to cooldown
                session.AddForts(new List <FortData>()
                {
                    pokeStop
                });                                                  //replace object in memory.
                pokeStop = await GetNextPokeStop(session);
            }

            //await VisitNearByGymTask.UpdateGymList(session, mapObjectTupe.Item2);
            //while (_pokestopList.Any())
            //{
            //    cancellationToken.ThrowIfCancellationRequested();
            //    await SnipeMSniperTask.CheckMSniperLocation(session, cancellationToken);

            //    _pokestopList =
            //        _pokestopList.OrderBy(
            //            i =>
            //                session.Navigation.WalkStrategy.CalculateDistance(
            //                    session.Client.CurrentLatitude, session.Client.CurrentLongitude, i.Latitude, i.Longitude, session)).ToList();

            //    // randomize next pokestop between first and second by distance
            //    var pokestopListNum = 0;
            //    if (_pokestopList.Count > 1)
            //        pokestopListNum = _rc.Next(0, 2);

            //    var pokeStop = _pokestopList[pokestopListNum];
            //    _pokestopList.RemoveAt(pokestopListNum);

            //    // this logic should only be called when we reach a pokestop either via GPX path or normal walking
            //    // as when walk-sniping, we want to get to the snipe ASAP rather than stop for lured pokemon upon
            //    // calling FarmPokestop; in that situation we are also always within 40m of the pokestop, so no
            //    // need to walk to it
            //    var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

            //    // we only move to the PokeStop, and send the associated FortTargetEvent, when not using GPX
            //    // also, GPX pathing uses its own EggWalker and calls the CatchPokemon tasks internally.
            //    if (!session.LogicSettings.UseGpxPathing)
            //    {
            //        // Will modify Lat,Lng and Name to fake position
            //        SetMoveToTargetTask.CheckSetMoveToTargetStatus(ref fortInfo, ref pokeStop);

            //        var eggWalker = new EggWalker(1000, session);

            //        var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
            //            session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude);
            //        cancellationToken.ThrowIfCancellationRequested();

            //        if (!session.LogicSettings.UseGoogleWalk && !session.LogicSettings.UseYoursWalk)
            //            session.EventDispatcher.Send(new FortTargetEvent { Name = fortInfo.Name, Distance = distance, Route = "NecroBot" });
            //        else
            //            BaseWalkStrategy.FortInfo = fortInfo;

            //        await session.Navigation.Move(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude,
            //            LocationUtils.getElevation(session, pokeStop.Latitude, pokeStop.Longitude)),
            //        async () =>
            //        {
            //            if (SetMoveToTargetTask.CheckStopforSetMoveToTarget())
            //                return false;
            //            // Catch normal map Pokemon
            //            await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
            //            //Catch Incense Pokemon
            //            await CatchIncensePokemonsTask.Execute(session, cancellationToken);
            //            // Minor fix google route ignore pokestop
            //            await LookPokestops(session, pokeStop, cancellationToken);
            //            return true;
            //        },
            //        session,
            //        cancellationToken);

            //        // we have moved this distance, so apply it immediately to the egg walker.
            //        await eggWalker.ApplyDistance(distance, cancellationToken);
            //    }

            //    if (SetMoveToTargetTask.CheckReachTarget(session))
            //        return;

            //    await FortAction(session, pokeStop, fortInfo, cancellationToken);

            //    if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
            //        await SnipePokemonTask.Execute(session, cancellationToken);
            //    //samuraitruong: since we has duplication code for gym. I temporary comment this line to disable my feature. keep the code as reference, will remove later.

            //    //await VisitNearByGymTask.Execute(session, cancellationToken);

            //    if (session.LogicSettings.EnableHumanWalkingSnipe)
            //    {
            //        //refactore to move this code inside the task later.
            //        await HumanWalkSnipeTask.Execute(session, cancellationToken,
            //            async (lat, lng) =>
            //            {
            //                //idea of this function is to spin pokestop on way. maybe risky.
            //                var reachablePokestops = _pokestopList.Where(i =>
            //                    LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
            //                        session.Client.CurrentLongitude, i.Latitude, i.Longitude) < 40
            //                        && i.CooldownCompleteTimestampMs == 0
            //                        ).ToList();
            //                reachablePokestops = reachablePokestops.OrderBy(i =>
            //                LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
            //                session.Client.CurrentLongitude, i.Latitude, i.Longitude)).ToList();

            //                foreach (var ps in reachablePokestops)
            //                {
            //                    if (!session.LogicSettings.UseGpxPathing)
            //                        _pokestopList.Remove(ps);
            //                    var fi = await session.Client.Fort.GetFort(ps.Id, ps.Latitude, ps.Longitude);
            //                    await FarmPokestop(session, ps, fi, cancellationToken, true);
            //                    await Task.Delay(2000, cancellationToken);
            //                }
            //            },
            //            async () =>
            //            {
            //                // if using GPX we have to move back to the original pokestop, to resume the path.
            //                // we do not try to use pokest;ops on the way back, as we will have used them getting
            //                // here.
            //                if (session.LogicSettings.UseGpxPathing)
            //                {
            //                    var eggWalker = new EggWalker(1000, session);

            //                    var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
            //                        session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude);
            //                    var geo = new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude);

            //                    await session.Navigation.Move(geo,
            //                        async () =>
            //                        {
            //                            await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
            //                            //Catch Incense Pokemon
            //                            await CatchIncensePokemonsTask.Execute(session, cancellationToken);
            //                        },
            //                        session,
            //                        cancellationToken);

            //                    await eggWalker.ApplyDistance(distance, cancellationToken);
            //                    return;
            //                }

            //                var nearestStop = _pokestopList.OrderBy(i =>
            //                    LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
            //                        session.Client.CurrentLongitude, i.Latitude, i.Longitude)).FirstOrDefault();

            //                if (nearestStop != null)
            //                {
            //                    var walkedDistance = LocationUtils.CalculateDistanceInMeters(nearestStop.Latitude, nearestStop.Longitude, session.Client.CurrentLatitude, session.Client.CurrentLongitude);
            //                    if (walkedDistance > session.LogicSettings.HumanWalkingSnipeWalkbackDistanceLimit)
            //                    {
            //                        await Task.Delay(3000, cancellationToken);
            //                        var nearbyPokeStops = await UpdateFortsData(session);
            //                        var notexists = nearbyPokeStops.Where(p => _pokestopList.All(x => x.Id != p.Id)).ToList();
            //                        _pokestopList.AddRange(notexists);
            //                        session.EventDispatcher.Send(new PokeStopListEvent { Forts = _pokestopList });
            //                        session.EventDispatcher.Send(new HumanWalkSnipeEvent
            //                        {
            //                            Type = HumanWalkSnipeEventTypes.PokestopUpdated,
            //                            Pokestops = notexists,
            //                            NearestDistance = walkedDistance
            //                        });
            //                    }
            //                }
            //            });
            //    }
            //}
        }