Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyautogui
- from PIL import Image
- import pytesseract
- import random
- import time
- pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract"
- def screenshot(filePath):
- myScreenshot = pyautogui.screenshot()
- myScreenshot.save(str(filePath));
- def crop(originalFile, left, top, right, bottom, outputFile):
- im = Image.open(originalFile);
- im1 = im.crop((left,top,right,bottom));
- im1.save(outputFile);
- def getLog(image=None):
- if image is None:
- image = "scr.png"
- screenshot(image);
- crop(image, 800, 130, 1340, 980, "log.png");
- return pytesseract.image_to_string("log.png");
- def getStatus(image=None):
- if image is None:
- image = "scr.png"
- screenshot(image);
- crop(image, 0, 550, 700, 585, "hp.png");
- return pytesseract.image_to_string("hp.png");
- def battle():
- currentHP = 244
- shellSmashes = 0
- enabledTimer = False
- turnsUntilAwake = 0
- while True:
- previousHP = currentHP;
- pyautogui.moveTo(100,100);
- status = getStatus();
- if "shuckle do" in status.lower():
- try:currentHP = int(status.lower().split("hp")[1].split("/")[0].replace(" ",""))
- except:currentHP=1;
- print(status);print(currentHP);
- log = getLog("scr.png");
- if "start the battle" in status.lower():
- if not enabledTimer:
- clickOn("Timer");
- time.sleep(1);
- clickOn("Start");
- enabledTimer = True;
- time.sleep(1);
- pyautogui.click(1000,1000);
- pyautogui.typewrite("Hi, I'm ThatShuckleBOT, coded by AddisonPascal. Good luck!");
- pyautogui.press("enter");
- time.sleep(1);
- clickOn("Shuckle");
- elif "shuckle do" in status.lower():
- if currentHP - 2*(previousHP-currentHP)<0:
- clickOn("Rest");
- turnsUntilAwake -= 1
- turnsUntilAwake = 2
- elif shellSmashes<6:
- clickOn("Shell Smash");
- turnsUntilAwake -= 1
- if turnsUntilAwake < 1: shellSmashes += 1
- else:
- clickOn(random.choice(["Infestation", "Toxic"]));
- turnsUntilAwake -= 1
- elif "won the battle" in log.lower():
- pyautogui.click(1000,1000);
- pyautogui.typewrite("Good game!");
- pyautogui.press('enter');
- time.sleep(1);
- clickOn("Upload and share replay");
- time.sleep(3);
- return;
- def clickOn(toClick):
- if toClick == "Upload and share replay":
- clickX = 600;
- clickY = 630;
- elif toClick == "Shuckle":
- clickX = 100;
- clickY = 630;
- elif toClick == "Rest":
- clickX = 100;
- clickY = 630;
- elif toClick == "Toxic":
- clickX = 250;
- clickY = 630;
- elif toClick == "Infestation":
- clickX = 450;
- clickY = 630;
- elif toClick == "Shell Smash":
- clickX = 650;
- clickY = 630;
- elif toClick == "Timer":
- clickX = 750;
- clickY = 570;
- elif toClick == "Start":
- clickX = 750;
- clickY = 600;
- pyautogui.click(clickX, clickY);
- input()
- while True:
- pyautogui.click(200,50);
- time.sleep(1)
- pyautogui.click(200,50);
- time.sleep(1)
- pyautogui.click(200,350);
- battle();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement