Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. private async Task ExecuteCatchAllNearbyPokemons(Client client)
  2. {
  3. var mapObjects = await client.GetMapObjects();
  4.  
  5. var pokemons = mapObjects.MapCells.SelectMany(i => i.CatchablePokemons);
  6.  
  7. var inventory2 = await client.GetInventory();
  8. var pokemons2 = inventory2.InventoryDelta.InventoryItems
  9. .Select(i => i.InventoryItemData?.Pokemon)
  10. .Where(p => p != null && p?.PokemonId > 0)
  11. .ToArray();
  12.  
  13. foreach (var pokemon in pokemons)
  14. {
  15. var update = await client.UpdatePlayerLocation(pokemon.Latitude, pokemon.Longitude);
  16. var encounterPokemonResponse = await client.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnpointId);
  17. var pokemonCP = encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp;
  18. var pokemonIV = ((float)(encounterPokemonResponse?.WildPokemon?.PokemonData?.IndividualAttack + encounterPokemonResponse?.WildPokemon?.PokemonData?.IndividualDefense + encounterPokemonResponse?.WildPokemon?.PokemonData?.IndividualStamina) / (3.0f * 15.0f)) * 100.0f;
  19. CatchPokemonResponse caughtPokemonResponse;
  20. do
  21. {
  22. if (ClientSettings.RazzBerryMode == "cp")
  23. if (pokemonCP > ClientSettings.RazzBerrySetting)
  24. await client.UseRazzBerry(client, pokemon.EncounterId, pokemon.SpawnpointId);
  25. if (ClientSettings.RazzBerryMode == "probability")
  26. if (encounterPokemonResponse.CaptureProbability.CaptureProbability_.First() < ClientSettings.RazzBerrySetting)
  27. await client.UseRazzBerry(client, pokemon.EncounterId, pokemon.SpawnpointId);
  28. 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
  29. } while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed || caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);
  30.  
  31. string pokemonName;
  32. if (ClientSettings.Language == "german")
  33. {
  34. string name_english = Convert.ToString(pokemon.PokemonId);
  35. var request = (HttpWebRequest)WebRequest.Create("http://boosting-service.de/pokemon/index.php?pokeName=" + name_english);
  36. var response = (HttpWebResponse)request.GetResponse();
  37. pokemonName = new StreamReader(response.GetResponseStream()).ReadToEnd();
  38. }
  39. else
  40. pokemonName = Convert.ToString(pokemon.PokemonId);
  41. if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess)
  42. {
  43. ColoredConsoleWrite(Color.Green, $"We caught a {pokemonName} with {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} CP and {pokemonIV} IV");
  44. foreach (int xp in caughtPokemonResponse.Scores.Xp)
  45. TotalExperience += xp;
  46. TotalPokemon += 1;
  47. }
  48. else
  49. ColoredConsoleWrite(Color.Red, $"{pokemonName} with {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} CP got away..");
  50.  
  51. if (ClientSettings.TransferType == "leaveStrongest")
  52. await TransferAllButStrongestUnwantedPokemon(client);
  53. else if (ClientSettings.TransferType == "all")
  54. await TransferAllGivenPokemons(client, pokemons2);
  55. else if (ClientSettings.TransferType == "duplicate")
  56. await TransferDuplicatePokemon(client);
  57. else if (ClientSettings.TransferType == "cp")
  58. await TransferAllWeakPokemon(client, ClientSettings.TransferCPThreshold);
  59.  
  60. await Task.Delay(3000);
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement