script_task.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # This Python file uses the following encoding: utf-8
  2. # @author runhey
  3. # github https://github.com/runhey
  4. from time import sleep
  5. from datetime import timedelta, datetime, time
  6. from cached_property import cached_property
  7. from module.exception import TaskEnd
  8. from module.logger import logger
  9. from module.base.timer import Timer
  10. from tasks.GameUi.game_ui import GameUi
  11. from tasks.GameUi.page import page_main, page_hunt, page_shikigami_records
  12. from tasks.Component.GeneralBattle.general_battle import GeneralBattle
  13. from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
  14. from tasks.Component.GeneralRoom.general_room import GeneralRoom
  15. from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
  16. from tasks.Hunt.assets import HuntAssets
  17. class ScriptTask(GameUi, GeneralBattle, GeneralRoom, SwitchSoul, HuntAssets):
  18. kirin_day = True # 不是麒麟就是阴界之门
  19. def run(self):
  20. if not self.check_datetime():
  21. # 设置下次运行时间 为今天的晚上七点钟
  22. now = datetime.now()
  23. next_run_time = datetime.combine(now.date(), time(19, 0, 0))
  24. self.set_next_run(task='Hunt', success=False, finish=True, target=next_run_time)
  25. raise TaskEnd('Hunt')
  26. con = self.config.hunt.hunt_config
  27. if con.kirin_group_team != '-1,-1' or con.netherworld_group_team != '-1,-1':
  28. self.ui_get_current_page()
  29. self.ui_goto(page_shikigami_records)
  30. if con.kirin_group_team != '-1,-1':
  31. self.run_switch_soul(con.kirin_group_team)
  32. if con.netherworld_group_team != '-1,-1':
  33. self.run_switch_soul(con.netherworld_group_team)
  34. self.ui_get_current_page()
  35. self.ui_goto(page_hunt)
  36. self.set_next_run(task='Hunt', success=True, finish=True)
  37. raise TaskEnd('Hunt')
  38. def check_datetime(self) -> bool:
  39. """
  40. 检查日期和时间, 会设置是麒麟还是阴界之门
  41. :return: 符合19:00-21:00的时间返回True, 否则返回False
  42. """
  43. now = datetime.now()
  44. day_of_week = now.weekday()
  45. if 0 <= day_of_week <= 3:
  46. self.kirin_day = True
  47. elif 4 <= day_of_week <= 6:
  48. self.kirin_day = False
  49. if time(18, 59) < now.time() < time(21, 1):
  50. return True
  51. else:
  52. logger.warning('Not in the time period')
  53. return False
  54. def kirin(self):
  55. pass
  56. def netherworld(self):
  57. pass
  58. if __name__ == '__main__':
  59. from module.config.config import Config
  60. from module.device.device import Device
  61. c = Config('oas1')
  62. d = Device(c)
  63. t = ScriptTask(c, d)
  64. t.screenshot()
  65. t.run()