Advertisement
Guest User

ThatShuckleBot code

a guest
Dec 12th, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. import pyautogui
  2. from PIL import Image
  3. import pytesseract
  4. import random
  5. import time
  6. pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract"
  7. def screenshot(filePath):
  8. myScreenshot = pyautogui.screenshot()
  9. myScreenshot.save(str(filePath));
  10. def crop(originalFile, left, top, right, bottom, outputFile):
  11. im = Image.open(originalFile);
  12. im1 = im.crop((left,top,right,bottom));
  13. im1.save(outputFile);
  14. def getLog(image=None):
  15. if image is None:
  16. image = "scr.png"
  17. screenshot(image);
  18. crop(image, 800, 130, 1340, 980, "log.png");
  19. return pytesseract.image_to_string("log.png");
  20. def getStatus(image=None):
  21. if image is None:
  22. image = "scr.png"
  23. screenshot(image);
  24. crop(image, 0, 550, 700, 585, "hp.png");
  25. return pytesseract.image_to_string("hp.png");
  26. def battle():
  27. currentHP = 244
  28. shellSmashes = 0
  29. enabledTimer = False
  30. turnsUntilAwake = 0
  31. while True:
  32. previousHP = currentHP;
  33. pyautogui.moveTo(100,100);
  34. status = getStatus();
  35. if "shuckle do" in status.lower():
  36. try:currentHP = int(status.lower().split("hp")[1].split("/")[0].replace(" ",""))
  37. except:currentHP=1;
  38. print(status);print(currentHP);
  39. log = getLog("scr.png");
  40. if "start the battle" in status.lower():
  41. if not enabledTimer:
  42. clickOn("Timer");
  43. time.sleep(1);
  44. clickOn("Start");
  45. enabledTimer = True;
  46. time.sleep(1);
  47. pyautogui.click(1000,1000);
  48. pyautogui.typewrite("Hi, I'm ThatShuckleBOT, coded by AddisonPascal. Good luck!");
  49. pyautogui.press("enter");
  50. time.sleep(1);
  51. clickOn("Shuckle");
  52. elif "shuckle do" in status.lower():
  53. if currentHP - 2*(previousHP-currentHP)<0:
  54. clickOn("Rest");
  55. turnsUntilAwake -= 1
  56. turnsUntilAwake = 2
  57. elif shellSmashes<6:
  58. clickOn("Shell Smash");
  59. turnsUntilAwake -= 1
  60. if turnsUntilAwake < 1: shellSmashes += 1
  61. else:
  62. clickOn(random.choice(["Infestation", "Toxic"]));
  63. turnsUntilAwake -= 1
  64. elif "won the battle" in log.lower():
  65. pyautogui.click(1000,1000);
  66. pyautogui.typewrite("Good game!");
  67. pyautogui.press('enter');
  68. time.sleep(1);
  69. clickOn("Upload and share replay");
  70. time.sleep(3);
  71. return;
  72. def clickOn(toClick):
  73. if toClick == "Upload and share replay":
  74. clickX = 600;
  75. clickY = 630;
  76. elif toClick == "Shuckle":
  77. clickX = 100;
  78. clickY = 630;
  79. elif toClick == "Rest":
  80. clickX = 100;
  81. clickY = 630;
  82. elif toClick == "Toxic":
  83. clickX = 250;
  84. clickY = 630;
  85. elif toClick == "Infestation":
  86. clickX = 450;
  87. clickY = 630;
  88. elif toClick == "Shell Smash":
  89. clickX = 650;
  90. clickY = 630;
  91. elif toClick == "Timer":
  92. clickX = 750;
  93. clickY = 570;
  94. elif toClick == "Start":
  95. clickX = 750;
  96. clickY = 600;
  97. pyautogui.click(clickX, clickY);
  98. input()
  99.  
  100. while True:
  101. pyautogui.click(200,50);
  102. time.sleep(1)
  103. pyautogui.click(200,50);
  104. time.sleep(1)
  105. pyautogui.click(200,350);
  106. battle();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement