예제 #1
0
파일: PoGoAsh.cs 프로젝트: wuyou/HaxtonBot
        public async Task CatchEmAll()
        {
            var currentLat  = _navigation.CurrentLatitude;
            var currentLong = _navigation.CurrentLongitude;
            var encounters  = (await SearchAndEncounterPokemon()).ToList();
            //logger.Info($"We found {encounters.Count} pokemon!");
            await _navigation.TeleportToLocation(currentLat, currentLong);

            foreach (var encounter in encounters)
            {
                encounter.Invoke();
                await Task.Delay(1500);
            }
        }
예제 #2
0
        public async Task EncounterPokemonAndCatch(IEnumerable <MapPokemon> pokemon)
        {
            var lat            = _navigation.CurrentLatitude;
            var lng            = _navigation.CurrentLongitude;
            var mapPokemons    = pokemon as MapPokemon[] ?? pokemon.ToArray();
            var pokemonToRetry = mapPokemons.ToList();

            foreach (var mapPokemon in mapPokemons)
            {
                if (_logicSettings.UsePokemonToNotCatchFilter && _logicSettings.PokemonsNotToCatch.Contains(mapPokemon.PokemonId))
                {
                    continue;
                }
                await _navigation.TeleportToLocation(mapPokemon.Latitude, mapPokemon.Longitude);

                var encounter = await _encounter.EncounterPokemonAsync(mapPokemon);

                if (encounter.Status == EncounterResponse.Types.Status.EncounterSuccess)
                {
                    try
                    {
                        await _navigation.TeleportToLocation(lat, lng);

                        pokemonToRetry.Remove(mapPokemon);

                        if ((await _encounter.CatchPokemon(encounter, mapPokemon)).Status ==
                            CatchPokemonResponse.Types.CatchStatus.CatchError)
                        {
                            _map.EncounterSpawnList.Remove(mapPokemon.EncounterId + mapPokemon.SpawnPointId);
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex, "Unable to catch pokemon");
                    }
                }
                else
                {
                    logger.Warn($"Encounter failed with reason : {encounter.Status}");
                }
            }
        }
예제 #3
0
        public async Task CatchEmAll()
        {
            var lat          = _navigation.CurrentLatitude;
            var lng          = _navigation.CurrentLongitude;
            var cloudPokemon = _pokemon.CloudPokemon(5).ToArray();

            logger.Warn($"{cloudPokemon.Count()} possible pokemon. Doing some magic now.");
            if (_inventory.Pokeballs > 5)
            {
                var encounters = new List <Action>();
                foreach (var mapPokemon in cloudPokemon)
                {
                    await _navigation.TeleportToLocation(mapPokemon.Latitude, mapPokemon.Longitude);

                    if (Math.Abs(_navigation.CurrentLatitude - mapPokemon.Latitude) > 0 || Math.Abs(_navigation.CurrentLongitude - mapPokemon.Longitude) > 0)
                    {
                        logger.Warn($"Did not teleport.");
                    }
                    var encounter = await _pokemon.EncounterPokemon(new List <MapPokemon> {
                        mapPokemon
                    });

                    encounters.AddRange(encounter);
                }
                await _navigation.TeleportToLocation(lat, lng);

                logger.Warn($"{encounters.Count} pokemon found. Catching them.");
                foreach (var encounter in encounters)
                {
                    encounter.Invoke();
                    await Task.Delay(1000);
                }
            }
            else
            {
                logger.Warn($"Low pokeballs {_inventory.Pokeballs}. Fetching some more before trying to catch.");
            }
        }
예제 #4
0
        public async Task DoSnipe()
        {
            try
            {
                var loc = GetNextSnipeLocation;
                logger.Warn($"Sniping at {loc.Key}, {loc.Value}");
                var startX = _navigation.CurrentLatitude;
                var startY = _navigation.CurrentLongitude;
                var funcs  = await _ash.BurstCatch(loc.Key, loc.Value, 0, 0);

                await _navigation.TeleportToLocation(startX, startY);

                foreach (var act in funcs)
                {
                    act.Invoke();
                }
            }
            catch (ArgumentException)
            {
                // warn
            }
        }