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(); }
private async void frmNewLogin_Load(object sender, EventArgs e) { if (await PokemonRaro.PokemonRaro.CheckServerState()) { lblVersao.Text = string.Format(await PokemonRaro.PokemonRaro.GetVersion() ? $"VERSÃO: {PokemonRaro.PokemonRaro.SpecterVersion}." : $"VERSÃO: DEZATUALIZADA."); UserGlobalConfiguration.LoadSettingsFromFile(); if (UserGlobalConfiguration.PogoRaroKey != string.Empty) { txtCodigo.Text = UserGlobalConfiguration.PogoRaroKey; } } }
private static async Task <bool> CatchPokemon(WildPokemon pokemon, ItemId pokebola, ItemId berry) { if (berry != ItemId.ItemUnknown) { if (berry == ItemId.ItemGoldenRazzBerry || berry == ItemId.ItemGoldenNanabBerry || berry == ItemId.ItemGoldenPinapBerry) { var useItemResponse = await PogoGlobalSettings.PogoClient.Inventory.UseRareCandy(SelectBerry(berry), pokemon.PokemonData.PokemonId); if (useItemResponse.Result == UseItemRareCandyResponse.Types.Result.Success) { _sayLog.Info($"{berry} Utilizada!"); } else { _sayLog.Error($"Erro ao utilizar {berry}."); } } else { var useItemResponse = await PogoGlobalSettings.PogoClient.Encounter.UseCaptureItem(pokemon.EncounterId, SelectBerry(berry), pokemon.SpawnPointId); if (useItemResponse.Success) { _sayLog.Info($"{berry} Utilizada!"); } else { _sayLog.Error($"Erro ao utilizar {berry}."); } } } _sayLog.Info($"Arremesando ({pokebola}) no Pokemon {pokemon.PokemonData.PokemonId}"); var catchPokemonResponse = await PogoGlobalSettings.PogoClient.Encounter.CatchPokemon(pokemon.EncounterId, pokemon.SpawnPointId, SelectPokeball(pokebola)); switch (catchPokemonResponse.Status) { case CatchPokemonResponse.Types.CatchStatus.CatchError: _sayLog.Warn("Ocorreu um erro desconhecido ao tentar capturar o Pokémon."); await PokemonRaro.PokemonRaro.PokemonCaughtFail(); return(false); case CatchPokemonResponse.Types.CatchStatus.CatchFlee: _sayLog.Error($"{pokemon.PokemonData.PokemonId} Fugiu ):!\n" + $"CP: {pokemon.PokemonData.Cp}\n" + $"IV: {Iv(pokemon.PokemonData.IndividualAttack, pokemon.PokemonData.IndividualDefense, pokemon.PokemonData.IndividualStamina):0.##}\n" + $"Moves: ({pokemon.PokemonData.Move1},{pokemon.PokemonData.Move2})"); await PokemonRaro.PokemonRaro.PokemonCaughtFail(); return(false); case CatchPokemonResponse.Types.CatchStatus.CatchSuccess: LastCatchName = pokemon.PokemonData.PokemonId.ToString(); LastCatchInfo = string.Format( $"[CP:{pokemon.PokemonData.Cp}]-[IV:{Iv(pokemon.PokemonData.IndividualAttack, pokemon.PokemonData.IndividualDefense, pokemon.PokemonData.IndividualStamina):0.##}]"); LastCatchDate = DateTime.Now; LastCatchNumber = (int)Enum.Parse(typeof(PokemonId), pokemon.PokemonData.PokemonId.ToString()); LastCatchLat = pokemon.Latitude.ToString(); LastCatchLong = pokemon.Longitude.ToString(); await PokemonRaro.PokemonRaro.SendPokemonLogToDatabase(); await PokemonRaro.PokemonRaro.PokemonCaughtSucess(); _sayLog.Debug($"{LastCatchName} foi capturado com sucesso!\n" + $"CP: {pokemon.PokemonData.Cp}\n" + $"IV: {Iv(pokemon.PokemonData.IndividualAttack,pokemon.PokemonData.IndividualDefense,pokemon.PokemonData.IndividualStamina):0.##}\n" + $"Moves: ({pokemon.PokemonData.Move1},{pokemon.PokemonData.Move2})"); UserGlobalConfiguration.SaveSettingsFromUserWithTime(); return(true); case CatchPokemonResponse.Types.CatchStatus.CatchEscape: if (_catchTryCount > 5) { _sayLog.Info( $"O total de tentativas se esgotou. Tente outro Pokémon. [Tentativas:{_catchTryCount+1}/5]"); return(false); } else if (_catchTryCount < 5) { _sayLog.Info($"O Pokémon escapou, tentando capturar novamente. [Tentativas:{_catchTryCount+1}/5]"); await Task.Delay(1000); _catchTryCount++; await CatchPokemon(pokemon, pokebola, berry); } break; case CatchPokemonResponse.Types.CatchStatus.CatchMissed: _sayLog.Info("Erramos a pokebola, tentando capturar novamente."); await CatchPokemon(pokemon, pokebola, berry); break; } return(false); }