Browse Source

partially working solution

main
Matt C 2 months ago
parent
commit
ddf84d6a46
  1. BIN
      cookie.png
  2. BIN
      cursor.png
  3. BIN
      farm.png
  4. BIN
      grandma.png
  5. 72
      main.py
  6. 1
      requirements.txt

BIN
cookie.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
cursor.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
farm.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
grandma.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

72
main.py

@ -0,0 +1,72 @@
import pyautogui,sys,threading,logging,time
from random import randint
cookie_location = None
cookie_pos = None
cursor_location = None
cursor_pos = None
grandma_location = None
grandma_pos = None
pyautogui.FAILSAFE = True
def check_failsafe(e):
if type(e) == pyautogui.FailSafeException:
sys.exit(1)
else:
logging.error(str(e))
locations = {}
def check_upgrade(upgrade):
if upgrade not in locations:
try:
logging.info("Searching for " + upgrade)
location = pyautogui.locateOnScreen(upgrade+".png")
if location != None:
locations[upgrade] = location
except Exception as e:
check_failsafe(e)
try:
location = locations[upgrade]
center = pyautogui.center(location)
pyautogui.click(center)
logging.info("Bought a " + upgrade)
except:
pass
upgrades = ["cursor", "grandma", "farm"]
if __name__ == '__main__':
format = "%(asctime)s: %(message)s"
logging.basicConfig(format=format, level=logging.INFO,datefmt="%H:%M:%S")
while True:
if cookie_pos == None:
try:
cookie_location = pyautogui.locateOnScreen('cookie.png')
cookie_pos = pyautogui.center(cookie_location)
except:
logging.error("Where the F U C K is the cookie??")
sys.exit(1)
try:
cx, cy = cookie_pos
pyautogui.click(cx,cy)
except Exception as e:
check_failsafe(e)
logging.info("Clicked")
if randint(1,20) == 10:
try:
logging.info("Checking upgrades")
for upgrade in upgrades:
check_upgrade(upgrade)
except Exception as e:
check_failsafe(e)
else:
logging.info("Not checking upgrades")

1
requirements.txt

@ -0,0 +1 @@
pyautogui
Loading…
Cancel
Save