This repository has been archived by the owner on Jul 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add buddy pokemon support
- Loading branch information
Showing
8 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/kotlin/ink/abb/pogo/scraper/tasks/SetBuddyPokemon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") | ||
} | ||
} | ||
} | ||
} | ||
} |