diff --git a/config.properties.template b/config.properties.template index 4a0538e0d..638fc15a7 100644 --- a/config.properties.template +++ b/config.properties.template @@ -83,8 +83,11 @@ transfer_cp_threshold=400 # if you want all pokemons to be transferred just leave it blank ignored_pokemon=EEVEE,MEWTWO,CHARMANDER -# list of pokemon you always want to trancsfer regardless of CP -obligatory_transfer=DODUO,RATTATA,CATERPIE,PIDGEY +# list of pokemon you always want to transfer regardless of CP +obligatory_transfer=DODUO,RATTATA,CATERPIE + +# list of pokemon you want to auto evolve +auto_evolve=PIDGEY #List of pokemon names #MISSINGNO diff --git a/pokemon-candy.csv b/pokemon-candy.csv new file mode 100644 index 000000000..071e1e81c --- /dev/null +++ b/pokemon-candy.csv @@ -0,0 +1,151 @@ +1,25 +2,100 +3,0 +4,25 +5,100 +6,0 +7,25 +8,100 +9,0 +10,12 +11,50 +12,0 +13,12 +14,50 +15,0 +16,12 +17,50 +18,0 +19,25 +20,0 +21,50 +22,0 +23,50 +24,0 +25,50 +26,0 +27,50 +28,0 +29,25 +30,100 +31,0 +32,25 +33,100 +34,0 +35,50 +36,0 +37,50 +38,0 +39,50 +40,0 +41,50 +42,0 +43,25 +44,100 +45,0 +46,50 +47,0 +48,50 +49,0 +50,50 +51,0 +52,50 +53,0 +54,50 +55,0 +56,50 +57,0 +58,50 +59,0 +60,25 +61,100 +62,0 +63,25 +64,100 +65,0 +66,25 +67,100 +68,0 +69,25 +70,100 +71,0 +72,50 +73,0 +74,25 +75,100 +76,0 +77,50 +78,0 +79,50 +80,0 +81,50 +82,0 +83,0 +84,50 +85,0 +86,50 +87,0 +88,50 +89,0 +90,50 +91,0 +92,25 +93,100 +94,0 +95,0 +96,50 +97,0 +98,50 +9,0 +100,50 +101,0 +102,50 +103,0 +104,50 +105,0 +106,0 +107,0 +108,0 +109,50 +110,0 +111,50 +112,0 +113,0 +114,0 +115,0 +116,50 +117,0 +118,50 +119,0 +120,50 +121,0 +122,0 +123,0 +124,0 +125,0 +126,0 +127,0 +128,0 +129,400 +130,0 +131,0 +132,0 +133,25 +134,0 +135,0 +136,0 +137,0 +138,50 +139,0 +140,50 +141,0 +142,0 +143,0 +144,0 +145,0 +146,0 +147,25 +148,100 +149,0 +150,0 +151,0 \ No newline at end of file diff --git a/src/main/kotlin/ink/abb/pogo/scraper/Bot.kt b/src/main/kotlin/ink/abb/pogo/scraper/Bot.kt index b80696156..f8cdd86b8 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/Bot.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/Bot.kt @@ -69,6 +69,7 @@ class Bot(val api: PokemonGo, val settings: Settings) { val catch = CatchOneNearbyPokemon() val release = ReleasePokemon() val hatchEggs = HatchEggs() + val evolve = EvolvePokemon() task(keepalive) Log.normal("Getting initial pokestops...") @@ -85,6 +86,7 @@ class Bot(val api: PokemonGo, val settings: Settings) { fixedRateTimer("BotLoop", false, 0, 5000, action = { thread(block = { task(keepalive) + task(evolve) if (settings.shouldCatchPokemons) task(catch) if (settings.shouldDropItems) @@ -101,4 +103,4 @@ class Bot(val api: PokemonGo, val settings: Settings) { fun task(task: Task) { task.run(this, ctx, settings) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt b/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt index b0d651945..08c607efd 100644 --- a/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt +++ b/src/main/kotlin/ink/abb/pogo/scraper/Settings.kt @@ -14,6 +14,7 @@ import ink.abb.pogo.scraper.util.Log import java.io.BufferedReader import java.io.FileOutputStream import java.io.FileReader +import java.io.File import java.util.* class Settings(val properties: Properties) { @@ -93,6 +94,19 @@ class Settings(val properties: Properties) { listOf() } + val candyRequiredByPokemon = getCandyByPokemon() + + val autoEvolve = getPropertyIfSet("list of pokemon you want to evolve when able to", "auto_evolve", "CATERPIE,PIDGEY,WEEDLE", String::toString).split(",") + + //This method only exists because I wasn't sure if this data was stored somewhere else. If it is then this can be removed. + private fun getCandyByPokemon(): Map { + val lines = File("pokemon-candy.csv").readLines() + return lines.map { + val split = it.split(",") + Pair(split[0].toInt(), split[1].toInt()) + }.toMap() + } + private fun getPropertyOrDie(description: String, property: String, conversion: (String) -> T): T { val settingString = "$description setting (\"$property\")" diff --git a/src/main/kotlin/ink/abb/pogo/scraper/tasks/EvolvePokemon.kt b/src/main/kotlin/ink/abb/pogo/scraper/tasks/EvolvePokemon.kt new file mode 100644 index 000000000..eb93bd194 --- /dev/null +++ b/src/main/kotlin/ink/abb/pogo/scraper/tasks/EvolvePokemon.kt @@ -0,0 +1,49 @@ +/** + * Pokemon Go Bot Copyright (C) 2016 PokemonGoBot-authors (see authors.md for more information) + * This program comes with ABSOLUTELY NO WARRANTY; + * This is free software, and you are welcome to redistribute it under certain conditions. + * + * For more information, refer to the LICENSE file in this repositories root directory + */ + +package ink.abb.pogo.scraper.tasks + +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 + +/** + * @author Michael Meehan (Javapt) + */ + +class EvolvePokemon : Task { + override fun run(bot: Bot, ctx: Context, settings: Settings) { + if (settings.autoEvolve.isEmpty()) { + return + } + val groupedPokemon = ctx.api.inventories.pokebank.pokemons.groupBy { it.pokemonId } + val autoEvolve = settings.autoEvolve + val canEvolve = groupedPokemon.filter { + val candyNeeded = settings.candyRequiredByPokemon[it.key.number] + candyNeeded != null && candyNeeded > 0 && autoEvolve.contains(it.key.name) && it.value.first().candy >= candyNeeded + } + if (canEvolve.isEmpty()) { + return + } + canEvolve.forEach { + val sorted = it.value.sortedByDescending { it.cp } + val candyNeeded = settings.candyRequiredByPokemon[it.key.number] + if (candyNeeded != null) { + for ((index, pokemon) in sorted.withIndex()) { + if (pokemon.candy < candyNeeded) { + break; + } + Log.green("Evolving ${pokemon.pokemonId.name} because we have ${pokemon.candy} candy and only need ${candyNeeded}.") + pokemon.evolve() + } + } + } + } +} \ No newline at end of file