diff --git a/.gitignore b/.gitignore index 96a0960..4f7f85c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.pyc *.pio .env/ +geckodriver.log # Misc conf.py diff --git a/mafbot.py b/mafbot.py index 9d20743..4826348 100755 --- a/mafbot.py +++ b/mafbot.py @@ -25,5 +25,5 @@ do_crime(1) time.sleep(60) except Exception as e: - print e + print(e) diff --git a/mafbot/utils.py b/mafbot/utils.py index 5679bfd..d534526 100644 --- a/mafbot/utils.py +++ b/mafbot/utils.py @@ -3,7 +3,7 @@ from PIL import Image import math import operator - +import functools from mafbot import driver from mafbot.authentication import login @@ -49,12 +49,13 @@ def inner(*args, **kwargs): lowest_rms = () for button in submit_buttons: - dimensions = (button.location['x'], button.location['y'], button.location['x'] + button.size['width'], button.location['y'] + button.size['height']) - + dimensions = (int(button.location['x']), int(button.location['y']), int(button.location['x']) + int(button.size['width']), int(button.location['y']) + int(button.size['height'])) button_img = screen_img.crop(dimensions) button_img.save(button_path) - rms = math.sqrt(reduce(operator.add,map(lambda a,b: (a-b)**2, ref_button.histogram(), button_img.histogram()))/len(ref_button.histogram())) + # I don't know what this does, exactly, + # but in the new version ( and tested in py2.7, it doesn't work anymore.) + rms = math.sqrt(functools.reduce(operator.add,map(lambda a,b: (a-b)**2, ref_button.histogram(), button_img.histogram()))/len(ref_button.histogram())) if len(lowest_rms) == 0 or rms < lowest_rms[1]: lowest_rms = (button, rms)