From 8f1042e97347cfc2ba8e09574cc466a05cc259a5 Mon Sep 17 00:00:00 2001 From: Brian Devins Date: Wed, 10 Aug 2016 17:21:42 -0400 Subject: [PATCH 01/11] Starting toward powerups --- config.properties.template | 4 ++ src/main/kotlin/ink/abb/pogo/scraper/Bot.kt | 3 ++ .../kotlin/ink/abb/pogo/scraper/Settings.kt | 8 ++++ .../ink/abb/pogo/scraper/tasks/PowerUp.kt | 46 +++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt diff --git a/config.properties.template b/config.properties.template index f227a6124..ce7852a0c 100644 --- a/config.properties.template +++ b/config.properties.template @@ -154,6 +154,10 @@ export= # Initial map size (S2 tiles) to fetch (max. 9: ~3*3km area) initial_map_size=9 +auto_power_up=false +power_up_iv_threshold=90 +power_up_only_best=true + # List of pokemon names #MISSINGNO #BULBASAUR diff --git a/src/main/kotlin/ink/abb/pogo/scraper/Bot.kt b/src/main/kotlin/ink/abb/pogo/scraper/Bot.kt index 67dc8fa1d..4f7bc2362 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/Bot.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/Bot.kt @@ -93,6 +93,7 @@ class Bot(val api: PokemonGo, val settings: Settings) { val release = ReleasePokemon() val hatchEggs = HatchEggs() val export = Export() + val powerUp = PowerUp() if (settings.export.length > 0) task(export) @@ -137,6 +138,8 @@ class Bot(val api: PokemonGo, val settings: Settings) { task(hatchEggs) if (settings.export.length > 0) task(export) + if (settings.autoPowerUp) + task(powerUp) } runLoop(TimeUnit.SECONDS.toMillis(5), "BotLoop") { diff --git a/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt b/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt index bd4dfe378..8bf13fa81 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt @@ -97,6 +97,10 @@ class SettingsParser(val properties: Properties) { transferIvThreshold = getPropertyIfSet("Minimum IV percentage to keep a pokemon", "transfer_iv_threshold", defaults.transferIvThreshold, String::toInt), + autoPowerUp = getPropertyIfSet("Automatically powerup pokemon that meet the threshold", "auto_power_up", defaults.autoPowerUp, String::toBoolean), + powerUpIvThreshold = getPropertyIfSet("Minimum IV percentage to powerup a pokemon", "power_up_iv_threshold", defaults.transferIvThreshold, String::toInt), + powerUpOnlyBest = getPropertyIfSet("Power up only the best of each species", "power_up_only_best", defaults.powerUpOnlyBest, String::toBoolean), + ignoredPokemon = getPropertyIfSet("Never transfer these Pokemon", "ignored_pokemon", defaults.ignoredPokemon.map { it.name }.joinToString(","), String::toString).split(",").filter { it.isNotBlank() }.map { PokemonId.valueOf(it) }, obligatoryTransfer = getPropertyIfSet("list of pokemon you always want to transfer regardless of CP", "obligatory_transfer", defaults.obligatoryTransfer.map { it.name }.joinToString(","), String::toString).split(",").filter { it.isNotBlank() }.map { PokemonId.valueOf(it) }, @@ -211,6 +215,10 @@ data class Settings( val transferIvThreshold: Int = 80, val ignoredPokemon: List = listOf(PokemonId.EEVEE, PokemonId.MEWTWO, PokemonId.CHARMANDER), + val autoPowerUp: Boolean = false, + val powerUpIvThreshold: Int = 90, + val powerUpOnlyBest: Boolean = true, + val obligatoryTransfer: List = listOf(PokemonId.DODUO, PokemonId.RATTATA, PokemonId.CATERPIE, PokemonId.PIDGEY), val export: String = "", diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt new file mode 100644 index 000000000..7d9f305ea --- /dev/null +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt @@ -0,0 +1,46 @@ +package ink.abb.pogo.scraper.tasks + +import com.pokegoapi.api.player.PlayerProfile +import com.pokegoapi.api.pokemon.Pokemon +import ink.abb.pogo.scraper.Bot +import ink.abb.pogo.scraper.Context +import ink.abb.pogo.scraper.Settings +import ink.abb.pogo.scraper.Task +import ink.abb.pogo.scraper.util.Log +import ink.abb.pogo.scraper.util.cachedInventories +import ink.abb.pogo.scraper.util.pokemon.getIvPercentage + +/** + * Created by ddcbdevins on 8/10/16. + */ +class PowerUp : Task { + override fun run(bot: Bot, ctx: Context, settings: Settings) { + val eligblePokes = ctx.api.cachedInventories.pokebank.pokemons.filter { + it.getIvPercentage() >= settings.powerUpIvThreshold && it.candiesToEvolve == 0 + }.sortedByDescending { + it.ivRatio + }.groupBy { + it.pokemonId + } + + eligblePokes.forEach { + if (settings.powerUpOnlyBest) { + powerUp(it.value[0], ctx) + } else { + it.value.forEach { + powerUp(it, ctx) + } + } + } + } + + fun powerUp(pokemon: Pokemon, ctx: Context) { + if (pokemon.candyCostsForPowerup <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily) && + pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { + while (true) { + Log.blue("PowerUp ${pokemon.pokemonId.name} IV ${pokemon.getIvPercentage()}% ${pokemon.cp} cp -> ${pokemon.cpAfterPowerup}") + pokemon.powerUp() + } + } + } +} \ No newline at end of file From 1ddccf3448bd699521bd0fe0cb6689cb5c5278a1 Mon Sep 17 00:00:00 2001 From: Brian Devins Date: Wed, 10 Aug 2016 17:41:47 -0400 Subject: [PATCH 02/11] Find the right gate for upgrading your best --- src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt index 7d9f305ea..01558f8a0 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt @@ -1,5 +1,6 @@ package ink.abb.pogo.scraper.tasks +import POGOProtos.Enums.PokemonIdOuterClass import com.pokegoapi.api.player.PlayerProfile import com.pokegoapi.api.pokemon.Pokemon import ink.abb.pogo.scraper.Bot @@ -37,7 +38,7 @@ class PowerUp : Task { fun powerUp(pokemon: Pokemon, ctx: Context) { if (pokemon.candyCostsForPowerup <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily) && pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { - while (true) { + while (pokemon.level < ctx.profile.stats.level + 2) { Log.blue("PowerUp ${pokemon.pokemonId.name} IV ${pokemon.getIvPercentage()}% ${pokemon.cp} cp -> ${pokemon.cpAfterPowerup}") pokemon.powerUp() } From 68c6228ff8feb45a968c500564ed94c1196917ea Mon Sep 17 00:00:00 2001 From: Brian Devins Date: Wed, 10 Aug 2016 17:45:00 -0400 Subject: [PATCH 03/11] Get rid of template comment --- src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt index 01558f8a0..294661ca9 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt @@ -11,9 +11,6 @@ import ink.abb.pogo.scraper.util.Log import ink.abb.pogo.scraper.util.cachedInventories import ink.abb.pogo.scraper.util.pokemon.getIvPercentage -/** - * Created by ddcbdevins on 8/10/16. - */ class PowerUp : Task { override fun run(bot: Bot, ctx: Context, settings: Settings) { val eligblePokes = ctx.api.cachedInventories.pokebank.pokemons.filter { From 0fda96d2c3cdd9b48369d417766c9995c5955bb3 Mon Sep 17 00:00:00 2001 From: Brian Devins Date: Wed, 10 Aug 2016 17:48:43 -0400 Subject: [PATCH 04/11] Break out when can do one power up but not a max power up --- src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt index 294661ca9..364c7593f 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt @@ -33,11 +33,13 @@ class PowerUp : Task { } fun powerUp(pokemon: Pokemon, ctx: Context) { - if (pokemon.candyCostsForPowerup <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily) && - pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { - while (pokemon.level < ctx.profile.stats.level + 2) { + while (pokemon.level < ctx.profile.stats.level + 2) { + if (pokemon.candyCostsForPowerup <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily) && + pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { Log.blue("PowerUp ${pokemon.pokemonId.name} IV ${pokemon.getIvPercentage()}% ${pokemon.cp} cp -> ${pokemon.cpAfterPowerup}") pokemon.powerUp() + } else { + return } } } From f86bb6277e5456e9fea1b89c54313a1370eb77a8 Mon Sep 17 00:00:00 2001 From: Brian Devins Date: Wed, 10 Aug 2016 18:36:00 -0400 Subject: [PATCH 05/11] The candyjar does not update automatically --- .../ink/abb/pogo/scraper/tasks/PowerUp.kt | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt index 364c7593f..20d9a240c 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt @@ -33,13 +33,21 @@ class PowerUp : Task { } fun powerUp(pokemon: Pokemon, ctx: Context) { - while (pokemon.level < ctx.profile.stats.level + 2) { - if (pokemon.candyCostsForPowerup <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily) && - pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { - Log.blue("PowerUp ${pokemon.pokemonId.name} IV ${pokemon.getIvPercentage()}% ${pokemon.cp} cp -> ${pokemon.cpAfterPowerup}") - pokemon.powerUp() - } else { - return + if (pokemon.candiesToEvolve <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)) { + while (pokemon.level < ctx.profile.stats.level + 2) { + if (pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { + Log.red("${ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)}/${pokemon.candyCostsForPowerup} candy") + Log.red("${ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!}/${pokemon.stardustCostsForPowerup} stardust") + Log.blue("PowerUp ${pokemon.pokemonId.name} IV ${pokemon.getIvPercentage()}% ${pokemon.cp} cp -> ${pokemon.cpAfterPowerup}") + pokemon.powerUp() + } else { + return + } + + // Update the candyjar to see if we should loop again + if (pokemon.candiesToEvolve > ctx.api.inventories.candyjar.getCandies(pokemon.pokemonFamily)) { + return + } } } } From 42c560f0d98acde162163378ae45213badc1ea33 Mon Sep 17 00:00:00 2001 From: Brian Devins Date: Wed, 10 Aug 2016 18:42:17 -0400 Subject: [PATCH 06/11] Wrong candies count --- src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt index 20d9a240c..0d5187032 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt @@ -33,7 +33,7 @@ class PowerUp : Task { } fun powerUp(pokemon: Pokemon, ctx: Context) { - if (pokemon.candiesToEvolve <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)) { + if (pokemon.candyCostsForPowerup <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)) { while (pokemon.level < ctx.profile.stats.level + 2) { if (pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { Log.red("${ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)}/${pokemon.candyCostsForPowerup} candy") @@ -45,7 +45,7 @@ class PowerUp : Task { } // Update the candyjar to see if we should loop again - if (pokemon.candiesToEvolve > ctx.api.inventories.candyjar.getCandies(pokemon.pokemonFamily)) { + if (pokemon.candyCostsForPowerup > ctx.api.inventories.candyjar.getCandies(pokemon.pokemonFamily)) { return } } From 0da211920b8d5d0862d7140940f9c3e4073b8958 Mon Sep 17 00:00:00 2001 From: Brian Devins Date: Wed, 10 Aug 2016 19:19:38 -0400 Subject: [PATCH 07/11] Power up once per profile loop --- .../ink/abb/pogo/scraper/tasks/PowerUp.kt | 48 ++++++++----------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt index 0d5187032..3d5ac60eb 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt @@ -13,42 +13,36 @@ import ink.abb.pogo.scraper.util.pokemon.getIvPercentage class PowerUp : Task { override fun run(bot: Bot, ctx: Context, settings: Settings) { - val eligblePokes = ctx.api.cachedInventories.pokebank.pokemons.filter { - it.getIvPercentage() >= settings.powerUpIvThreshold && it.candiesToEvolve == 0 + var eligiblePokemon = ctx.api.cachedInventories.pokebank.pokemons.filter { + it.getIvPercentage() >= settings.powerUpIvThreshold && + it.candiesToEvolve == 0 && + it.level < ctx.profile.stats.level + 2 }.sortedByDescending { it.ivRatio - }.groupBy { - it.pokemonId } - eligblePokes.forEach { - if (settings.powerUpOnlyBest) { - powerUp(it.value[0], ctx) - } else { - it.value.forEach { - powerUp(it, ctx) - } + if (settings.powerUpOnlyBest) { + eligiblePokemon = eligiblePokemon.groupBy { + it.pokemonId + }.flatMap { + listOf(it.value[0]) } } + + eligiblePokemon.forEach { + powerUp(it, ctx) + } } fun powerUp(pokemon: Pokemon, ctx: Context) { - if (pokemon.candyCostsForPowerup <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)) { - while (pokemon.level < ctx.profile.stats.level + 2) { - if (pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { - Log.red("${ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)}/${pokemon.candyCostsForPowerup} candy") - Log.red("${ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!}/${pokemon.stardustCostsForPowerup} stardust") - Log.blue("PowerUp ${pokemon.pokemonId.name} IV ${pokemon.getIvPercentage()}% ${pokemon.cp} cp -> ${pokemon.cpAfterPowerup}") - pokemon.powerUp() - } else { - return - } - - // Update the candyjar to see if we should loop again - if (pokemon.candyCostsForPowerup > ctx.api.inventories.candyjar.getCandies(pokemon.pokemonFamily)) { - return - } - } + if (pokemon.candyCostsForPowerup <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily) && + pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { + Log.red("${ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)}/${pokemon.candyCostsForPowerup} candy") + Log.red("${ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!}/${pokemon.stardustCostsForPowerup} stardust") + Log.blue("PowerUp ${pokemon.pokemonId.name} IV ${pokemon.getIvPercentage()}% ${pokemon.cp} cp -> ${pokemon.cpAfterPowerup}") + val powerUpCostCandies = pokemon.candyCostsForPowerup + pokemon.powerUp() + ctx.api.cachedInventories.candyjar.removeCandy(pokemon.pokemonFamily, powerUpCostCandies) } } } \ No newline at end of file From 5014a3687aa8509c9a5b8c5b4aa6a7c277c57d12 Mon Sep 17 00:00:00 2001 From: Brian Devins Date: Wed, 10 Aug 2016 19:30:07 -0400 Subject: [PATCH 08/11] Max power up --- .../ink/abb/pogo/scraper/tasks/PowerUp.kt | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt index 3d5ac60eb..6be4d60f6 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt @@ -35,14 +35,18 @@ class PowerUp : Task { } fun powerUp(pokemon: Pokemon, ctx: Context) { - if (pokemon.candyCostsForPowerup <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily) && - pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { - Log.red("${ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)}/${pokemon.candyCostsForPowerup} candy") - Log.red("${ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!}/${pokemon.stardustCostsForPowerup} stardust") - Log.blue("PowerUp ${pokemon.pokemonId.name} IV ${pokemon.getIvPercentage()}% ${pokemon.cp} cp -> ${pokemon.cpAfterPowerup}") - val powerUpCostCandies = pokemon.candyCostsForPowerup - pokemon.powerUp() - ctx.api.cachedInventories.candyjar.removeCandy(pokemon.pokemonFamily, powerUpCostCandies) + while (pokemon.level < ctx.profile.stats.level + 2) { + if (pokemon.candyCostsForPowerup <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily) && + pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { + Log.red("${ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)}/${pokemon.candyCostsForPowerup} candy") + Log.red("${ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!}/${pokemon.stardustCostsForPowerup} stardust") + Log.blue("PowerUp ${pokemon.pokemonId.name} IV ${pokemon.getIvPercentage()}% ${pokemon.cp} cp -> ${pokemon.cpAfterPowerup}") + val powerUpCostCandies = pokemon.candyCostsForPowerup + pokemon.powerUp() + ctx.api.cachedInventories.candyjar.removeCandy(pokemon.pokemonFamily, powerUpCostCandies) + } else { + return + } } } } \ No newline at end of file From 5d47e55811711f8c92d1b2f547438edd44413094 Mon Sep 17 00:00:00 2001 From: Brian Devins Date: Wed, 10 Aug 2016 19:43:45 -0400 Subject: [PATCH 09/11] Guess I have to update stardust on my own too --- src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt index 6be4d60f6..2c9d3bffa 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt @@ -42,8 +42,10 @@ class PowerUp : Task { Log.red("${ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!}/${pokemon.stardustCostsForPowerup} stardust") Log.blue("PowerUp ${pokemon.pokemonId.name} IV ${pokemon.getIvPercentage()}% ${pokemon.cp} cp -> ${pokemon.cpAfterPowerup}") val powerUpCostCandies = pokemon.candyCostsForPowerup + val powerUpCostStardust = pokemon.stardustCostsForPowerup pokemon.powerUp() ctx.api.cachedInventories.candyjar.removeCandy(pokemon.pokemonFamily, powerUpCostCandies) + ctx.api.playerProfile.addCurrency(PlayerProfile.Currency.STARDUST.name, powerUpCostStardust * -1) } else { return } From 93667777287092b536607fd50f66e887ac7791e8 Mon Sep 17 00:00:00 2001 From: Brian Devins Date: Thu, 11 Aug 2016 12:30:01 -0400 Subject: [PATCH 10/11] Only power up the best thats not full strength --- .../kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt index 2c9d3bffa..88977d3c1 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt @@ -1,6 +1,5 @@ package ink.abb.pogo.scraper.tasks -import POGOProtos.Enums.PokemonIdOuterClass import com.pokegoapi.api.player.PlayerProfile import com.pokegoapi.api.pokemon.Pokemon import ink.abb.pogo.scraper.Bot @@ -13,10 +12,10 @@ import ink.abb.pogo.scraper.util.pokemon.getIvPercentage class PowerUp : Task { override fun run(bot: Bot, ctx: Context, settings: Settings) { + // TODO exclude those where a better poke in the same family exists that be evolved to here var eligiblePokemon = ctx.api.cachedInventories.pokebank.pokemons.filter { it.getIvPercentage() >= settings.powerUpIvThreshold && - it.candiesToEvolve == 0 && - it.level < ctx.profile.stats.level + 2 + it.candiesToEvolve == 0 }.sortedByDescending { it.ivRatio } @@ -29,17 +28,18 @@ class PowerUp : Task { } } - eligiblePokemon.forEach { - powerUp(it, ctx) - } + val poke = eligiblePokemon.filter { it.level < ctx.profile.stats.level + 2 }[0] + Log.blue("Attempting to PowerUp ${poke.pokemonId.name} IV ${poke.getIvPercentage()}%") + // Use stardust on best possible only + powerUp(poke, ctx) } fun powerUp(pokemon: Pokemon, ctx: Context) { while (pokemon.level < ctx.profile.stats.level + 2) { + Log.red("${ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)}/${pokemon.candyCostsForPowerup} candy") + Log.red("${ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!}/${pokemon.stardustCostsForPowerup} stardust") if (pokemon.candyCostsForPowerup <= ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily) && pokemon.stardustCostsForPowerup <= ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!) { - Log.red("${ctx.api.cachedInventories.candyjar.getCandies(pokemon.pokemonFamily)}/${pokemon.candyCostsForPowerup} candy") - Log.red("${ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!!}/${pokemon.stardustCostsForPowerup} stardust") Log.blue("PowerUp ${pokemon.pokemonId.name} IV ${pokemon.getIvPercentage()}% ${pokemon.cp} cp -> ${pokemon.cpAfterPowerup}") val powerUpCostCandies = pokemon.candyCostsForPowerup val powerUpCostStardust = pokemon.stardustCostsForPowerup From 7ed5cbc407287460055425ef25039afea459052a Mon Sep 17 00:00:00 2001 From: Brian Devins Date: Thu, 11 Aug 2016 12:41:41 -0400 Subject: [PATCH 11/11] AddCurrency didnt mean add this ammount to the currency. setting instead --- src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt index 88977d3c1..6ca74c726 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/PowerUp.kt @@ -45,7 +45,7 @@ class PowerUp : Task { val powerUpCostStardust = pokemon.stardustCostsForPowerup pokemon.powerUp() ctx.api.cachedInventories.candyjar.removeCandy(pokemon.pokemonFamily, powerUpCostCandies) - ctx.api.playerProfile.addCurrency(PlayerProfile.Currency.STARDUST.name, powerUpCostStardust * -1) + ctx.api.playerProfile.currencies.put(PlayerProfile.Currency.STARDUST, ctx.profile.currencies.get(PlayerProfile.Currency.STARDUST)!! - powerUpCostStardust) } else { return }