script_task.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # This Python file uses the following encoding: utf-8
  2. # @author runhey
  3. # github https://github.com/runhey
  4. from datetime import datetime, timedelta
  5. from module.exception import TaskEnd
  6. from module.logger import logger
  7. from random import choice
  8. from tasks.Component.GeneralBattle.general_battle import GeneralBattle
  9. from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
  10. from tasks.GameUi.game_ui import GameUi
  11. from tasks.GameUi.page import page_shikigami_records, page_goryou_realm
  12. from tasks.GoryouRealm.assets import GoryouRealmAssets
  13. from tasks.GoryouRealm.config import GoryouClass
  14. class ScriptTask(GeneralBattle, GameUi, SwitchSoul, GoryouRealmAssets):
  15. def run(self):
  16. con = self.config.goryou_realm
  17. limit_time = con.goryou_config.limit_time
  18. self.limit_time: timedelta = timedelta(hours=limit_time.hour, minutes=limit_time.minute,
  19. seconds=limit_time.second)
  20. if con.switch_soul_config.enable:
  21. self.goto_page(page_shikigami_records)
  22. self.run_switch_soul(con.switch_soul_config.switch_group_team)
  23. self.goto_page(page_goryou_realm)
  24. match_click = {
  25. GoryouClass.Dark_Divine_Dragon: self.C_GR_C_1,
  26. GoryouClass.Dark_Hakuzousu: self.C_GR_C_2,
  27. GoryouClass.Dark_Black_Panther: self.C_GR_C_3,
  28. GoryouClass.Dark_Peacock: self.C_GR_C_4,
  29. }
  30. goryou_class = con.goryou_config.goryou_class
  31. if goryou_class == GoryouClass.RANDOM:
  32. goryou_class = choice(list(match_click.keys()))
  33. while 1:
  34. self.screenshot()
  35. if self.appear(self.I_GR_FIRE):
  36. logger.info('Enter GoryouRealm')
  37. break
  38. if self.click(match_click[goryou_class], interval=1):
  39. continue
  40. self.check_lock(con.general_battle_config.lock_team_enable, self.I_GR_LOCK, self.I_GR_UNLOCK)
  41. # 开始循环
  42. while 1:
  43. self.screenshot()
  44. if not self.appear(self.I_GR_FIRE):
  45. continue
  46. if self.current_count >= con.goryou_config.limit_count:
  47. logger.info('GoryouRealm count limit out')
  48. break
  49. if datetime.now() - self.start_time >= self.limit_time:
  50. logger.info('GoryouRealm time limit out')
  51. break
  52. ticket = self.O_GR_TICKET.ocr(self.device.image)
  53. if ticket == 0:
  54. break
  55. # 点击挑战
  56. while 1:
  57. self.screenshot()
  58. if self.appear_then_click(self.I_GR_FIRE, interval=1):
  59. pass
  60. if not self.appear(self.I_GR_FIRE):
  61. self.run_general_battle(config=con.general_battle_config)
  62. break
  63. self.ui_click(self.I_UI_BACK_YELLOW, self.I_CHECK_EXPLORATION)
  64. logger.info('Back to exploration')
  65. self.set_next_run(task='GoryouRealm', success=True, finish=True)
  66. raise TaskEnd
  67. if __name__ == '__main__':
  68. from module.config.config import Config
  69. from module.device.device import Device
  70. c = Config('oas1')
  71. d = Device(c)
  72. t = ScriptTask(c, d)
  73. t.screenshot()
  74. t.run()