Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async Task ExecuteCatchAllNearbyPokemons(Client client)
- {
- var mapObjects = await client.GetMapObjects();
- var pokemons = mapObjects.MapCells.SelectMany(i => i.CatchablePokemons);
- var inventory2 = await client.GetInventory();
- var pokemons2 = inventory2.InventoryDelta.InventoryItems
- .Select(i => i.InventoryItemData?.Pokemon)
- .Where(p => p != null && p?.PokemonId > 0)
- .ToArray();
- foreach (var pokemon in pokemons)
- {
- var update = await client.UpdatePlayerLocation(pokemon.Latitude, pokemon.Longitude);
- var encounterPokemonResponse = await client.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnpointId);
- var pokemonCP = encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp;
- var pokemonIV = ((float)(encounterPokemonResponse?.WildPokemon?.PokemonData?.IndividualAttack + encounterPokemonResponse?.WildPokemon?.PokemonData?.IndividualDefense + encounterPokemonResponse?.WildPokemon?.PokemonData?.IndividualStamina) / (3.0f * 15.0f)) * 100.0f;
- CatchPokemonResponse caughtPokemonResponse;
- do
- {
- if (ClientSettings.RazzBerryMode == "cp")
- if (pokemonCP > ClientSettings.RazzBerrySetting)
- await client.UseRazzBerry(client, pokemon.EncounterId, pokemon.SpawnpointId);
- if (ClientSettings.RazzBerryMode == "probability")
- if (encounterPokemonResponse.CaptureProbability.CaptureProbability_.First() < ClientSettings.RazzBerrySetting)
- await client.UseRazzBerry(client, pokemon.EncounterId, pokemon.SpawnpointId);
- caughtPokemonResponse = await client.CatchPokemon(pokemon.EncounterId, pokemon.SpawnpointId, pokemon.Latitude, pokemon.Longitude, MiscEnums.Item.ITEM_POKE_BALL, pokemonCP); ; //note: reverted from settings because this should not be part of settings but part of logic
- } while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed || caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);
- string pokemonName;
- if (ClientSettings.Language == "german")
- {
- string name_english = Convert.ToString(pokemon.PokemonId);
- var request = (HttpWebRequest)WebRequest.Create("http://boosting-service.de/pokemon/index.php?pokeName=" + name_english);
- var response = (HttpWebResponse)request.GetResponse();
- pokemonName = new StreamReader(response.GetResponseStream()).ReadToEnd();
- }
- else
- pokemonName = Convert.ToString(pokemon.PokemonId);
- if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess)
- {
- ColoredConsoleWrite(Color.Green, $"We caught a {pokemonName} with {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} CP and {pokemonIV} IV");
- foreach (int xp in caughtPokemonResponse.Scores.Xp)
- TotalExperience += xp;
- TotalPokemon += 1;
- }
- else
- ColoredConsoleWrite(Color.Red, $"{pokemonName} with {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} CP got away..");
- if (ClientSettings.TransferType == "leaveStrongest")
- await TransferAllButStrongestUnwantedPokemon(client);
- else if (ClientSettings.TransferType == "all")
- await TransferAllGivenPokemons(client, pokemons2);
- else if (ClientSettings.TransferType == "duplicate")
- await TransferDuplicatePokemon(client);
- else if (ClientSettings.TransferType == "cp")
- await TransferAllWeakPokemon(client, ClientSettings.TransferCPThreshold);
- await Task.Delay(3000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement