private async void SnipePokemon(ItemId pokebolaId, ItemId berryId) { if (!FieldErrorCheck("snipePokemon")) { return; } PokemonId pokemon; Enum.TryParse(Convert.ToString(gridPokemons.CurrentRow.Cells[cName.DisplayIndex].FormattedValue), true, out pokemon); var cLatitudes = Convert.ToDouble(gridPokemons.CurrentRow.Cells[cLatitude.DisplayIndex].FormattedValue); var cLongitudes = Convert.ToDouble(gridPokemons.CurrentRow.Cells[cLongitude.DisplayIndex].FormattedValue); SayLog.Info($"Capturando {pokemon} na localização {cLatitudes},{cLongitudes}. Aguarde!"); try { if (await PogoCatchPokemon.CatchPokemon(pokemon, cLatitudes, cLongitudes, pokebolaId, berryId)) { UpdateLastPokemonCaught(false); } } catch (Exception e) { SayLog.Error(e.Message + e.StackTrace); } }
private async void btnLogin_Click_1(object sender, EventArgs e) { if (!FieldErrorCheck("login")) { return; } try { SayLog.Info("Processo de login iniciado! Isso pode levar alguns segundos, aguarde..."); //Check if account its PTC / Google. if (rbGoogle.Checked) { PogoGlobalSettings.PogoClient = await PogoClient.GetClient(txtPogoUsername.Text, txtPogoPassword.Text, AuthType.Google); } else if (rbPTC.Checked) { PogoGlobalSettings.PogoClient = await PogoClient.GetClient(txtPogoUsername.Text, txtPogoPassword.Text, AuthType.Ptc); } } catch (Exception) { SayLog.Error("Falha no login..."); return; } if (PogoGlobalSettings.PogoClient.Player.PlayerData == null) { SayLog.Fatal( "Infelizmente a conta informada aparenta estar temporariamente suspensa. Tente outra conta."); return; } SayLog.Debug("Logado com sucesso!"); PogoGlobalSettings.PogoClient.Inventory.OnInventoryUpdated += Inventory_OnInventoryUpdated; btnLogout.Enabled = true; btnLogin.Enabled = false; UpdatePlayerStatistic(); timerAtualizaStatus.Enabled = true; //Save settings updated to file UserGlobalConfiguration.Username = txtPogoUsername.Text; UserGlobalConfiguration.Password = txtPogoPassword.Text; if (rbGoogle.Checked) { UserGlobalConfiguration.TypeAcc = AuthType.Google; } else { UserGlobalConfiguration.TypeAcc = AuthType.Ptc; } UserGlobalConfiguration.SaveSettingsFromUser(); }
/// <summary> /// Update Player Details on UI /// </summary> private async void UpdatePlayerStatistic() { await Task.Run(() => { Invoke((MethodInvoker) delegate { //Panel Left lblNomeValue.Text = PogoGlobalSettings.PlayerName; lblTimeValue.Text = PogoGlobalSettings.PlayerTeam; lblMochilaValue.Text = string.Format( $"{PogoGlobalSettings.PlayerTotalPokemons}/{PogoGlobalSettings.PlayerAvailableStoragePokemons}"); lblPokebolasValue.Text = PogoGlobalSettings.PlayerTotalPokeballs.ToString(); // Panel Right lblTotalCapturado.Text = string.Format( $"{PokemonRaro.PokemonRaro.PokemonCaught} Total | {PokemonRaro.PokemonRaro.PokemonMax} Max"); lblEscapadoValue.Text = string.Format($"{PokemonRaro.PokemonRaro.PokemonFlee}"); if (PokemonRaro.PokemonRaro.PokemonCaught >= PokemonRaro.PokemonRaro.PokemonMax) { btnLogin.Enabled = false; btnProcurarPokemon.Enabled = false; menuSniperCatchManual.Enabled = false; menuSniperGoldenBerry.Enabled = false; menuSniperCatchStandard.Enabled = false; menuSniperRazzBerry.Enabled = false; menuSniperPinapBerry.Enabled = false; menuSniperRazzBerry.Enabled = false; SayLog.Warn("Limite de Pokémons atingido, realize a compra de uma nova chave!"); } //Menu Strip info menuSniperRazzBerry.Text = string.Format($"CAPTURAR [RazzBerry] ({PogoGlobalSettings.PlayerTotalRazzBerry})"); menuSniperPinapBerry.Text = string.Format($"CAPTURAR [Pinap Berry] ({PogoGlobalSettings.PlayerTotalPinapBerry})"); menuSniperNanaBerry.Text = string.Format( $"CAPTURAR [Nana Berry] ({PogoGlobalSettings.PlayerTotalNanaBerry})"); menuSniperGoldenBerry.Text = string.Format($"CAPTURAR [Golden Berry] ({PogoGlobalSettings.PlayerTotalNanaBerry})"); }); }); }
// DESLOGAR DO JOGO private async void btnDeslogar_Click(object sender, EventArgs e) { if (!PogoGlobalSettings.PogoClient.AccessToken.IsExpired) { //TODO: CANCEL THE HTTP CLIENT SayLog.Info("Deslogando..."); await Task.Delay(3000); //TODO: VERY IF WE LOGOUT WITH SUCESS SayLog.Debug("Deslogado com sucesso!"); btnLogout.Enabled = false; btnLogin.Enabled = true; lblNomeValue.Text = "0"; lblMochilaValue.Text = "0"; lblTimeValue.Text = "0"; lblPokebolasValue.Text = "0"; } }
private bool FieldErrorCheck(string type) { switch (type) { case "login": if (txtPogoUsername.Text == string.Empty || txtPogoPassword.Text == string.Empty) { SayLog.Warn("Existem campo(s) em branco. Verifque seu usuario e senha."); return(false); } else if (rbGoogle.Checked == false && rbPTC.Checked == false) { SayLog.Warn( "Você esqueceu de selecionar se sua conta é Google ou PTC. Selecione e realize o login novamente."); return(false); } return(true); case "searchPokemon": var isPokemonInList = false; foreach (string pokemonName in PokemonNames) { if (pokemonName == txtProcuraPoke.Text) { isPokemonInList = true; } } if (!isPokemonInList) { SayLog.Warn("Você digitou o nome do Pokémon incorretamente."); return(false); } if (PogoGlobalSettings.PogoClient == null) { SayLog.Warn("Realize o login antes de iniciar a procura de Pokémon."); return(false); } else if (txtProcuraPoke.Text == string.Empty) { SayLog.Warn("Você não especificou o nome do Pokémon. Digite novamente."); return(false); } else if (btnAutoCatch.Value) { SayLog.Warn("Desative a captura automatica."); return(false); } return(true); case "snipePokemon": if (PogoGlobalSettings.PogoClient == null) { SayLog.Warn("Realize o login antes de iniciar a captura do Pokemon."); return(false); } return(true); default: return(true); } }
//PROCURAR POKÉMON private async void btnProcurarPokemon_Click(object sender, EventArgs e) { if (!FieldErrorCheck("searchPokemon")) { return; } timerUpdateGrid.Enabled = false; timerUpdateGrid.Stop(); gridPokemons.Rows.Clear(); btnProcurarPokemon.Enabled = false; txtProcuraPoke.Enabled = false; btnProcurarPokemon.Text = "PROCURANDO"; PokemonAttributes pokemonList = null; try { if (cbIv100.Checked) { pokemonList = await PesquisaPokemon.SearchPokemon(true, (int)Enum.Parse(typeof(PokemonId), txtProcuraPoke.Text)); } else { pokemonList = await PesquisaPokemon.SearchPokemon(false, (int)Enum.Parse(typeof(PokemonId), txtProcuraPoke.Text)); } if (pokemonList == null) { timerUpdateGrid.Enabled = true; timerUpdateGrid.Start(); btnProcurarPokemon.Enabled = true; txtProcuraPoke.Enabled = true; btnProcurarPokemon.Text = "PROCURAR"; return; } } catch (Exception exception) { SayLog.Error(exception.Message + exception.StackTrace); return; } var countryImage = new DataGridViewImageColumn(); countryImage.Description = "image"; countryImage.ImageLayout = DataGridViewImageCellLayout.Normal; var pokemonIcon = new DataGridViewImageColumn(); pokemonIcon.Description = "image"; pokemonIcon.ImageLayout = DataGridViewImageCellLayout.Stretch; foreach (var pokemon in pokemonList.PokemonAtribbutes) { if (pokemon == null) { continue; } if (!string.IsNullOrEmpty(pokemon.Country)) { try { var imagePathCountry = @"Images\flags\" + pokemon.Country + ".gif"; var imagePathIcon = @"Images\pokemons\" + pokemon.Number + ".png"; countryImage.Image = Image.FromFile(imagePathCountry); pokemonIcon.Image = Image.FromFile(imagePathIcon); gridPokemons.Rows.Add(pokemonIcon.Image, pokemon.Number, pokemon.Name, countryImage.Image, pokemon.Iv, pokemon.Cp, pokemon.TimeLeft, pokemon.Latitude, pokemon.Longitude, PesquisaPokemon.CalculateTimeLeft(PogoGlobalSettings.PlayerLatitude, PogoGlobalSettings.PlayerLongitude, pokemon.Latitude, pokemon.Longitude).ToString()); } catch (Exception exception) { Console.WriteLine(exception); SayLog.Error(exception.Message + "\t" + exception.StackTrace); } } else { var imagePathCountry = @"Images\flags\bra.gif"; var imagePathIcon = @"Images\pokemons\" + pokemon.Number + ".png"; countryImage.Image = Image.FromFile(imagePathCountry); pokemonIcon.Image = Image.FromFile(imagePathIcon); gridPokemons.Rows.Add(pokemonIcon.Image, pokemon.Number, pokemon.Name, countryImage.Image, pokemon.Iv, pokemon.Cp, pokemon.TimeLeft, pokemon.Latitude, pokemon.Longitude, PesquisaPokemon.CalculateTimeLeft(PogoGlobalSettings.PlayerLatitude, PogoGlobalSettings.PlayerLongitude, pokemon.Latitude, pokemon.Longitude).ToString()); } } timerUpdateGrid.Enabled = true; timerUpdateGrid.Start(); btnProcurarPokemon.Enabled = true; txtProcuraPoke.Enabled = true; btnProcurarPokemon.Text = "PROCURAR"; }