Skip to content

Commit

Permalink
修改网络问题的处理
Browse files Browse the repository at this point in the history
1. 修改网络问题的处理
2. 修改map_page识别的图片
  • Loading branch information
veadex committed May 2, 2024
1 parent aa9ffbd commit 564bdd5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
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.29"
__version__ = "0.2.2.30"
2 changes: 1 addition & 1 deletion autowsgr/controller/emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def click_image(self, image, must_click=False, timeout=0, delay=0.5):
"""
pos = self.wait_images_position(image, gap=0.03, timeout=timeout)
if pos is None:
if must_click == False:
if not must_click:
return False
else:
raise ImageNotFoundErr(f"Target image not found:{str(image.filepath)}")
Expand Down
31 changes: 16 additions & 15 deletions autowsgr/controller/run_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,25 +212,26 @@ def process_bad_network(self, extra_info="", timeout=10):
"""
start_time = time.time()
while self.is_bad_network(timeout):
self.logger.log_image(self.update_screen, name="bad_network", ignore_existed_image=True)
self.logger.error(f"bad network: {extra_info}")
while True:
if time.time() - start_time >= 180:
raise TimeoutError("Process bad network timeout")
if self.Windows.check_network() != False:
break

start_time2 = time.time()
while self.image_exist([IMG.symbol_image[10]] + [IMG.error_image["bad_network"]]):

# 等待网络恢复

if not self.Windows.wait_network():
raise NetworkErr("can't connect to www.moefantasy.com")

# 处理网络问题
while self.wait_images([IMG.symbol_image[10]] + [IMG.error_image["bad_network"]], timeout=3):
time.sleep(0.5)
if time.time() - start_time2 >= 60:
break
if self.image_exist(IMG.error_image["bad_network"]):
self.Android.click(476, 298, delay=2)

if time.time() - start_time2 < 60:
self.logger.debug("ok network problem solved, at", time.time())
return True
if self.image_exist(IMG.error_image["bad_network"]):
self.click_image(IMG.error_image["network_retry"])

if not self.wait_images([IMG.symbol_image[10]] + [IMG.error_image["bad_network"]], timeout=5):
self.logger.debug("ok network problem solved")
return True
if time.time() - start_time > 1800:
raise TimeoutError("process bad network timeout")
return False

# ========================= 维护当前所在游戏界面 =========================
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions autowsgr/fight/event/event_2024_0419.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ def _go_fight_prepare_page(self) -> None:
self.timer.Android.click(*entrance_position[int(self.from_alpha)])

if not self.timer.click_image(self.event_image[1], timeout=10):
self.timer.logger.error("进入战斗准备页面失败")
self.timer.logger.error("进入战斗准备页面失败,重新尝试进入战斗准备页面")
self.timer.Android.click(*NODE_POSITION[self.map])
self.timer.click_image(self.event_image[1], timeout=10)

try:
self.timer.wait_pages("fight_prepare_page", after_wait=0.15)
except Exception as e:
Expand All @@ -96,6 +99,6 @@ class EventFightInfo20240419(Event, NormalFightInfo):
def __init__(self, timer: Timer, chapter_id, map_id, event="20240419") -> None:
NormalFightInfo.__init__(self, timer, chapter_id, map_id)
Event.__init__(self, timer, event)
self.map_image = self.common_image["easy"] + self.common_image["hard"] + [self.event_image[1]]
self.map_image = self.common_image["easy"] + self.common_image["hard"] + [self.event_image[1]] + [self.event_image[2]]
self.end_page = "unknown_page"
self.state2image["map_page"] = [self.map_image, 5]
5 changes: 4 additions & 1 deletion autowsgr/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ def all_in(elements, set):

def yaml_to_dict(yaml_file):
"""将yaml文件转换为字典"""
# 处理yaml文件中的转义字符\
with open(yaml_file, "r", encoding="utf-8") as f:
return yaml.load(f, Loader=yaml.FullLoader)
content = f.read()
content = content.replace("\\", "\\\\")
return yaml.load(content, Loader=yaml.FullLoader)


def dict_to_yaml(dict_data, yaml_file):
Expand Down

0 comments on commit 564bdd5

Please sign in to comment.