Ver código fonte

Merge nearaura dev through f73072c8 for fatigue summon priority

After runhey returned Repository not found, integrate 13221d2c..f73072c8
(three commits including one merge). Adopt the configurable, default-on
summon priority when fatigue is 61 through 100 and no own boss exists,
plus Chinese labels and help. Adopt the upstream md_enter2 PNG unchanged
and its expanded matching region in both the rule and JSON metadata.

Normal merge retains the corrected right-enter PNG dimensions, bounded
team unlock, local battle hooks and prior exploration and donation fixes.
The new behavior was not present locally. No upstream hunk was skipped.

Validation: 583 tests passed across tests/ and both FrogBoss suites,
with three existing deprecation warnings. Eight new regression cases
exercise fatigue boundaries, disabled priority, own boss precedence,
full-fatigue exit and legacy config/default/opt-out loading.
Checked four Python files, three production imports, two JSON files,
source PNG byte identity, two rule/PNG/metadata sets, eight synthetic
matches and git diff --check. No emulator run.
unknown 2 dias atrás
pai
commit
2e256d99da

+ 2 - 0
assets/i18n/zh-CN.json

@@ -72,6 +72,8 @@
   "limit_cultivation_drills_help": "搜寻到一只后会一直打,直到打完算一次",
   "limit_cultivation_drills_help": "搜寻到一只后会一直打,直到打完算一次",
   "auto_shared_boss": "自动挑战共享鬼王",
   "auto_shared_boss": "自动挑战共享鬼王",
   "auto_shared_boss_help": "是否自动挑战其他玩家共享的鬼王",
   "auto_shared_boss_help": "是否自动挑战其他玩家共享的鬼王",
+  "md_fatigue_summon_first": "疲劳≥61优先召唤鬼王",
+  "md_fatigue_summon_first_help": "开启后,疲劳值达到61及以上且自己没有鬼王在线时,优先召唤鬼王(先于协战鬼王判定);疲劳满后仍按原逻辑买茶/退出",
   "enable_switch_daily_training": "日常训练开启切换御魂",
   "enable_switch_daily_training": "日常训练开启切换御魂",
   "enable_switch_cultivation_drills": "修行合训开启切换御魂",
   "enable_switch_cultivation_drills": "修行合训开启切换御魂",
   "demon_battle_config": "逢魔战斗内切换阵容",
   "demon_battle_config": "逢魔战斗内切换阵容",

+ 1 - 1
tasks/MetaDemon/assets.py

@@ -21,7 +21,7 @@ class MetaDemonAssets:
 	# 右侧进去 
 	# 右侧进去 
 	I_RIGHT_ENTER = RuleImage(roi_front=(1188,220,46,34), roi_back=(1150,131,100,360), threshold=0.75, method="Template matching", file="./tasks/MetaDemon/md/md_right_enter.png")
 	I_RIGHT_ENTER = RuleImage(roi_front=(1188,220,46,34), roi_back=(1150,131,100,360), threshold=0.75, method="Template matching", file="./tasks/MetaDemon/md/md_right_enter.png")
 	# description 
 	# description 
-	I_ENTER2 = RuleImage(roi_front=(933,150,73,125), roi_back=(893,47,116,244), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/md_enter2.png")
+	I_ENTER2 = RuleImage(roi_front=(933,150,73,125), roi_back=(893,47,130,259), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/md_enter2.png")
 	# 寻找鬼王 
 	# 寻找鬼王 
 	I_FIND_DEMON = RuleImage(roi_front=(1140,582,86,81), roi_back=(1102,546,132,133), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/md_find_demon.png")
 	I_FIND_DEMON = RuleImage(roi_front=(1140,582,86,81), roi_back=(1102,546,132,133), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/md_find_demon.png")
 	# 点击战斗 
 	# 点击战斗 

+ 1 - 0
tasks/MetaDemon/config.py

@@ -77,6 +77,7 @@ class MetaDemonConfig(ConfigBase):
     meta_crafting_card: bool = Field(default=True, description='craft_essence_help')
     meta_crafting_card: bool = Field(default=True, description='craft_essence_help')
     auto_tea: bool = Field(default=False, description='auto_tea_help')
     auto_tea: bool = Field(default=False, description='auto_tea_help')
     auto_shared_boss: bool = Field(default=True, description='auto_shared_boss_help')
     auto_shared_boss: bool = Field(default=True, description='auto_shared_boss_help')
+    md_fatigue_summon_first: bool = Field(default=True, description='md_fatigue_summon_first_help')
     # extreme_notify: bool = Field(default=False, description='extreme_notify_help')
     # extreme_notify: bool = Field(default=False, description='extreme_notify_help')
     md_strategy_count: int = Field(default=0, ge=0, description='md_strategy_count_help')
     md_strategy_count: int = Field(default=0, ge=0, description='md_strategy_count_help')
     md_use_strategy: bool = Field(default=False, description='md_use_strategy_help')
     md_use_strategy: bool = Field(default=False, description='md_use_strategy_help')

+ 2 - 2
tasks/MetaDemon/md/image_2025.json

@@ -12,7 +12,7 @@
     "itemName": "enter2",
     "itemName": "enter2",
     "imageName": "md_enter2.png",
     "imageName": "md_enter2.png",
     "roiFront": "933,150,73,125",
     "roiFront": "933,150,73,125",
-    "roiBack": "893,47,116,244",
+    "roiBack": "893,47,130,259",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
@@ -161,4 +161,4 @@
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "已公开"
     "description": "已公开"
   }
   }
-]
+]

BIN
tasks/MetaDemon/md/md_enter2.png


+ 9 - 0
tasks/MetaDemon/script_task.py

@@ -113,6 +113,15 @@ class ScriptTask(RightActivity, Battle, GeneralBattle, SwitchSoul, Star56):
             if not (self.appear(self.I_FIND_DEMON) or self.appear(self.I_BATTLE_DEMON)):
             if not (self.appear(self.I_FIND_DEMON) or self.appear(self.I_BATTLE_DEMON)):
                 continue
                 continue
 
 
+            # 疲劳达到阈值时优先召唤鬼王(开关控制,判定先于原有逻辑)
+            if self.config.meta_demon.meta_demon_config.md_fatigue_summon_first:
+                fatigue = self.current_exhaustion()
+                if 61 <= fatigue <= 100 and self.appear(self.I_BOSS_EMPTY):
+                    logger.info('Fatigue >= 61, summon demon first')
+                    if self.find_demon():
+                        boss_timer.reset()
+                        continue
+
             # 先看自己有没有鬼王要打
             # 先看自己有没有鬼王要打
             if (not self.appear(self.I_BOSS_EMPTY) and
             if (not self.appear(self.I_BOSS_EMPTY) and
                     (self.appear(self.I_BOSS_CONVENE) or self.appear(self.I_BOOS_PUBLIC))):
                     (self.appear(self.I_BOSS_CONVENE) or self.appear(self.I_BOOS_PUBLIC))):

+ 70 - 0
tests/tasks/MetaDemon/test_summon_priority.py

@@ -0,0 +1,70 @@
+"""Exercise fatigue priority through the normal task loop without a device."""
+from types import SimpleNamespace
+
+import pytest
+
+from module.exception import TaskEnd
+from tasks.MetaDemon.config import MetaDemon
+from tasks.MetaDemon.script_task import ScriptTask
+
+
+class ActionSelected(Exception):
+    pass
+
+
+@pytest.mark.parametrize('fatigue,enabled,own_boss,expected', [
+    (60, True, False, 'shared'),
+    (61, True, False, 'summon'),
+    (90, True, False, 'summon'),
+    (100, True, False, 'summon'),
+    (101, True, False, 'exit'),
+    (61, False, False, 'shared'),
+    (61, True, True, 'own'),
+])
+def test_summoning_priority_boundaries(fatigue, enabled, own_boss, expected):
+    task = object.__new__(ScriptTask)
+    task.config = SimpleNamespace(meta_demon=MetaDemon.model_validate({
+        'meta_demon_config': {
+            'meta_crafting_card': False,
+            'md_fatigue_summon_first': enabled,
+        },
+        'switch_soul': {'enable': False, 'enable_switch_by_name': False},
+    }))
+    visible = {task.I_BATTLE_DEMON.name}
+    visible.add(task.I_BOSS_CONVENE.name if own_boss else task.I_BOSS_EMPTY.name)
+    task.appear = lambda rule, **kwargs: rule.name in visible
+    task.screenshot = lambda: None
+    task.enter = lambda *args: None
+    task.ocr_appear = lambda rule: True
+    task.current_exhaustion = lambda: fatigue
+    task.is_star56 = lambda: False
+    task.ui_click = lambda *args, **kwargs: True
+    task.set_next_run = lambda **kwargs: None
+    selected = []
+    task.click = lambda rule, **kwargs: selected.append(
+        'own' if rule is task.I_BOSS_EMPTY else 'shared')
+
+    def summon():
+        assert selected == []
+        raise ActionSelected('summon')
+
+    def battle(*args):
+        raise ActionSelected(selected[-1])
+
+    task.find_demon = summon
+    task.battle_boss = battle
+    if expected == 'exit':
+        with pytest.raises(TaskEnd):
+            task.run()
+    else:
+        with pytest.raises(ActionSelected, match=expected):
+            task.run()
+
+
+def test_existing_saved_configs_get_default_and_preserve_opt_out():
+    old = MetaDemon.model_validate({'meta_demon_config': {'auto_shared_boss': False}})
+    assert old.meta_demon_config.md_fatigue_summon_first is True
+    assert old.meta_demon_config.auto_shared_boss is False
+    saved = old.model_dump()
+    saved['meta_demon_config']['md_fatigue_summon_first'] = False
+    assert MetaDemon.model_validate(saved).meta_demon_config.md_fatigue_summon_first is False