script_task.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 time, datetime, timedelta
  6. from tasks.GameUi.game_ui import GameUi
  7. from tasks.GameUi.page import page_main, page_summon, page_guild, page_mall, page_friends
  8. from tasks.DailyTrifles.config import DailyTriflesConfig
  9. from tasks.DailyTrifles.assets import DailyTriflesAssets
  10. from tasks.Component.Summon.summon import Summon
  11. from module.logger import logger
  12. from module.exception import TaskEnd
  13. from module.base.timer import Timer
  14. class ScriptTask(GameUi, Summon, DailyTriflesAssets):
  15. def run(self):
  16. con = self.config.daily_trifles.trifles_config
  17. if con.one_summon:
  18. self.run_one_summon()
  19. if con.guild_wish:
  20. pass
  21. if con.friend_love:
  22. self.run_friend_love()
  23. self.run_luck_msg()
  24. if con.store_sign:
  25. self.run_store_sign()
  26. self.set_next_run('DailyTrifles', success=True, finish=False)
  27. raise TaskEnd('DailyTrifles')
  28. def run_one_summon(self):
  29. self.ui_get_current_page()
  30. self.ui_goto(page_summon)
  31. self.summon_one()
  32. self.back_summon_main()
  33. def run_guild_wish(self):
  34. pass
  35. def run_luck_msg(self):
  36. self.ui_get_current_page()
  37. self.ui_goto(page_friends)
  38. while 1:
  39. self.screenshot()
  40. if self.appear(self.I_LUCK_TITLE):
  41. break
  42. if self.appear_then_click(self.I_LUCK_MSG, interval=1):
  43. continue
  44. logger.info('Start luck msg')
  45. check_timer = Timer(2)
  46. check_timer.start()
  47. while 1:
  48. self.screenshot()
  49. if self.appear_then_click(self.I_CLICK_BLESS, interval=1):
  50. continue
  51. if self.appear_then_click(self.I_ONE_CLICK_BLESS, interval=1):
  52. continue
  53. if self.ui_reward_appear_click():
  54. logger.info('Get reward of friend love')
  55. break
  56. if check_timer.reached():
  57. logger.warning('There is no any love')
  58. break
  59. self.ui_click(self.I_UI_BACK_RED, self.I_CHECK_MAIN)
  60. def run_friend_love(self):
  61. self.ui_get_current_page()
  62. self.ui_goto(page_friends)
  63. while 1:
  64. self.screenshot()
  65. if self.appear(self.I_L_LOVE):
  66. break
  67. if self.appear_then_click(self.I_L_FRIENDS, interval=1):
  68. continue
  69. logger.info('Start friend love')
  70. check_timer = Timer(2)
  71. check_timer.start()
  72. while 1:
  73. self.screenshot()
  74. if self.appear_then_click(self.I_L_COLLECT, interval=1):
  75. continue
  76. if self.ui_reward_appear_click():
  77. logger.info('Get reward of friend love')
  78. break
  79. if check_timer.reached():
  80. logger.warning('There is no any love')
  81. break
  82. self.ui_click(self.I_UI_BACK_RED, self.I_CHECK_MAIN)
  83. def run_store_sign(self):
  84. self.ui_get_current_page()
  85. self.ui_goto(page_mall, confirm_wait=3)
  86. while 1:
  87. self.screenshot()
  88. if self.appear(self.I_GIFT_RECOMMEND):
  89. break
  90. if self.appear_then_click(self.I_ROOM_GIFT, interval=1):
  91. continue
  92. self.screenshot()
  93. self.appear_then_click(self.I_GIFT_RECOMMEND, interval=1)
  94. logger.info('Enter store sign')
  95. sleep(1) # 等个动画
  96. self.screenshot()
  97. if not self.appear(self.I_GIFT_SIGN):
  98. logger.warning('There is no gift sign')
  99. self.ui_click(self.I_UI_BACK_YELLOW, self.I_CHECK_MALL)
  100. self.ui_get_current_page()
  101. self.ui_goto(page_main)
  102. return
  103. if self.ui_get_reward(self.I_GIFT_SIGN, click_interval=2.5):
  104. logger.info('Get reward of gift sign')
  105. self.ui_click(self.I_UI_BACK_YELLOW, self.I_CHECK_MALL)
  106. self.ui_get_current_page()
  107. self.ui_goto(page_main)
  108. if __name__ == '__main__':
  109. from module.config.config import Config
  110. from module.device.device import Device
  111. c = Config('du')
  112. d = Device(c)
  113. t = ScriptTask(c, d)
  114. # t.run_one_summon()
  115. t.run_luck_msg()