Ejemplo n.º 1
0
 private void UsageTick(object sender, EventArgs e)
 {
     APINotifications.UpdateAppUsage();
 }
Ejemplo n.º 2
0
        private async Task ExecuteCatchAllNearbyPokemons()
        {
            var mapObjects = await _client.GetMapObjects();

            var pokemons = mapObjects.MapCells.SelectMany(i => i.CatchablePokemons);

            var mapPokemons = pokemons as IList <MapPokemon> ?? pokemons.ToList();

            if (mapPokemons.Count <MapPokemon>() > 0)
            {
                Logger.Write("Found " + mapPokemons.Count <MapPokemon>() + " Pokemons in the area.");
            }
            foreach (var pokemon in mapPokemons)
            {
                var update = await _client.UpdatePlayerLocation(pokemon.Latitude, pokemon.Longitude, _settings.DefaultAltitude); // Redundant?

                var encounterPokemonResponse = await _client.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnpointId);

                var pokemonCp = encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp;
                var pokemonIv = Logic.Logic.CalculatePokemonPerfection(encounterPokemonResponse?.WildPokemon?.PokemonData).ToString("0.00") + "%";
                var pokeball  = await GetBestBall(pokemonCp);

                if (encounterPokemonResponse.ToString().Contains("ENCOUNTER_NOT_FOUND"))
                {
                    Logger.Write("Pokemon ran away...");
                    continue;
                }

                Logger.Write($"Fighting {pokemon.PokemonId} with Capture Probability of {(encounterPokemonResponse?.CaptureProbability.CaptureProbability_.First())*100:0.0}%");

                boxPokemonName.Text       = pokemon.PokemonId.ToString();
                boxPokemonCaughtProb.Text = (encounterPokemonResponse?.CaptureProbability.CaptureProbability_.First() * 100).ToString() + @"%";

                CatchPokemonResponse caughtPokemonResponse;
                do
                {
                    if (encounterPokemonResponse?.CaptureProbability.CaptureProbability_.First() < (GUISettings.Default.minBerry / 100))
                    {
                        await UseBerry(pokemon.EncounterId, pokemon.SpawnpointId);
                    }

                    caughtPokemonResponse = await _client.CatchPokemon(pokemon.EncounterId, pokemon.SpawnpointId, pokemon.Latitude, pokemon.Longitude, pokeball);

                    await Task.Delay(1000);
                }while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed);

                Logger.Write(caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess ? $"We caught a {pokemon.PokemonId} with CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} using a {pokeball}" : $"{pokemon.PokemonId} with CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} got away while using a {pokeball}..");

                if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess)
                {
                    // Calculate Experience
                    int fightExperience = 0;
                    foreach (int exp in caughtPokemonResponse.Scores.Xp)
                    {
                        fightExperience += exp;
                    }
                    _totalExperience += fightExperience;
                    Logger.Write("Gained " + fightExperience + " XP.");
                    _pokemonCaughtCount++;

                    // Update Pokemon Information
                    APINotifications.UpdatePokemonCaptured(pokemon.PokemonId.ToString(),
                                                           encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp,
                                                           float.Parse(pokemonIv.Replace('%', ' ')),
                                                           pokemon.Latitude,
                                                           pokemon.Longitude
                                                           );

                    // Add Row to the DataGrid
                    dGrid.Rows.Insert(0, "Captured", pokemon.PokemonId.ToString(), encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp, pokemonIv);
                }
                else
                {
                    // Add Row to the DataGrid
                    dGrid.Rows.Insert(0, "Ran Away", pokemon.PokemonId.ToString(), encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp, pokemonIv);
                }

                boxPokemonName.Clear();
                boxPokemonCaughtProb.Clear();

                await GetCurrentPlayerInformation();

                if (!_isFarmingActive)
                {
                    Logger.Write("Stopping Farming Pokemons.");
                    return;
                }

                Logger.Write("Waiting before moving to the next Pokemon.");
                await Task.Delay(GUISettings.Default.pokemonDelay * 1000);
            }
        }
Ejemplo n.º 3
0
        private async Task ExecuteCatchAllNearbyPokemons()
        {
            var mapObjects = await _client.GetMapObjects();

            var pokemons = mapObjects.MapCells.SelectMany(i => i.CatchablePokemons);

            var mapPokemons = pokemons as IList <MapPokemon> ?? pokemons.ToList();

            if (mapPokemons.Count <MapPokemon>() > 0)
            {
                Logger.Write("Найдено " + mapPokemons.Count <MapPokemon>() + " Покемонов в текущей локации.");
            }
            foreach (var pokemon in mapPokemons)
            {
                var update = await _client.UpdatePlayerLocation(pokemon.Latitude, pokemon.Longitude, _settings.DefaultAltitude); // Redundant?

                var encounterPokemonResponse = await _client.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnpointId);

                var pokemonCp = encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp;
                var pokemonIv = Logic.Logic.CalculatePokemonPerfection(encounterPokemonResponse?.WildPokemon?.PokemonData).ToString("0.00") + "%";
                var pokeball  = await GetBestBall(pokemonCp);

                if (encounterPokemonResponse.ToString().Contains("ENCOUNTER_NOT_FOUND"))
                {
                    Logger.Write("Покемон убежал...");
                    continue;
                }

                Logger.Write($"Захват {pokemon.PokemonId} с вероятностью захвата {(encounterPokemonResponse?.CaptureProbability.CaptureProbability_.First())*100:0.0}%");

                boxPokemonName.Text       = pokemon.PokemonId.ToString();
                boxPokemonCaughtProb.Text = (encounterPokemonResponse?.CaptureProbability.CaptureProbability_.First() * 100).ToString() + @"%";

                CatchPokemonResponse caughtPokemonResponse;
                do
                {
                    if (encounterPokemonResponse?.CaptureProbability.CaptureProbability_.First() < (GUISettings.Default.minBerry / 100))
                    {
                        await UseBerry(pokemon.EncounterId, pokemon.SpawnpointId);
                    }

                    caughtPokemonResponse = await _client.CatchPokemon(pokemon.EncounterId, pokemon.SpawnpointId, pokemon.Latitude, pokemon.Longitude, pokeball);

                    await Task.Delay(1000);
                }while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed);

                Logger.Write(caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess ? $"Мы поймали {pokemon.PokemonId} с CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} используя {pokeball}" : $"{pokemon.PokemonId} с CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} убежал при использование {pokeball}..");

                if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess)
                {
                    // Calculate Experience
                    int fightExperience = 0;
                    foreach (int exp in caughtPokemonResponse.Scores.Xp)
                    {
                        fightExperience += exp;
                    }
                    _totalExperience += fightExperience;
                    Logger.Write("Получено " + fightExperience + " XP.");
                    _pokemonCaughtCount++;

                    // Update Pokemon Information
                    APINotifications.UpdatePokemonCaptured(pokemon.PokemonId.ToString(),
                                                           encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp,
                                                           float.Parse(pokemonIv.Replace('%', ' ')),
                                                           pokemon.Latitude,
                                                           pokemon.Longitude
                                                           );

                    // Add Row to the DataGrid
                    dGrid.Rows.Insert(0, "Пойман", pokemon.PokemonId.ToString(), encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp, pokemonIv);
                }
                else
                {
                    // Add Row to the DataGrid
                    dGrid.Rows.Insert(0, "Сбежал", pokemon.PokemonId.ToString(), encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp, pokemonIv);
                }

                boxPokemonName.Clear();
                boxPokemonCaughtProb.Clear();

                await GetCurrentPlayerInformation();

                if (!_isFarmingActive)
                {
                    Logger.Write("Прекращаю фармить покемонов.");
                    return;
                }

                Logger.Write("Ожидание.");
                await Task.Delay(GUISettings.Default.pokemonDelay * 1000);
            }
        }
        private async Task ExecuteCatchAllNearbyPokemons()
        {
            var mapObjects = await _client.GetMapObjects();

            var pokemons = mapObjects.MapCells.SelectMany(i => i.CatchablePokemons);

            var mapPokemons = pokemons as IList <MapPokemon> ?? pokemons.ToList();

            if (mapPokemons.Count <MapPokemon>() > 0)
            {
                textResults.AppendText("Found " + mapPokemons.Count <MapPokemon>() + " Pokemon(s) in the area." + Environment.NewLine);
            }
            else
            {
                textResults.AppendText("No Pokemon(s) found in the area." + Environment.NewLine);
                return;
            }

            foreach (var pokemon in mapPokemons)
            {
                var update = await _client.UpdatePlayerLocation(pokemon.Latitude, pokemon.Longitude, _client.Settings.DefaultAltitude);

                var encounterPokemonResponse = await _client.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnpointId);

                var pokemonCp = encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp;
                var pokemonIv = Logic.Logic.CalculatePokemonPerfection(encounterPokemonResponse?.WildPokemon?.PokemonData).ToString("0.00") + "%";
                var pokeball  = await GetBestBall(pokemonCp);

                if (encounterPokemonResponse.ToString().Contains("ENCOUNTER_NOT_FOUND"))
                {
                    textResults.AppendText("Pokemon ran away...");
                    continue;
                }


                textResults.AppendText($"Fighting {pokemon.PokemonId} with Capture Probability of {(encounterPokemonResponse?.CaptureProbability.CaptureProbability_.First()) * 100:0.0}%" + Environment.NewLine);
                textResults.AppendText($"Current Location is {pokemon.Latitude}, {pokemon.Longitude}" + Environment.NewLine);

                CatchPokemonResponse caughtPokemonResponse;
                do
                {
                    if (encounterPokemonResponse?.CaptureProbability.CaptureProbability_.First() < (GUISettings.Default.minBerry / 100))
                    {
                        await UseBerry(pokemon.EncounterId, pokemon.SpawnpointId);
                    }

                    caughtPokemonResponse = await _client.CatchPokemon(pokemon.EncounterId, pokemon.SpawnpointId, pokemon.Latitude, pokemon.Longitude, pokeball);

                    await Task.Delay(1000);
                }while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed);

                textResults.AppendText(caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess ? $"We caught a {pokemon.PokemonId} with CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} using a {pokeball}" + Environment.NewLine : $"{pokemon.PokemonId} with CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} got away while using a {pokeball}.." + Environment.NewLine);

                if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess)
                {
                    // Update Pokemon Information
                    APINotifications.UpdatePokemonCaptured(pokemon.PokemonId.ToString(),
                                                           encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp,
                                                           float.Parse(pokemonIv.Replace('%', ' ')),
                                                           pokemon.Latitude,
                                                           pokemon.Longitude
                                                           );
                }
            }
        }