Skip to content
This repository was archived by the owner on Jul 22, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions config.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ 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

# Threshold delay time in hours:
threshold_wait_time=12

# List of pokemon names
#MISSINGNO
#BULBASAUR
Expand Down
8 changes: 7 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,12 @@ 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),

var pokemonLockTime: Long = 0L,
var pokestopLockTime: Long = 0L

)
16 changes: 13 additions & 3 deletions src/main/kotlin/ink/abb/pogo/scraper/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ 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
Copy Markdown
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
Copy Markdown
Contributor

@alexlautenschlager alexlautenschlager 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),

thresholdWaitTime = getPropertyIfSet("Threshold delay time in hours", "threshold_wait_time", defaults.thresholdWaitTime, String::toInt)
)
}

Expand Down Expand Up @@ -235,7 +241,7 @@ data class Settings(
val displayPokemonCatchRewards: Boolean = true,
val displayIfPokemonFromLure: Boolean = true,

val lootPokestop: Boolean = true,
var lootPokestop: Boolean = true,
var catchPokemon: Boolean = true,
val autoFillIncubator: Boolean = true,

Expand Down Expand Up @@ -268,7 +274,11 @@ data class Settings(

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

val thresholdWaitTime: Int = 12,
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,21 @@ import ink.abb.pogo.scraper.util.pokemon.shouldTransfer
class CatchOneNearbyPokemon : Task {
override fun run(bot: Bot, ctx: Context, settings: Settings) {
// STOP WALKING

if (ctx.pokemonLockTime != 0L && bot.api.currentTimeMillis() > ctx.pokemonLockTime)
{
settings.catchPokemon = true
ctx.caughtPokemon.set(0)
}

if (ctx.caughtPokemon.get() > settings.pokemonThreshold) {
if (settings.catchPokemon) {
settings.catchPokemon = false
ctx.pokemonLockTime = bot.api.currentTimeMillis() + (3600 * settings.thresholdWaitTime.toLong())
}
return
}

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

Expand Down Expand Up @@ -96,6 +111,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
14 changes: 14 additions & 0 deletions src/main/kotlin/ink/abb/pogo/scraper/tasks/ProcessPokestops.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ class ProcessPokestops(var pokestops: MutableCollection<Pokestop>) : Task {
if (startPokestop == null)
startPokestop = sortedPokestops.first()

if (ctx.pokestopLockTime != 0L && bot.api.currentTimeMillis() > ctx.pokestopLockTime)
{
settings.lootPokestop = true
ctx.lootedPokestops.set(0)
}

if (ctx.lootedPokestops.get() > settings.pokestopThreshold) {
if (settings.lootPokestop) {
settings.lootPokestop = false
ctx.pokestopLockTime = bot.api.currentTimeMillis() + (3600 * settings.thresholdWaitTime.toLong())
}
return
}

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