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

fix: 寶箱改爲游戲内匹配

doge 3 месяцев назад
Родитель
Сommit
e1b29462d4

+ 1 - 0
.gitignore

@@ -272,3 +272,4 @@ console.bat
 .vscode/*
 .vscode/*
 tasks/AutoCheckinBigGod/frida-server-17.6.2-android-x86_64
 tasks/AutoCheckinBigGod/frida-server-17.6.2-android-x86_64
 oas.bat
 oas.bat
+exploration_state_machine.md

+ 66 - 0
exploration_state_machine.md

@@ -85,6 +85,72 @@ stateDiagram-v2
     END --> [*]
     END --> [*]
 ```
 ```
 
 
+## 队长邀请好友子状态机
+
+探索队长模式进入 `TEAM` 后,邀请逻辑由两段代码共同驱动:
+
+- `tasks/Exploration/solo.py`
+  - `run_leader()`:识别 `Scene.TEAM`,决定是否直接开火或进入邀请流程。
+  - `invite_friend()`:探索覆盖的好友选择逻辑。
+- `tasks/Component/GeneralInvite/general_invite.py`
+  - `run_invite()`:通用组队等待、重复邀请、开火判断。
+  - `invite_friends()`:调用具体的 `invite_friend()`。
+
+### 子状态定义
+
+| 状态 | 含义 |
+| --- | --- |
+| `TEAM_CHECK` | 队长在组队房间内检查邀请位和挑战按钮。 |
+| `INVITE_ENTER` | 确认已进入组队房间,初始化房间类型和邀请定时器。 |
+| `INVITE_OPEN_LIST` | 点击邀请位 `I_ADD_2`,等待好友列表加载或邀请确认按钮出现。 |
+| `INVITE_SELECT_FRIEND` | 按配置的查找方式选择好友。 |
+| `INVITE_CONFIRM` | 点击邀请确认按钮,关闭好友列表。 |
+| `WAIT_MEMBER` | 等待队友进入房间。 |
+| `INVITE_AGAIN` | 定时器到达后再次邀请。 |
+| `START_CHALLENGE` | 探索双人房检测到 `I_ADD_2` 消失,点击挑战。 |
+| `INVITE_FAILED` | 等待超时、房间消失或好友查找失败。 |
+
+### 子状态图
+
+```mermaid
+stateDiagram-v2
+    [*] --> TEAM_CHECK
+
+    TEAM_CHECK --> START_CHALLENGE: I_FIRE 出现且 I_ADD_2 消失
+    TEAM_CHECK --> INVITE_ENTER: I_ADD_2 出现,调用 run_invite(is_first=True)
+    TEAM_CHECK --> INVITE_FAILED: 无法开火且无法邀请
+
+    INVITE_ENTER --> INVITE_OPEN_LIST: ensure_enter() 成功,初始化 room_type 和 Timer(20)
+    INVITE_ENTER --> INVITE_FAILED: ensure_enter() 失败
+
+    INVITE_OPEN_LIST --> INVITE_SELECT_FRIEND: I_LOAD_FRIEND 或 I_INVITE_ENSURE 出现
+    INVITE_SELECT_FRIEND --> INVITE_CONFIRM: 找到好友或完成查找
+    INVITE_CONFIRM --> WAIT_MEMBER: 关闭邀请列表
+    INVITE_CONFIRM --> INVITE_FAILED: 未找到好友
+
+    WAIT_MEMBER --> START_CHALLENGE: NORMAL_2 且 I_ADD_2 消失
+    WAIT_MEMBER --> INVITE_AGAIN: is_first=True 且 Timer(20) 到达
+    WAIT_MEMBER --> INVITE_FAILED: wait_time 到达或出现 I_MATCHING
+    WAIT_MEMBER --> WAIT_MEMBER: 仍在房间且邀请位未消失
+
+    INVITE_AGAIN --> INVITE_OPEN_LIST: timer_invite.reset() 后再次 invite_friends()
+
+    START_CHALLENGE --> [*]: click_fire() 后进入章节
+    INVITE_FAILED --> [*]: run_leader() 退出房间并回到 WORLD
+```
+
+### 当前边界风险
+
+主等待循环可以处理队友进房:探索房间是 `RoomType.NORMAL_2`,当 `I_ADD_2` 消失时,`run_invite()` 会进入 `START_CHALLENGE` 并点击挑战。
+
+风险在 `INVITE_OPEN_LIST` 到 `INVITE_CONFIRM` 之间。探索自己的 `invite_friend()` 在点击 `I_ADD_2` 后,只等待:
+
+- `I_LOAD_FRIEND`
+- `I_INVITE_ENSURE`
+- 再次点击到 `I_ADD_2` / `I_ADD_5_4`
+
+它没有检测“队友已进入房间导致 `I_ADD_2` 消失”的条件,也没有内部超时。因此如果第二次邀请刚触发时,队友正好进入房间,邀请列表或确认按钮又没有按预期出现,流程可能停在 `INVITE_OPEN_LIST` 或后续好友列表切换循环里,无法回到 `WAIT_MEMBER` 去触发 `START_CHALLENGE`。
+
 ## 关键转换条件
 ## 关键转换条件
 
 
 ### `WORLD -> POST_PROCESS`
 ### `WORLD -> POST_PROCESS`

+ 3 - 1
tasks/Exploration/assets.py

@@ -110,7 +110,7 @@ class ExplorationAssets:
 	# description 
 	# description 
 	I_E_EXIT_CONFIRM = RuleImage(roi_front=(694,380,163,49), roi_back=(694,380,163,49), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_exit_confirm.png")
 	I_E_EXIT_CONFIRM = RuleImage(roi_front=(694,380,163,49), roi_back=(694,380,163,49), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_exit_confirm.png")
 	# 宝箱 
 	# 宝箱 
-	I_TREASURE_BOX_CLICK = RuleImage(roi_front=(34,386,47,37), roi_back=(2,130,135,406), threshold=0.65, method="Template matching", file="./tasks/Exploration/res/res_treasure_box_click.png")
+	I_TREASURE_BOX_CLICK = RuleImage(roi_front=(31,537,39,29), roi_back=(11,520,378,65), threshold=0.65, method="Template matching", file="./tasks/Exploration/res/res_treasure_box_click.png")
 	# 困28滚动到最后 
 	# 困28滚动到最后 
 	I_SWIPE_END = RuleImage(roi_front=(994,234,119,100), roi_back=(968,196,311,165), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_swipe_end.png")
 	I_SWIPE_END = RuleImage(roi_front=(994,234,119,100), roi_back=(968,196,311,165), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_swipe_end.png")
 	# 队伍的表情标志 
 	# 队伍的表情标志 
@@ -123,6 +123,8 @@ class ExplorationAssets:
 	I_EXP_ARROW_RIGHT = RuleImage(roi_front=(1240,117,24,21), roi_back=(1178,74,100,100), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_exp_arrow_right.png")
 	I_EXP_ARROW_RIGHT = RuleImage(roi_front=(1240,117,24,21), roi_back=(1178,74,100,100), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_exp_arrow_right.png")
 	# 箭头,打开 
 	# 箭头,打开 
 	I_EXP_ARROW_LEFT = RuleImage(roi_front=(1244,115,18,26), roi_back=(1178,78,100,100), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_exp_arrow_left.png")
 	I_EXP_ARROW_LEFT = RuleImage(roi_front=(1244,115,18,26), roi_back=(1178,78,100,100), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_exp_arrow_left.png")
+	# 組隊時隊長是否在副本内 
+	I_EXP_LEADER = RuleImage(roi_front=(119,299,17,21), roi_back=(1,105,162,248), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_exp_leader.png")
 
 
 
 
 	# Long Click Rule Assets
 	# Long Click Rule Assets

+ 11 - 2
tasks/Exploration/res/image.json

@@ -173,8 +173,8 @@
   {
   {
     "itemName": "treasure_box_click",
     "itemName": "treasure_box_click",
     "imageName": "res_treasure_box_click.png",
     "imageName": "res_treasure_box_click.png",
-    "roiFront": "34,386,47,37",
-    "roiBack": "2,130,135,406",
+    "roiFront": "31,537,39,29",
+    "roiBack": "11,520,378,65",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.65,
     "threshold": 0.65,
     "description": "宝箱"
     "description": "宝箱"
@@ -232,5 +232,14 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "箭头,打开"
     "description": "箭头,打开"
+  },
+  {
+    "itemName": "exp_leader",
+    "imageName": "res_exp_leader.png",
+    "roiFront": "119,299,17,21",
+    "roiBack": "1,105,162,248",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "組隊時隊長是否在副本内"
   }
   }
 ]
 ]

BIN
tasks/Exploration/res/res_exp_leader.png


+ 21 - 22
tasks/Exploration/solo.py

@@ -83,8 +83,7 @@ class SoloExploration(BaseExploration):
                     continue
                     continue
                 # 小纸人
                 # 小纸人
                 if self.appear(self.I_BATTLE_REWARD):
                 if self.appear(self.I_BATTLE_REWARD):
-                    if self.ui_get_reward(self.I_BATTLE_REWARD):
-                        continue
+                    continue
                 # boss
                 # boss
                 if self.appear(self.I_BOSS_BATTLE_BUTTON):
                 if self.appear(self.I_BOSS_BATTLE_BUTTON):
                     if self.fire(self.I_BOSS_BATTLE_BUTTON):
                     if self.fire(self.I_BOSS_BATTLE_BUTTON):
@@ -144,22 +143,22 @@ class SoloExploration(BaseExploration):
                 # 打开右边箭头
                 # 打开右边箭头
                 if not self.wait_world_stable():
                 if not self.wait_world_stable():
                     continue
                     continue
-                if self.appear(self.I_TREASURE_BOX_CLICK):
-                    # 宝箱
-                    logger.info('Treasure box appear, get it.')
-                    self.wait_until_stable(self.I_UI_CANCEL, timer=Timer(0.6, 1))
-                    while 1:
-                        self.screenshot()
-                        if self.appear(self.I_REWARD):
-                            self.ui_click_until_disappear(self.I_REWARD)
-                            logger.info('Get reward.')
-                            break
-                        if self.ui_reward_appear_click():
-                            continue
-                        if self.appear_then_click(self.I_UI_CANCEL, interval=0.8):
-                            continue
-                        if self.appear_then_click(self.I_TREASURE_BOX_CLICK, interval=1):
-                            continue
+                # if self.appear(self.I_TREASURE_BOX_CLICK):
+                #     # 宝箱
+                #     logger.info('Treasure box appear, get it.')
+                #     self.wait_until_stable(self.I_UI_CANCEL, timer=Timer(0.6, 1))
+                #     while 1:
+                #         self.screenshot()
+                #         if self.appear(self.I_REWARD):
+                #             self.ui_click_until_disappear(self.I_REWARD)
+                #             logger.info('Get reward.')
+                #             break
+                #         if self.ui_reward_appear_click():
+                #             continue
+                #         if self.appear_then_click(self.I_UI_CANCEL, interval=0.8):
+                #             continue
+                #         if self.appear_then_click(self.I_TREASURE_BOX_CLICK, interval=1):
+                #             continue
                 if self.check_exit():
                 if self.check_exit():
                     self.wait_until_stable(self.I_UI_CANCEL, timer=Timer(0.6, 2))
                     self.wait_until_stable(self.I_UI_CANCEL, timer=Timer(0.6, 2))
                     if self.appear(self.I_UI_CANCEL):
                     if self.appear(self.I_UI_CANCEL):
@@ -293,10 +292,10 @@ class SoloExploration(BaseExploration):
                 # 打开右边箭头
                 # 打开右边箭头
                 if not self.wait_world_stable():
                 if not self.wait_world_stable():
                     continue
                     continue
-                if self.appear(self.I_TREASURE_BOX_CLICK):
-                    # 宝箱
-                    logger.info('Treasure box appear, get it.')
-                    self.ui_click_until_disappear(self.I_TREASURE_BOX_CLICK)
+                # if self.appear(self.I_TREASURE_BOX_CLICK):
+                #     # 宝箱
+                #     logger.info('Treasure box appear, get it.')
+                #     self.ui_click_until_disappear(self.I_TREASURE_BOX_CLICK)
                 if self.check_exit():
                 if self.check_exit():
                     break
                     break
                 if self.check_then_accept():
                 if self.check_then_accept():