Browse Source

Merge pull request #79 from endlesswxk/dev

add exploration
huangrunheng 3 years ago
parent
commit
2f06662887
31 changed files with 694 additions and 35 deletions
  1. 1 1
      module/config/config_manual.py
  2. 1 1
      module/config/config_menu.py
  3. 2 0
      module/config/config_model.py
  4. 86 0
      tasks/Exploration/assets.py
  5. 89 0
      tasks/Exploration/config.py
  6. 50 0
      tasks/Exploration/res/click.json
  7. 137 0
      tasks/Exploration/res/image.json
  8. 20 0
      tasks/Exploration/res/ocr.json
  9. BIN
      tasks/Exploration/res/res_battle_reward.png
  10. BIN
      tasks/Exploration/res/res_boss_battle_button.png
  11. BIN
      tasks/Exploration/res/res_e_auto_rotate_off.png
  12. BIN
      tasks/Exploration/res/res_e_auto_rotate_on.png
  13. BIN
      tasks/Exploration/res/res_e_enter_choose_rarity.png
  14. BIN
      tasks/Exploration/res/res_e_exploration_click.png
  15. BIN
      tasks/Exploration/res/res_e_exploration_open.png
  16. BIN
      tasks/Exploration/res/res_e_n_rarity.png
  17. BIN
      tasks/Exploration/res/res_e_open_settings.png
  18. BIN
      tasks/Exploration/res/res_e_ratate_exsit.png
  19. BIN
      tasks/Exploration/res/res_e_s_rarity.png
  20. BIN
      tasks/Exploration/res/res_e_settings_button.png
  21. BIN
      tasks/Exploration/res/res_e_sure_button.png
  22. BIN
      tasks/Exploration/res/res_exploration_title.png
  23. BIN
      tasks/Exploration/res/res_normal_battle_button.png
  24. 44 0
      tasks/Exploration/res/swipe.json
  25. 234 0
      tasks/Exploration/script_task.py
  26. 4 2
      tasks/RyouToppa/assets.py
  27. 13 4
      tasks/RyouToppa/res/image.json
  28. BIN
      tasks/RyouToppa/res/res_ryou_reward_90.png
  29. BIN
      tasks/RyouToppa/res/res_start_toppa_button.png
  30. BIN
      tasks/RyouToppa/res/res_success_penetration.png
  31. 13 27
      tasks/RyouToppa/script_task.py

+ 1 - 1
module/config/config_manual.py

@@ -10,7 +10,7 @@ class ConfigManual:
     SCHEDULER_PRIORITY = """
         Restart
         >KekkaiUtilize > KekkaiActivation > DemonEncounter
-        > AreaBoss > GoldYoukai > ExperienceYoukai > Nian > RealmRaid > RyouToppa > DailyTrifles
+        > AreaBoss > GoldYoukai > ExperienceYoukai > Nian > RealmRaid > RyouToppa > DailyTrifles > Exploration
         > Hunt
         > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea > ExploreZones
         > ActivityShikigami

+ 1 - 1
module/config/config_menu.py

@@ -21,7 +21,7 @@ class ConfigMenu:
         self.menu["Soul Zones"] = ['Orochi', 'Sougenbi', 'FallenSun', 'EternitySea']
         # 日常的任务
         self.menu["Daily Task"] = ['DailyTrifles', 'AreaBoss', 'GoldYoukai', 'ExperienceYoukai', 'Nian',
-                                   'TalismanPass', 'DemonEncounter', 'Pets', 'SoulsTidy', 'Delegation']
+                                   'TalismanPass', 'DemonEncounter', 'Pets', 'SoulsTidy', 'Delegation', 'Exploration']
         # 很肝的任务
         self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone', 'GoryouRealm', 'ExploreZones']
         # 阴阳寮

+ 2 - 0
module/config/config_model.py

@@ -11,6 +11,7 @@ from module.logger import logger
 
 # 导入配置的Python文件
 from tasks.Component.config_base import ConfigBase
+from tasks.Exploration.config import Exploration
 from tasks.RyouToppa.config import RyouToppa
 from tasks.Script.config import Script
 from tasks.Restart.config import Restart
@@ -79,6 +80,7 @@ class ConfigModel(ConfigBase):
     pets: Pets = Field(default_factory=Pets)
     souls_tidy: SoulsTidy = Field(default_factory=SoulsTidy)
     delegation: Delegation = Field(default_factory=Delegation)
+    exploration: Exploration = Field(default_factory=Exploration)
 
     # 这些是刷御魂的
     orochi: Orochi = Field(default_factory=Orochi)

+ 86 - 0
tasks/Exploration/assets.py

@@ -0,0 +1,86 @@
+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 ExplorationAssets: 
+
+
+	# Click Rule Assets
+	# 点击设置按钮 
+	C_CLICK_SETTINGS = RuleClick(roi_front=(55,662,21,21), roi_back=(55,662,21,21), name="click_settings")
+	# 选中候补出战 
+	C_CLICK_STANDBY_TEAM = RuleClick(roi_front=(545,222,506,100), roi_back=(545,222,506,100), name="click_standby_team")
+	# 点击全部式神按钮 
+	C_CLICK_ALL_SHIKI = RuleClick(roi_front=(31,623,65,58), roi_back=(31,623,65,58), name="click_all_shiki")
+	# 选中n阶式神 
+	C_CLICK_N_SHIKI = RuleClick(roi_front=(146,301,45,54), roi_back=(146,301,45,54), name="click_n_shiki")
+	# 位置1 
+	C_CLICK_ROTATE_1 = RuleClick(roi_front=(516,582,22,21), roi_back=(516,582,22,21), name="click_rotate_1")
+	# 位置2 
+	C_CLICK_ROTATE_2 = RuleClick(roi_front=(650,587,21,21), roi_back=(650,587,21,21), name="click_rotate_2")
+	# 位置3 
+	C_CLICK_ROTATE_3 = RuleClick(roi_front=(785,587,21,21), roi_back=(785,587,21,21), name="click_rotate_3")
+	# 位置4 
+	C_CLICK_ROTATE_4 = RuleClick(roi_front=(921,590,21,21), roi_back=(921,590,21,21), name="click_rotate_4")
+
+
+	# Image Rule Assets
+	# 进入难度选择界面 
+	I_E_EXPLORATION_OPEN = RuleImage(roi_front=(1077,248,37,80), roi_back=(1072,242,47,92), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_exploration_open.png")
+	# 探索按钮 
+	I_E_EXPLORATION_CLICK = RuleImage(roi_front=(898,518,96,42), roi_back=(898,518,96,42), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_exploration_click.png")
+	# 自动轮换开着 
+	I_E_AUTO_ROTATE_ON = RuleImage(roi_front=(104,649,153,44), roi_back=(104,649,153,44), threshold=0.9, method="Template matching", file="./tasks/Exploration/res/res_e_auto_rotate_on.png")
+	# 自动轮换关闭 
+	I_E_AUTO_ROTATE_OFF = RuleImage(roi_front=(108,650,150,46), roi_back=(108,650,150,46), threshold=0.85, method="Template matching", file="./tasks/Exploration/res/res_e_auto_rotate_off.png")
+	# 成功打开设置 
+	I_E_OPEN_SETTINGS = RuleImage(roi_front=(466,110,170,50), roi_back=(466,110,170,50), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_open_settings.png")
+	# 选择式神稀有度 
+	I_E_ENTER_CHOOSE_RARITY = RuleImage(roi_front=(34,288,62,47), roi_back=(34,288,62,47), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_enter_choose_rarity.png")
+	# 候补N卡 
+	I_E_N_RARITY = RuleImage(roi_front=(42,625,46,49), roi_back=(42,625,46,49), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_n_rarity.png")
+	# 候补素材 
+	I_E_S_RARITY = RuleImage(roi_front=(33,620,63,59), roi_back=(33,620,63,59), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_s_rarity.png")
+	# 已候补出战的狗粮 
+	I_E_RATATE_EXSIT = RuleImage(roi_front=(108,580,995,32), roi_back=(108,580,995,32), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_ratate_exsit.png")
+	# 确定按钮 
+	I_E_SURE_BUTTON = RuleImage(roi_front=(1135,426,43,37), roi_back=(1135,426,43,37), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_sure_button.png")
+	# 设置按钮 
+	I_E_SETTINGS_BUTTON = RuleImage(roi_front=(37,692,53,26), roi_back=(37,692,53,26), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_settings_button.png")
+	# 普通怪 
+	I_NORMAL_BATTLE_BUTTON = RuleImage(roi_front=(636,263,42,39), roi_back=(0,0,1279,719), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_normal_battle_button.png")
+	# boss 
+	I_BOSS_BATTLE_BUTTON = RuleImage(roi_front=(683,256,38,34), roi_back=(0,0,1276,719), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_boss_battle_button.png")
+	# 战后奖励 
+	I_BATTLE_REWARD = RuleImage(roi_front=(647,395,31,21), roi_back=(1,1,1278,718), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_battle_reward.png")
+	# 妖 
+	I_EXPLORATION_TITLE = RuleImage(roi_front=(1133,124,47,43), roi_back=(1133,124,47,43), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_exploration_title.png")
+
+
+	# Ocr Rule Assets
+	# 识别当前显示的章节 
+	O_E_EXPLORATION_LEVEL_NUMBER = RuleOcr(roi=(1079,193,147,467), area=(1079,193,147,467), mode="Full", method="Default", keyword="", name="e_exploration_level_number")
+	# 候补出战的数量 
+	O_E_ALTERNATE_NUMBER = RuleOcr(roi=(1092,122,69,32), area=(1092,122,69,32), mode="DigitCounter", method="Default", keyword="", name="e_alternate_number")
+
+
+	# Swipe Rule Assets
+	# 向上滑动章节 
+	S_SWIPE_LEVEL_UP = RuleSwipe(roi_front=(1142,328,21,21), roi_back=(1143,444,21,21), mode="default", name="swipe_level_up")
+	# 向下滑动章节 
+	S_SWIPE_LEVEL_DOWN = RuleSwipe(roi_front=(1143,486,21,21), roi_back=(1143,367,21,23), mode="default", name="swipe_level_down")
+	# 往左滑动 
+	S_SWIPE_BACKGROUND_RIGHT = RuleSwipe(roi_front=(1093,148,21,21), roi_back=(397,140,21,21), mode="default", name="swipe_background_right")
+	# 往右滑动 
+	S_SWIPE_BACKGROUND_LEFT = RuleSwipe(roi_front=(420,142,21,21), roi_back=(1183,146,21,21), mode="default", name="swipe_background_left")
+	# 滑动狗粮选择界面 
+	S_SWIPE_SHIKI_TO_LEFT = RuleSwipe(roi_front=(890,587,21,21), roi_back=(351,584,21,21), mode="default", name="swipe_shiki_to_left")
+	# 滑动一个式神的宽度 
+	S_SWIPE_SHIKI_TO_LEFT_ONE = RuleSwipe(roi_front=(977,582,21,21), roi_back=(889,584,21,22), mode="default", name="swipe_shiki_to_left_one")
+
+

+ 89 - 0
tasks/Exploration/config.py

@@ -0,0 +1,89 @@
+from pydantic import BaseModel, Field
+from enum import Enum
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
+from tasks.Component.config_base import ConfigBase
+from tasks.Component.config_scheduler import Scheduler
+
+
+class ExplorationLevel(str, Enum):
+    EXPLORATION_1 = '第一章'
+    EXPLORATION_2 = '第二章'
+    EXPLORATION_3 = '第三章'
+    EXPLORATION_4 = '第四章'
+    EXPLORATION_5 = '第五章'
+    EXPLORATION_6 = '第六章'
+    EXPLORATION_7 = '第七章'
+    EXPLORATION_8 = '第八章'
+    EXPLORATION_9 = '第九章'
+    EXPLORATION_10 = '第十章'
+    EXPLORATION_11 = '第十一章'
+    EXPLORATION_12 = '第十二章'
+    EXPLORATION_13 = '第十三章'
+    EXPLORATION_14 = '第十四章'
+    EXPLORATION_15 = '第十五章'
+    EXPLORATION_16 = '第十六章'
+    EXPLORATION_17 = '第十七章'
+    EXPLORATION_18 = '第十八章'
+    EXPLORATION_19 = '第十九章'
+    EXPLORATION_20 = '第二十章'
+    EXPLORATION_21 = '第二十一章'
+    EXPLORATION_22 = '第二十二章'
+    EXPLORATION_23 = '第二十三章'
+    EXPLORATION_24 = '第二十四章'
+    EXPLORATION_25 = '第二十五章'
+    EXPLORATION_26 = '第二十六章'
+    EXPLORATION_27 = '第二十七章'
+    EXPLORATION_28 = '第二十八章'
+
+
+class AttackNumber(str, Enum):
+    SEVEN = '7'
+    ALL = 'all'
+
+
+# class AttackRole(str, Enum):
+#     exp = '经验'
+#     gold = '金币'
+#     box = '奖励'
+#     ALL = '无所谓'
+
+
+# 是否自动添加候补式神
+class AutoRotate(str, Enum):
+    no = '不'
+    yes = '是'
+
+
+class ChooseRarity(str, Enum):
+    N = 'N卡'
+    S = '素材'
+
+
+class ExplorationConfig(BaseModel):
+    attack_number: AttackNumber = Field(title='探索次数', default=AttackNumber.SEVEN,
+                                        description='默认探索7次')
+
+    current_exploration_times: str = Field(default='0', description='探索次数')
+
+    exploration_level: ExplorationLevel = Field(title='探索等级', default=ExplorationLevel.EXPLORATION_28,
+                                                description='探索等级 默认二十八')
+
+    auto_rotate: AutoRotate = Field(title='自动添加候补式神', default=AutoRotate.no,
+                                    description='自动添加候补式神 默认 否')
+
+    # attack_role: AttackRole = Field(title='进攻的类型',
+    #                                 default=AttackRole.ALL, description='攻击的类型')
+
+    choose_rarity: ChooseRarity = Field(title='选择狗粮稀有度', default=ChooseRarity.N, description='N')
+
+
+
+class Exploration(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    exploration_config: ExplorationConfig = Field(default_factory=ExplorationConfig)
+    general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
+    switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
+    # auto_rotate_after_times: str = Field(default='30', description='探索30次后, 检测是否需要添加候补式神')
+    # go_to_realm_after_times: str = Field(default='5', description='探索5次后, 检测是否需要进行结界突破')
+

+ 50 - 0
tasks/Exploration/res/click.json

@@ -0,0 +1,50 @@
+[
+  {
+    "itemName": "click_settings",
+    "roiFront": "55,662,21,21",
+    "roiBack": "55,662,21,21",
+    "description": "点击设置按钮"
+  },
+  {
+    "itemName": "click_standby_team",
+    "roiFront": "545,222,506,100",
+    "roiBack": "545,222,506,100",
+    "description": "选中候补出战"
+  },
+  {
+    "itemName": "click_all_shiki",
+    "roiFront": "31,623,65,58",
+    "roiBack": "31,623,65,58",
+    "description": "点击全部式神按钮"
+  },
+  {
+    "itemName": "click_n_shiki",
+    "roiFront": "146,301,45,54",
+    "roiBack": "146,301,45,54",
+    "description": "选中n阶式神"
+  },
+  {
+    "itemName": "click_rotate_1",
+    "roiFront": "516,582,22,21",
+    "roiBack": "516,582,22,21",
+    "description": "位置1"
+  },
+  {
+    "itemName": "click_rotate_2",
+    "roiFront": "650,587,21,21",
+    "roiBack": "650,587,21,21",
+    "description": "位置2"
+  },
+  {
+    "itemName": "click_rotate_3",
+    "roiFront": "785,587,21,21",
+    "roiBack": "785,587,21,21",
+    "description": "位置3"
+  },
+  {
+    "itemName": "click_rotate_4",
+    "roiFront": "921,590,21,21",
+    "roiBack": "921,590,21,21",
+    "description": "位置4"
+  }
+]

+ 137 - 0
tasks/Exploration/res/image.json

@@ -0,0 +1,137 @@
+[
+  {
+    "itemName": "e_exploration_open",
+    "imageName": "res_e_exploration_open.png",
+    "roiFront": "1077,248,37,80",
+    "roiBack": "1072,242,47,92",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "进入难度选择界面"
+  },
+  {
+    "itemName": "e_exploration_click",
+    "imageName": "res_e_exploration_click.png",
+    "roiFront": "898,518,96,42",
+    "roiBack": "898,518,96,42",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "探索按钮"
+  },
+  {
+    "itemName": "e_auto_rotate_on",
+    "imageName": "res_e_auto_rotate_on.png",
+    "roiFront": "104,649,153,44",
+    "roiBack": "104,649,153,44",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "自动轮换开着"
+  },
+  {
+    "itemName": "e_auto_rotate_off",
+    "imageName": "res_e_auto_rotate_off.png",
+    "roiFront": "108,650,150,46",
+    "roiBack": "108,650,150,46",
+    "method": "Template matching",
+    "threshold": 0.85,
+    "description": "自动轮换关闭"
+  },
+  {
+    "itemName": "e_open_settings",
+    "imageName": "res_e_open_settings.png",
+    "roiFront": "466,110,170,50",
+    "roiBack": "466,110,170,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "成功打开设置"
+  },
+  {
+    "itemName": "e_enter_choose_rarity",
+    "imageName": "res_e_enter_choose_rarity.png",
+    "roiFront": "34,288,62,47",
+    "roiBack": "34,288,62,47",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "选择式神稀有度"
+  },
+  {
+    "itemName": "e_n_rarity",
+    "imageName": "res_e_n_rarity.png",
+    "roiFront": "42,625,46,49",
+    "roiBack": "42,625,46,49",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "候补N卡"
+  },
+  {
+    "itemName": "e_s_rarity",
+    "imageName": "res_e_s_rarity.png",
+    "roiFront": "33,620,63,59",
+    "roiBack": "33,620,63,59",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "候补素材"
+  },
+  {
+    "itemName": "e_ratate_exsit",
+    "imageName": "res_e_ratate_exsit.png",
+    "roiFront": "108,580,995,32",
+    "roiBack": "108,580,995,32",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "已候补出战的狗粮"
+  },
+  {
+    "itemName": "e_sure_button",
+    "imageName": "res_e_sure_button.png",
+    "roiFront": "1135,426,43,37",
+    "roiBack": "1135,426,43,37",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "确定按钮"
+  },
+  {
+    "itemName": "e_settings_button",
+    "imageName": "res_e_settings_button.png",
+    "roiFront": "37,692,53,26",
+    "roiBack": "37,692,53,26",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "设置按钮"
+  },
+  {
+    "itemName": "normal_battle_button",
+    "imageName": "res_normal_battle_button.png",
+    "roiFront": "636,263,42,39",
+    "roiBack": "0,0,1279,719",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "普通怪"
+  },
+  {
+    "itemName": "boss_battle_button",
+    "imageName": "res_boss_battle_button.png",
+    "roiFront": "683,256,38,34",
+    "roiBack": "0,0,1276,719",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "boss"
+  },
+  {
+    "itemName": "battle_reward",
+    "imageName": "res_battle_reward.png",
+    "roiFront": "647,395,31,21",
+    "roiBack": "1,1,1278,718",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "战后奖励"
+  },
+  {
+    "itemName": "exploration_title",
+    "imageName": "res_exploration_title.png",
+    "roiFront": "1133,124,47,43",
+    "roiBack": "1133,124,47,43",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "妖"
+  }
+]

+ 20 - 0
tasks/Exploration/res/ocr.json

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "e_exploration_level_number",
+    "roiFront": "1079,193,147,467",
+    "roiBack": "1079,193,147,467",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "",
+    "description": "识别当前显示的章节"
+  },
+  {
+    "itemName": "e_alternate_number",
+    "roiFront": "1092,122,69,32",
+    "roiBack": "1092,122,69,32",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "候补出战的数量"
+  }
+]

BIN
tasks/Exploration/res/res_battle_reward.png


BIN
tasks/Exploration/res/res_boss_battle_button.png


BIN
tasks/Exploration/res/res_e_auto_rotate_off.png


BIN
tasks/Exploration/res/res_e_auto_rotate_on.png


BIN
tasks/Exploration/res/res_e_enter_choose_rarity.png


BIN
tasks/Exploration/res/res_e_exploration_click.png


BIN
tasks/Exploration/res/res_e_exploration_open.png


BIN
tasks/Exploration/res/res_e_n_rarity.png


BIN
tasks/Exploration/res/res_e_open_settings.png


BIN
tasks/Exploration/res/res_e_ratate_exsit.png


BIN
tasks/Exploration/res/res_e_s_rarity.png


BIN
tasks/Exploration/res/res_e_settings_button.png


BIN
tasks/Exploration/res/res_e_sure_button.png


BIN
tasks/Exploration/res/res_exploration_title.png


BIN
tasks/Exploration/res/res_normal_battle_button.png


+ 44 - 0
tasks/Exploration/res/swipe.json

@@ -0,0 +1,44 @@
+[
+  {
+    "itemName": "swipe_level_up",
+    "roiFront": "1142,328,21,21",
+    "roiBack": "1143,444,21,21",
+    "mode": "default",
+    "description": "向上滑动章节"
+  },
+  {
+    "itemName": "swipe_level_down",
+    "roiFront": "1143,486,21,21",
+    "roiBack": "1143,367,21,23",
+    "mode": "default",
+    "description": "向下滑动章节"
+  },
+  {
+    "itemName": "swipe_background_right",
+    "roiFront": "1093,148,21,21",
+    "roiBack": "397,140,21,21",
+    "mode": "default",
+    "description": "往左滑动"
+  },
+  {
+    "itemName": "swipe_background_left",
+    "roiFront": "420,142,21,21",
+    "roiBack": "1183,146,21,21",
+    "mode": "default",
+    "description": "往右滑动"
+  },
+  {
+    "itemName": "swipe_shiki_to_left",
+    "roiFront": "890,587,21,21",
+    "roiBack": "351,584,21,21",
+    "mode": "default",
+    "description": "滑动狗粮选择界面"
+  },
+  {
+    "itemName": "swipe_shiki_to_left_one",
+    "roiFront": "977,582,21,21",
+    "roiBack": "889,584,21,22",
+    "mode": "default",
+    "description": "滑动一个式神的宽度"
+  }
+]

+ 234 - 0
tasks/Exploration/script_task.py

@@ -0,0 +1,234 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import time
+
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
+from tasks.Exploration.assets import ExplorationAssets
+from tasks.Exploration.config import ChooseRarity, AutoRotate, AttackNumber
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_exploration, page_shikigami_records
+
+from module.logger import logger
+from module.exception import RequestHumanTakeover
+from module.atom.image_grid import ImageGrid
+
+
+class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
+    medal_grid: ImageGrid = None
+
+    def run(self):
+        """
+        执行
+        :return:
+        """
+        # 探索的 config
+        config = self.config.exploration
+
+        # 切换御魂
+        if config.switch_soul_config.enable:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul(config.switch_soul_config.switch_group_team)
+
+        if config.switch_soul_config.enable_switch_by_name:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul_by_name(config.switch_soul_config.group_name, config.switch_soul_config.team_name)
+
+        self.ui_get_current_page()
+        # 探索页面
+        self.ui_goto(page_exploration)
+
+        # ************************* 跳转至对应指定章节并进入 *******************
+        # 默认全部解锁, 当前处于第二十八章
+        # 查找指定的章节:
+        if not self.open_expect_level():
+            logger.critical(f'Not find {config.exploration_config.exploration_level} or'
+                            f' Enter {config.exploration_config.exploration_level} failed!')
+            raise RequestHumanTakeover
+
+        # 只探索7次
+        if config.exploration_config.attack_number == AttackNumber.SEVEN:
+            count = 0
+            while count < 7:
+                self.screenshot()
+                if self.appear_then_click(self.I_E_EXPLORATION_CLICK):
+                    count += 1
+                    # 进入战斗环节
+                    self.battle_process()
+                if self.appear_then_click(self.I_EXPLORATION_TITLE):
+                    self.open_expect_level()
+
+    # 查找指定的章节:
+    def open_expect_level(self):
+        swipeCount = 0
+        while 1:
+            # 判断有无目标章节
+            self.screenshot()
+            # 获取当前章节名
+            results = self.O_E_EXPLORATION_LEVEL_NUMBER.detect_and_ocr(self.device.image)
+            text1 = [result.ocr_text for result in results]
+            # 判断当前章节有无目标章节
+            result = set(text1).intersection({config.exploration.exploration_config.exploration_level})
+            # 有则跳出检测
+            if result and len(result) > 0:
+                break
+            self.device.click_record_clear()
+            self.swipe(self.S_SWIPE_LEVEL_UP)
+            swipeCount += 1
+            if swipeCount >= 25:
+                return False
+
+        # 选中对应章节
+        while 1:
+            self.screenshot()
+            self.O_E_EXPLORATION_LEVEL_NUMBER.keyword = config.exploration.exploration_config.exploration_level
+            if self.ocr_appear_click(self.O_E_EXPLORATION_LEVEL_NUMBER):
+                self.wait_until_appear(self.I_E_EXPLORATION_CLICK)
+            if self.appear(self.I_E_EXPLORATION_CLICK):
+                break
+
+        return True
+
+    # 候补:
+    def enter_settings_and_do_operations(self):
+        # 打开设置
+        self.click(self.C_CLICK_SETTINGS)
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_E_OPEN_SETTINGS):
+                break
+            else:
+                self.click(self.C_CLICK_SETTINGS)
+                if self.wait_until_appear(self.I_E_OPEN_SETTINGS):
+                    break
+        # 候补出战数量识别
+        self.screenshot()
+        cu, res, total = self.O_E_ALTERNATE_NUMBER.ocr(self.device.image)
+        if cu >= 40:
+            self.appear_then_click(self.I_E_SURE_BUTTON)
+            return
+        else:
+            self.add_shiki()
+
+    # 添加式神
+    def add_shiki(self):
+        self.screenshot()
+        # 点击展开式神稀有度选择界面
+        self.click(self.C_CLICK_ALL_SHIKI)
+        while 1:
+            self.screenshot()
+            # 成功进入稀有度选择界面
+            if self.appear(self.I_E_ENTER_CHOOSE_RARITY):
+                if self.config.exploration.exploration_config.choose_rarity == ChooseRarity.N:
+                    # N 卡
+                    self.click(self.C_CLICK_N_SHIKI)
+                else:
+                    # 素材卡
+                    self.appear_then_click(self.I_E_ENTER_CHOOSE_RARITY)
+            self.screenshot()
+            if self.appear(self.I_E_N_RARITY):
+                # 进入N卡添加界面  退出
+                break
+            if self.appear(self.I_E_S_RARITY):
+                # 进入素材添加界面 退出
+                break
+        # 选中候补出战框
+        self.click(self.C_CLICK_STANDBY_TEAM)
+        # 移动至未候补的狗粮
+        while 1:
+            # 慢一点
+            time.sleep(0.5)
+            self.screenshot()
+            if self.appear(self.I_E_RATATE_EXSIT):
+                self.swipe(self.S_SWIPE_SHIKI_TO_LEFT)
+            else:
+                break
+        while 1:
+            # 候补出战数量识别
+            self.screenshot()
+            cu, res, total = self.O_E_ALTERNATE_NUMBER.ocr(self.device.image)
+            if cu >= 40:
+                break
+            self.swipe(self.S_SWIPE_SHIKI_TO_LEFT_ONE)
+            # 慢一点
+            time.sleep(0.5)
+            self.screenshot()
+            self.click(self.C_CLICK_ROTATE_1)
+            self.device.click_record_clear()
+
+        self.appear_then_click(self.I_E_SURE_BUTTON)
+
+    # 探索战斗流程
+    def do_battle(self):
+        while 1:
+            self.screenshot()
+            # boss 战
+            if self.appear_then_click(self.I_BOSS_BATTLE_BUTTON):
+                self.run_general_battle(self.config.exploration.general_battle_config)
+                self.screenshot()
+                if self.wait_until_appear(self.I_E_SETTINGS_BUTTON):
+                    while 1:
+                        self.screenshot()
+                        if self.appear_then_click(self.I_BATTLE_REWARD):
+                            self.screenshot()
+                            self.click(self.C_CLICK_ROTATE_1)
+                            time.sleep(0.5)
+                        if self.appear(self.I_EXPLORATION_TITLE):
+                            break
+                        if self.appear(self.I_E_EXPLORATION_CLICK):
+                            break
+                if self.appear(self.I_E_EXPLORATION_CLICK) or self.appear(self.I_EXPLORATION_TITLE):
+                    break
+            # 小怪 战
+            if self.appear_then_click(self.I_NORMAL_BATTLE_BUTTON):
+                self.run_general_battle(self.config.exploration.general_battle_config)
+                self.screenshot()
+                while self.appear(self.I_BATTLE_REWARD):
+                    self.screenshot()
+                    self.appear_then_click(self.I_BATTLE_REWARD)
+                    self.screenshot()
+            else:
+                self.swipe(self.S_SWIPE_BACKGROUND_RIGHT)
+
+    # 战斗流程
+    def battle_process(self):
+        # 进入指定章节
+        self.screenshot()
+        if self.appear_then_click(self.I_E_EXPLORATION_CLICK):
+            self.appear_then_click(self.I_E_SETTINGS_BUTTON)
+
+        # ************************* 进入设置并操作 *******************
+        # 候补以及自动轮换打开:
+        # 自动轮换功能打开
+        while 1:
+            self.screenshot()
+            # 自动轮换开着 则跳过
+            if self.appear(self.I_E_AUTO_ROTATE_ON):
+                break
+            # 自动轮换关着 则打开
+            if self.appear_then_click(self.I_E_AUTO_ROTATE_OFF):
+                if self.appear(self.I_E_AUTO_ROTATE_ON):
+                    break
+
+        # 自动添加候补式神
+        if self.config.exploration.exploration_config.auto_rotate == AutoRotate.yes:
+            self.enter_settings_and_do_operations()
+
+        # 进入战斗环节
+        self.do_battle()
+
+
+if __name__ == "__main__":
+    from module.config.config import Config
+    from module.device.device import Device
+
+    config = Config('oas1')
+    device = Device(config)
+    t = ScriptTask(config, device)
+    t.config.exploration.exploration_config.exploration_level = '第二十八章'
+    t.run()
+    # t.battle_process()
+    # t.enter_settings_and_do_operations()

+ 4 - 2
tasks/RyouToppa/assets.py

@@ -21,15 +21,17 @@ class RyouToppaAssets:
 	# 寮突选择阴阳寮按钮 
 	I_SELECT_RYOU_BUTTON = RuleImage(roi_front=(560,577,156,46), roi_back=(560,577,156,46), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_select_ryou_button.png")
 	# 开始寮突按钮 
-	I_START_TOPPA_BUTTON = RuleImage(roi_front=(834,504,127,38), roi_back=(4,3,1056,716), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_start_toppa_button.png")
+	I_START_TOPPA_BUTTON = RuleImage(roi_front=(832,279,130,43), roi_back=(1,1,1055,718), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_start_toppa_button.png")
 	# 寮击破奖励 
 	I_RYOU_REWARD = RuleImage(roi_front=(134,417,241,40), roi_back=(134,417,241,40), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_ryou_reward.png")
 	# 勋章奖励标题 
 	I_GUILD_ORDERS_REWARDS = RuleImage(roi_front=(1123,31,115,56), roi_back=(1123,31,115,56), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_guild_orders_rewards.png")
 	# 攻破阴阳寮 
-	I_SUCCESS_PENETRATION = RuleImage(roi_front=(206,149,100,100), roi_back=(206,149,100,100), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_success_penetration.png")
+	I_SUCCESS_PENETRATION = RuleImage(roi_front=(141,374,234,37), roi_back=(141,374,234,37), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_success_penetration.png")
 	# 个人突破刷新按钮 
 	I_REAL_RAID_REFRESH = RuleImage(roi_front=(963,569,174,60), roi_back=(963,569,174,60), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_real_raid_refresh.png")
+	# 击破后的寮奖励 
+	I_RYOU_REWARD_90 = RuleImage(roi_front=(134,415,232,38), roi_back=(134,415,232,38), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_ryou_reward_90.png")
 
 
 	# Ocr Rule Assets

+ 13 - 4
tasks/RyouToppa/res/image.json

@@ -20,8 +20,8 @@
   {
     "itemName": "start_toppa_button",
     "imageName": "res_start_toppa_button.png",
-    "roiFront": "834,504,127,38",
-    "roiBack": "4,3,1056,716",
+    "roiFront": "832,279,130,43",
+    "roiBack": "1,1,1055,718",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "开始寮突按钮"
@@ -47,8 +47,8 @@
   {
     "itemName": "success_penetration",
     "imageName": "res_success_penetration.png",
-    "roiFront": "206,149,100,100",
-    "roiBack": "206,149,100,100",
+    "roiFront": "141,374,234,37",
+    "roiBack": "141,374,234,37",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "攻破阴阳寮"
@@ -61,5 +61,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "个人突破刷新按钮"
+  },
+  {
+    "itemName": "ryou_reward_90",
+    "imageName": "res_ryou_reward_90.png",
+    "roiFront": "134,415,232,38",
+    "roiBack": "134,415,232,38",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "击破后的寮奖励"
   }
 ]

BIN
tasks/RyouToppa/res/res_ryou_reward_90.png


BIN
tasks/RyouToppa/res/res_start_toppa_button.png


BIN
tasks/RyouToppa/res/res_success_penetration.png


+ 13 - 27
tasks/RyouToppa/script_task.py

@@ -25,19 +25,19 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
         执行
         :return:
         """
-        config = self.config.ryou_toppa
+        ryou_config = self.config.ryou_toppa
         self.medal_grid = ImageGrid([RealmRaidAssets.I_MEDAL_5, RealmRaidAssets.I_MEDAL_4, RealmRaidAssets.I_MEDAL_3,
                                      RealmRaidAssets.I_MEDAL_2, RealmRaidAssets.I_MEDAL_1, RealmRaidAssets.I_MEDAL_0])
 
-        if config.switch_soul_config.enable:
+        if ryou_config.switch_soul_config.enable:
             self.ui_get_current_page()
             self.ui_goto(page_shikigami_records)
-            self.run_switch_soul(config.switch_soul_config.switch_group_team)
+            self.run_switch_soul(ryou_config.switch_soul_config.switch_group_team)
 
-        if config.switch_soul_config.enable_switch_by_name:
+        if ryou_config.switch_soul_config.enable_switch_by_name:
             self.ui_get_current_page()
             self.ui_goto(page_shikigami_records)
-            self.run_switch_soul_by_name(config.switch_soul_config.group_name, config.switch_soul_config.team_name)
+            self.run_switch_soul_by_name(ryou_config.switch_soul_config.group_name, ryou_config.switch_soul_config.team_name)
 
         self.ui_get_current_page()
         self.ui_goto(page_kekkai_toppa)
@@ -61,20 +61,18 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
                 ryou_toppa_start_flag = False
                 break
             # 出现寮奖励, 说明寮突已开
-            elif self.appear(self.I_RYOU_REWARD, threshold=0.8):
+            elif self.appear(self.I_RYOU_REWARD, threshold=0.8) or self.appear(self.I_RYOU_REWARD_90, threshold=0.8):
                 ryou_toppa_start_flag = True
                 break
 
         # 寮突未开 并且有权限, 开开寮突
-        if not ryou_toppa_start_flag and config.raid_config.ryou_access == 'yes':
+        if not ryou_toppa_start_flag and ryou_config.raid_config.ryou_access == 'yes':
             # 开寮突
             self.start_ryou_toppa()
 
-        # 切换阵容 待实现
-
         # 开始突破
         while 1:
-            if self.execute_round(config):
+            if self.execute_round():
                 continue
             else:
                 break
@@ -129,7 +127,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
             return False
         return True
 
-    def medal_fire(self) -> bool:
+    def medal_fire(self):
         """
         点击勋章
         :return:
@@ -170,30 +168,18 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
                 break
         logger.info(f'Click {RealmRaidAssets.I_FIRE.name}')
 
-    def execute_round(self, config: RaidMode) -> bool:
+    def execute_round(self) -> bool:
         """
         执行一轮 除非票不够,一直到到九次
         :return:
         """
+        ryou_config = self.config.ryou_toppa
         # 如果没有票了,就退出
         if not self.is_ticket():
             return False
         if not self.is_target_available():
             return False
-        # # 判断是退四打九还是全部打
-        # if config.raid_config.raid_mode == RaidMode.NORMAL:
-        #     logger.info(f'Execute round, retreat four attack nine')
-        #     self.medal_fire()
-        #     self.run_general_battle_back(config.general_battle_config)
-        #
-        #     self.medal_fire()
-        #     self.run_general_battle_back(config.general_battle_config)
-        #
-        #     self.medal_fire()
-        #     self.run_general_battle_back(config.general_battle_config)
-        #
-        #     self.medal_fire()
-        #     self.run_general_battle_back(config.general_battle_config)
+
 
         # 打20次
         for i in range(30):
@@ -202,7 +188,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
             if not self.is_target_available():
                 return False
             self.medal_fire()
-            self.run_general_battle(config.general_battle_config)
+            self.run_general_battle(ryou_config.general_battle_config)
             self.wait_until_appear(RealmRaidAssets.I_BACK_RED)
 
         return True