PokemonGoBot
PokemonGoBot copied to clipboard
[BUG] isTooMany logic
As I've commented in PR #522:
// Move this outside the if so it will always update `pokemonCounts`
// and because the `obligatoryTransfer` check is redundant
val (shouldRelease, reason) = pokemon.shouldTransfer(settings, pokemonCounts)
// We could even move the `keepPokemonAmount` condition into `shouldTransfer`
// as it doesn't need to know the `index`, cause it has `pokemonCounts` for that
if (shouldRelease && index >= settings.keepPokemonAmount) {
Log.yellow("Going to transfer ${pokemon.pokemonId.name} with " +
"CP ${pokemon.cp} and IV $ivPercentage%; reason: $reason")
val result = pokemon.transferPokemon()
if (result == Result.SUCCESS) {
ctx.pokemonStats.second.andIncrement
ctx.server.releasePokemon(pokemon.id)
ctx.server.sendProfile()
} else {
Log.red("Failed to transfer ${pokemon.pokemonId.name}: ${result.name}")
}
}
That would explain the maxPokemonAmount
bug, which in some cases keeps more Pokemon than it should.