Просмотр исходного кода

Merge nearaura invite, Six Realms and weekly collection fixes

Review b2f9e032..5ae88f00 after runhey returned Repository not found.
Replay five source patches on the previously reviewed branch with their
original IDs. Both upstream merges have no independent changes. The
reviewed tree matches the fallback tip outside the previously deferred
AutoCheckinBigGod change b2f02602.

Use the mean color of the first friend tab in GeneralInvite. Exploration
already used this method. Sample the badge itself even when the desktop
template search padding is enabled. Retain the invite confirmation crop.

Use the upstream give-up, alternate result and share-progress PNGs as
supplied. Correct the alternate portrait crop height in the rule and
JSON from 122 to the actual 121 pixels, keeping its original search area.
Check both result portraits every frame within the original 20-second
window. Leave island 103 on seeing the boss marker. Accept the collection
progress arrow as well as the original share button. Retain local island
entry safeguards and weekly guild navigation.

601 tests passed across tests/ and both FrogBoss suites, including four
new invite and boss-result replay cases. Verified production imports,
syntax, three PNGs against upstream, JSON metadata, blank/positive
matches, island 103 exit, both share buttons, and git diff --check.
Three deprecation warnings in the final run. No emulator run.
unknown 19 часов назад
Родитель
Сommit
454e25fecb

+ 2 - 2
module/atom/image.py

@@ -567,7 +567,7 @@ class RuleImage(RuleImageMallResourceMixin):
             cv2.destroyAllWindows()
         return result
 
-    def match_mean_color(self, image, color: tuple, bias=10) -> bool:
+    def match_mean_color(self, image, color: tuple, bias=10, roi=None) -> bool:
         """
 
         :param image:
@@ -575,7 +575,7 @@ class RuleImage(RuleImageMallResourceMixin):
         :param bias:
         :return:
         """
-        image = self.corp(image)
+        image = self.corp(image, roi)
         average_color = cv2.mean(image)
         if self.debug_mode:
             logger.info(f'{self.name} average_color: {average_color}')

+ 4 - 2
tasks/Component/GeneralInvite/general_invite.py

@@ -417,9 +417,11 @@ class GeneralInvite(BaseTask, GeneralInviteAssets):
             # 首先切换到不同的好友列表
             while index == 0:
                 self.screenshot()
-                if self.appear(self.I_FLAG_1_ON):
+                # Sample only the badge, excluding the desktop template search padding.
+                flag = self.I_FLAG_1_ON
+                if flag.match_mean_color(self.device.image, (227, 193, 153), roi=flag.roi_back):
                     break
-                if self.appear_then_click(self.I_FLAG_1_OFF, interval=1):
+                if self.click(self.I_FLAG_1_OFF, interval=1):
                     continue
             while index == 1:
                 self.screenshot()

+ 4 - 2
tasks/SixRealms/assets.py

@@ -34,10 +34,12 @@ class SixRealmsAssets:
 	I_BOSS_SHARE = RuleImage(roi_front=(1090,604,70,74), roi_back=(1074,587,100,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_share.png")
 	# 结算的椒图 
 	I_BOSS_SHUTU = RuleImage(roi_front=(108,141,173,122), roi_back=(108,141,173,122), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_shutu.png")
-	# description 
+	# description
+	I_BOSS_SHUTU2 = RuleImage(roi_front=(108,141,173,121), roi_back=(108,141,173,122), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_shutu2.png")
+	# description
 	I_BOSS_BATTLE_AGAIN = RuleImage(roi_front=(435,403,173,64), roi_back=(409,390,212,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_battle_again.png")
 	# description 
-	I_BOSS_BATTLE_GIVEUP = RuleImage(roi_front=(671,399,175,59), roi_back=(649,381,219,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_battle_giveup.png")
+	I_BOSS_BATTLE_GIVEUP = RuleImage(roi_front=(664,409,175,59), roi_back=(649,391,219,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_battle_giveup.png")
 
 
 	# Click Rule Assets

+ 12 - 3
tasks/SixRealms/gate1/boss.json

@@ -71,6 +71,15 @@
     "threshold": 0.8,
     "description": "结算的椒图"
   },
+  {
+    "itemName": "boss_shutu2",
+    "imageName": "gate1_boss_shutu2.png",
+    "roiFront": "108,141,173,121",
+    "roiBack": "108,141,173,122",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
   {
     "itemName": "boss_battle_again",
     "imageName": "gate1_boss_battle_again.png",
@@ -83,10 +92,10 @@
   {
     "itemName": "boss_battle_giveup",
     "imageName": "gate1_boss_battle_giveup.png",
-    "roiFront": "671,399,175,59",
-    "roiBack": "649,381,219,100",
+    "roiFront": "664,409,175,59",
+    "roiBack": "649,391,219,100",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
   }
-]
+]

BIN
tasks/SixRealms/gate1/gate1_boss_battle_giveup.png


BIN
tasks/SixRealms/gate1/gate1_boss_shutu2.png


+ 3 - 0
tasks/SixRealms/moon_sea/l103.py

@@ -16,6 +16,9 @@ class MoonSeaL103(MoonSeaSkills):
                 if self.appear(self.I_M_STORE):
                     logger.info('Not punched the treasure  box')
                     return
+                if self.appear(self.I_BOSS_FIRE):
+                    logger.info('Not punched the treasure  box')
+                    return
                 if self.appear_then_click(self.I_UI_UNCHECK, interval=0.5):
                     continue
                 if self.appear_then_click(self.I_UI_CONFIRM, interval=1):

+ 11 - 2
tasks/SixRealms/moon_sea/moon_sea.py

@@ -1,5 +1,6 @@
 import time
 
+from module.base.timer import Timer
 from module.logger import logger
 
 from cached_property import cached_property
@@ -222,8 +223,16 @@ class MoonSea(MoonSeaMap, MoonSeaL101, MoonSeaL102, MoonSeaL103, MoonSeaL104, Mo
                 self.device.stuck_record_add('BATTLE_STATUS_S')
                 continue
         logger.info('Boss battle end')
-        if self.wait_until_appear(self.I_BOSS_SHUTU, wait_time=20):
-            self.ui_click(self.I_BOSS_SHUTU, stop=self.I_MSTART)
+        result_timer = Timer(20).start()
+        while not result_timer.reached():
+            self.screenshot()
+            if self.appear(self.I_MSTART):
+                return True
+            for portrait in (self.I_BOSS_SHUTU, self.I_BOSS_SHUTU2):
+                if self.appear(portrait):
+                    self.ui_click(portrait, stop=self.I_MSTART)
+                    return True
+        logger.warning('Boss result portrait did not appear')
         return True
 
     def select_shikigami_and_confirm(self):

+ 2 - 0
tasks/WeeklyTrifles/assets.py

@@ -58,6 +58,8 @@ class WeeklyTriflesAssets:
 	I_WT_SHIKIAGMI = RuleImage(roi_front=(280,620,920,100), roi_back=(280,620,920,100), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/collect/collect_wt_shikiagmi.png")
 	# 点击式神绘卷 
 	I_WT_SHARE = RuleImage(roi_front=(336,280,50,48), roi_back=(266,241,199,141), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/collect/collect_wt_share.png")
+	# 点击式神图鉴收集进度旁的分享箭头
+	I_WT_SHARE_PROGRESS = RuleImage(roi_front=(822,610,32,29), roi_back=(738,591,192,61), threshold=0.9, method="Template matching", file="./tasks/WeeklyTrifles/collect/collect_wt_share_progress.png")
 	# 百鬼夜行图 
 	I_WT_LOGO = RuleImage(roi_front=(1106,72,34,111), roi_back=(1065,11,117,207), threshold=0.7, method="Template matching", file="./tasks/WeeklyTrifles/collect/collect_wt_logo.png")
 	# 微信分享 

BIN
tasks/WeeklyTrifles/collect/collect_wt_share_progress.png


+ 9 - 0
tasks/WeeklyTrifles/collect/image.json

@@ -17,6 +17,15 @@
     "threshold": 0.8,
     "description": "点击式神绘卷"
   },
+  {
+    "itemName": "wt_share_progress",
+    "imageName": "collect_wt_share_progress.png",
+    "roiFront": "822,610,32,29",
+    "roiBack": "738,591,192,61",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "点击式神图鉴收集进度旁的分享箭头"
+  },
   {
     "itemName": "wt_logo",
     "imageName": "collect_wt_logo.png",

+ 2 - 0
tasks/WeeklyTrifles/script_task.py

@@ -140,6 +140,8 @@ class ScriptTask(GameUi, WeeklyTriflesAssets):
                 continue
             if self.appear_then_click(self.I_WT_SHARE, interval=1):
                 continue
+            if self.appear_then_click(self.I_WT_SHARE_PROGRESS, interval=1):
+                continue
         # 点击分享
         while 1:
             self.screenshot()

+ 41 - 0
tests/tasks/Component/GeneralInvite/test_friend_tab.py

@@ -0,0 +1,41 @@
+from types import SimpleNamespace
+
+import numpy as np
+import pytest
+
+from module.atom import image
+from tasks.Component.GeneralInvite.general_invite import GeneralInvite
+
+
+@pytest.mark.parametrize('padding', [0, 2])
+def test_first_friend_tab_ignores_surrounding_colors(monkeypatch, padding):
+    task = object.__new__(GeneralInvite)
+    task.device = SimpleNamespace(image=np.zeros((720, 1280, 3), dtype=np.uint8))
+    x, y, w, h = task.I_FLAG_1_ON.roi_back
+    badge = task.device.image[y:y+h, x:x+w]
+    badge[:] = (156, 110, 86)
+    clicks = []
+    frames = 0
+
+    def screenshot():
+        nonlocal frames
+        frames += 1
+        assert frames < 9
+
+    def click(rule, interval):
+        assert rule is task.I_FLAG_1_OFF
+        clicks.append(rule)
+        badge[:] = (227, 193, 153)
+        return True
+
+    task.screenshot = screenshot
+    task.click = click
+    task.appear = lambda rule: rule is task.I_LOAD_FRIEND
+    task.detect_select = lambda name: True
+    for i in range(1, 5):
+        label = '好友' if i == 1 else ''
+        setattr(task, f'O_F_LIST_{i}', SimpleNamespace(ocr=lambda frame, label=label: label))
+    monkeypatch.setattr(image, 'ROI_MATCH_PAD', padding)
+    monkeypatch.setattr('tasks.Component.GeneralInvite.general_invite.sleep', lambda _: None)
+    assert task.invite_friend('friend')
+    assert clicks == [task.I_FLAG_1_OFF]

+ 29 - 0
tests/test_six_realms_boss_result.py

@@ -0,0 +1,29 @@
+from types import SimpleNamespace
+from unittest.mock import Mock
+
+import pytest
+
+from module.base import timer
+from tasks.SixRealms.moon_sea.moon_sea import MoonSea
+
+
+@pytest.mark.parametrize('portrait_name, after', [('I_BOSS_SHUTU', 12), ('I_BOSS_SHUTU2', 1)])
+def test_settlement_accepts_either_portrait_on_the_frame_it_appears(monkeypatch, portrait_name, after):
+    task = object.__new__(MoonSea)
+    task.device = SimpleNamespace(stuck_record_clear=Mock(), stuck_record_add=Mock())
+    task.ui_click_until_disappear = Mock()
+    task.ui_click = Mock()
+    frames = 0
+
+    def screenshot():
+        nonlocal frames
+        frames += 1
+        assert frames <= 22
+
+    task.screenshot = screenshot
+    portrait = getattr(task, portrait_name)
+    task.appear = lambda rule: (rule is task.I_BOSS_SHARE and frames == 1) or (
+        rule is portrait and frames == 1 + after)
+    monkeypatch.setattr(timer, 'time', SimpleNamespace(time=lambda: 100.0 + frames))
+    assert task.boss_battle() is True
+    task.ui_click.assert_called_once_with(portrait, stop=task.I_MSTART)