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

Feature: Thresholds #1109

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions config.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ wait_chance=0.0
wait_time_min=0
wait_time_max=0

# Maximum of times to loot Pokestops and catch Pokemon (24hr period):
# Recommended pokestops threshold is 1500
# Recommended pokemon threshold is 1000
pokestop_threshold=1500
pokemon_threshold=1000

# List of pokemon names
#MISSINGNO
#BULBASAUR
Expand Down
5 changes: 4 additions & 1 deletion src/main/kotlin/ink/abb/pogo/scraper/Context.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ data class Context(

val walking: AtomicBoolean = AtomicBoolean(false),

val pauseWalking: AtomicBoolean = AtomicBoolean(false)
val pauseWalking: AtomicBoolean = AtomicBoolean(false),

val lootedPokestops: AtomicInteger = AtomicInteger(0),
val caughtPokemon: AtomicInteger = AtomicInteger(0)

)
11 changes: 9 additions & 2 deletions src/main/kotlin/ink/abb/pogo/scraper/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ class SettingsParser(val properties: Properties) {

waitTimeMin = getPropertyIfSet("Minimal time to wait", "wait_time_min", defaults.waitTimeMin, String::toInt),

waitTimeMax = getPropertyIfSet("Maximal time to wait", "wait_time_max", defaults.waitTimeMax, String::toInt)
waitTimeMax = getPropertyIfSet("Maximal time to wait", "wait_time_max", defaults.waitTimeMax, String::toInt),
Copy link
Owner

@jabbink jabbink Aug 16, 2016

Choose a reason for hiding this comment

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

*Maximum

EDIT: Oh lol I see you didn't add this.

Copy link
Contributor

@alexbulyha alexbulyha Aug 16, 2016

Choose a reason for hiding this comment

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

It was me, ill change it in my commit :)
FIXED


pokestopThreshold = getPropertyIfSet("The maximum amount of pokestops to loot before stopping", "pokestop_threshold", defaults.pokestopThreshold, String::toInt),

pokemonThreshold = getPropertyIfSet("The maximum amount of pokemon to catch before stopping", "pokemon_threshold", defaults.pokemonThreshold, String::toInt)
)
}

Expand Down Expand Up @@ -266,7 +270,10 @@ data class Settings(

val waitChance: Double = 0.0,
val waitTimeMin: Int = 0,
val waitTimeMax: Int = 0
val waitTimeMax: Int = 0,

val pokestopThreshold: Int = 1500,
val pokemonThreshold: Int = 1000
) {
fun withName(name: String): Settings {
this.name = name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ import ink.abb.pogo.scraper.util.pokemon.shouldTransfer
class CatchOneNearbyPokemon : Task {
override fun run(bot: Bot, ctx: Context, settings: Settings) {
// STOP WALKING

if (ctx.caughtPokemon.get() > settings.pokemonThreshold) {
Thread.sleep(3600 * 12000)
Copy link
Owner

Choose a reason for hiding this comment

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

instead of sleeping, maybe set the settings.catchPokemon to false and store the time it was disabled and then re-enable it later on. See how this is done with a full pokebag: https://github.com/muschter/PokemonGoBot/blob/83c9dc6077f63f34342534076101615e0a87701a/src/main/kotlin/ink/abb/pogo/scraper/tasks/CatchOneNearbyPokemon.kt#L141

ctx.caughtPokemon.set(0)
return
}

ctx.pauseWalking.set(true)
val pokemon = ctx.api.map.getCatchablePokemon(ctx.blacklistedEncounters)

Expand Down Expand Up @@ -96,6 +103,7 @@ class CatchOneNearbyPokemon : Task {
// TODO: temp fix for server timing issues regarding GetMapObjects
ctx.blacklistedEncounters.add(catchablePokemon.encounterId)
if (result.status == CatchPokemonResponse.CatchStatus.CATCH_SUCCESS) {
ctx.caughtPokemon.andIncrement
ctx.pokemonStats.first.andIncrement
if (wasFromLure) {
ctx.luredPokemonStats.andIncrement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class LootOneNearbyPokestop(val sortedPokestops: List<Pokestop>, val lootTimeout

override fun run(bot: Bot, ctx: Context, settings: Settings) {
// STOP WALKING! until loot is done

ctx.pauseWalking.set(true)
ctx.api.setLocation(ctx.lat.get(), ctx.lng.get(), 0.0)
val nearbyPokestops = sortedPokestops.filter {
Expand Down Expand Up @@ -60,6 +61,7 @@ class LootOneNearbyPokestop(val sortedPokestops: List<Pokestop>, val lootTimeout

when (result.result) {
Result.SUCCESS -> {
ctx.lootedPokestops.andIncrement
ctx.server.sendPokestop(closest)
ctx.server.sendProfile()
var message = "Looted pokestop $pokestopID; +${result.experience} XP"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ class ProcessPokestops(var pokestops: MutableCollection<Pokestop>) : Task {
if (startPokestop == null)
startPokestop = sortedPokestops.first()

if (ctx.lootedPokestops.get() > settings.pokestopThreshold) {
Thread.sleep(3600 * 12000)
Copy link
Owner

Choose a reason for hiding this comment

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

same as with catching pokemon limit: maybe just disable the setting.

ctx.lootedPokestops.set(0)
return
}

if (settings.lootPokestop) {
val loot = LootOneNearbyPokestop(sortedPokestops, lootTimeouts)
try {
Expand Down