示例#1
0
        private async Task CatchEncounter(EncounterResponse encounter, MapPokemon pokemon, Client client)
        {
            CatchPokemonResponse caughtPokemonResponse;

            do
            {
                if (encounter?.CaptureProbability.CaptureProbability_.First() < 0.40)
                {
                    _logger.Write("Using berry", LogLevel.INFO);
                    await _pokemonItems.UseBerry(pokemon.EncounterId, pokemon.SpawnPointId, client);
                }

                var pokeball = await _pokemonItems.GetBestBall(encounter?.WildPokemon, client.Inventory);

                await Task.Delay(1000);

                caughtPokemonResponse =
                    await client.Encounter.CatchPokemon(pokemon.EncounterId, pokemon.SpawnPointId, pokeball);

                await Task.Delay(500);
            } while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed ||
                     caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);

            if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess)
            {
                var wildPokemon = encounter?.WildPokemon.PokemonData;
                if (wildPokemon != null)
                {
                    OnCatch?.Invoke(wildPokemon);
                    OnExperienceAwarded?.Invoke(caughtPokemonResponse.CaptureAward.Xp.Sum(x => x));

                    var iv = wildPokemon.IndividualAttack + wildPokemon.IndividualDefense +
                             wildPokemon.IndividualStamina;

                    _logger.Write($"Gotcha! {pokemon.PokemonId} - CP: {wildPokemon.Cp}, " +
                                  $"IV {iv}", LogLevel.SUCC);

                    if (_settings.Settings.QuickTransfer)
                    {
                        if (_pokemonHelper.ShouldTranferPokemon(wildPokemon, _settings.Settings.IvPercentageDiscart,
                                                                _settings.Settings.KeepMinCp, _settings.Settings.IvOverCp))
                        {
                            await _transferPokemonHandler.TransferPokemon(client, wildPokemon, true);
                        }
                    }
                }
                else
                {
                    _logger.Write($"Caught status: {caughtPokemonResponse.Status}", LogLevel.WARN);
                }
            }
        }
示例#2
0
        public async Task TransferDuplicatePokemon(Client client, bool keepPokemonsThatCanEvolve)
        {
            var duplicatePokemons = await GetDuplicatePokemonToTransfer(client, keepPokemonsThatCanEvolve);

            foreach (var duplicatePokemon in duplicatePokemons)
            {
                if (duplicatePokemon.Cp < _settings.Settings.KeepMinCp)
                {
                    if (_pokemonHelper.ShouldTranferPokemon(duplicatePokemon, _settings.Settings.IvPercentageDiscart,
                                                            _settings.Settings.KeepMinCp, _settings.Settings.IvOverCp))
                    {
                        await TransferPokemon(client, duplicatePokemon);

                        await Task.Delay(500);
                    }
                }
            }
        }