script_task.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.ui_get_current_page()
  22. self.ui_goto(page_shikigami_records)
  23. self.run_switch_soul(con.switch_soul_config.switch_group_team)
  24. self.ui_get_current_page()
  25. self.ui_goto(page_goryou_realm)
  26. match_click = {
  27. GoryouClass.Dark_Divine_Dragon: self.C_GR_C_1,
  28. GoryouClass.Dark_Hakuzousu: self.C_GR_C_2,
  29. GoryouClass.Dark_Black_Panther: self.C_GR_C_3,
  30. GoryouClass.Dark_Peacock: self.C_GR_C_4,
  31. }
  32. goryou_class = con.goryou_config.goryou_class
  33. if goryou_class == GoryouClass.RANDOM:
  34. goryou_class = choice(list(match_click.keys()))
  35. while 1:
  36. self.screenshot()
  37. if self.appear(self.I_GR_FIRE):
  38. logger.info('Enter GoryouRealm')
  39. break
  40. if self.click(match_click[goryou_class], interval=1):
  41. continue
  42. self.check_lock(con.general_battle_config.lock_team_enable, self.I_GR_LOCK, self.I_GR_UNLOCK)
  43. # 开始循环
  44. while 1:
  45. self.screenshot()
  46. if not self.appear(self.I_GR_FIRE):
  47. continue
  48. if self.current_count >= con.goryou_config.limit_count:
  49. logger.info('GoryouRealm count limit out')
  50. break
  51. if datetime.now() - self.start_time >= self.limit_time:
  52. logger.info('GoryouRealm time limit out')
  53. break
  54. ticket = self.O_GR_TICKET.ocr(self.device.image)
  55. if ticket == 0:
  56. break
  57. # 点击挑战
  58. while 1:
  59. self.screenshot()
  60. if self.appear_then_click(self.I_GR_FIRE, interval=1):
  61. pass
  62. if not self.appear(self.I_GR_FIRE):
  63. self.run_general_battle(config=con.general_battle_config)
  64. break
  65. self.ui_click(self.I_UI_BACK_YELLOW, self.I_CHECK_EXPLORATION)
  66. logger.info('Back to exploration')
  67. self.set_next_run(task='GoryouRealm', success=True, finish=True)
  68. raise TaskEnd
  69. if __name__ == '__main__':
  70. from module.config.config import Config
  71. from module.device.device import Device
  72. c = Config('oas1')
  73. d = Device(c)
  74. t = ScriptTask(c, d)
  75. t.screenshot()
  76. t.run()