Skip to content

Commit

Permalink
添加其他设备登录的错误识别
Browse files Browse the repository at this point in the history
  • Loading branch information
veadex committed May 3, 2024
1 parent 00a509f commit 4c28276
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autowsgr/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.2.30"
__version__ = "0.2.2.31"
21 changes: 21 additions & 0 deletions autowsgr/controller/run_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,20 @@ def restart(self, times=0, *args, **kwargs):
self.Windows.connect_android()
self.restart(times + 1, *args, **kwargs)

def is_other_device_login(self, timeout=2):
"""检查是否有其他设备登录顶号"""
return self.wait_image(IMG.error_image["user_remote_login"], timeout=timeout) != None

def process_other_device_login(self, timeout=2):
"""处理其他设备登录顶号
重新登录以后写,暂时留空,直接抛出错误
"""
if self.is_other_device_login(timeout):
self.logger.error("other device login")
raise CriticalErr("other device login")

def is_bad_network(self, timeout=10):
"""检查是否为网络状况问题"""
return self.wait_images([IMG.error_image["bad_network"]] + [IMG.symbol_image[10]], timeout=timeout) != None

def process_bad_network(self, extra_info="", timeout=10):
Expand Down Expand Up @@ -276,6 +289,9 @@ def wait_pages(self, names, timeout=10, gap=0.1, after_wait=0.1):
if self.process_bad_network("can't wait pages"):
res = self.wait_pages(names, timeout, gap, after_wait)
return res
if self.is_other_device_login():
self.process_other_device_login()

raise TimeoutError(f"identify timeout of{str(names)}")

def get_now_page(self):
Expand Down Expand Up @@ -360,6 +376,8 @@ def walk_to(self, end, try_times=0):
except TimeoutError as exception:
if try_times > 3:
raise TimeoutError("can't access the page")
if self.is_other_device_login():
self.process_other_device_login()
if not self.is_bad_network(timeout=2):
self.logger.debug("wrong path is operated,anyway we find a way to solve,processing")
self.logger.debug("wrong info is:", exception)
Expand Down Expand Up @@ -391,6 +409,9 @@ def go_main_page(self, QuitOperationTime=0, List=[], ExList=[]):
ValueError: _description_
"""
if QuitOperationTime > 200:
if self.is_other_device_login():
self.process_other_device_login()

if self.is_bad_network(timeout=3):
if self.process_bad_network("can't go main page"):
self.go_main_page(0, List)
Expand Down
Binary file modified autowsgr/data/images/error_image/bad_network.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions autowsgr/fight/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ def update_state(self):
except ImageNotFoundErr as _:
# 处理点击延迟或者网络波动导致的匹配失败
self.logger.error("Image Match Failed, Processing")
if self.timer.is_other_device_login():
self.timer.process_other_device_login() # TODO: 处理其他设备登录
if self.timer.is_bad_network(timeout=5):
self.timer.process_bad_network(extra_info="update_state", timeout=5)
if self.Info.last_state == "spot_enemy_success":
Expand Down

0 comments on commit 4c28276

Please sign in to comment.