Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

Auto Evolve #347

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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
7 changes: 5 additions & 2 deletions config.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
151 changes: 151 additions & 0 deletions pokemon-candy.csv
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion src/main/kotlin/ink/abb/pogo/scraper/Bot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand All @@ -94,11 +95,12 @@ class Bot(val api: PokemonGo, val settings: Settings) {

task(process)
task(hatchEggs)
task(evolve)
Copy link
Author

@tonysguo tonysguo Jul 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you check for a null string if auto_evolve in config is empty, so as to not run it?

Via != null or .length? Strings can't be null in kotlin right?

Copy link
Owner

@jabbink jabbink Jul 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings can't be null. But you most likely have a String?, which is nullable

})
})
}

fun task(task: Task) {
task.run(this, ctx, settings)
}
}
}
12 changes: 12 additions & 0 deletions src/main/kotlin/ink/abb/pogo/scraper/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -93,6 +94,17 @@ class Settings(val properties: Properties) {
listOf()
}

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<Int, Int> {
val lines = File("pokemon-candy.csv").readLines()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be in src/main/resources and loaded from the classpath?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is in PokemonMeta.java if someone wants to mod and remove .csv --

public PokemonMeta( int baseStam,
                    double baseCaptureRate,
                    int candiesToEvolve,

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"IF PokeBank > # (or FULL)
USE Lucky Egg
EVOLVE for 30 Mins"

as far as lucky egg I think it would be better to have bot count number of possible evolutions from listing in config aka

+# list of pokemon you want to auto evolve
+auto_evolve=PIDGEY,weedle,caterpie
+# Minimum Number of evolutions possible before Auto, Leave at -1 or blank to evolve always.
+auto_evolvemin=50
+# Use Lucky Egg before Evolve cycle
+auto_evolveUseEgg=true

so that would wait for 50 possible evolutions from that list, then use lucky egg.

+# list of pokemon you want to auto evolve
+auto_evolve=PIDGEY,weedle,caterpie
+# Minimum Number of evolutions possible before Auto, Leave at -1 or blank to evolve always.
+auto_evolvemin=-1
+# Use Lucky Egg before Evolve cycle
+auto_evolveUseEgg=false

Would evolve every pidgey etc after a catch. no egg

Copy link
Author

@tonysguo tonysguo Jul 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea, I just ran this and it evolved 87 Pidgies in less than a minute (build in delays?). Best to leave egg on toggle or manual, they're rare to come by without spending.

Copy link

@pascalpfeil pascalpfeil Jul 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Xenxes i suggest letting the user decide how many evolutions/minute he wants (-1 for unlimited)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Xenxes : do you have a link to a compiled jar of this to check out? I can't compile because windows is stupid and I get too long of a file path when compiling dependencies.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

windows is stupid and I get too long of a file path

Clone the repo high on your SSD/HDD, eg. in C:\

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up doing that, which worked.

return lines.map {
val split = it.split(",")
Pair(split[0].toInt(), split[1].toInt())
}.toMap()
}

private fun <T> getPropertyOrDie(description: String, property: String, conversion: (String) -> T): T {
val settingString = "$description setting (\"$property\")"

Expand Down
49 changes: 49 additions & 0 deletions src/main/kotlin/ink/abb/pogo/scraper/tasks/EvolvePokemon.kt
Original file line number Diff line number Diff line change
@@ -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 }
Copy link
Contributor

@Forty-Tw0 Forty-Tw0 Jul 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea just change this: val sorted = it.value.sortedByDescending { it.cp } with this:
val sorted = if (settings.sortByIV) {
it.value.sortedByDescending { it.getIv() }
} else {
it.value.sortedByDescending { it.cp }
}
I dont know how to make a pull request so i only can write it here sorry!

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()
}
}
}
}
}