public static async Task Execute() { await Inventory.GetCachedInventory(true); var pokemonToEvolve = await Inventory.GetPokemonToEvolve(Logic._client.Settings.PrioritizeIVOverCP, Logic._client.Settings.PokemonsToEvolve); if (pokemonToEvolve == null || !pokemonToEvolve.Any()) { return; } Logger.Write($"Found {pokemonToEvolve.Count()} Pokemon for Evolve:", LogLevel.Debug); foreach (var pokemon in pokemonToEvolve) { var evolvePokemonOutProto = await Logic._client.Inventory.EvolvePokemon(pokemon.Id); await Inventory.GetCachedInventory(true); Logger.Write(evolvePokemonOutProto.Result == EvolvePokemonResponse.Types.Result.Success ? $"{pokemon.PokemonId} [CP: {pokemon.Cp}/{PokemonInfo.CalculateMaxCp(pokemon)} | IV: { PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% perfect] | received XP {evolvePokemonOutProto.ExperienceAwarded}" : $"Failed: {pokemon.PokemonId}. EvolvePokemonOutProto.Result was {evolvePokemonOutProto.Result}, stopping evolving {pokemon.PokemonId}" , LogLevel.Evolve); if (evolvePokemonOutProto.Result == EvolvePokemonResponse.Types.Result.Success) { BotStats.ExperienceThisSession += evolvePokemonOutProto.ExperienceAwarded; } } await BotStats.GetPokeDexCount(); BotStats.UpdateConsoleTitle(); }
public static async Task Execute() { await Inventory.GetCachedInventory(true); var pokemonToTransfer = await Inventory.GetPokemonToTransfer(Logic._clientSettings.NotTransferPokemonsThatCanEvolve, Logic._clientSettings.PrioritizeIVOverCP, Logic._clientSettings.PokemonsToNotTransfer); if (pokemonToTransfer == null || !pokemonToTransfer.Any()) { return; } Logger.Write($"Found {pokemonToTransfer.Count()} Pokemon for Transfer:", LogLevel.Debug); foreach (var pokemon in pokemonToTransfer) { await Logic._client.Inventory.TransferPokemon(pokemon.Id); await Inventory.GetCachedInventory(true); var myPokemonSettings = await Inventory.GetPokemonSettings(); var pokemonSettings = myPokemonSettings.ToList(); var myPokemonFamilies = await Inventory.GetPokemonFamilies(); var pokemonFamilies = myPokemonFamilies.ToArray(); var settings = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId); var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId); var familyCandies = $"{familyCandy.Candy_}"; BotStats.PokemonTransferedThisSession += 1; var bestPokemonOfType = Logic._client.Settings.PrioritizeIVOverCP ? await Inventory.GetHighestPokemonOfTypeByIv(pokemon) : await Inventory.GetHighestPokemonOfTypeByCp(pokemon); var bestPokemonInfo = "NONE"; if (bestPokemonOfType != null) { bestPokemonInfo = $"CP: {bestPokemonOfType.Cp}/{PokemonInfo.CalculateMaxCp(bestPokemonOfType)} | IV: {PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType).ToString("0.00")}% perfect"; } Logger.Write($"{pokemon.PokemonId} [CP: {pokemon.Cp}/{PokemonInfo.CalculateMaxCp(pokemon)} | IV: { PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% perfect] | Best: [{bestPokemonInfo}] | Family Candies: {familyCandies}", LogLevel.Transfer); } await BotStats.GetPokemonCount(); BotStats.UpdateConsoleTitle(); }
public static async Task Execute() { await Inventory.GetCachedInventory(true); var items = await Inventory.GetItemsToRecycle(Logic._clientSettings); if (items == null || !items.Any()) { return; } Logger.Write($"Found {items.Count()} Recyclable {(items.Count() == 1 ? "Item" : "Items")}:", LogLevel.Debug); foreach (var item in items) { await Logic._client.Inventory.RecycleItem(item.ItemId, item.Count); Logger.Write($"{item.Count}x {item.ItemId}", LogLevel.Recycling); BotStats.ItemsRemovedThisSession += item.Count; } BotStats.UpdateConsoleTitle(); _recycleCounter = 0; }
public async Task PostLoginExecute() { Logger.Write($"Client logged in", LogLevel.Info); while (true) { if (!_isInitialized) { await Inventory.GetCachedInventory(); _playerProfile = await _client.Player.GetPlayer(); BotStats.UpdateConsoleTitle(); var stats = await Inventory.GetPlayerStats(); var stat = stats.FirstOrDefault(); if (stat != null) { BotStats.KmWalkedOnStart = stat.KmWalked; } Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow); if (_clientSettings.AuthType == AuthType.Ptc) { Logger.Write($"PTC Account: {BotStats.GetUsername(_playerProfile)}\n", LogLevel.None, ConsoleColor.Cyan); } Logger.Write($"Latitude: {_clientSettings.DefaultLatitude}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write($"Longitude: {_clientSettings.DefaultLongitude}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow); Logger.Write("Your Account:\n"); Logger.Write($"Name: {BotStats.GetUsername(_playerProfile)}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write($"Team: {_playerProfile.PlayerData.Team}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write($"Level: {BotStats.GetCurrentInfo()}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write($"Stardust: {_playerProfile.PlayerData.Currencies.ToArray()[1].Amount}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow); await DisplayHighests(); Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow); var pokemonsToNotTransfer = _clientSettings.PokemonsToNotTransfer; var pokemonsToNotCatch = _clientSettings.PokemonsToNotCatch; var pokemonsToEvolve = _clientSettings.PokemonsToEvolve; await RecycleItemsTask.Execute(); if (_client.Settings.UseLuckyEggs) { await UseLuckyEggTask.Execute(); } if (_client.Settings.EvolvePokemon || _client.Settings.EvolvePokemonAboveIV) { await EvolvePokemonTask.Execute(); } if (_client.Settings.TransferPokemon) { await TransferPokemonTask.Execute(); } await ExportPokemonToCsv.Execute(_playerProfile.PlayerData); if (_clientSettings.HatchEggs) { await HatchEggsTask.Execute(); } } _isInitialized = true; await Main(); await RefreshTokens(); /* * Example calls below * * var profile = await _client.GetProfile(); * var settings = await _client.GetSettings(); * var mapObjects = await _client.GetMapObjects(); * var inventory = await _client.GetInventory(); * var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon).Where(p => p != null && p?.PokemonId > 0); */ await Task.Delay(10000); } }
public static async Task Execute() { var distanceFromStart = LocationUtils.CalculateDistanceInMeters( Logic._client.Settings.DefaultLatitude, Logic._client.Settings.DefaultLongitude, Logic._client.CurrentLatitude, Logic._client.CurrentLongitude); // Edge case for when the client somehow ends up outside the defined radius if (Logic._client.Settings.MaxTravelDistanceInMeters != 0 && distanceFromStart > Logic._client.Settings.MaxTravelDistanceInMeters) { Logger.Write( $"You're outside of your defined radius! Walking to Default Coords ({distanceFromStart:0.##}m away). Is your LastCoords.ini file correct?", LogLevel.Warning); await Navigation.HumanLikeWalking( new GeoUtils(Logic._client.Settings.DefaultLatitude, Logic._client.Settings.DefaultLongitude), async() => { // Catch normal map Pokemon await CatchMapPokemonsTask.Execute(); //Catch Incense Pokemon await CatchIncensePokemonsTask.Execute(); return(true); }); } var pokestops = await Inventory.GetPokestops(); if (pokestops == null || !pokestops.Any()) { Logger.Write("No usable PokeStops found in your area. Reasons: Softbanned - Server Issues - MaxTravelDistanceInMeters too small", LogLevel.Warning); } else { Logger.Write($"Found {pokestops.Count()} {(pokestops.Count() == 1 ? "Pokestop" : "Pokestops")}", LogLevel.Info); } while (pokestops.Any()) { if (Logic._client.Settings.ExportPokemonToCsvEveryMinutes > 0 && ExportPokemonToCsv._lastExportTime.AddMinutes(Logic._client.Settings.ExportPokemonToCsvEveryMinutes).Ticks < DateTime.Now.Ticks) { var _playerProfile = await Logic._client.Player.GetPlayer(); await ExportPokemonToCsv.Execute(_playerProfile.PlayerData); } if (Logic._client.Settings.UseLuckyEggs) { await UseLuckyEggTask.Execute(); } if (Logic._client.Settings.CatchIncensePokemon) { await UseIncenseTask.Execute(); } var pokestopwithcooldown = pokestops.Where(p => p.CooldownCompleteTimestampMs > DateTime.UtcNow.ToUnixTime()).FirstOrDefault(); if (pokestopwithcooldown != null) { pokestops.Remove(pokestopwithcooldown); } var pokestop = pokestops.Where(p => p.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime()) .OrderBy( i => LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, i.Latitude, i.Longitude)).First(); var lured = string.Empty; var distance = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, pokestop.Latitude, pokestop.Longitude); if (distance > 100) { var lurePokestop = pokestops.FirstOrDefault(x => x.LureInfo != null); if (lurePokestop != null) { distance = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, pokestop.Latitude, pokestop.Longitude); if (distance < 200) { lured = " is Lured"; pokestop = lurePokestop; } else { pokestops.Remove(pokestop); } } } else { pokestops.Remove(pokestop); } var fortInfo = await Logic._client.Fort.GetFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude); var latlngDebug = string.Empty; if (Logic._client.Settings.DebugMode) { latlngDebug = $" | Latitude: {pokestop.Latitude} - Longitude: {pokestop.Longitude}"; } Logger.Write($"Name: {fortInfo.Name} in {distance:0.##} m distance{lured}{latlngDebug}", LogLevel.Pokestop); if (Logic._client.Settings.UseTeleportInsteadOfWalking) { await Logic._client.Player.UpdatePlayerLocation(pokestop.Latitude, pokestop.Longitude, Logic._client.Settings.DefaultAltitude); await RandomHelper.RandomDelay(500); Logger.Write($"Using Teleport instead of Walking!", LogLevel.Navigation); } else { await Navigation.HumanLikeWalking(new GeoUtils(pokestop.Latitude, pokestop.Longitude), async() => { // Catch normal map Pokemon await CatchMapPokemonsTask.Execute(); //Catch Incense Pokemon await CatchIncensePokemonsTask.Execute(); return(true); }); } //Catch Lure Pokemon if (pokestop.LureInfo != null && Logic._client.Settings.CatchLuredPokemon) { await CatchLurePokemonsTask.Execute(pokestop); } var timesZeroXPawarded = 0; var fortTry = 0; //Current check const int retryNumber = 45; //How many times it needs to check to clear softban const int zeroCheck = 5; //How many times it checks fort before it thinks it's softban do { var fortSearch = await Logic._client.Fort.SearchFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude); if (fortSearch.ExperienceAwarded > 0 && timesZeroXPawarded > 0) { timesZeroXPawarded = 0; } if (fortSearch.ExperienceAwarded == 0) { if (fortSearch.Result == FortSearchResponse.Types.Result.InCooldownPeriod) { Logger.Write("Pokestop is on Cooldown", LogLevel.Debug); break; } timesZeroXPawarded++; if (timesZeroXPawarded > zeroCheck) { fortTry += 1; if (Logic._client.Settings.DebugMode) { Logger.Write( $"Seems your Soft-Banned. Trying to Unban via Pokestop Spins. Retry {fortTry} of {retryNumber - zeroCheck}", LogLevel.Warning); } await RandomHelper.RandomDelay(450); } } else if (fortSearch.ExperienceAwarded != 0) { BotStats.ExperienceThisSession += fortSearch.ExperienceAwarded; BotStats.UpdateConsoleTitle(); Logger.Write($"XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Items: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}", LogLevel.Pokestop); RecycleItemsTask._recycleCounter++; HatchEggsTask._hatchUpdateDelay++; break; //Continue with program as loot was succesfull. } } while (fortTry < retryNumber - zeroCheck); //Stop trying if softban is cleaned earlier or if 40 times fort looting failed. if (RecycleItemsTask._recycleCounter >= 5) { await RecycleItemsTask.Execute(); } if (HatchEggsTask._hatchUpdateDelay >= 15) { await HatchEggsTask.Execute(); } } }
public static async Task Execute(dynamic encounter, MapPokemon pokemon, FortData currentFortData = null, ulong encounterId = 0) { // If the encounter is null nothing will work below, so exit now if (encounter == null) { return; } float probability = encounter.CaptureProbability?.CaptureProbability_[0]; var catchType = encounter is EncounterResponse ? "Normal" : encounter is DiskEncounterResponse ? "Lure" : "Incense"; var Id = encounter is EncounterResponse ? pokemon.PokemonId : encounter?.PokemonData.PokemonId; var Level = PokemonInfo.GetLevel(encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData : encounter?.PokemonData); var Cp = encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData?.Cp : encounter?.PokemonData?.Cp ?? 0; var MaxCp = PokemonInfo.CalculateMaxCp(encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData : encounter?.PokemonData); var Iv = PokemonInfo.CalculatePokemonPerfection(encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData : encounter?.PokemonData); var Probability = Math.Round(probability * 100, 2); var distance = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, encounter is EncounterResponse || encounter is IncenseEncounterResponse ? pokemon.Latitude : currentFortData.Latitude, encounter is EncounterResponse || encounter is IncenseEncounterResponse ? pokemon.Longitude : currentFortData.Longitude); if (!float.IsNaN(probability) && probability < 0.35) { await UseBerry(encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.EncounterId : encounterId, encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.SpawnPointId : currentFortData?.Id); } CatchPokemonResponse caughtPokemonResponse; var attemptCounter = 1; do { var pokeball = await GetBestBall(encounter, probability); if (pokeball == ItemId.ItemUnknown) { Logger.Write($"You don't own any Pokeballs :( - We missed a {Id} with CP {Cp}", LogLevel.Warning); return; } caughtPokemonResponse = await Logic._client.Encounter.CatchPokemon( encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.EncounterId : encounterId, encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.SpawnPointId : currentFortData.Id, pokeball); if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess) { BotStats.ExperienceThisSession += caughtPokemonResponse.CaptureAward.Xp.Sum(); BotStats.PokemonCaughtThisSession += 1; await BotStats.GetPokeDexCount(); await BotStats.GetPokemonCount(); var profile = await Logic._client.Player.GetPlayer(); BotStats.TotalStardust = profile.PlayerData.Currencies.ToArray()[1].Amount; BotStats.UpdateConsoleTitle(); } if (encounter?.CaptureProbability?.CaptureProbability_ != null) { Func <ItemId, string> returnRealBallName = a => { switch (a) { case ItemId.ItemPokeBall: return("Poke"); case ItemId.ItemGreatBall: return("Great"); case ItemId.ItemUltraBall: return("Ultra"); case ItemId.ItemMasterBall: return("Master"); default: return("Unknown"); } }; var catchStatus = attemptCounter > 1 ? $"{caughtPokemonResponse.Status} Attempt #{attemptCounter}" : $"{caughtPokemonResponse.Status}"; var receivedXp = caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess ? $"and received XP {caughtPokemonResponse.CaptureAward.Xp.Sum()}" : $""; await Inventory.GetCachedInventory(true); var BallAmount = await Inventory.GetItemAmountByType(pokeball); Logger.Write($"({catchStatus} / {catchType}) | {Id} - Lvl {Level} [CP {Cp}/{MaxCp} | IV: {Iv.ToString("0.00")}% perfect] | Chance: {Probability} | {distance:0.##}m dist | with a {returnRealBallName(pokeball)}Ball [Remaining: {BallAmount}] {receivedXp}", LogLevel.Pokemon); } attemptCounter++; }while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed || caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape); }
//Please do not change GetPokeStops() in this file, it's specifically set //to only find stops within 40 meters //this is for gpx pathing, we are not going to the pokestops, //so do not make it more than 40 because it will never get close to those stops. public static async Task Execute() { if (Logic._client.Settings.GPXIgnorePokestops) { return; } var pokestops = await Inventory.GetPokestops(true); while (pokestops.Any()) { var pokestop = pokestops.OrderBy( i => LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, i.Latitude, i.Longitude)).First(); pokestops.Remove(pokestop); var distance = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, pokestop.Latitude, pokestop.Longitude); var fortInfo = await Logic._client.Fort.GetFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude); var latlngDebug = string.Empty; if (Logic._client.Settings.DebugMode) { latlngDebug = $"| Latitude: {pokestop.Latitude} - Longitude: {pokestop.Longitude}"; } Logger.Write($"Name: {fortInfo.Name} in {distance:0.##} m distance {latlngDebug}", LogLevel.Pokestop); //Catch Lure Pokemon if (pokestop.LureInfo != null && Logic._client.Settings.CatchLuredPokemon) { await CatchLurePokemonsTask.Execute(pokestop); } var timesZeroXPawarded = 0; var fortTry = 0; //Current check const int retryNumber = 50; //How many times it needs to check to clear softban const int zeroCheck = 5; //How many times it checks fort before it thinks it's softban do { var fortSearch = await Logic._client.Fort.SearchFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude); if (fortSearch.ExperienceAwarded > 0 && timesZeroXPawarded > 0) { timesZeroXPawarded = 0; } if (fortSearch.ExperienceAwarded == 0) { timesZeroXPawarded++; if (timesZeroXPawarded <= zeroCheck) { continue; } if ((int)fortSearch.CooldownCompleteTimestampMs != 0) { break; // Check if successfully looted, if so program can continue as this was "false alarm". } fortTry += 1; if (Logic._client.Settings.DebugMode) { Logger.Write($"Seems your Soft-Banned. Trying to Unban via Pokestop Spins. Retry {fortTry} of {retryNumber - zeroCheck}", LogLevel.Warning); } await RandomHelper.RandomDelay(75, 100); } else { BotStats.ExperienceThisSession += fortSearch.ExperienceAwarded; BotStats.UpdateConsoleTitle(); Logger.Write($"XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Items: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}", LogLevel.Pokestop); RecycleItemsTask._recycleCounter++; HatchEggsTask._hatchUpdateDelayGPX++; break; //Continue with program as loot was succesfull. } } while (fortTry < retryNumber - zeroCheck); //Stop trying if softban is cleaned earlier or if 40 times fort looting failed. if (RecycleItemsTask._recycleCounter >= 5) { await RecycleItemsTask.Execute(); } if (HatchEggsTask._hatchUpdateDelayGPX >= 5) { await HatchEggsTask.Execute(); } } }
public async Task PrintPlayerInfos(CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); await Inventory.GetCachedInventory(); _playerProfile = await _client.Player.GetPlayer(); BotStats.UpdateConsoleTitle(); var playerStats = (await Inventory.GetPlayerStats()).FirstOrDefault(); if (playerStats != null) { BotStats.KmWalkedOnStart = playerStats.KmWalked; } Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow); if (_clientSettings.AuthType == AuthType.Ptc) { Logger.Write($"PTC Account: {BotStats.GetUsername(_playerProfile)}\n", LogLevel.None, ConsoleColor.Cyan); } Logger.Write($"Latitude: {_clientSettings.DefaultLatitude}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write($"Longitude: {_clientSettings.DefaultLongitude}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow); Logger.Write("Your Account:\n"); Logger.Write($"Name: {BotStats.GetUsername(_playerProfile)}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write($"Team: {_playerProfile.PlayerData.Team}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write($"Level: {BotStats.GetCurrentInfo()}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write($"Stardust: {_playerProfile.PlayerData.Currencies.ToArray()[1].Amount}", LogLevel.None, ConsoleColor.DarkGray); Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow); await DisplayHighests(); Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow); var pokemonToNotTransfer = _clientSettings.PokemonToNotTransfer; var pokemonsToNotCatch = _clientSettings.PokemonToNotCatch; var pokemonsToEvolve = _clientSettings.PokemonToEvolve; await RecycleItemsTask.Execute(); if (_client.Settings.UseLuckyEggs) { await UseLuckyEggTask.Execute(); } if (_client.Settings.EvolvePokemon || _client.Settings.EvolveOnlyPokemonAboveIV) { await EvolvePokemonTask.Execute(); } if (_client.Settings.TransferPokemon) { await TransferPokemonTask.Execute(); } if (_client.Settings.UseCSVExport) { await ExportPokemonToCsv.Execute(_playerProfile.PlayerData); } if (_clientSettings.HatchEggs) { await HatchEggsTask.Execute(); } }