Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better pokeball choosing #456

Merged
merged 2 commits into from
Jul 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions PokemonGo.RocketAPI.Logic/Logic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private async Task CatchEncounter(EncounterResponse encounter, MapPokemon pokemo
//test
var probability = encounter?.CaptureProbability?.CaptureProbability_?.FirstOrDefault();

var pokeball = await GetBestBall(encounter?.WildPokemon);
var pokeball = await GetBestBall(encounter);
if (pokeball == MiscEnums.Item.ITEM_UNKNOWN)
{
Logger.Write(
Expand Down Expand Up @@ -423,25 +423,28 @@ await _navigation.HumanLikeWalking(
}


private async Task<MiscEnums.Item> GetBestBall(WildPokemon pokemon)
private async Task<MiscEnums.Item> GetBestBall(EncounterResponse encounter)
{
var pokemonCp = pokemon?.PokemonData?.Cp;
var pokemonCp = encounter?.WildPokemon?.PokemonData?.Cp;
var iV = Math.Round(PokemonInfo.CalculatePokemonPerfection(encounter?.WildPokemon?.PokemonData));
var proba = encounter?.CaptureProbability?.CaptureProbability_.First();

var pokeBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_POKE_BALL);
var greatBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_GREAT_BALL);
var ultraBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_ULTRA_BALL);
var masterBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_MASTER_BALL);

if (masterBallsCount > 0 && pokemonCp >= 2000)
if (masterBallsCount > 0 && pokemonCp >= 1200)
return MiscEnums.Item.ITEM_MASTER_BALL;
if (ultraBallsCount > 0 && pokemonCp >= 2000)
if (ultraBallsCount > 0 && pokemonCp >= 1000)
return MiscEnums.Item.ITEM_ULTRA_BALL;
if (greatBallsCount > 0 && pokemonCp >= 2000)
if (greatBallsCount > 0 && pokemonCp >= 750)
return MiscEnums.Item.ITEM_GREAT_BALL;

if (ultraBallsCount > 0 && pokemonCp >= 1000)
if (ultraBallsCount > 0 && iV >= _clientSettings.KeepMinIVPercentage && proba < 0.40)
return MiscEnums.Item.ITEM_ULTRA_BALL;
if (greatBallsCount > 0 && pokemonCp >= 1000)

if (greatBallsCount > 0 && iV >= _clientSettings.KeepMinIVPercentage && proba < 0.50)
return MiscEnums.Item.ITEM_GREAT_BALL;

if (greatBallsCount > 0 && pokemonCp >= 300)
Expand Down