private async Task ExecuteFarmingPokestopsAndPokemons(Client client) { var distanceFromStart = LocationUtils.CalculateDistanceInMeters(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude, _client.CurrentLat, _client.CurrentLng); if (_clientSettings.MaxWalkingRadiusInMeters != 0 && distanceFromStart > _clientSettings.MaxWalkingRadiusInMeters) { Logger.ColoredConsoleWrite(ConsoleColor.Green, "Youre outside of the defined Max Walking Radius. Walking back!"); var update = await _navigation.HumanLikeWalking(new GeoCoordinate(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons); var start = await _navigation.HumanLikeWalking(new GeoCoordinate(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons); } Resources.OutPutWalking = true; var mapObjects = await _client.GetMapObjects(); //var pokeStops = mapObjects.MapCells.SelectMany(i => i.Forts).Where(i => i.Type == FortType.Checkpoint && i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime()); var pokeStops = _navigation.pathByNearestNeighbour( mapObjects.MapCells.SelectMany(i => i.Forts) .Where( i => i.Type == FortType.Checkpoint && i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime()) .OrderBy( i => LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, i.Latitude, i.Longitude)).ToArray(), _clientSettings.WalkingSpeedInKilometerPerHour); if (_clientSettings.MaxWalkingRadiusInMeters != 0) { pokeStops = pokeStops.Where(i => LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, i.Latitude, i.Longitude) <= _clientSettings.MaxWalkingRadiusInMeters).ToArray(); if (pokeStops.Count() == 0) { Logger.ColoredConsoleWrite(ConsoleColor.Red, "We cant find any PokeStops in a range of " + _clientSettings.MaxWalkingRadiusInMeters + "m!"); await ExecuteCatchAllNearbyPokemons(); } } if (pokeStops.Count() == 0) { Logger.ColoredConsoleWrite(ConsoleColor.Red, "We cant find any PokeStops, which are unused! Probably Server unstable, or you visted them all. Retrying.."); await ExecuteCatchAllNearbyPokemons(); } else { Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "We found " + pokeStops.Count() + " PokeStops near."); } foreach (var pokeStop in pokeStops) { // replace this true with settings variable!! await UseIncense(); await ExecuteCatchAllNearbyPokemons(); if (count >= 3) { count = 0; await StatsLog(client); if (_clientSettings.EvolvePokemonsIfEnoughCandy) { await EvolveAllPokemonWithEnoughCandy(); } await TransferDuplicatePokemon(_clientSettings.keepPokemonsThatCanEvolve); await RecycleItems(); //// if (_clientSettings.UseLuckyEggIfNotRunning) { await _inventory.UseLuckyEgg(_client); } } //if (_clientSettings.pokevision) //{ // foreach (spottedPoke p in await _pokevision.GetNearPokemons(_client.CurrentLat, _client.CurrentLng)) // { // var dist = LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, p._lat, p._lng); // Logger.ColoredConsoleWrite(ConsoleColor.Magenta, $"PokeVision: A {StringUtils.getPokemonNameByLanguage(_clientSettings, p._pokeId)} in {dist:0.##}m distance. Trying to catch."); // var upd = await _navigation.HumanLikeWalking(new GeoCoordinate(p._lat, p._lng), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons); // } //} _infoObservable.PushNewGeoLocations(new GeoCoordinate(_client.CurrentLat, _client.CurrentLng)); var distance = LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, pokeStop.Latitude, pokeStop.Longitude); var fortInfo = await _client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); if (fortInfo == null) { continue; } Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Next Pokestop: {fortInfo.Name} in {distance:0.##}m distance."); var update = await _navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons); ////var fortInfo = await client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); var fortSearch = await _client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); count++; if (fortSearch.ExperienceAwarded > 0) { failed_softban = 0; _botStats.addExperience(fortSearch.ExperienceAwarded); var egg = ""; if (fortSearch.PokemonDataEgg != null) { egg = ", Egg " + fortSearch.PokemonDataEgg.EggKmWalkedTarget; } else { egg = ""; } var gems = ""; if (fortSearch.GemsAwarded > 0) { gems = ", Gems:" + fortSearch.GemsAwarded; } else { gems = ""; } var items = ""; if (StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded) != "") { items = StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded); } else { items = "Nothing (Inventory Full?)"; } Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Farmed XP: {fortSearch.ExperienceAwarded}{gems}{egg}, Items: {items}", LogLevel.Info); int eggs = 0; if (fortSearch.PokemonDataEgg != null) { eggs = fortSearch.PokemonDataEgg.EggKmWalkedTarget; } try { TelegramUtil.getInstance().sendInformationText(TelegramUtil.TelegramUtilInformationTopics.Pokestop, fortInfo.Name, fortSearch.ExperienceAwarded, eggs, fortSearch.GemsAwarded, items); } catch (Exception) { } } else { failed_softban++; if (failed_softban >= 6) { Logger.Error("Detected Softban. Trying to use our Special 1337 Unban Methode."); for (int i = 0; i < 60; i++) { var unban = await client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); if (unban.ExperienceAwarded > 0) { break; } } failed_softban = 0; Logger.ColoredConsoleWrite(ConsoleColor.Green, "Probably unbanned you."); } } await RandomHelper.RandomDelay(50, 200); } if (_clientSettings.WalkBackToDefaultLocation) { Logger.ColoredConsoleWrite(ConsoleColor.Green, "Walking back to Default Location."); await _navigation.HumanLikeWalking(new GeoCoordinate(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons); } }
private async Task ExecuteFarmingPokestopsAndPokemons(Client client) { var distanceFromStart = LocationUtils.CalculateDistanceInMeters(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude, _client.CurrentLat, _client.CurrentLng); if (_clientSettings.MaxWalkingRadiusInMeters != 0 && distanceFromStart > _clientSettings.MaxWalkingRadiusInMeters) { Logger.ColoredConsoleWrite(ConsoleColor.Green, "Youre outside of the defined Max Walking Radius. Walking back!"); var update = await _navigation.HumanLikeWalking(new GeoCoordinate(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons); var start = await _navigation.HumanLikeWalking(new GeoCoordinate(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons); } Resources.OutPutWalking = true; var mapObjects = await client.GetMapObjects(); //var pokeStops = mapObjects.MapCells.SelectMany(i => i.Forts).Where(i => i.Type == FortType.Checkpoint && i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime()); var pokeStops = _navigation.pathByNearestNeighbour( mapObjects.MapCells.SelectMany(i => i.Forts) .Where( i => i.Type == FortType.Checkpoint && i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime()) .OrderBy( i => LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, i.Latitude, i.Longitude)).ToArray(), _clientSettings.WalkingSpeedInKilometerPerHour); if (_clientSettings.MaxWalkingRadiusInMeters != 0) { pokeStops = pokeStops.Where(i => LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, i.Latitude, i.Longitude) <= _clientSettings.MaxWalkingRadiusInMeters).ToArray(); if (pokeStops.Count() == 0) { Logger.ColoredConsoleWrite(ConsoleColor.Red, "We cant find any PokeStops in a range of " + _clientSettings.MaxWalkingRadiusInMeters + "m!"); } } if (pokeStops.Count() == 0) { Logger.ColoredConsoleWrite(ConsoleColor.Red, "We cant find any PokeStops, which are unused! Probably Server unstable, or you visted them all. Retrying.."); await ExecuteCatchAllNearbyPokemons(); } else { Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "We found " + pokeStops.Count() + " PokeStops near."); } foreach (var pokeStop in pokeStops) { // replace this true with settings variable!! if (true) { await UseIncense(); } await ExecuteCatchAllNearbyPokemons(); count++; if (count >= 3) { count = 0; await StatsLog(client); if (_clientSettings.EvolvePokemonsIfEnoughCandy) { await EvolveAllPokemonWithEnoughCandy(); } await TransferDuplicatePokemon(false); await RecycleItems(); } var distance = LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, pokeStop.Latitude, pokeStop.Longitude); var fortInfo = await client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Next Pokestop: {fortInfo.Name} in {distance:0.##}m distance."); var update = await _navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons); ////var fortInfo = await client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); var fortSearch = await client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); if (fortSearch.ExperienceAwarded > 0) { failed_softban = 0; _botStats.addExperience(fortSearch.ExperienceAwarded); var egg = ""; if (fortSearch.PokemonDataEgg != null) { egg = "Egg " + fortSearch.PokemonDataEgg.EggKmWalkedTarget; } else { egg = "/"; } var i = ""; if (StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded) != null) { i = StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded); } else { i = "/"; } Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Farmed XP: {fortSearch.ExperienceAwarded}, Gems: { fortSearch.GemsAwarded}, Eggs: {egg} Items: {i}", LogLevel.Info); } else { failed_softban++; if (failed_softban => 6) { Logger.Error("Detected a Softban. Trying to use our Special 1337 Unban Methode."); for (int i = 0; i < 60; i++) { var unban = await client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); if (unban.ExperienceAwarded > 0) { break; } } failed_softban = 0; Logger.ColoredConsoleWrite(ConsoleColor.Green, "Probably unbanned you."); } } await RandomHelper.RandomDelay(50, 200); } if (_clientSettings.WalkBackToDefaultLocation) { Logger.ColoredConsoleWrite(ConsoleColor.Green, "Walking back to Default Location."); await _navigation.HumanLikeWalking(new GeoCoordinate(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons); } }