fix(meowfficer): 处理喂猫在大世界中导致的无限点击

- 记录连续出现相同按钮名的次数
- 当连续次数达到 7 次时,判断指挥猫在大世界中,直接确认,结束任务
This commit is contained in:
POLAR me 2025-02-15 06:09:49 +08:00
parent fd5c1982c5
commit c0a9ef06fe

View File

@ -156,7 +156,8 @@ class MeowfficerEnhance(MeowfficerBase):
current = 0
retry = Timer(1, count=2)
skip_first_screenshot = True
last_button_names = None # 上一次检测到的按钮特征
same_button_time = 0
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
@ -173,6 +174,22 @@ class MeowfficerEnhance(MeowfficerBase):
if not len(buttons):
break
current_button_names = tuple(sorted(button.name for button in buttons))
# 如果特征与上一次一致,记录
if current_button_names == last_button_names:
same_button_time += 1
else:
# 特征不一致时重置记录
same_button_time = 0
last_button_names = current_button_names
if same_button_time >= 7:
logger.warning("指挥猫在大世界中!")
current = 0 #修改扫描数,不然还会"ENHANCE ONCE"
self.ui_click(MEOWFFICER_FEED_CONFIRM, check_button=MEOWFFICER_ENHANCE_CONFIRM,
offset=(20, 20), skip_first_screenshot=True)
self.meow_enhance_confirm()
break #重复点击太多次猫说明这个猫在大世界
# Else click each button to
# apply green check mark
# Sleep for stable image