tellomichmich / PokeNoxBot

Slow but safe Pokemon GO Bot
23 stars 19 forks source link

Blocked on Infinite loop on GetPokemonCP #26

Closed Picardu57 closed 8 years ago

Picardu57 commented 8 years ago

Hello,

Sometime, after capture Pokemon, it's blocked on the opened Pokemon window. It's because, on some Pokemon (like Zubat but not all the time) the CP is partially masked by the Pokemon animation (wings of zubat, etc...) and the OCR does not match "CP" and you enter into a infinite loop. And make a modification like this and the problem seem to be solved

def GetPokemonCP():

Need to that because of some Pokemon animation

t = 0
while True:
    t+=1
    img = GetScreen()
    Frame = img.crop(((160, 49, 160+121, 49+38)))
    RemoveColor(Frame, (255, 255, 255), 0.2)
    BlackOrWhite(Frame)
    PokemonCP = ImgToString(Frame, "bin\CP_CONFIG.txt").upper()
    #print PokemonCP
    if PokemonCP[:2] == "CP" and t <=5 :
        try:  
            return int(PokemonCP[2:])
        except:
            pass
    else:
        return 10
    ClearScreen()

--> try only 5 times and if no success return 10 to drop pokemon to professor.

tellomichmich commented 8 years ago

This is committed !