Exemplo n.º 1
0
        private ulong TrySnipePokemons(PokemonId pokeid, GeoCoordinate pokeCoords, GeoCoordinate returnCoords)
        {
            const bool goBack = false; // since new changes in server before of api 0.63 it must be "false".
            var        tries  = 1;
            var        found  = false;
            ulong      caught = 0;

            do
            {
                SendToLog($"Try {tries} of {GlobalVars.SnipeOpts.NumTries}");
                var mapObjectsResponse = _client.Map.GetMapObjects(true).Result;
                var pokemons           = mapObjectsResponse.MapCells.SelectMany(i => i.CatchablePokemons);
                if (pokemons.Any())
                {
                    SendToLog($"Found {pokemons.Count()} catchable Pokemon(s)");
                    MapPokemon pokemon = null;
                    found = FindPokemon(pokeid, pokeCoords, pokemons, out pokemon);
                    if (found)
                    {
                        caught = CatchingLogic.CatchPokemon(pokemon.EncounterId, pokemon.SpawnPointId, pokemon.PokemonId, pokemon.Longitude, pokemon.Latitude, goBack, returnCoords.Latitude, returnCoords.Longitude);
                    }
                }
                tries++;
                if (!found)
                {
                    SendToLog($"No Pokemon Found!");
                    if ((tries <= GlobalVars.SnipeOpts.NumTries))
                    {
                        SendToLog($"Waiting {GlobalVars.SnipeOpts.WaitSecond} seconds for Pokemon to appear...");
                        RandomHelper.RandomSleep(GlobalVars.SnipeOpts.WaitSecond * 1200);
                    }
                }
            } while ((tries <= GlobalVars.SnipeOpts.NumTries) && !found);

            if (caught != 0)
            {
                SendToLog($"{pokeid} caught!");
            }
            else if (found)
            {
                SendToLog($"{ pokeid} not caught!");
            }

            return(caught);
        }
Exemplo n.º 2
0
        public static StartGymBattleResponse StartGymBattle(Client client, string gymId, ulong defendingPokemonId,
                                                            IEnumerable <ulong> attackingPokemonIds)
        {
            StartGymBattleResponse resp = null;
            var numTries = 3;
            var startOk  = false;

            do
            {
                try {
                    resp = client.Fort.StartGymBattle(gymId, defendingPokemonId, attackingPokemonIds).Result;
                    if (resp == null)
                    {
                        Logger.Debug("(Gym) - Response to start battle was null.");
                    }
                    else
                    {
                        if (resp.BattleLog == null)
                        {
                            Logger.Debug("(Gym) - BatlleLog to start battle was null");
                        }
                        else
                        {
                            startOk = true;
                            Logger.Debug("StartGymBattle Response:" + resp);
                        }
                    }
                } catch (Exception ex1) {
                    Logger.ExceptionInfo("StartGymBattle: " + ex1);
                    RandomHelper.RandomSleep(5000);
                    if (GlobalVars.Gyms.Testing == "Relogin")
                    {
                        client.Login.DoLogin().Wait();
                    }
                    else if (GlobalVars.Gyms.Testing == "GetPlayer")
                    {
                        client.Player.GetPlayer();
                        RandomHelper.RandomSleep(3000);
                    }
                    else if (GlobalVars.Gyms.Testing == "Wait 2 minutes catching pokemons")
                    {
                        if (GlobalVars.CatchPokemon)
                        {
                            Logger.Info("Trying to catch pokemons until next attack");
                        }
                        // 0.00001 = 1 meters
                        // http://www.um.es/geograf/sigmur/temariohtml/node6_mn.html
                        //http://gizmodo.com/how-precise-is-one-degree-of-longitude-or-latitude-1631241162
                        var gymloc = new GeoCoordinate(client.CurrentLongitude, client.CurrentLatitude, client.CurrentAltitude);
                        for (var times = 1; times < 5; times++)
                        {
                            var rnd = RandomHelper.GetLongRandom(8, 9) * 0.00001;
                            Logger.Debug("going to 8 meters far of gym");
                            LocationUtils.updatePlayerLocation(client, gymloc.Longitude + rnd, gymloc.Latitude, gymloc.Altitude);
                            RandomHelper.RandomSleep(10000);
                            CatchingLogic.Execute();
                            rnd = RandomHelper.GetLongRandom(8, 9) * 0.00001;
                            Logger.Debug("going to 8 meters far of gym");
                            LocationUtils.updatePlayerLocation(client, gymloc.Longitude + rnd, gymloc.Latitude, gymloc.Altitude);
                            RandomHelper.RandomSleep(10000);
                            CatchingLogic.Execute();
                            Logger.Debug("returning to gym location");
                            // go back
                            LocationUtils.updatePlayerLocation(client, gymloc.Longitude, gymloc.Latitude, gymloc.Altitude);
                            RandomHelper.RandomSleep(10000);
                            CatchingLogic.Execute();
                        }
                        RandomHelper.RandomSleep(2000);
                    }
                    else
                    {
                        RandomHelper.RandomSleep(115000);
                        client.Login.DoLogin().Wait();
                    }
                }
                numTries--;
            } while (!startOk && numTries > 0);
            return(resp);
        }
Exemplo n.º 3
0
        public static StartGymBattleResponse StartGymBattle(Client client, string gymId, ulong defendingPokemonId,
                                                            IEnumerable <ulong> attackingPokemonIds)
        {
            StartGymBattleResponse resp = null;
            var numTries    = 3;
            var startFailed = false;

            do
            {
                resp = client.Fort.StartGymBattle(gymId, defendingPokemonId, attackingPokemonIds);
                if (resp == null)
                {
                    Logger.Debug("(Gym) - Response to start battle was null.");
                    startFailed = true;
                }
                else
                {
                    if (resp.BattleLog == null)
                    {
                        Logger.Debug("(Gym) - BatlleLog to start battle was null");
                        startFailed = true;
                    }
                }

                if (startFailed)
                {
                    RandomHelper.RandomSleep(5000);
                    if (GlobalVars.Gyms.Testing == "Fire Request Block Two")
                    {
                        client.Login.FireRequestBlockTwo().Wait();
                        RandomHelper.RandomSleep(2000);
                    }
                    else if (GlobalVars.Gyms.Testing == "Wait 2 minutes before of next try" && numTries == 3)
                    {
                        if (GlobalVars.CatchPokemon)
                        {
                            Logger.Info("While, we will try to catch pokemons");
                        }
                        // 0.00001 = 1 meters
                        // http://www.um.es/geograf/sigmur/temariohtml/node6_mn.html
                        //http://gizmodo.com/how-precise-is-one-degree-of-longitude-or-latitude-1631241162
                        var gymloc = new GeoCoordinate(client.CurrentLongitude, client.CurrentLatitude, client.CurrentAltitude);
                        for (var times = 1; times < 5; times++)
                        {
                            var rnd = RandomHelper.RandomNumber(50, 90) * 0.00001;
                            Logger.Debug("going to 50 meters far of gym");
                            LocationUtils.updatePlayerLocation(client, gymloc.Longitude + rnd, gymloc.Latitude, gymloc.Altitude);
                            RandomHelper.RandomSleep(10000);
                            CatchingLogic.Execute();
                            rnd = RandomHelper.RandomNumber(50, 90) * 0.00001;
                            Logger.Debug("going to 50 meters far of gym");
                            LocationUtils.updatePlayerLocation(client, gymloc.Longitude + rnd, gymloc.Latitude, gymloc.Altitude);
                            RandomHelper.RandomSleep(10000);
                            CatchingLogic.Execute();
                            Logger.Debug("returning to gym location");
                            // go back
                            LocationUtils.updatePlayerLocation(client, gymloc);
                            RandomHelper.RandomSleep(10000);
                            CatchingLogic.Execute();
                        }
                        RandomHelper.RandomSleep(2000);
                    }
                    else
                    {
                        RandomHelper.RandomSleep(5000);
                    }
                }
                else
                {
                    Logger.Debug("StartGymBattle Response:" + resp);
                }
                numTries--;
            } while (startFailed && numTries > 0);
            return(resp);
        }