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

Division by zero #1147

Closed
gise88 opened this issue Aug 17, 2016 · 12 comments
Closed

Division by zero #1147

gise88 opened this issue Aug 17, 2016 · 12 comments

Comments

@gise88
Copy link

gise88 commented Aug 17, 2016

Description:
If you enter a fully evolved pokemon inside the "evolve_before_transfer" list, the variable pokemonMeta.candyToEvolve (https://github.com/jabbink/PokemonGoBot/blob/develop/src/main/kotlin/ink/abb/pogo/scraper/tasks/EvolvePokemon.kt#L32) will be zero..
I know, this is a user error but seems easy to prevent..

Steps to reproduce:
Add a latest evolution of a pokemon inside the "evolve_before_transfer" list

Expected behavior:
Warn and ignore fully evolved pokemon

Actual behavior:
Stacktrace (If it's a crash):
17 ago 18:07:43 [default: ProfileLoop] - Error running loop ProfileLoop!
java.lang.ArithmeticException: / by zero
at ink.abb.pogo.scraper.tasks.EvolvePokemon.run(EvolvePokemon.kt:32)
at ink.abb.pogo.scraper.Bot.task(Bot.kt:262)
at ink.abb.pogo.scraper.Bot$start$3.invoke(Bot.kt:144)
at ink.abb.pogo.scraper.Bot$start$3.invoke(Bot.kt:36)
at ink.abb.pogo.scraper.Bot$runLoop$1.invoke(Bot.kt:204)
at ink.abb.pogo.scraper.Bot$runLoop$1.invoke(Bot.kt:36)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:18)

Version:
f9c163e

Operating System:
Debian 8

Java version:
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Leave this sentence in your issue as proof that you have read and used this template.

@meekzyr
Copy link
Contributor

meekzyr commented Aug 17, 2016

It's a simple check to see if pokemonMeta.candyToEvolve is greater than 0, if it isn't set maxPossibleEvolves to 0

@gise88
Copy link
Author

gise88 commented Aug 17, 2016

I think is better if we do the check when the bot loads the list and removes all the fully evolved pokemon from it..

@meekzyr
Copy link
Contributor

meekzyr commented Aug 17, 2016

Good idea, didn't quite read through and understand your steps to reproduce.

@alexbulyha
Copy link
Contributor

This isnt possible currently @gise88 , or so I believe, as you cant delete anything from the settings object. Furthermore, if there will be new pokemon later on, it would be wise just to add a check if the pokemon can be evolved

@gise88
Copy link
Author

gise88 commented Aug 17, 2016

Oh, ok! Than, what @muschter has said is the our best option! 😃

@alexbulyha
Copy link
Contributor

alexbulyha commented Aug 17, 2016

// an existing function
 sorted.forEach {
                    maxPossibleEvolves--
                    if (maxPossibleEvolves < 0) {
                        releasePokemon(it,"Not enough candy to save for evolve",ctx)
                        if(settings.autotransferTimeDelay != (-1).toLong()){
                            val transferWaitTime = settings.autotransferTimeDelay/2 + (Math.random()*settings.autotransferTimeDelay).toLong()
                            Thread.sleep(transferWaitTime)
                        }
                    }
                    // this should do the trick
                    it.evolutionForm.isFullyEvolved........
                    .....
                }

I can rewrite you the function however I can not test it.
If you want I could send you the needed changed files @gise88 and you test it?

@gise88
Copy link
Author

gise88 commented Aug 17, 2016

Ok, no problem! If you prefer I can clone your own repo and test it.. =)

@alexbulyha
Copy link
Contributor

I'll tell you when Im ready. I am not sure it will be today as some guests are coming over soon

@alexbulyha
Copy link
Contributor

alexbulyha commented Aug 17, 2016

EvolvePokemon.kt.zip
@gise88 try this out, it is the EvolvePokemon.kt file under /src/main/kotlin/ink/abb/pogo/scraper/tasks

I can not push this into the develop branch as there is an open PR. If its too difficult I can however create a new branch, just tell me

@gise88
Copy link
Author

gise88 commented Aug 18, 2016

I was trying it when i get my account banned! 😢 Tomorrow i will try with a new account... Sorry for this late..

@meekzyr
Copy link
Contributor

meekzyr commented Aug 18, 2016

@gise88 I have submitted a pull request to fix this issue.

@alexbulyha
Copy link
Contributor

@muschter ok you fixed it the other way but should work too :)

kalijason pushed a commit to kalijason/PokemonGoBot that referenced this issue Aug 19, 2016
Sieberkev pushed a commit that referenced this issue Aug 19, 2016
* Use correct altitude

* Rebase (#1)

* Updated explanation in several files (#1152)

* Updated some of the readme files (API/FAQ/USAGE and ISSUE TEMPLATE)

* Additional information

* Fixed some words with feedback from jabbink

* Lowercase "ptc", to be sure ^-^

* Some more clarification

* Fix #1147 (#1157)

* Ensure template correctness (#1154)

* fixed typo in template file

* wrote tests for json-template

* fixed json-template with help from the new TestSettings

* Separated json credential testing from properties testing

* Use correct altitude(and cache it)

* Rebase (#2)

* Updated explanation in several files (#1152)

* Updated some of the readme files (API/FAQ/USAGE and ISSUE TEMPLATE)

* Additional information

* Fixed some words with feedback from jabbink

* Lowercase "ptc", to be sure ^-^

* Some more clarification

* Fix #1147 (#1157)

* Ensure template correctness (#1154)

* fixed typo in template file

* wrote tests for json-template

* fixed json-template with help from the new TestSettings

* Separated json credential testing from properties testing

* Cleaner string concatenation

* Use Google API first(without API key), when it hits the rate limit, use mapzen

* More try block coverage

* Added logging if requests fail, removed unused import

* More detailed log message
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants