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

Merge pull request #418 from qiyh99/master

增加英杰试炼功能
huangrunheng 2 лет назад
Родитель
Сommit
c50c0b053c
34 измененных файлов с 719 добавлено и 13 удалено
  1. 3 0
      .gitignore
  2. 27 0
      config/template.json
  3. 1 3
      module/config/config_manual.py
  4. 8 2
      module/config/config_menu.py
  5. 5 6
      module/config/config_model.py
  6. BIN
      tasks/HeroTest/as/as_back.png
  7. BIN
      tasks/HeroTest/as/as_battle.png
  8. BIN
      tasks/HeroTest/as/as_bcmj.png
  9. BIN
      tasks/HeroTest/as/as_bcmj__defalut_attribute.png
  10. BIN
      tasks/HeroTest/as/as_bcmj_battle.png
  11. BIN
      tasks/HeroTest/as/as_bcmj_bless.png
  12. BIN
      tasks/HeroTest/as/as_bcmj_lock.png
  13. BIN
      tasks/HeroTest/as/as_bcmj_property_add_critical.png
  14. BIN
      tasks/HeroTest/as/as_bcmj_reset_close.png
  15. BIN
      tasks/HeroTest/as/as_bcmj_reset_confirm.png
  16. BIN
      tasks/HeroTest/as/as_bcmj_skill_add1.png
  17. BIN
      tasks/HeroTest/as/as_bcmj_skill_add2.png
  18. BIN
      tasks/HeroTest/as/as_bcmj_skill_add_confirm.png
  19. BIN
      tasks/HeroTest/as/as_bcmj_unlock.png
  20. BIN
      tasks/HeroTest/as/as_bcmj_win.png
  21. BIN
      tasks/HeroTest/as/as_gbb.png
  22. BIN
      tasks/HeroTest/as/as_gbb_back.png
  23. BIN
      tasks/HeroTest/as/as_gbb_back2.png
  24. BIN
      tasks/HeroTest/as/as_lock.png
  25. BIN
      tasks/HeroTest/as/as_one.png
  26. BIN
      tasks/HeroTest/as/as_two.png
  27. BIN
      tasks/HeroTest/as/as_unlock.png
  28. 191 0
      tasks/HeroTest/as/image.json
  29. 29 0
      tasks/HeroTest/as/ocr.json
  30. 66 0
      tasks/HeroTest/assets.py
  31. 39 0
      tasks/HeroTest/config.py
  32. 310 0
      tasks/HeroTest/script_task.py
  33. 17 1
      tasks/Orochi/config.py
  34. 23 1
      tasks/Orochi/script_task.py

+ 3 - 0
.gitignore

@@ -38,6 +38,9 @@ hya
 deploy/launcher/oas-backend.bat
 deploy/launcher/oas-server.bat
 oas-backend.bat
+.eslintignore
+.eslintrc.js
+.prettierrc.js
 
 
 

+ 27 - 0
config/template.json

@@ -920,6 +920,33 @@
       "enable_switch_by_name": false,
       "group_name": "",
       "team_name": ""
+    },
+    "hero_test": {
+      "scheduler": {
+        "enable": false,
+        "next_run": "2023-01-01 00:00:00",
+        "priority": 5,
+        "success_interval": "01 00:00:00",
+        "failure_interval": "01 00:00:00",
+        "server_update": "19:00:00",
+        "float_time": "00:00:00"
+      },
+      "herotest_config": {
+        "layer": "鬼兵演武",
+        "limit_time": "00:30:00",
+        "limit_count": 30,
+        "exp_50_buff_enable_help": false,
+        "exp_100_buff_enable_help": false
+      },
+      "general_battle_config": {
+        "lock_team_enable": false,
+        "preset_enable": false,
+        "preset_group": 1,
+        "preset_team": 1,
+        "green_enable": false,
+        "green_mark": "green_left1",
+        "random_click_swipt_enable": false
+      }
     }
   } 
 }

+ 1 - 3
module/config/config_manual.py

@@ -14,7 +14,7 @@ class ConfigManual:
         > Dokan > Hunt 
         > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea > SixRealms
         > ActivityShikigami > WantedQuests
-        > BondlingFairyland > EvoZone > GoryouRealm
+        > BondlingFairyland > EvoZone > GoryouRealm > HeroTest
         > TrueOrochi > RichMan
         > CollectiveMissions
         > Pets > TalismanPass > SoulsTidy > Delegation > Hyakkiyakou
@@ -36,5 +36,3 @@ class ConfigManual:
     MINITOUCH_FILEPATH_REMOTE = '/data/local/tmp/minitouch'
 
     HERMIT_FILEPATH_LOCAL = './bin/hermit/hermit.apk'
-
-

+ 8 - 2
module/config/config_menu.py

@@ -25,8 +25,14 @@ class ConfigMenu:
                                    'TalismanPass', 'DemonEncounter', 'Pets', 'SoulsTidy', 'Delegation', 'WantedQuests',
                                    'Tako']
         # 很肝的任务
-        self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone', 'GoryouRealm', 'Exploration',
-                                                'Hyakkiyakou']
+        self.menu["Liver Emperor Exclusive"] = [
+            "BondlingFairyland",
+            "EvoZone",
+            "GoryouRealm",
+            "Exploration",
+            "Hyakkiyakou",
+            "HeroTest",
+        ]
         # 阴阳寮
         self.menu["Guild"] = ['KekkaiUtilize', 'KekkaiActivation', 'RealmRaid', 'RyouToppa', 'Dokan', 'CollectiveMissions',
                               'Hunt']

+ 5 - 6
module/config/config_model.py

@@ -59,6 +59,8 @@ from tasks.BondlingFairyland.config import BondlingFairyland
 from tasks.EvoZone.config import EvoZone
 from tasks.GoryouRealm.config import GoryouRealm
 from tasks.Hyakkiyakou.config import Hyakkiyakou
+from tasks.HeroTest.config import HeroTest
+
 # ----------------------------------------------------------------------------------------------------------------------
 
 # 每周任务---------------------------------------------------------------------------------------------------------------
@@ -115,6 +117,7 @@ class ConfigModel(ConfigBase):
     evo_zone: EvoZone = Field(default_factory=EvoZone)
     goryou_realm: GoryouRealm = Field(default_factory=GoryouRealm)
     hyakkiyakou: Hyakkiyakou = Field(default_factory=Hyakkiyakou)
+    hero_test: HeroTest = Field(default_factory=HeroTest)
 
     # 这些是每周任务
     true_orochi: TrueOrochi = Field(default_factory=TrueOrochi)
@@ -157,8 +160,6 @@ class ConfigModel(ConfigBase):
         logger.info("auto save config")
         self.save()
 
-
-
     @staticmethod
     def read_json(config_name: str) -> dict:
         """
@@ -282,7 +283,7 @@ class ConfigModel(ConfigBase):
         except (AttributeError, KeyError):
             return False
 
-# ----------------------------------- fastapi -----------------------------------
+    # ----------------------------------- fastapi -----------------------------------
     def script_task(self, task: str) -> dict:
         """
 
@@ -377,7 +378,7 @@ class ConfigModel(ConfigBase):
         if argument_object is None:
             logger.error(f'Set arg {task}.{group}.{argument}.{value} failed')
             return False
-        
+
         # XXX temp implementation to enable oasx control the datetime configuration globally rather than a single task
         if task == "restart" and group == "task_config" and argument == "reset_task_datetime_enable" and value == True:
             date_time = self.restart.task_config.reset_task_datetime
@@ -432,5 +433,3 @@ if __name__ == "__main__":
 
     # c.save()
     print(c.script_task('Orochi'))
-
-

BIN
tasks/HeroTest/as/as_back.png


BIN
tasks/HeroTest/as/as_battle.png


BIN
tasks/HeroTest/as/as_bcmj.png


BIN
tasks/HeroTest/as/as_bcmj__defalut_attribute.png


BIN
tasks/HeroTest/as/as_bcmj_battle.png


BIN
tasks/HeroTest/as/as_bcmj_bless.png


BIN
tasks/HeroTest/as/as_bcmj_lock.png


BIN
tasks/HeroTest/as/as_bcmj_property_add_critical.png


BIN
tasks/HeroTest/as/as_bcmj_reset_close.png


BIN
tasks/HeroTest/as/as_bcmj_reset_confirm.png


BIN
tasks/HeroTest/as/as_bcmj_skill_add1.png


BIN
tasks/HeroTest/as/as_bcmj_skill_add2.png


BIN
tasks/HeroTest/as/as_bcmj_skill_add_confirm.png


BIN
tasks/HeroTest/as/as_bcmj_unlock.png


BIN
tasks/HeroTest/as/as_bcmj_win.png


BIN
tasks/HeroTest/as/as_gbb.png


BIN
tasks/HeroTest/as/as_gbb_back.png


BIN
tasks/HeroTest/as/as_gbb_back2.png


BIN
tasks/HeroTest/as/as_lock.png


BIN
tasks/HeroTest/as/as_one.png


BIN
tasks/HeroTest/as/as_two.png


BIN
tasks/HeroTest/as/as_unlock.png


+ 191 - 0
tasks/HeroTest/as/image.json

@@ -0,0 +1,191 @@
+[
+  {
+    "itemName": "one",
+    "imageName": "as_one.png",
+    "roiFront": "633,106,88,105",
+    "roiBack": "633,106,88,105",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "进入活动第一步"
+  },
+  {
+    "itemName": "two",
+    "imageName": "as_two.png",
+    "roiFront": "819,685,95,26",
+    "roiBack": "819,685,95,26",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "进入活动第二步"
+  },
+  {
+    "itemName": "gbb",
+    "imageName": "as_gbb.png",
+    "roiFront": "95,344,37,131",
+    "roiBack": "95,344,37,131",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "点击鬼兵演武"
+  },
+  {
+    "itemName": "gbb_back",
+    "imageName": "as_gbb_back.png",
+    "roiFront": "11,13,63,56",
+    "roiBack": "11,13,63,56",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "爬塔返回按钮"
+  },
+  {
+    "itemName": "back",
+    "imageName": "as_back.png",
+    "roiFront": "20,24,75,76",
+    "roiBack": "20,24,75,76",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "鬼兵演武返回按钮"
+  },
+  {
+    "itemName": "battle",
+    "imageName": "as_battle.png",
+    "roiFront": "1129,588,99,49",
+    "roiBack": "1129,588,99,49",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "挑战按钮"
+  },
+  {
+    "itemName": "unlock",
+    "imageName": "as_unlock.png",
+    "roiFront": "817,648,33,31",
+    "roiBack": "817,648,33,31",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "解锁阵容"
+  },
+  {
+    "itemName": "lock",
+    "imageName": "as_lock.png",
+    "roiFront": "816,644,36,38",
+    "roiBack": "816,644,36,38",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "bcmj",
+    "imageName": "as_bcmj.png",
+    "roiFront": "1086,350,45,131",
+    "roiBack": "1086,350,45,131",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "兵藏秘境"
+  },
+  {
+    "itemName": "bcmj_lock",
+    "imageName": "as_bcmj_lock.png",
+    "roiFront": "901,159.5,36,26",
+    "roiBack": "901,650,36,38",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "兵藏秘境阵容锁"
+  },
+  {
+    "itemName": "bcmj_battle",
+    "imageName": "as_bcmj_battle.png",
+    "roiFront": "1131,598,92,50",
+    "roiBack": "1131,598,92,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "兵藏秘境挑战"
+  },
+  {
+    "itemName": "bcmj_win",
+    "imageName": "as_bcmj_win.png",
+    "roiFront": "431,141,100,100",
+    "roiBack": "431,141,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "兵藏秘境胜利"
+  },
+  {
+    "itemName": "bcmj_skill_add1",
+    "imageName": "as_bcmj_skill_add1.png",
+    "roiFront": "109,361,90,32",
+    "roiBack": "103,359,1076,37",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "兵藏秘境选择八华斩"
+  },
+  {
+    "itemName": "bcmj_skill_add2",
+    "imageName": "as_bcmj_skill_add2.png",
+    "roiFront": "728,359,61,32",
+    "roiBack": "106,356,1068,38",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "技能选择 无畏"
+  },
+  {
+    "itemName": "bcmj_skill_add_confirm",
+    "imageName": "as_bcmj_skill_add_confirm.png",
+    "roiFront": "608,633,64,36",
+    "roiBack": "608,633,64,36",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "技能祝福确定"
+  },
+  {
+    "itemName": "bcmj_property_add_critical",
+    "imageName": "as_bcmj_property_add_critical.png",
+    "roiFront": "704,359,115,34",
+    "roiBack": "120,356,1038,39",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "兵藏秘境的暴击伤害属性奖励"
+  },
+  {
+    "itemName": "bcmj_bless",
+    "imageName": "as_bcmj_bless.png",
+    "roiFront": "261,159,21,20",
+    "roiBack": "256,156,939,27",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "兵藏秘境默认祝福"
+  },
+  {
+    "itemName": "bcmj__defalut_attribute",
+    "imageName": "as_bcmj__defalut_attribute.png",
+    "roiFront": "1168,159,21,22",
+    "roiBack": "255,155,944,31",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "默认属性"
+  },
+  {
+    "itemName": "bcmj_unlock",
+    "imageName": "as_bcmj_unlock.png",
+    "roiFront": "906,652,22,30",
+    "roiBack": "906,652,22,30",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "兵藏秘境的阵容未锁"
+  },
+  {
+    "itemName": "bcmj_reset_confirm",
+    "imageName": "as_bcmj_reset_confirm.png",
+    "roiFront": "668,399,180,70",
+    "roiBack": "668,399,180,70",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "通过兵藏秘境确认重置按钮"
+  },
+  {
+    "itemName": "bcmj_reset_close",
+    "imageName": "as_bcmj_reset_close.png",
+    "roiFront": "429,397,186,71",
+    "roiBack": "429,397,186,71",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "通过兵藏秘境取消重置按钮"
+  }
+]

+ 29 - 0
tasks/HeroTest/as/ocr.json

@@ -0,0 +1,29 @@
+[
+  {
+    "itemName": "remain_ap",
+    "roiFront": "1095,24,123,33",
+    "roiBack": "1095,24,123,33",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "投喂的体力"
+  },
+  {
+    "itemName": "art_war_card",
+    "roiFront": "712,21,98,36",
+    "roiBack": "712,21,98,36",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "兵藏秘境兵道帖"
+  },
+  {
+    "itemName": "art_war_card_plus",
+    "roiFront": "916,25,90,29",
+    "roiBack": "916,25,90,29",
+    "mode": "SINGLE",
+    "method": "Default",
+    "keyword": "",
+    "description": "兵道帖机密"
+  }
+]

+ 66 - 0
tasks/HeroTest/assets.py

@@ -0,0 +1,66 @@
+from module.atom.image import RuleImage
+from module.atom.click import RuleClick
+from module.atom.long_click import RuleLongClick
+from module.atom.swipe import RuleSwipe
+from module.atom.ocr import RuleOcr
+from module.atom.list import RuleList
+
+# This file was automatically generated by ./dev_tools/assets_extract.py.
+# Don't modify it manually.
+class HeroTestAssets: 
+
+
+	# Image Rule Assets
+	# 进入活动第一步 
+	I_ONE = RuleImage(roi_front=(633,106,88,105), roi_back=(633,106,88,105), threshold=0.7, method="Template matching", file="./tasks/HeroTest/as/as_one.png")
+	# 进入活动第二步 
+	I_TWO = RuleImage(roi_front=(819,685,95,26), roi_back=(819,685,95,26), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_two.png")
+	# 点击鬼兵演武 
+	I_GBB = RuleImage(roi_front=(95,344,37,131), roi_back=(95,344,37,131), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_gbb.png")
+	# 爬塔返回按钮 
+	I_GBB_BACK = RuleImage(roi_front=(11,13,63,56), roi_back=(11,13,63,56), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_gbb_back.png")
+	# 鬼兵演武返回按钮 
+	I_BACK = RuleImage(roi_front=(20,24,75,76), roi_back=(20,24,75,76), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_back.png")
+	# 挑战按钮 
+	I_BATTLE = RuleImage(roi_front=(1129,588,99,49), roi_back=(1129,588,99,49), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_battle.png")
+	# 解锁阵容 
+	I_UNLOCK = RuleImage(roi_front=(817,648,33,31), roi_back=(817,648,33,31), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_unlock.png")
+	# description 
+	I_LOCK = RuleImage(roi_front=(816,644,36,38), roi_back=(816,644,36,38), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_lock.png")
+	# 兵藏秘境 
+	I_BCMJ = RuleImage(roi_front=(1086,350,45,131), roi_back=(1086,350,45,131), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj.png")
+	# 兵藏秘境阵容锁 
+	I_BCMJ_LOCK = RuleImage(roi_front=(901,159.5,36,26), roi_back=(901,650,36,38), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj_lock.png")
+	# 兵藏秘境挑战 
+	I_BCMJ_BATTLE = RuleImage(roi_front=(1131,598,92,50), roi_back=(1131,598,92,50), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj_battle.png")
+	# 兵藏秘境胜利 
+	I_BCMJ_WIN = RuleImage(roi_front=(431,141,100,100), roi_back=(431,141,100,100), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj_win.png")
+	# 兵藏秘境选择八华斩 
+	I_BCMJ_SKILL_ADD1 = RuleImage(roi_front=(109,361,90,32), roi_back=(103,359,1076,37), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj_skill_add1.png")
+	# 技能选择 无畏 
+	I_BCMJ_SKILL_ADD2 = RuleImage(roi_front=(728,359,61,32), roi_back=(106,356,1068,38), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj_skill_add2.png")
+	# 技能祝福确定 
+	I_BCMJ_SKILL_ADD_CONFIRM = RuleImage(roi_front=(608,633,64,36), roi_back=(608,633,64,36), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj_skill_add_confirm.png")
+	# 兵藏秘境的暴击伤害属性奖励 
+	I_BCMJ_PROPERTY_ADD_CRITICAL = RuleImage(roi_front=(704,359,115,34), roi_back=(120,356,1038,39), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj_property_add_critical.png")
+	# 兵藏秘境默认祝福 
+	I_BCMJ_BLESS = RuleImage(roi_front=(261,159,21,20), roi_back=(256,156,939,27), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj_bless.png")
+	# 默认属性 
+	I_BCMJ__DEFALUT_ATTRIBUTE = RuleImage(roi_front=(1168,159,21,22), roi_back=(255,155,944,31), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj__defalut_attribute.png")
+	# 兵藏秘境的阵容未锁 
+	I_BCMJ_UNLOCK = RuleImage(roi_front=(906,652,22,30), roi_back=(906,652,22,30), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj_unlock.png")
+	# 通过兵藏秘境确认重置按钮 
+	I_BCMJ_RESET_CONFIRM = RuleImage(roi_front=(668,399,180,70), roi_back=(668,399,180,70), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj_reset_confirm.png")
+	# 通过兵藏秘境取消重置按钮 
+	I_BCMJ_RESET_CLOSE = RuleImage(roi_front=(429,397,186,71), roi_back=(429,397,186,71), threshold=0.8, method="Template matching", file="./tasks/HeroTest/as/as_bcmj_reset_close.png")
+
+
+	# Ocr Rule Assets
+	# 投喂的体力 
+	O_REMAIN_AP = RuleOcr(roi=(1095,24,123,33), area=(1095,24,123,33), mode="DigitCounter", method="Default", keyword="", name="remain_ap")
+	# 兵藏秘境兵道帖 
+	O_ART_WAR_CARD = RuleOcr(roi=(712,21,98,36), area=(712,21,98,36), mode="DigitCounter", method="Default", keyword="", name="art_war_card")
+	# 兵道帖机密 
+	O_ART_WAR_CARD_PLUS = RuleOcr(roi=(916,25,90,29), area=(916,25,90,29), mode="SINGLE", method="Default", keyword="", name="art_war_card_plus")
+
+

+ 39 - 0
tasks/HeroTest/config.py

@@ -0,0 +1,39 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from enum import Enum  # type: ignore
+from datetime import datetime, time  # type: ignore
+from pydantic import BaseModel, Field
+
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.config_scheduler import Scheduler
+from tasks.Component.config_base import ConfigBase, Time, TimeDelta
+from tasks.Component.BaseActivity.config_activity import GeneralClimb
+
+
+class Layer(str, Enum):
+    YANWU: str = "鬼兵演武"
+    MIJING: str = "兵藏秘境"
+
+
+class HeroTestConfig(BaseModel):
+    # 副本选择
+    layer: Layer = Field(
+        default=Layer.YANWU,
+        description="选择要打的关卡,兵藏秘境默认不开经验加成。\n升级顺序八华斩->无畏 -> 暴击伤害 -> 默认祝福 -> 默认属性",
+    )
+    # 限制时间
+    limit_time: Time = Field(default=Time(minute=30), description="limit_time_help")
+    # 限制次数
+    limit_count: int = Field(default=100, description="limit_count_help")
+    # 是否开启经验加成
+    exp_50_buff_enable_help: bool = Field(default=False, description="打开经验50%加成")
+    exp_100_buff_enable_help: bool = Field(
+        default=False, description="打开经验100%加成"
+    )
+
+
+class HeroTest(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    herotest: HeroTestConfig = Field(default_factory=HeroTestConfig)
+    general_battle: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)

+ 310 - 0
tasks/HeroTest/script_task.py

@@ -0,0 +1,310 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from datetime import datetime, timedelta, time
+import random  # type: ignore
+
+from tasks.Component.BaseActivity.base_activity import BaseActivity
+from tasks.HeroTest.assets import HeroTestAssets
+from tasks.GameUi.page import page_main
+from tasks.GameUi.game_ui import GameUi
+
+from module.logger import logger
+from module.exception import TaskEnd
+
+
+class ScriptTask(GameUi, BaseActivity, HeroTestAssets):
+
+    is_update = False
+    is_skill = False
+
+    def run(self) -> None:
+
+        config = self.config.hero_test
+        global is_update
+        global is_skill
+        if config.herotest.layer.value == "鬼兵演武":
+            is_update = True
+            is_skill = False
+        if config.herotest.layer.value == "兵藏秘境":
+            is_skill = True
+            is_update = False
+
+        self.limit_time: timedelta = config.herotest.limit_time
+        if isinstance(self.limit_time, time):
+            self.limit_time = timedelta(
+                hours=self.limit_time.hour,
+                minutes=self.limit_time.minute,
+                seconds=self.limit_time.second,
+            )
+        self.limit_count = config.herotest.limit_count
+
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+        self.home_main()
+        # 设定是否锁定阵容
+        if is_update:
+            if config.general_battle.lock_team_enable:
+                logger.info("Lock team")
+                while 1:
+                    self.screenshot()
+                    if self.appear_then_click(self.I_UNLOCK, interval=1):
+                        continue
+                    if self.appear(self.I_LOCK):
+                        break
+            else:
+                logger.info("Unlock team")
+                while 1:
+                    self.screenshot()
+                    if self.appear_then_click(self.I_LOCK, interval=1):
+                        continue
+                    if self.appear(self.I_UNLOCK):
+                        break
+        elif is_skill:
+            if config.general_battle.lock_team_enable:
+                logger.info("Lock team")
+                while 1:
+                    self.screenshot()
+                    if self.appear_then_click(self.I_BCMJ_UNLOCK, interval=1):
+                        continue
+                    if self.appear(self.I_BCMJ_LOCK):
+                        break
+            else:
+                logger.info("Unlock team")
+                while 1:
+                    self.screenshot()
+                    if self.appear_then_click(self.I_BCMJ_LOCK, interval=1):
+                        continue
+                    if self.appear(self.I_BCMJ_UNLOCK):
+                        break
+
+        while 1:
+            # 1
+            if (
+                self.limit_time is not None
+                and self.limit_time + self.start_time < datetime.now()
+            ):
+                logger.info("Time out")
+                break
+            if self.current_count >= self.limit_count:
+                logger.info("Count out")
+                break
+            # 2
+            if is_update:
+                self.wait_until_appear(self.I_BATTLE)
+            if is_skill:
+                self.wait_until_appear(self.I_BCMJ_BATTLE)
+
+            # 如果是兵藏秘境 看看是否有兵道帖
+            if is_skill:
+                if not self.check_art_war_card():
+                    logger.info("Art war card is enough")
+                    break
+            # 点击战斗
+            logger.info("Click battle")
+            while 1:
+                self.screenshot()
+                if is_update:
+                    if self.appear_then_click(self.I_BATTLE, interval=2):
+                        self.device.stuck_record_clear()
+                        continue
+                    if not self.appear(self.I_BATTLE):
+                        break
+                elif is_skill:
+                    if self.appear_then_click(self.I_BCMJ_RESET_CONFIRM, interval=1):
+                        continue
+                    if self.appear_then_click(self.I_BCMJ_BATTLE, interval=2):
+                        self.device.stuck_record_clear()
+                        continue
+                    if not self.appear(self.I_BCMJ_BATTLE):
+                        break
+
+            if self.run_general_battle(config=config.general_battle):
+                logger.info("General battle success")
+
+        self.main_home()
+        self.set_next_run(task="HeroTest", success=True)
+        raise TaskEnd
+
+    def battle_wait(self, random_click_swipt_enable: bool) -> bool:
+        self.device.stuck_record_add("BATTLE_STATUS_S")
+        self.device.click_record_clear()
+        logger.info("Start battle process")
+        win: bool = False
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_WIN, threshold=0.8) or self.appear(self.I_DE_WIN):
+                logger.info("Battle result is win")
+                if self.appear(self.I_DE_WIN):
+                    self.ui_click_until_disappear(self.I_DE_WIN)
+                win = True
+                break
+
+            # 如果出现失败 就点击,返回False
+            if self.appear(self.I_FALSE, threshold=0.8):
+                logger.info("Battle result is false")
+                win = False
+                break
+
+            # 如果领奖励
+            if self.appear(self.I_REWARD, threshold=0.6):
+                win = True
+                break
+
+            # 如果领奖励出现金币
+            if self.appear(self.I_REWARD_GOLD, threshold=0.8):
+                win = True
+                break
+            # 如果开启战斗过程随机滑动
+            if random_click_swipt_enable:
+                self.random_click_swipt()
+
+        # 再次确认战斗结果
+        logger.info("Reconfirm the results of the battle")
+        while 1:
+            self.screenshot()
+            if win:
+                # 点击赢了
+                action_click = random.choice([self.C_WIN_1, self.C_WIN_2, self.C_WIN_3])
+                if self.appear_then_click(
+                    self.I_WIN, action=action_click, interval=0.5
+                ):
+                    continue
+                if not self.appear(self.I_WIN):
+                    break
+            else:
+                # 如果失败且 点击失败后
+                if self.appear_then_click(self.I_FALSE, threshold=0.6):
+                    continue
+                if not self.appear(self.I_FALSE, threshold=0.6):
+                    return False
+        # 最后保证能点击 获得奖励
+        if not is_skill and not self.wait_until_appear(self.I_REWARD, wait_time=2):
+            # 有些的战斗没有下面的奖励,所以直接返回
+            logger.info("There is no reward, Exit battle")
+            return win
+        else:
+            if self.wait_until_appear(self.I_BCMJ_SKILL_ADD_CONFIRM, wait_time=2):
+                while 1:
+                    self.screenshot()
+                    if self.appear_then_click(self.I_BCMJ_SKILL_ADD1, interval=1):
+                        break
+                    if self.appear_then_click(self.I_BCMJ_SKILL_ADD2, interval=1):
+                        break
+                    if self.appear_then_click(
+                        self.I_BCMJ_PROPERTY_ADD_CRITICAL, interval=1
+                    ):
+                        break
+                    if self.appear_then_click(self.I_BCMJ_BLESS, interval=1):
+                        break
+                    if self.appear_then_click(
+                        self.I_BCMJ__DEFALUT_ATTRIBUTE, interval=1
+                    ):
+                        break
+                if self.appear_then_click(self.I_BCMJ_SKILL_ADD_CONFIRM, interval=1):
+                    return win
+
+        logger.info("Get reward")
+        while 1:
+            self.screenshot()
+            # 如果出现领奖励
+            action_click = random.choice(
+                [self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3]
+            )
+            if self.appear_then_click(
+                self.I_REWARD, action=action_click, interval=1.5
+            ) or self.appear_then_click(
+                self.I_REWARD_GOLD, action=action_click, interval=1.5
+            ):
+                continue
+            if not self.appear(self.I_REWARD) and not self.appear(self.I_REWARD_GOLD):
+                break
+
+        return win
+
+    def check_art_war_card(self):
+        self.screenshot()
+        cu = self.O_ART_WAR_CARD.ocr(image=self.device.image)
+        if cu[0] >= 1:
+            logger.info("Art war card is enough")
+            return True
+        cu = self.O_ART_WAR_CARD_PLUS.ocr(image=self.device.image)
+        # 转换为int
+        if cu != "":
+            cu = int(cu)
+        else:
+            cu = 0
+        if cu >= 1:
+            logger.info("Art war card is not enough, but plus card is enough")
+            return True
+        return False
+
+    def home_main(self) -> bool:
+        """
+        从庭院到活动的爬塔界面
+        :return:
+        """
+        logger.hr("Enter HeroTest", 2)
+        global is_update
+        global is_skill
+        # 启动经验加成
+        if is_update:
+            self.open_buff()
+            self.exp_100(True)
+            self.exp_50(True)
+            self.close_buff()
+        while 1:
+            self.screenshot()
+            if is_update:
+                if self.appear(self.I_BATTLE):
+                    break
+            if is_skill:
+                if self.appear(self.I_BCMJ_BATTLE):
+                    break
+            if self.appear_then_click(self.I_ONE, interval=1):
+                continue
+            if self.appear_then_click(self.I_TWO, interval=1):
+                continue
+            if is_update:
+                if self.appear_then_click(self.I_GBB, interval=1):
+                    continue
+            if is_skill:
+                if self.appear_then_click(self.I_BCMJ, interval=1):
+                    continue
+
+    def main_home(self) -> bool:
+        """
+        从活动的爬塔界面到庭院
+        :return:
+        """
+        logger.hr("Exit HeroTest", 2)
+        global is_update
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_ONE):
+                if is_update:
+                    # 关闭经验加成
+                    self.open_buff()
+                    self.exp_100(False)
+                    self.exp_50(False)
+                    self.close_buff()
+                break
+            if self.appear_then_click(self.I_UI_BACK_RED, interval=2):
+                continue
+            if self.appear_then_click(self.I_UI_BACK_YELLOW, interval=2):
+                continue
+            if self.appear_then_click(self.I_BACK, interval=2):
+                continue
+            if self.appear_then_click(self.I_GBB_BACK, interval=2):
+                continue
+
+
+if __name__ == "__main__":
+    from module.config.config import Config
+    from module.device.device import Device
+
+    c = Config("oas1")
+    d = Device(c)
+    t = ScriptTask(c, d)
+
+    t.run()

+ 17 - 1
tasks/Orochi/config.py

@@ -5,7 +5,7 @@ from pydantic import BaseModel, Field
 from enum import Enum
 from datetime import datetime, time
 
-from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
+from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig as BaseSwitchSoulConfig
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_base import ConfigBase, Time
 from tasks.Component.GeneralInvite.config_invite import InviteConfig
@@ -44,9 +44,25 @@ class OrochiConfig(ConfigBase):
     # 是否开启御魂加成
     soul_buff_enable: bool = Field(default=False, description='soul_buff_enable_help')
 
+class SwitchSoulConfig(BaseSwitchSoulConfig):
+    enable: bool = Field(default=False)
+    switch_group_team: str = Field(default='-1,-1', description='switch_group_team_help')
+    enable_switch_by_name: bool = Field(default=False, description='enable_switch_by_name_help')
+    group_name: str = Field(default='')
+    team_name: str = Field(default='')
+    auto_switch_soul: bool = Field(default=False, description='auto_switch_soul_help')
+    # 十层 config
+    # ten_switch: str = Field(default='-1,-1', description='ten_switch_help')
+    # 悲鸣 config
+    eleven_switch: str = Field(default='-1,-1', description='eleven_switch_help')
+    # 神罚 config
+    twelve_switch: str = Field(default='-1,-1', description='twelve_switch_help')
+
+
 class Orochi(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     orochi_config: OrochiConfig = Field(default_factory=OrochiConfig)
     invite_config: InviteConfig = Field(default_factory=InviteConfig)
     general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
     switch_soul: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
+

+ 23 - 1
tasks/Orochi/script_task.py

@@ -13,7 +13,7 @@ from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.page import page_main, page_soul_zones, page_shikigami_records
 from tasks.Orochi.assets import OrochiAssets
-from tasks.Orochi.config import Orochi, UserStatus
+from tasks.Orochi.config import Orochi, UserStatus, Layer
 from module.logger import logger
 from module.exception import TaskEnd
 
@@ -32,6 +32,8 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
             self.ui_goto(page_shikigami_records)
             self.run_switch_soul_by_name(self.config.orochi.switch_soul.group_name,
                                          self.config.orochi.switch_soul.team_name)
+        # 根据选层切换御魂
+        self.orochi_switch_soul()
 
         limit_count = self.config.orochi.orochi_config.limit_count
         limit_time = self.config.orochi.orochi_config.limit_time
@@ -471,6 +473,26 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
             if random_click_swipt_enable:
                 self.random_click_swipt()
 
+    def orochi_switch_soul(self) -> None:
+        # 判断是否开启根据选层切换御魂
+        orochi_switch_soul = self.config.orochi.switch_soul
+        if not orochi_switch_soul.auto_switch_soul:
+            return
+
+        group_team: str = None
+        layer = self.config.orochi.orochi_config.layer
+        match layer:
+            # case Layer.TEN:
+            #     group_team = orochi_switch_soul.ten_switch
+            case Layer.ELEVEN:
+                group_team = orochi_switch_soul.eleven_switch
+            case Layer.TWELVE:
+                group_team = orochi_switch_soul.twelve_switch
+
+        if orochi_switch_soul.auto_switch_soul:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul(group_team)
 
 
 if __name__ == '__main__':