game_ui.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # This Python file uses the following encoding: utf-8
  2. # @author runhey
  3. # github https://github.com/runhey
  4. import time
  5. from tasks.GameUi.assets import GameUiAssets
  6. from tasks.base_task import BaseTask
  7. from module.logger import logger
  8. class GameUi(BaseTask, GameUiAssets):
  9. def home_explore(self) -> bool:
  10. """
  11. 使用ocr识别到探索按钮并点击
  12. :return:
  13. """
  14. while 1:
  15. self.screenshot()
  16. if self.ocr_appear_click(self.O_HOME_EXPLORE, interval=2):
  17. continue
  18. if self.appear(self.I_BACK_BLUE, threshold=0.6):
  19. break
  20. logger.info(f'Click {self.O_HOME_EXPLORE.name}')
  21. return True
  22. def explore_home(self) -> bool:
  23. """
  24. :return:
  25. """
  26. while 1:
  27. self.screenshot()
  28. if self.appear_then_click(self.I_BACK_BLUE, threshold=0.6, interval=2):
  29. continue
  30. if self.appear(self.I_HOME_SHIKIKAMI, threshold=0.6):
  31. break
  32. logger.info(f'Click {self.I_HOME_SHIKIKAMI.name}')
  33. return True