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

Commit

Permalink
fix "MISSINGNO" hatch messages
Browse files Browse the repository at this point in the history
add buddy pokemon support
  • Loading branch information
jabbink committed Nov 12, 2016
1 parent 0ba1d20 commit 510db85
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'ink.abb'
version '0.7.3'
version '0.7.4'

buildscript {
ext {
Expand Down
2 changes: 2 additions & 0 deletions config.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ bot_timeout_after_catching_pokemon=-1
# Set if you want the bot to stop after visiting certain amount of pokestops, -1 skips it
bot_timeout_after_visiting_pokestops=-1

# desired type of buddy pokemon
buddy_pokemon=

# List of pokemon names
#MISSINGNO
Expand Down
3 changes: 2 additions & 1 deletion json-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"waitTimeMax" : 0,
"botTimeoutAfterMinutes" : -1,
"botTimeoutAfterCatchingPokemon" : -1,
"botTimeoutAfterVisitingPokestops" : -1
"botTimeoutAfterVisitingPokestops" : -1,
"buddyPokemon" : ""
}

Binary file modified lib/api-0.0.2.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions src/main/kotlin/ink/abb/pogo/scraper/Bot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Bot(val api: PoGoApi, val settings: Settings) {
val drop = DropUselessItems()
val profile = UpdateProfile()
val catch = CatchOneNearbyPokemon()
val buddy = SetBuddyPokemon()
val release = ReleasePokemon()
val evolve = EvolvePokemon()
val hatchEggs = HatchEggs()
Expand Down Expand Up @@ -148,6 +149,9 @@ class Bot(val api: PoGoApi, val settings: Settings) {
ctx.pauseWalking.set(false)
}
}
if (settings.buddyPokemon.isNotBlank()) {
task(buddy)
}
if (settings.dropItems)
task(drop)
if (settings.autotransfer)
Expand Down
19 changes: 11 additions & 8 deletions src/main/kotlin/ink/abb/pogo/scraper/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SettingsParser(val properties: Properties) {
longitude = getPropertyOrDie("Starting Longitude", "longitude", String::toDouble),
saveLocationOnShutdown = getPropertyIfSet("Save last location when the bot stop", "save_location_on_shutdown", defaults.saveLocationOnShutdown, String::toBoolean),
savedLatitude = getPropertyIfSet("Saved start Latitude", "saved_latitude", defaults.savedLatitude, String::toDouble),
savedLongitude = getPropertyIfSet("Saved start Longitude", "saved_longitude", defaults.savedLongitude, String::toDouble),
savedLongitude = getPropertyIfSet("Saved start Longitude", "saved_longitude", defaults.savedLongitude, String::toDouble),

credentials = if (properties.getProperty("username", "").isEmpty()) {
GoogleCredentials(properties.getProperty("token", ""))
Expand All @@ -61,7 +61,7 @@ class SettingsParser(val properties: Properties) {
mapzenApiKey = getPropertyIfSet("If you use MAPZEN as route provider, you can use a Mapzen Turn by Turn API key", "mapzen_api_key", defaults.mapzenApiKey, String::toString),
googleApiKey = getPropertyIfSet("If you use GOOGLE as route provider, you must use a Google API key", "google_api_key", defaults.googleApiKey, String::toString),
dropItems = dropItems,
itemDropDelay = getPropertyIfSet("Delay between each drop of items","item_drop_delay",defaults.itemDropDelay, String::toLong),
itemDropDelay = getPropertyIfSet("Delay between each drop of items", "item_drop_delay", defaults.itemDropDelay, String::toLong),
groupItemsByType = getPropertyIfSet("Should the items that are kept be grouped by type (keep best from same type)", "group_items_by_type", defaults.groupItemsByType, String::toBoolean),

uselessItems = mapOf(
Expand All @@ -88,7 +88,7 @@ class SettingsParser(val properties: Properties) {
randomBallThrows = getPropertyIfSet("Randomize Ball Throwing", "random_ball_throws", defaults.randomBallThrows, String::toBoolean),
waitBetweenThrows = getPropertyIfSet("Waiting between throws", "wait_between_throws", defaults.waitBetweenThrows, String::toBoolean),
autotransfer = getPropertyIfSet("Autotransfer", "autotransfer", defaults.autotransfer, String::toBoolean),
autotransferTimeDelay = getPropertyIfSet("Delay between each transfer","autotransfer_time_delay", defaults.autotransferTimeDelay, String::toLong),
autotransferTimeDelay = getPropertyIfSet("Delay between each transfer", "autotransfer_time_delay", defaults.autotransferTimeDelay, String::toLong),
keepPokemonAmount = getPropertyIfSet("minimum keep pokemon amount", "keep_pokemon_amount", defaults.keepPokemonAmount, String::toInt),
maxPokemonAmount = getPropertyIfSet("maximum keep pokemon amount", "max_pokemon_amount", defaults.maxPokemonAmount, String::toInt),
displayKeepalive = getPropertyIfSet("Display Keepalive Coordinates", "display_keepalive", defaults.displayKeepalive, String::toBoolean),
Expand Down Expand Up @@ -132,7 +132,7 @@ class SettingsParser(val properties: Properties) {

useLuckyEgg = getPropertyIfSet("Use lucky egg before evolves", "use_lucky_egg", defaults.useLuckyEgg, String::toInt),

evolveTimeDelay = getPropertyIfSet("Set time delay between evolutions", "evolve_time_delay", defaults.evolveTimeDelay, String::toLong),
evolveTimeDelay = getPropertyIfSet("Set time delay between evolutions", "evolve_time_delay", defaults.evolveTimeDelay, String::toLong),

export = getPropertyIfSet("Export on Profile Update", "export", defaults.export, String::toString),

Expand All @@ -150,7 +150,9 @@ class SettingsParser(val properties: Properties) {

botTimeoutAfterMinutes = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_minutes", defaults.botTimeoutAfterMinutes, String::toInt),
botTimeoutAfterCatchingPokemon = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_catching_pokemon", defaults.botTimeoutAfterCatchingPokemon, String::toInt),
botTimeoutAfterVisitingPokestops = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_visiting_pokestops", defaults.botTimeoutAfterVisitingPokestops, String::toInt)
botTimeoutAfterVisitingPokestops = getPropertyIfSet("Bot times out after X minutes and waits", "bot_timeout_after_visiting_pokestops", defaults.botTimeoutAfterVisitingPokestops, String::toInt),

buddyPokemon = getPropertyIfSet("Desired buddy pokemon", "buddy_pokemon", defaults.buddyPokemon, String::toString)
)
}

Expand Down Expand Up @@ -237,7 +239,6 @@ data class Settings(
Pair(ItemId.ITEM_LUCKY_EGG, -1),
Pair(ItemId.ITEM_INCENSE_ORDINARY, -1),
Pair(ItemId.ITEM_TROY_DISK, -1)

),

val profileUpdateTimer: Long = 60,
Expand Down Expand Up @@ -297,8 +298,10 @@ data class Settings(
val waitTimeMax: Int = 0,

val botTimeoutAfterMinutes: Int = -1,
val botTimeoutAfterCatchingPokemon:Int = -1,
val botTimeoutAfterVisitingPokestops:Int = -1
val botTimeoutAfterCatchingPokemon: Int = -1,
val botTimeoutAfterVisitingPokestops: Int = -1,

val buddyPokemon: String = ""
) {
fun withName(name: String): Settings {
this.name = name
Expand Down
5 changes: 4 additions & 1 deletion src/main/kotlin/ink/abb/pogo/scraper/tasks/ReleasePokemon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class ReleasePokemon : Task {
}
for ((index, pokemon) in sorted.withIndex()) {
// don't drop favorited, deployed, or nicknamed pokemon
val isFavourite = pokemon.pokemonData.nickname.isNotBlank() || pokemon.pokemonData.favorite != 0 || !pokemon.pokemonData.deployedFortId.isEmpty()
val isFavourite = pokemon.pokemonData.nickname.isNotBlank() ||
pokemon.pokemonData.favorite != 0 ||
!pokemon.pokemonData.deployedFortId.isEmpty() ||
(ctx.api.playerData.hasBuddyPokemon() && ctx.api.playerData.buddyPokemon.id == pokemon.pokemonData.id)
if (!isFavourite) {
val ivPercentage = pokemon.pokemonData.getIvPercentage()
// never transfer highest rated Pokemon (except for obligatory transfer)
Expand Down
48 changes: 48 additions & 0 deletions src/main/kotlin/ink/abb/pogo/scraper/tasks/SetBuddyPokemon.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 POGOProtos.Networking.Responses.SetBuddyPokemonResponseOuterClass
import ink.abb.pogo.api.request.SetBuddyPokemon
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


class SetBuddyPokemon : Task {
override fun run(bot: Bot, ctx: Context, settings: Settings) {
var replaceBuddy = false
val currentBuddy = if (ctx.api.playerData.hasBuddyPokemon()) {
ctx.api.inventory.pokemon[ctx.api.playerData.buddyPokemon.id]
} else {
null
}
if (currentBuddy != null) {
if (settings.buddyPokemon.toUpperCase().trim() != currentBuddy.pokemonData.pokemonId.name) {
replaceBuddy = true
}
} else {
replaceBuddy = true
}
if (replaceBuddy) {
val desiredBuddies = ctx.api.inventory.pokemon.filter {
it.value.pokemonData.pokemonId.name == settings.buddyPokemon.toUpperCase().trim()
}.toList()
if (desiredBuddies.size > 0) {
val setBuddyRequest = SetBuddyPokemon().withPokemonId(desiredBuddies[0].first)
val response = ctx.api.queueRequest(setBuddyRequest).toBlocking().first().response
if (response.result == SetBuddyPokemonResponseOuterClass.SetBuddyPokemonResponse.Result.SUCCESS) {
Log.green("Updated Buddy Pokemon to ${ctx.api.inventory.pokemon[response.updatedBuddy.id]?.pokemonData?.pokemonId?.name}")
}
}
}
}
}

0 comments on commit 510db85

Please sign in to comment.