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

feat(TrueOrochi):用玩法 tab 模块在场检测替代本地次数记账

- 新增 I_ST_MODULE 资产与 st_module.png 模板;run() 开头 goto_page(page_gameplay) 后用八岐大蛇模块在场性判断本周剩余次数(在场继续、消失按本周已打完处理)
- 删除 config 的 current_success 计数及跨周重置逻辑,check_times 改为纯调度(打完走 success_interval,否则 failure_interval)
- 删除战斗前 O_TIMES 计数回写及 O_TIMES / ocr.json 资产
User 1 месяц назад
Родитель
Сommit
f7db71b253

+ 2 - 5
tasks/TrueOrochi/assets.py

@@ -58,10 +58,7 @@ class TrueOrochiAssets:
 	I_ST_CREATE_ROOM = RuleImage(roi_front=(528,482,223,62), roi_back=(528,482,223,62), threshold=0.8, method="Template matching", file="./tasks/TrueOrochi/st/st_st_create_room.png")
 	# 头像框 
 	I_ST_FRAME = RuleImage(roi_front=(571,442,135,65), roi_back=(571,442,135,65), threshold=0.8, method="Template matching", file="./tasks/TrueOrochi/st/st_st_frame.png")
-
-
-	# Ocr Rule Assets
-	# 本周剩余奖励次数 
-	O_TIMES = RuleOcr(roi=(461,388,40,26), area=(461,388,40,26), mode="DigitCounter", method="Default", keyword="", name="times")
+	# 玩法tab八岐大蛇模块,在场说明本周还有次数 
+	I_ST_MODULE = RuleImage(roi_front=(1111,322,84,22), roi_back=(1068,210,191,313), threshold=0.85, method="Template matching", file="./tasks/TrueOrochi/st/st_module.png")
 
 

+ 0 - 1
tasks/TrueOrochi/config.py

@@ -30,7 +30,6 @@ class TrueOrochiConfig(BaseModel):
     find_true_orochi: bool = Field(default=True, description='find_true_orochi_help')
     # green_enable: bool = Field(default=False, description='green_enable_help')
     # green_mark_type: GreenMarkType = Field(default=GreenMarkType.LEFT_1, description='green_mark_type_help')
-    current_success: int = Field(default=0, description='current_success_help')
 
 class TrueOrochi(ConfigBase):
     scheduler: TrueOrochiScheduler = Field(default_factory=TrueOrochiScheduler)

+ 12 - 35
tasks/TrueOrochi/script_task.py

@@ -2,7 +2,7 @@
 # @author runhey
 # github https://github.com/runhey
 from time import sleep
-from datetime import datetime, time
+from datetime import datetime
 
 from module.logger import logger
 from module.exception import TaskEnd, GameStuckError
@@ -16,6 +16,7 @@ from tasks.Orochi.script_task import ScriptTask as OrochiScriptTask
 from tasks.Orochi.config import Layer
 from tasks.Orochi.page import page_orochi
 from tasks.GameUi.page import page_main, page_shikigami_records
+from tasks.Exploration.page import page_gameplay
 from tasks.TrueOrochi.assets import TrueOrochiAssets
 
 
@@ -25,9 +26,10 @@ class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
     
         conf = self.config.true_orochi.true_orochi_config
 
-        if conf.current_success >= 2:
-            # 超过两次就说明这周打完了没有必要再打了
-            logger.warning('This week is full')
+        # 玩法tab的八岐大蛇模块在场说明本周还有次数,消失说明本周已打完
+        self.goto_page(page_gameplay)
+        if not self.appear(self.I_ST_MODULE):
+            logger.warning('True orochi module absent, no attempts left this week')
             self.check_times(True)
             raise TaskEnd('TrueOrochi')
 
@@ -91,7 +93,7 @@ class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
         # 检查是否还有真蛇入口,支持存储两次
         self.goto_page(page_orochi)
         sleep(0.5)
-        if conf.current_success < 2 and self.check_true_orochi(True):
+        if self.check_true_orochi(True):
             battle = True
             logger.info('Find another true orochi entry, continue')
             self.run_true_orochi_battle()
@@ -110,13 +112,6 @@ class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
             if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
                 continue
             if self.appear_then_click(self.I_ST_FIRE, interval=4):
-                # 修正已经挑战的次数, 注意这个是战斗开始之前的次数
-                current, current_success, total = self.O_TIMES.ocr(self.device.image)
-                if current_success < 0 or current_success > 2:
-                    continue
-                logger.info(f'current: {current}, current_success: {current_success}, total: {total}')
-                conf.current_success = current_success
-                self.config.save()
                 continue
             if self.appear_then_click(self.I_FIND_TS, interval=1):
                 continue
@@ -192,31 +187,13 @@ class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
 
     def check_times(self, battle: bool):
         """
-        后续的次数和时间设置
-        :param battle: 本次是否挑战了真蛇
-        :param current_success: 这周的成功次数
+        根据是否有战斗结果设置下次运行时间
+        :param battle:
         :return:
         """
-        now = datetime.now()
-        now_year, now_week_number, now_weekday = now.isocalendar()
-        if battle:
-            # 只有真正打过才加一次数
-            logger.info('Add current_success by 1')
-            self.config.true_orochi.true_orochi_config.current_success += 1
-            self.config.true_orochi.true_orochi_config.current_success = min(2, self.config.true_orochi.true_orochi_config.current_success)
-            next_run = now + self.config.true_orochi.scheduler.success_interval
-        else:
-            logger.info('Battle skipped or not found True Orochi')
-            next_run = now + self.config.true_orochi.scheduler.failure_interval
-        next_run_year, next_run_week_number, next_run_weekday = next_run.isocalendar()
-        # 如果下次运行的时间是下一周,那么就重置成功次数
-        if now_week_number != next_run_week_number:
-            logger.info('Reset current_success')
-            self.config.true_orochi.true_orochi_config.current_success = 0
-
-        self.config.save()
-        self.set_next_run(task='TrueOrochi', target=next_run)
-        # self.set_next_run('TrueOrochi', finish=True, success=True)
+        interval = self.config.true_orochi.scheduler.success_interval if battle \
+            else self.config.true_orochi.scheduler.failure_interval
+        self.set_next_run(task='TrueOrochi', target=datetime.now() + interval)
 
     def run_true_orochi(self) -> bool:
         pass

+ 9 - 0
tasks/TrueOrochi/st/image.json

@@ -124,5 +124,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "头像框"
+  },
+  {
+    "itemName": "st_module",
+    "imageName": "st_module.png",
+    "roiFront": "1111,322,84,22",
+    "roiBack": "1068,210,191,313",
+    "method": "Template matching",
+    "threshold": 0.85,
+    "description": "玩法tab八岐大蛇模块,在场说明本周还有次数"
   }
 ]

+ 0 - 11
tasks/TrueOrochi/st/ocr.json

@@ -1,11 +0,0 @@
-[
-  {
-    "itemName": "times",
-    "roiFront": "461,388,40,26",
-    "roiBack": "461,388,40,26",
-    "mode": "DigitCounter",
-    "method": "Default",
-    "keyword": "",
-    "description": "本周剩余奖励次数"
-  }
-]

BIN
tasks/TrueOrochi/st/st_module.png