|
|
@@ -1,6 +1,7 @@
|
|
|
# This Python file uses the following encoding: utf-8
|
|
|
# @author runhey
|
|
|
# github https://github.com/runhey
|
|
|
+import random
|
|
|
from time import sleep
|
|
|
from datetime import time, datetime, timedelta
|
|
|
|
|
|
@@ -58,8 +59,6 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
|
|
|
|
|
|
raise TaskEnd
|
|
|
|
|
|
-
|
|
|
-
|
|
|
def fallen_sun_enter(self) -> bool:
|
|
|
logger.info('Enter fallen_sun')
|
|
|
while True:
|
|
|
@@ -101,7 +100,6 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
|
|
|
if self.appear_then_click(self.I_FALLEN_SUN_LOCK, interval=1):
|
|
|
continue
|
|
|
|
|
|
-
|
|
|
def run_leader(self):
|
|
|
logger.info('Start run leader')
|
|
|
self.ui_get_current_page()
|
|
|
@@ -148,8 +146,6 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
|
|
|
logger.info('FallenSun time limit out')
|
|
|
break
|
|
|
|
|
|
-
|
|
|
-
|
|
|
# 如果没有进入房间那就不需要后面的邀请
|
|
|
if not self.is_in_room():
|
|
|
# 如果在探索界面或者是出现在组队界面, 那就是可能房间死了
|
|
|
@@ -302,40 +298,79 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
|
|
|
self.ui_current = page_soul_zones
|
|
|
self.ui_goto(page_main)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
def run_wild(self):
|
|
|
logger.error('Wild mode is not implemented')
|
|
|
pass
|
|
|
|
|
|
+ def battle_wait(self, random_click_swipt_enable: bool) -> bool:
|
|
|
+ """
|
|
|
+ 重写战斗等待
|
|
|
+ # https://github.com/runhey/OnmyojiAutoScript/issues/95
|
|
|
+ :param random_click_swipt_enable:
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 重写
|
|
|
+ self.device.stuck_record_add('BATTLE_STATUS_S')
|
|
|
+ self.device.click_record_clear()
|
|
|
+ self.C_REWARD_1.name = 'C_REWARD'
|
|
|
+ self.C_REWARD_2.name = 'C_REWARD'
|
|
|
+ self.C_REWARD_3.name = 'C_REWARD'
|
|
|
+ # 战斗过程 随机点击和滑动 防封
|
|
|
+ logger.info("Start battle process")
|
|
|
+ while 1:
|
|
|
+ self.screenshot()
|
|
|
+ action_click = random.choice([self.C_WIN_1, self.C_WIN_2, self.C_WIN_3])
|
|
|
+ if self.appear_then_click(self.I_WIN, action=action_click ,interval=0.8):
|
|
|
+ # 赢的那个鼓
|
|
|
+ continue
|
|
|
+ if self.appear(self.I_GREED_GHOST):
|
|
|
+ # 贪吃鬼
|
|
|
+ logger.info('Win battle')
|
|
|
+ self.wait_until_appear(self.I_REWARD, wait_time=1.5)
|
|
|
+ self.screenshot()
|
|
|
+ if not self.appear(self.I_GREED_GHOST):
|
|
|
+ logger.warning('Greedy ghost disappear. Maybe it is a false battle')
|
|
|
+ continue
|
|
|
+ while 1:
|
|
|
+ self.screenshot()
|
|
|
+ action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
|
|
|
+ if not self.appear(self.I_GREED_GHOST):
|
|
|
+ break
|
|
|
+ if self.click(action_click, interval=1.5):
|
|
|
+ continue
|
|
|
+ return True
|
|
|
+ if self.appear(self.I_REWARD):
|
|
|
+ # 魂
|
|
|
+ logger.info('Win battle')
|
|
|
+ while 1:
|
|
|
+ self.screenshot()
|
|
|
+ action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
|
|
|
+ if self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5):
|
|
|
+ continue
|
|
|
+ if not self.appear(self.I_REWARD):
|
|
|
+ break
|
|
|
+ return True
|
|
|
|
|
|
+ if self.appear(self.I_FALSE):
|
|
|
+ logger.warning('False battle')
|
|
|
+ self.ui_click_until_disappear(self.I_FALSE)
|
|
|
+ return False
|
|
|
|
|
|
-
|
|
|
+ # 如果开启战斗过程随机滑动
|
|
|
+ if random_click_swipt_enable:
|
|
|
+ self.random_click_swipt()
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
from module.config.config import Config
|
|
|
from module.device.device import Device
|
|
|
- from memory_profiler import profile
|
|
|
c = Config('oas1')
|
|
|
d = Device(c)
|
|
|
t = ScriptTask(c, d)
|
|
|
|
|
|
- # t.run()
|
|
|
-
|
|
|
- # t.check_layer('悲')
|
|
|
-
|
|
|
- from module.base.timer import timer
|
|
|
+ t.run()
|
|
|
+ # t.check_layer('日蚀')
|
|
|
|
|
|
- @timer
|
|
|
- @profile
|
|
|
- def test_memory():
|
|
|
- t.screenshot()
|
|
|
- print(t.ocr_appear(t.O_O_TEST_OCR))
|
|
|
- print(t.L_LAYER_LIST.image_appear(t.device.image, '叁'))
|
|
|
- for i in range(4):
|
|
|
- test_memory()
|
|
|
- print('=====================')
|
|
|
|
|
|
|
|
|
|