Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.pyc
*.pio
.env/
geckodriver.log

# Misc
conf.py
2 changes: 1 addition & 1 deletion mafbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
do_crime(1)
time.sleep(60)
except Exception as e:
print e
print(e)

9 changes: 5 additions & 4 deletions mafbot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PIL import Image
import math
import operator

import functools
from mafbot import driver
from mafbot.authentication import login

Expand Down Expand Up @@ -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)
Expand Down