コード例 #1
0
        public async Task <CatchPokemonResponse> CatchPokemon(ulong encounterId, string id, DiskEncounterResponse encounter, PokemonId pokemonId)
        {
            CatchPokemonResponse caughtPokemonResponse;
            var attempts = 0;

            do
            {
                var probability = encounter?.CaptureProbability?.CaptureProbability_?.FirstOrDefault();
                var pokeball    = GetPokeball(encounter);
                if (pokeball == ItemId.ItemUnknown)
                {
                    logger.Error("Catch failed due to no pokeballs.");
                    return(new CatchPokemonResponse());
                }
                else
                {
                    _inventory.PokeballsDictionary[pokeball] = _inventory.PokeballsDictionary[pokeball] - 1;
                }

                caughtPokemonResponse =
                    await _apiEncounter.CatchPokemon(encounterId, id, pokeball);

                logger.Info($"[{caughtPokemonResponse.Status} - {attempts}] {pokemonId} encountered. {PokemonInfo.CalculatePokemonPerfection(encounter?.PokemonData)}% perfect. {encounter?.PokemonData?.Cp} CP. Probability: {probability}");
                attempts++;
            } while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed ||
                     caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);
            return(caughtPokemonResponse);
        }
コード例 #2
0
        public async Task <CatchPokemonResponse> CatchPokemon(ulong encounterId, string id, DiskEncounterResponse encounter, PokemonId pokemonId)
        {
            CatchPokemonResponse caughtPokemonResponse;
            var attempts = 0;

            do
            {
                var probability = encounter?.CaptureProbability?.CaptureProbability_?.FirstOrDefault();
                var pokeball    = GetPokeball(encounter);

                caughtPokemonResponse =
                    await _apiEncounter.CatchPokemon(encounterId, id, pokeball);

                logger.Info($"[{caughtPokemonResponse.Status} - {attempts}] {pokemonId} encountered. {PokemonInfo.CalculatePokemonPerfection(encounter?.PokemonData)}% perfect. {encounter?.PokemonData?.Cp} CP. Probability: {probability}");
                attempts++;
            } while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed ||
                     caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);
            return(caughtPokemonResponse);
        }