Przeglądaj źródła

Merge pull request #216 from runhey/dev

Dev
huangrunheng 2 lat temu
rodzic
commit
4d1453b3d9
64 zmienionych plików z 870 dodań i 225 usunięć
  1. 1 1
      README.md
  2. 1 1
      dev_tools/assets_extract.py
  3. 5 5
      dev_tools/assets_test.py
  4. BIN
      tasks/ActivityShikigami/0110/0110_battle_check_1.png
  5. BIN
      tasks/ActivityShikigami/0110/0110_battle_check_2.png
  6. BIN
      tasks/ActivityShikigami/0110/0110_battle_check_3.png
  7. BIN
      tasks/ActivityShikigami/0110/0110_battle_check_4.png
  8. BIN
      tasks/ActivityShikigami/0110/0110_battle_class_1.png
  9. BIN
      tasks/ActivityShikigami/0110/0110_battle_class_2.png
  10. BIN
      tasks/ActivityShikigami/0110/0110_battle_class_3.png
  11. BIN
      tasks/ActivityShikigami/0110/0110_battle_class_4.png
  12. BIN
      tasks/ActivityShikigami/0110/0110_c_confirm1.png
  13. BIN
      tasks/ActivityShikigami/0110/0110_n_battle.png
  14. BIN
      tasks/ActivityShikigami/0110/0110_n_confirm.png
  15. 12 57
      tasks/ActivityShikigami/0110/image.json
  16. BIN
      tasks/ActivityShikigami/as/as_ap.png
  17. BIN
      tasks/ActivityShikigami/as/as_ap_activity.png
  18. BIN
      tasks/ActivityShikigami/as/as_battle.png
  19. BIN
      tasks/ActivityShikigami/as/as_fire.png
  20. BIN
      tasks/ActivityShikigami/as/as_lock.png
  21. BIN
      tasks/ActivityShikigami/as/as_shi.png
  22. BIN
      tasks/ActivityShikigami/as/as_switch.png
  23. BIN
      tasks/ActivityShikigami/as/as_unlock.png
  24. 16 16
      tasks/ActivityShikigami/as/image.json
  25. 4 4
      tasks/ActivityShikigami/as/ocr.json
  26. 13 23
      tasks/ActivityShikigami/assets.py
  27. 60 46
      tasks/ActivityShikigami/script_task.py
  28. 6 1
      tasks/Component/Buy/buy.py
  29. 5 0
      tasks/Component/GeneralBattle/assets.py
  30. 11 0
      tasks/Component/GeneralBattle/gb/ocr.json
  31. 16 20
      tasks/Component/GeneralBattle/general_battle.py
  32. 8 1
      tasks/Component/RightActivity/assets.py
  33. 20 0
      tasks/Component/RightActivity/ra/image.json
  34. BIN
      tasks/Component/RightActivity/ra/ra_ra_close.png
  35. BIN
      tasks/Component/RightActivity/ra/ra_ra_open.png
  36. 6 1
      tasks/Component/RightActivity/right_activity.py
  37. 2 0
      tasks/Exploration/assets.py
  38. 9 0
      tasks/Exploration/res/image.json
  39. BIN
      tasks/Exploration/res/res_e_exit_confirm.png
  40. 2 1
      tasks/Exploration/script_task.py
  41. 2 2
      tasks/GameUi/assets.py
  42. 3 3
      tasks/GameUi/page/page_img_3.json
  43. BIN
      tasks/GameUi/page/page_main_goto_daily.png
  44. 3 0
      tasks/Hyakkiyakou/.gitignore
  45. 17 4
      tasks/Hyakkiyakou/assets.py
  46. 8 0
      tasks/Hyakkiyakou/train/click.json
  47. 33 6
      tasks/Hyakkiyakou/train/image.json
  48. 9 2
      tasks/Hyakkiyakou/train/swipe.json
  49. BIN
      tasks/Hyakkiyakou/train/train_check_run.png
  50. BIN
      tasks/Hyakkiyakou/train/train_tcheck_22.png
  51. BIN
      tasks/Hyakkiyakou/train/train_tcheck_32.png
  52. BIN
      tasks/Hyakkiyakou/train/train_tcheck_5.png
  53. BIN
      tasks/Hyakkiyakou/train/train_tpage_2.png
  54. 326 0
      tasks/Hyakkiyakou/utils/exp_test.py
  55. 15 0
      tasks/Hyakkiyakou/utils/fast_device.py
  56. 89 14
      tasks/Hyakkiyakou/utils/generate.py
  57. 28 0
      tasks/Hyakkiyakou/utils/utils.py
  58. 126 0
      tasks/Hyakkiyakou/utils/video2images.py
  59. 2 2
      tasks/KekkaiActivation/assets.py
  60. BIN
      tasks/KekkaiActivation/cards/cards_cards_fish_5.png
  61. 4 4
      tasks/KekkaiActivation/cards/image.json
  62. 2 10
      tasks/RichMan/mall/special.py
  63. 2 1
      tasks/Script/config_device.py
  64. 4 0
      tasks/base_task.py

+ 1 - 1
README.md

@@ -87,7 +87,7 @@ OAS 在其基础上进行了如下优化:
 - 你必须拥有一个 Github 账户来点一个 **Star** (这并不影响你入群后取消Star),同样的要求注册时间过半年。
 - 入群验证填入你的 Github id,无需在意问题是什么,由QQ机器人审核(机器永远的对的)。
 
-#### QQ开发群: 207613181
+#### QQ开发群: 207613181 (有意开发本项目请加此群, 请不要胡乱加群)
 
 - 发展规划:[#54](https://github.com/runhey/OnmyojiAutoScript/issues/54)
 - OAS 继承了 Alas 的设计思路,极大简便了开发,欢迎提交 PR,挑选你感兴趣的部分进行开发即可。

+ 1 - 1
dev_tools/assets_extract.py

@@ -267,7 +267,7 @@ class AssetsExtractor:
         获取所有json文件
         :return: json文件(带后缀)列表
         """
-        return [str(x) for x in self.task_path.rglob('*.json')]
+        return [str(x) for x in self.task_path.rglob('*.json') if 'temp' not in str(x)]
 
     @classmethod
     def read_file(cls, file: str) -> list:

+ 5 - 5
dev_tools/assets_test.py

@@ -27,20 +27,20 @@ def detect_image(file: str, targe: RuleImage) -> bool:
     logger.info(f'[{targe.name}]: {result}')
     return result
 
+
 def detect_ocr(file: str, target: RuleOcr):
     img = load_image(file)
     return target.ocr(img)
 
 
-
 # 图片文件路径 可以是相对路径
-IMAGE_FILE = './log/error/1707301227880/error1707301227880.png'
+IMAGE_FILE = r'C:\Users\Ryland\Downloads\QQ截图20240402214513.png'
 if __name__ == '__main__':
     from tasks.KekkaiActivation.assets import KekkaiActivationAssets
-    targe = KekkaiActivationAssets.I_CARDS_KAIKO_5
+    from tasks.GameUi.assets import GameUiAssets
+
+    targe = GameUiAssets.I_MAIN_GOTO_DAILY
     print(detect_image(IMAGE_FILE, targe))
     # from tasks.KekkaiActivation.assets import KekkaiActivationAssets
     # target = KekkaiActivationAssets.O_CARD_ALL_TIME
     # print(detect_ocr(IMAGE_FILE, target))
-
-

BIN
tasks/ActivityShikigami/0110/0110_battle_check_1.png


BIN
tasks/ActivityShikigami/0110/0110_battle_check_2.png


BIN
tasks/ActivityShikigami/0110/0110_battle_check_3.png


BIN
tasks/ActivityShikigami/0110/0110_battle_check_4.png


BIN
tasks/ActivityShikigami/0110/0110_battle_class_1.png


BIN
tasks/ActivityShikigami/0110/0110_battle_class_2.png


BIN
tasks/ActivityShikigami/0110/0110_battle_class_3.png


BIN
tasks/ActivityShikigami/0110/0110_battle_class_4.png


BIN
tasks/ActivityShikigami/0110/0110_c_confirm1.png


BIN
tasks/ActivityShikigami/0110/0110_n_battle.png


BIN
tasks/ActivityShikigami/0110/0110_n_confirm.png


+ 12 - 57
tasks/ActivityShikigami/0110/image.json

@@ -1,72 +1,27 @@
 [
   {
-    "itemName": "battle_class_1",
-    "imageName": "0110_battle_class_1.png",
-    "roiFront": "126,132,124,81",
-    "roiBack": "126,132,124,81",
+    "itemName": "n_battle",
+    "imageName": "0110_n_battle.png",
+    "roiFront": "131,164,86,86",
+    "roiBack": "119,50,1075,635",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
   },
   {
-    "itemName": "battle_class_2",
-    "imageName": "0110_battle_class_2.png",
-    "roiFront": "120,231,129,83",
-    "roiBack": "120,231,129,83",
+    "itemName": "n_confirm",
+    "imageName": "0110_n_confirm.png",
+    "roiFront": "670,402,176,63",
+    "roiBack": "670,402,176,63",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
   },
   {
-    "itemName": "battle_class_3",
-    "imageName": "0110_battle_class_3.png",
-    "roiFront": "141,331,100,89",
-    "roiBack": "141,331,100,89",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "description"
-  },
-  {
-    "itemName": "battle_class_4",
-    "imageName": "0110_battle_class_4.png",
-    "roiFront": "141,435,100,83",
-    "roiBack": "141,435,100,83",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "description"
-  },
-  {
-    "itemName": "battle_check_1",
-    "imageName": "0110_battle_check_1.png",
-    "roiFront": "36,643,39,41",
-    "roiBack": "36,643,39,41",
-    "method": "Template matching",
-    "threshold": 0.7,
-    "description": "description"
-  },
-  {
-    "itemName": "battle_check_2",
-    "imageName": "0110_battle_check_2.png",
-    "roiFront": "31,649,39,45",
-    "roiBack": "31,649,39,45",
-    "method": "Template matching",
-    "threshold": 0.7,
-    "description": "description"
-  },
-  {
-    "itemName": "battle_check_3",
-    "imageName": "0110_battle_check_3.png",
-    "roiFront": "34,652,38,42",
-    "roiBack": "34,652,38,42",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "description"
-  },
-  {
-    "itemName": "battle_check_4",
-    "imageName": "0110_battle_check_4.png",
-    "roiFront": "33,652,38,40",
-    "roiBack": "33,652,38,40",
+    "itemName": "c_confirm1",
+    "imageName": "0110_c_confirm1.png",
+    "roiFront": "560,341,37,38",
+    "roiBack": "560,341,37,38",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

BIN
tasks/ActivityShikigami/as/as_ap.png


BIN
tasks/ActivityShikigami/as/as_ap_activity.png


BIN
tasks/ActivityShikigami/as/as_battle.png


BIN
tasks/ActivityShikigami/as/as_fire.png


BIN
tasks/ActivityShikigami/as/as_lock.png


BIN
tasks/ActivityShikigami/as/as_shi.png


BIN
tasks/ActivityShikigami/as/as_switch.png


BIN
tasks/ActivityShikigami/as/as_unlock.png


+ 16 - 16
tasks/ActivityShikigami/as/image.json

@@ -2,8 +2,8 @@
   {
     "itemName": "shi",
     "imageName": "as_shi.png",
-    "roiFront": "443,307,28,39",
-    "roiBack": "64,265,1029,277",
+    "roiFront": "427,337,82,120",
+    "roiBack": "64,265,1110,277",
     "method": "Template matching",
     "threshold": 0.7,
     "description": "进入活动"
@@ -20,8 +20,8 @@
   {
     "itemName": "battle",
     "imageName": "as_battle.png",
-    "roiFront": "207,264,47,172",
-    "roiBack": "187,239,105,220",
+    "roiFront": "111,176,35,165",
+    "roiBack": "74,148,105,220",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "进入爬塔"
@@ -38,8 +38,8 @@
   {
     "itemName": "lock",
     "imageName": "as_lock.png",
-    "roiFront": "795,654,25,32",
-    "roiBack": "795,654,25,32",
+    "roiFront": "666,597,25,32",
+    "roiBack": "666,597,25,32",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "上锁图标"
@@ -47,8 +47,8 @@
   {
     "itemName": "unlock",
     "imageName": "as_unlock.png",
-    "roiFront": "795,656,28,28",
-    "roiBack": "795,656,28,28",
+    "roiFront": "665,597,28,28",
+    "roiBack": "665,597,28,28",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "还未上锁图片"
@@ -56,8 +56,8 @@
   {
     "itemName": "fire",
     "imageName": "as_fire.png",
-    "roiFront": "1132,592,70,79",
-    "roiBack": "1132,592,70,79",
+    "roiFront": "983,547,107,62",
+    "roiBack": "983,547,107,62",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "点击战斗"
@@ -65,8 +65,8 @@
   {
     "itemName": "ap",
     "imageName": "as_ap.png",
-    "roiFront": "1118,510,32,26",
-    "roiBack": "1118,510,32,26",
+    "roiFront": "984,474,29,26",
+    "roiBack": "984,474,29,26",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "体力按钮"
@@ -74,8 +74,8 @@
   {
     "itemName": "ap_activity",
     "imageName": "as_ap_activity.png",
-    "roiFront": "1122,515,27,25",
-    "roiBack": "1122,515,27,25",
+    "roiFront": "987,476,27,25",
+    "roiBack": "987,476,27,25",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "活动体力"
@@ -83,8 +83,8 @@
   {
     "itemName": "switch",
     "imageName": "as_switch.png",
-    "roiFront": "1212,517,23,23",
-    "roiBack": "1212,517,23,23",
+    "roiFront": "1075,480,23,23",
+    "roiBack": "1075,480,23,23",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "切换按键"

+ 4 - 4
tasks/ActivityShikigami/as/ocr.json

@@ -1,8 +1,8 @@
 [
   {
     "itemName": "remain_ap",
-    "roiFront": "1177,679,77,25",
-    "roiBack": "1177,679,77,25",
+    "roiFront": "1011,612,77,25",
+    "roiBack": "1011,612,77,25",
     "mode": "DigitCounter",
     "method": "Default",
     "keyword": "",
@@ -10,8 +10,8 @@
   },
   {
     "itemName": "remain_ap_activity",
-    "roiFront": "714,26,95,30",
-    "roiBack": "714,26,95,30",
+    "roiFront": "1062,13,95,30",
+    "roiBack": "1062,13,95,30",
     "mode": "DigitCounter",
     "method": "Default",
     "keyword": "",

+ 13 - 23
tasks/ActivityShikigami/assets.py

@@ -12,21 +12,11 @@ class ActivityShikigamiAssets:
 
 	# Image Rule Assets
 	# description 
-	I_BATTLE_CLASS_1 = RuleImage(roi_front=(126,132,124,81), roi_back=(126,132,124,81), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/0110/0110_battle_class_1.png")
+	I_N_BATTLE = RuleImage(roi_front=(131,164,86,86), roi_back=(119,50,1075,635), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/0110/0110_n_battle.png")
 	# description 
-	I_BATTLE_CLASS_2 = RuleImage(roi_front=(120,231,129,83), roi_back=(120,231,129,83), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/0110/0110_battle_class_2.png")
+	I_N_CONFIRM = RuleImage(roi_front=(670,402,176,63), roi_back=(670,402,176,63), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/0110/0110_n_confirm.png")
 	# description 
-	I_BATTLE_CLASS_3 = RuleImage(roi_front=(141,331,100,89), roi_back=(141,331,100,89), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/0110/0110_battle_class_3.png")
-	# description 
-	I_BATTLE_CLASS_4 = RuleImage(roi_front=(141,435,100,83), roi_back=(141,435,100,83), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/0110/0110_battle_class_4.png")
-	# description 
-	I_BATTLE_CHECK_1 = RuleImage(roi_front=(36,643,39,41), roi_back=(36,643,39,41), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/0110/0110_battle_check_1.png")
-	# description 
-	I_BATTLE_CHECK_2 = RuleImage(roi_front=(31,649,39,45), roi_back=(31,649,39,45), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/0110/0110_battle_check_2.png")
-	# description 
-	I_BATTLE_CHECK_3 = RuleImage(roi_front=(34,652,38,42), roi_back=(34,652,38,42), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/0110/0110_battle_check_3.png")
-	# description 
-	I_BATTLE_CHECK_4 = RuleImage(roi_front=(33,652,38,40), roi_back=(33,652,38,40), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/0110/0110_battle_check_4.png")
+	I_C_CONFIRM1 = RuleImage(roi_front=(560,341,37,38), roi_back=(560,341,37,38), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/0110/0110_c_confirm1.png")
 
 
 	# Click Rule Assets
@@ -44,25 +34,25 @@ class ActivityShikigamiAssets:
 
 	# Image Rule Assets
 	# 进入活动 
-	I_SHI = RuleImage(roi_front=(443,307,28,39), roi_back=(64,265,1029,277), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_shi.png")
+	I_SHI = RuleImage(roi_front=(427,337,82,120), roi_back=(64,265,1110,277), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_shi.png")
 	# 左上角返回 
 	I_BACK_GREEN = RuleImage(roi_front=(23,27,44,44), roi_back=(23,27,44,44), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_back_green.png")
 	# 进入爬塔 
-	I_BATTLE = RuleImage(roi_front=(207,264,47,172), roi_back=(187,239,105,220), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_battle.png")
+	I_BATTLE = RuleImage(roi_front=(111,176,35,165), roi_back=(74,148,105,220), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_battle.png")
 	# 归鹿之途 
 	I_DRUM = RuleImage(roi_front=(1011,114,29,31), roi_back=(1011,114,29,31), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_drum.png")
 	# 上锁图标 
-	I_LOCK = RuleImage(roi_front=(795,654,25,32), roi_back=(795,654,25,32), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_lock.png")
+	I_LOCK = RuleImage(roi_front=(666,597,25,32), roi_back=(666,597,25,32), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_lock.png")
 	# 还未上锁图片 
-	I_UNLOCK = RuleImage(roi_front=(795,656,28,28), roi_back=(795,656,28,28), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_unlock.png")
+	I_UNLOCK = RuleImage(roi_front=(665,597,28,28), roi_back=(665,597,28,28), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_unlock.png")
 	# 点击战斗 
-	I_FIRE = RuleImage(roi_front=(1132,592,70,79), roi_back=(1132,592,70,79), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_fire.png")
+	I_FIRE = RuleImage(roi_front=(983,547,107,62), roi_back=(983,547,107,62), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_fire.png")
 	# 体力按钮 
-	I_AP = RuleImage(roi_front=(1118,510,32,26), roi_back=(1118,510,32,26), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap.png")
+	I_AP = RuleImage(roi_front=(984,474,29,26), roi_back=(984,474,29,26), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap.png")
 	# 活动体力 
-	I_AP_ACTIVITY = RuleImage(roi_front=(1122,515,27,25), roi_back=(1122,515,27,25), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap_activity.png")
+	I_AP_ACTIVITY = RuleImage(roi_front=(987,476,27,25), roi_back=(987,476,27,25), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap_activity.png")
 	# 切换按键 
-	I_SWITCH = RuleImage(roi_front=(1212,517,23,23), roi_back=(1212,517,23,23), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_switch.png")
+	I_SWITCH = RuleImage(roi_front=(1075,480,23,23), roi_back=(1075,480,23,23), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_switch.png")
 	# 购买活动的体力 
 	I_BUY_JADE = RuleImage(roi_front=(1004,192,38,42), roi_back=(836,619,38,42), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_buy_jade.png")
 	# 增加到最大 
@@ -73,9 +63,9 @@ class ActivityShikigamiAssets:
 
 	# Ocr Rule Assets
 	# 体力的数量检测 
-	O_REMAIN_AP = RuleOcr(roi=(1177,679,77,25), area=(1177,679,77,25), mode="DigitCounter", method="Default", keyword="", name="remain_ap")
+	O_REMAIN_AP = RuleOcr(roi=(1011,612,77,25), area=(1011,612,77,25), mode="DigitCounter", method="Default", keyword="", name="remain_ap")
 	# 活动体力的剩余检测 
-	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(714,26,95,30), area=(714,26,95,30), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
+	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(1062,13,95,30), area=(1062,13,95,30), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
 	# 还有多少次购买体力的机会 
 	O_REMAIN_BUY = RuleOcr(roi=(808,531,39,42), area=(808,531,39,42), mode="DigitCounter", method="Default", keyword="", name="remain_buy")
 

+ 60 - 46
tasks/ActivityShikigami/script_task.py

@@ -32,6 +32,13 @@ class ScriptTask(GameUi, BaseActivity, ActivityShikigamiAssets):
         self.ui_goto(page_main)
         self.home_main()
 
+        # 2024-04-04 ---------------------start
+        config.general_climb.ap_mode = ApMode.AP_GAME
+        # 2024-04-04 ---------------------end
+        # 选择是游戏的体力还是活动的体力
+        current_ap = config.general_climb.ap_mode
+        self.switch(current_ap)
+
         # 设定是否锁定阵容
         if config.general_battle.lock_team_enable:
             logger.info("Lock team")
@@ -50,10 +57,6 @@ class ScriptTask(GameUi, BaseActivity, ActivityShikigamiAssets):
                 if self.appear(self.I_UNLOCK):
                     break
 
-        # 选择是游戏的体力还是活动的体力
-        current_ap = config.general_climb.ap_mode
-        self.switch(current_ap)
-
         # 流程应该是 在页面处:
         # 1. 判定计数是否超了,时间是否超了
         # 2. 如果是消耗活动体力,判定活动体力是否足够 如果是消耗一般的体力,判定一般体力是否足够
@@ -84,16 +87,20 @@ class ScriptTask(GameUi, BaseActivity, ActivityShikigamiAssets):
                     logger.info("Activity ap out")
                     break
 
-
             # 点击战斗
-
             logger.info("Click battle")
             while 1:
                 self.screenshot()
-                if self.appear_then_click(self.I_FIRE, interval=1):
+                if self.appear_then_click(self.I_FIRE, interval=2):
                     continue
                 if not self.appear(self.I_FIRE):
                     break
+                if self.appear_then_click(self.I_C_CONFIRM1, interval=0.6):
+                    continue
+                if self.appear_then_click(self.I_UI_CONFIRM_SAMLL, interval=1):
+                    continue
+                if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                    continue
 
             if self.run_general_battle(config=config.general_battle):
                 logger.info("General battle success")
@@ -102,7 +109,6 @@ class ScriptTask(GameUi, BaseActivity, ActivityShikigamiAssets):
         self.set_next_run(task="ActivityShikigami", success=True)
         raise TaskEnd
 
-
     def home_main(self) -> bool:
         """
         从庭院到活动的爬塔界面
@@ -114,6 +120,10 @@ class ScriptTask(GameUi, BaseActivity, ActivityShikigamiAssets):
             self.screenshot()
             if self.appear(self.I_FIRE):
                 break
+            # 2024-04-04 --------------start
+            if self.appear_then_click(self.I_N_BATTLE, interval=1):
+                continue
+            # 2024-04-04 --------------end
             if self.appear_then_click(self.I_SHI, interval=1):
                 continue
             if self.appear_then_click(self.I_DRUM, interval=1):
@@ -121,8 +131,6 @@ class ScriptTask(GameUi, BaseActivity, ActivityShikigamiAssets):
             if self.appear_then_click(self.I_BATTLE, interval=1):
                 continue
 
-
-
     def main_home(self) -> bool:
         """
         从活动的爬塔界面到庭院
@@ -133,11 +141,12 @@ class ScriptTask(GameUi, BaseActivity, ActivityShikigamiAssets):
             self.screenshot()
             if self.appear(self.I_SHI):
                 break
-            if self.appear_then_click(self.I_UI_BACK_YELLOW, interval=1):
+            if self.appear_then_click(self.I_UI_BACK_RED, interval=2):
                 continue
-            if self.appear_then_click(self.I_BACK_GREEN, interval=1):
+            if self.appear_then_click(self.I_UI_BACK_YELLOW, interval=2):
+                continue
+            if self.appear_then_click(self.I_BACK_GREEN, interval=2):
                 continue
-
 
     def check_ap_remain(self, current_ap: ApMode) -> bool:
         """
@@ -175,6 +184,10 @@ class ScriptTask(GameUi, BaseActivity, ActivityShikigamiAssets):
                 self.screenshot()
                 if self.appear(self.I_AP_ACTIVITY):
                     break
+                if self.appear_then_click(self.I_UI_CONFIRM_SAMLL, interval=1):
+                    continue
+                if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                    continue
                 if self.appear(self.I_AP, interval=1):
                     self.appear_then_click(self.I_SWITCH, interval=2)  # 点击切换
         else:
@@ -186,44 +199,45 @@ class ScriptTask(GameUi, BaseActivity, ActivityShikigamiAssets):
                 if self.appear(self.I_AP_ACTIVITY, interval=1):
                     self.appear_then_click(self.I_SWITCH, interval=2)
 
-    # 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")
-    #     self.C_RANDOM_LEFT.name = "BATTLE_RANDOM"
-    #     self.C_RANDOM_RIGHT.name = "BATTLE_RANDOM"
-    #     self.C_RANDOM_TOP.name = "BATTLE_RANDOM"
-    #     self.C_RANDOM_BOTTOM.name = "BATTLE_RANDOM"
-    #     while 1:
-    #         self.screenshot()
-    #         # 如果出现了 “获得奖励”
-    #         reward_click = random.choice([self.C_RANDOM_LEFT, self.C_RANDOM_RIGHT, self.C_RANDOM_TOP, self.C_RANDOM_BOTTOM])
-    #         if self.appear_then_click(self.I_UI_REWARD, action=reward_click, interval=1.3):
-    #             continue
-    #         # 如果出现了 “鼓”
-    #         if self.appear(self.I_WIN):
-    #             logger.info("Win")
-    #             while 1:
-    #                 self.screenshot()
-    #                 if not self.appear(self.I_WIN):
-    #                     break
-    #                 if self.appear_then_click(self.I_WIN, action=self.C_RANDOM_ALL, interval=1.1):
-    #                     continuee
-    #             return True
-    #         # 失败 -> 正常人不会失败
-    #         if self.appear(self.I_FALSE):
-    #             logger.warning('False battle')
-    #             self.ui_click_until_disappear(self.I_FALSE)
-    #             return False
-    #         # 如果开启战斗过程随机滑动
-    #         if random_click_swipt_enable:
-    #             self.random_click_swipt()
+    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")
+        self.C_RANDOM_LEFT.name = "BATTLE_RANDOM"
+        self.C_RANDOM_RIGHT.name = "BATTLE_RANDOM"
+        self.C_RANDOM_TOP.name = "BATTLE_RANDOM"
+        self.C_RANDOM_BOTTOM.name = "BATTLE_RANDOM"
+        while 1:
+            self.screenshot()
+            # 如果出现了 “获得奖励”
+            reward_click = random.choice([self.C_RANDOM_LEFT, self.C_RANDOM_RIGHT, self.C_RANDOM_TOP, self.C_RANDOM_BOTTOM])
+            if self.appear_then_click(self.I_UI_REWARD, action=reward_click, interval=1.3):
+                continue
+            # 如果出现了 “鼓”
+            if self.appear(self.I_WIN):
+                logger.info("Win")
+                while 1:
+                    self.screenshot()
+                    if not self.appear(self.I_WIN):
+                        break
+                    if self.appear_then_click(self.I_WIN, action=self.C_RANDOM_ALL, interval=1.1):
+                        continue
+                return True
+            # 失败 -> 正常人不会失败
+            if self.appear(self.I_FALSE):
+                logger.warning('False battle')
+                self.ui_click_until_disappear(self.I_FALSE)
+                return False
+            # 如果开启战斗过程随机滑动
+            if random_click_swipt_enable:
+                self.random_click_swipt()
 
 
 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)

+ 6 - 1
tasks/Component/Buy/buy.py

@@ -133,7 +133,6 @@ class Buy(BaseTask, BuyAssets):
                         break
                     number_record.pop(0)
 
-
         # 购买确认
         while 1:
             self.screenshot()
@@ -151,6 +150,12 @@ class Buy(BaseTask, BuyAssets):
                         continue
                 break
 
+            # 如果这个购买已达上限
+            if self.appear(self.I_UI_CONFIRM_SAMLL):
+                self.ui_click_until_disappear(self.I_UI_CONFIRM_SAMLL, interval=1)
+                logger.warning('Buy number limit')
+                break
+
             if self.click(self.C_BUY_MORE, interval=2):
                 continue
 

+ 5 - 0
tasks/Component/GeneralBattle/assets.py

@@ -120,6 +120,11 @@ class GeneralBattleAssets:
 	I_GREED_GHOST = RuleImage(roi_front=(56,40,45,45), roi_back=(56,40,45,45), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_greed_ghost.png")
 
 
+	# Ocr Rule Assets
+	# 准备 
+	O_BATTLE_PREPARE = RuleOcr(roi=(1122,546,92,51), area=(1122,546,92,51), mode="Single", method="Default", keyword="准备", name="battle_prepare")
+
+
 	# Swipe Rule Assets
 	# description 
 	S_BATTLE_RANDOM_LEFT = RuleSwipe(roi_front=(122,155,480,426), roi_back=(667,147,461,427), mode="default", name="battle_random_left")

+ 11 - 0
tasks/Component/GeneralBattle/gb/ocr.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "battle_prepare",
+    "roiFront": "1122,546,92,51",
+    "roiBack": "1122,546,92,51",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "准备",
+    "description": "准备"
+  }
+]

+ 16 - 20
tasks/Component/GeneralBattle/general_battle.py

@@ -10,17 +10,15 @@ from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
 from tasks.Component.GeneralBuff.config_buff import BuffClass
 from tasks.Component.GeneralBuff.general_buff import GeneralBuff
 
-
 from module.logger import logger
 
 
-
 class GeneralBattle(GeneralBuff, GeneralBattleAssets):
     """
     使用这个通用的战斗必须要求这个任务的config有config_general_battle
     """
 
-    def run_general_battle(self, config: GeneralBattleConfig=None, buff: BuffClass or list[BuffClass]=None) -> bool:
+    def run_general_battle(self, config: GeneralBattleConfig = None, buff: BuffClass or list[BuffClass] = None) -> bool:
         """
         运行脚本
         :return:
@@ -32,7 +30,6 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
         if config is None:
             config = GeneralBattleConfig()
 
-
         # 如果没有锁定队伍。那么可以根据配置设定队伍
         if not config.lock_team_enable:
             logger.info("Lock team is not enable")
@@ -46,11 +43,15 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
             # 点击准备按钮
             self.wait_until_appear(self.I_PREPARE_HIGHLIGHT)
             self.wait_until_appear(self.I_BUFF)
+            occur_prepare_button = False
             while 1:
                 self.screenshot()
                 if not self.appear(self.I_BUFF):
                     break
                 if self.appear_then_click(self.I_PREPARE_HIGHLIGHT, interval=1.5):
+                    occur_prepare_button = True
+                    continue
+                if occur_prepare_button and self.ocr_appear_click(self.O_BATTLE_PREPARE, interval=2):
                     continue
             logger.info("Click prepare ensure button")
 
@@ -68,8 +69,7 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
         else:
             return False
 
-
-    def run_general_battle_back(self, config: GeneralBattleConfig=None) -> bool:
+    def run_general_battle_back(self, config: GeneralBattleConfig = None) -> bool:
         """
         进入挑战然后直接返回
         :param config:
@@ -117,8 +117,7 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
 
         return True
 
-
-    def exit_battle(self, skip_first: bool=False) -> bool:
+    def exit_battle(self, skip_first: bool = False) -> bool:
         """
         在战斗的时候强制退出战斗
         :return:
@@ -150,7 +149,6 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
 
         return True
 
-
     def battle_wait(self, random_click_swipt_enable: bool) -> bool:
         """
         等待战斗结束 !!!
@@ -221,15 +219,15 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
             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):
+            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 green_mark(self, enable: bool=False, mark_mode: GreenMarkType=GreenMarkType.GREEN_MAIN):
+    def green_mark(self, enable: bool = False, mark_mode: GreenMarkType = GreenMarkType.GREEN_MAIN):
         """
         绿标, 如果不使能就直接返回
         :param enable:
@@ -271,7 +269,7 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
             # 点击绿标
             self.device.click(x, y)
 
-    def switch_preset_team(self, enable: bool=False, preset_group: int=1, preset_team: int=1):
+    def switch_preset_team(self, enable: bool = False, preset_group: int = 1, preset_team: int = 1):
         """
         切换预设的队伍, 要求是在不锁定队伍时的情况下
         :param enable:
@@ -368,9 +366,9 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
         if is_screenshot:
             self.screenshot()
         if self.appear(self.I_FRIENDS) or \
-                        self.appear(self.I_WIN) or \
-                        self.appear(self.I_FALSE) or \
-                        self.appear(self.I_REWARD):
+                self.appear(self.I_WIN) or \
+                self.appear(self.I_FALSE) or \
+                self.appear(self.I_REWARD):
             return True
         else:
             return False
@@ -443,7 +441,7 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
                 if self.appear_then_click(lock_image, interval=1):
                     continue
 
-    def check_buff(self, buff: BuffClass or list[BuffClass]=None):
+    def check_buff(self, buff: BuffClass or list[BuffClass] = None):
         """
         检测是否开启buff
         :param buff:
@@ -485,11 +483,9 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
 if __name__ == '__main__':
     from module.config.config import Config
     from module.device.device import Device
+
     c = Config('oas1')
     d = Device(c)
     t = GeneralBattle(c, d)
 
     t.check_buff([BuffClass.EXP_50, BuffClass.GOLD_50])
-
-
-

+ 8 - 1
tasks/Component/RightActivity/assets.py

@@ -8,5 +8,12 @@ from module.atom.list import RuleList
 # This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 class RightActivityAssets: 
-	pass
+
+
+	# Image Rule Assets
+	# description 
+	I_RA_OPEN = RuleImage(roi_front=(1257,78,22,58), roi_back=(1257,78,22,58), threshold=0.8, method="Template matching", file="./tasks/Component/RightActivity/ra/ra_ra_open.png")
+	# description 
+	I_RA_CLOSE = RuleImage(roi_front=(1256,123,23,44), roi_back=(1256,123,23,44), threshold=0.8, method="Template matching", file="./tasks/Component/RightActivity/ra/ra_ra_close.png")
+
 

+ 20 - 0
tasks/Component/RightActivity/ra/image.json

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "ra_open",
+    "imageName": "ra_ra_open.png",
+    "roiFront": "1257,78,22,58",
+    "roiBack": "1257,78,22,58",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "ra_close",
+    "imageName": "ra_ra_close.png",
+    "roiFront": "1256,123,23,44",
+    "roiBack": "1256,123,23,44",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  }
+]

BIN
tasks/Component/RightActivity/ra/ra_ra_close.png


BIN
tasks/Component/RightActivity/ra/ra_ra_open.png


+ 6 - 1
tasks/Component/RightActivity/right_activity.py

@@ -7,14 +7,19 @@ from module.logger import logger
 from tasks.base_task import BaseTask
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.page import page_main
+from tasks.Component.RightActivity.assets import RightActivityAssets
 
 
-class RightActivity(GameUi):
+class RightActivity(GameUi, RightActivityAssets):
     def enter(self, target: RuleImage):
         self.ui_get_current_page()
         self.ui_goto(page_main)
         self.ui_click_until_disappear(target, interval=3.5)
 
+    def right_open(self):
+        self.ui_click(self.I_RA_CLOSE, self.I_RA_OPEN, interval=2)
 
+    def right_close(self):
+        self.ui_click(self.I_RA_OPEN, self.I_RA_CLOSE, interval=2)
 
 

+ 2 - 0
tasks/Exploration/assets.py

@@ -66,6 +66,8 @@ class ExplorationAssets:
 	I_GET_REWARD = RuleImage(roi_front=(464,231,339,44), roi_back=(464,231,339,44), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_get_reward.png")
 	# description 
 	I_RED_CLOSE = RuleImage(roi_front=(1027,129,41,42), roi_back=(1021,121,54,55), threshold=0.6, method="Template matching", file="./tasks/Exploration/res/res_red_close.png")
+	# 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")
 
 
 	# Ocr Rule Assets

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

@@ -160,5 +160,14 @@
     "method": "Template matching",
     "threshold": 0.6,
     "description": "description"
+  },
+  {
+    "itemName": "e_exit_confirm",
+    "imageName": "res_e_exit_confirm.png",
+    "roiFront": "694,380,163,49",
+    "roiBack": "694,380,163,49",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
   }
 ]

BIN
tasks/Exploration/res/res_e_exit_confirm.png


+ 2 - 1
tasks/Exploration/script_task.py

@@ -11,7 +11,7 @@ from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.page import page_exploration, page_shikigami_records, page_main
 
 from module.logger import logger
-from module.exception import RequestHumanTakeover
+from module.exception import RequestHumanTakeover, TaskEnd
 from module.atom.image_grid import ImageGrid
 
 
@@ -78,6 +78,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
                 self.appear_then_click(self.I_RED_CLOSE)
             self.ui_goto(page_main)
             self.set_next_run(task='Exploration', success=True, finish=False)
+        raise TaskEnd
 
     # 查找指定的章节:
     def open_expect_level(self):

+ 2 - 2
tasks/GameUi/assets.py

@@ -126,8 +126,8 @@ class GameUiAssets:
 	I_MAIN_GOTO_ONMYODO = RuleImage(roi_front=(992,614,51,60), roi_back=(992,614,51,60), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_onmyodo.png")
 	# description 
 	I_MAIN_GOTO_FRIENDS = RuleImage(roi_front=(879,623,55,55), roi_back=(867,606,79,77), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_friends.png")
-	# description 
-	I_MAIN_GOTO_DAILY = RuleImage(roi_front=(778,612,52,54), roi_back=(759,595,84,84), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_daily.png")
+	# 进入花合战 
+	I_MAIN_GOTO_DAILY = RuleImage(roi_front=(779,612,51,67), roi_back=(754,595,89,97), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_daily.png")
 	# description 
 	I_MAIN_GOTO_MALL = RuleImage(roi_front=(663,661,41,22), roi_back=(644,613,81,78), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_mall.png")
 	# description 

+ 3 - 3
tasks/GameUi/page/page_img_3.json

@@ -29,11 +29,11 @@
   {
     "itemName": "main_goto_daily",
     "imageName": "page_main_goto_daily.png",
-    "roiFront": "778,612,52,54",
-    "roiBack": "759,595,84,84",
+    "roiFront": "779,612,51,67",
+    "roiBack": "754,595,89,97",
     "method": "Template matching",
     "threshold": 0.7,
-    "description": "description"
+    "description": "进入花合战"
   },
   {
     "itemName": "main_goto_mall",

BIN
tasks/GameUi/page/page_main_goto_daily.png


+ 3 - 0
tasks/Hyakkiyakou/.gitignore

@@ -0,0 +1,3 @@
+
+/utils/exp_gen.py
+/temp

+ 17 - 4
tasks/Hyakkiyakou/assets.py

@@ -10,13 +10,18 @@ from module.atom.list import RuleList
 class HyakkiyakouAssets: 
 
 
+	# Click Rule Assets
+	# description 
+	C_CLICK = RuleClick(roi_front=(26,250,33,100), roi_back=(26,250,33,100), name="click")
+
+
 	# Image Rule Assets
 	# 缘结之庭 
 	I_TPAGE_1 = RuleImage(roi_front=(238,504,221,123), roi_back=(121,480,950,166), threshold=0.7, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tpage_1.png")
 	# 本丸御殿 
-	I_TPAGE_2 = RuleImage(roi_front=(491,506,231,120), roi_back=(132,479,933,171), threshold=0.7, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tpage_2.png")
+	I_TPAGE_2 = RuleImage(roi_front=(411,506,231,120), roi_back=(132,479,933,171), threshold=0.5, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tpage_2.png")
 	# 之境 
-	I_TPAGE_3 = RuleImage(roi_front=(748,504,240,118), roi_back=(125,482,937,166), threshold=0.7, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tpage_3.png")
+	I_TPAGE_3 = RuleImage(roi_front=(748,504,240,118), roi_back=(125,482,937,166), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tpage_3.png")
 	# 鲸歌潜岸 
 	I_TPAGE_4 = RuleImage(roi_front=(281,507,233,120), roi_back=(124,484,933,163), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tpage_4.png")
 	# 杨帆远航 
@@ -32,15 +37,23 @@ class HyakkiyakouAssets:
 	# description 
 	I_TCHECK_4 = RuleImage(roi_front=(7,108,100,332), roi_back=(0,101,120,347), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tcheck_4.png")
 	# description 
-	I_TCHECK_5 = RuleImage(roi_front=(23,111,100,355), roi_back=(9,99,134,378), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tcheck_5.png")
+	I_TCHECK_5 = RuleImage(roi_front=(132,28,77,103), roi_back=(94,13,152,234), threshold=0.4, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tcheck_5.png")
 	# description 
 	I_TCHECK_6 = RuleImage(roi_front=(9,107,100,350), roi_back=(3,97,113,369), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tcheck_6.png")
 	# description 
 	I_SWITCH_BACKGROUND = RuleImage(roi_front=(992,649,105,36), roi_back=(969,627,152,72), threshold=0.7, method="Template matching", file="./tasks/Hyakkiyakou/train/train_switch_background.png")
+	# description 
+	I_TCHECK_22 = RuleImage(roi_front=(14,150,100,100), roi_back=(5,139,124,127), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tcheck_22.png")
+	# description 
+	I_TCHECK_32 = RuleImage(roi_front=(35,175,100,100), roi_back=(26,155,123,141), threshold=0.7, method="Template matching", file="./tasks/Hyakkiyakou/train/train_tcheck_32.png")
+	# 检查是否在砸豆子 
+	I_CHECK_RUN = RuleImage(roi_front=(95,598,92,45), roi_back=(68,578,143,100), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/train/train_check_run.png")
 
 
 	# Swipe Rule Assets
 	# description 
-	S_TSWIPE = RuleSwipe(roi_front=(612,527,21,91), roi_back=(359,519,23,100), mode="default", name="tswipe")
+	S_TSWIPE = RuleSwipe(roi_front=(421,521,21,91), roi_back=(273,516,23,100), mode="default", name="tswipe")
+	# description 
+	S_TBACK = RuleSwipe(roi_front=(259,515,21,100), roi_back=(993,521,22,100), mode="default", name="tback")
 
 

+ 8 - 0
tasks/Hyakkiyakou/train/click.json

@@ -0,0 +1,8 @@
+[
+  {
+    "itemName": "click",
+    "roiFront": "26,250,33,100",
+    "roiBack": "26,250,33,100",
+    "description": "description"
+  }
+]

+ 33 - 6
tasks/Hyakkiyakou/train/image.json

@@ -11,10 +11,10 @@
   {
     "itemName": "tpage_2",
     "imageName": "train_tpage_2.png",
-    "roiFront": "491,506,231,120",
+    "roiFront": "411,506,231,120",
     "roiBack": "132,479,933,171",
     "method": "Template matching",
-    "threshold": 0.7,
+    "threshold": 0.5,
     "description": "本丸御殿"
   },
   {
@@ -23,7 +23,7 @@
     "roiFront": "748,504,240,118",
     "roiBack": "125,482,937,166",
     "method": "Template matching",
-    "threshold": 0.7,
+    "threshold": 0.8,
     "description": "之境"
   },
   {
@@ -92,10 +92,10 @@
   {
     "itemName": "tcheck_5",
     "imageName": "train_tcheck_5.png",
-    "roiFront": "23,111,100,355",
-    "roiBack": "9,99,134,378",
+    "roiFront": "132,28,77,103",
+    "roiBack": "94,13,152,234",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.4,
     "description": "description"
   },
   {
@@ -115,5 +115,32 @@
     "method": "Template matching",
     "threshold": 0.7,
     "description": "description"
+  },
+  {
+    "itemName": "tcheck_22",
+    "imageName": "train_tcheck_22.png",
+    "roiFront": "14,150,100,100",
+    "roiBack": "5,139,124,127",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "tcheck_32",
+    "imageName": "train_tcheck_32.png",
+    "roiFront": "35,175,100,100",
+    "roiBack": "26,155,123,141",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "description"
+  },
+  {
+    "itemName": "check_run",
+    "imageName": "train_check_run.png",
+    "roiFront": "95,598,92,45",
+    "roiBack": "68,578,143,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "检查是否在砸豆子"
   }
 ]

+ 9 - 2
tasks/Hyakkiyakou/train/swipe.json

@@ -1,8 +1,15 @@
 [
   {
     "itemName": "tswipe",
-    "roiFront": "612,527,21,91",
-    "roiBack": "359,519,23,100",
+    "roiFront": "421,521,21,91",
+    "roiBack": "273,516,23,100",
+    "mode": "default",
+    "description": "description"
+  },
+  {
+    "itemName": "tback",
+    "roiFront": "259,515,21,100",
+    "roiBack": "993,521,22,100",
     "mode": "default",
     "description": "description"
   }

BIN
tasks/Hyakkiyakou/train/train_check_run.png


BIN
tasks/Hyakkiyakou/train/train_tcheck_22.png


BIN
tasks/Hyakkiyakou/train/train_tcheck_32.png


BIN
tasks/Hyakkiyakou/train/train_tcheck_5.png


BIN
tasks/Hyakkiyakou/train/train_tpage_2.png


+ 326 - 0
tasks/Hyakkiyakou/utils/exp_test.py

@@ -0,0 +1,326 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import cv2
+import random
+
+from datetime import datetime
+from pathlib import Path
+from cached_property import cached_property
+
+from module.logger import logger
+from module.base.timer import Timer
+from module.atom.click import RuleClick
+
+from tasks.Exploration.assets import ExplorationAssets
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_main, page_town, page_exploration
+from tasks.base_task import BaseTask
+from tasks.Script.config_device import ScreenshotMethod, ControlMethod
+from tasks.Component.RightActivity.right_activity import RightActivity
+from tasks.Restart.assets import RestartAssets
+
+from utils import usage_time
+from fast_device import FastDevice
+
+
+class Step:
+    def __init__(self,
+                 step_name: str,
+                 pos: tuple,
+                 time: float,
+                 check=None,
+                 save_img: bool = False,
+                 save_interval: float = 0.1,
+                 save_time: float = None,
+                 save_max: int = None,
+                 save_roi: tuple = (0, 0),
+                 info: dict = None,
+                 ) -> None:
+        self.step_name = step_name
+        self.pos = pos
+        self.time = time
+        self.check = check
+        self.save_img = save_img
+        self.save_interval = save_interval
+        self.save_time = save_time if save_time else time
+        self.save_max = save_max
+        self.save_roi = save_roi
+        self.info = info
+        x_start, y_start = self.save_roi
+        if x_start > 640 or y_start > 80:
+            raise ValueError(f'Invalid roi: {self.save_roi}')
+
+    def __str__(self):
+        return f'{self.step_name}'
+
+    def __repr__(self):
+        return f'{self.step_name}'
+
+
+# -----------------------------------------------------------------------
+
+
+# -----------------------------------------------------------------------
+
+class ExpTest(RightActivity, FastDevice, RestartAssets, ExplorationAssets):
+
+    @cached_property
+    def save_path(self) -> Path:
+        save_path = Path(f'./tasks/Hyakkiyakou/temp/{self.name}')
+        save_path.mkdir(parents=True, exist_ok=True)
+        return save_path
+
+    def init(self, name: str):
+        self.name = name
+        self.config.model.script.device.screenshot_method = ScreenshotMethod.WINDOW_BACKGROUND
+        self.config.model.script.device.control_method = ControlMethod.WINDOW_MESSAGE
+
+    def _exit(self):
+        self.ui_get_current_page()
+        self.ui_goto(page_town)
+        self.right_close()
+        self.ui_click(self.I_LOGIN_SCROOLL_OPEN, self.I_LOGIN_SCROOLL_CLOSE, interval=1)
+
+    def _go(self):
+        self.ui_get_current_page()
+        self.ui_goto(page_exploration)
+
+    def run_step(self, step: Step):
+        logger.hr(f'Running step: {step}', 1)
+        cache_image: dict = {}
+        timer_step = Timer(step.time)
+        timer_save_img = Timer(step.save_time)
+        timer_save_interval = Timer(step.save_interval)
+        save_image_count = 0
+        start_flag = False
+        while 1:
+            with usage_time('screenshot'):
+                self.fast_screenshot()
+
+            if not start_flag:
+                with usage_time('click'):
+                    self.device.click(x=step.pos[0], y=step.pos[1])
+                timer_step.start()
+                timer_save_img.start()
+                timer_save_interval.start()
+                start_flag = True
+            if not start_flag:
+                continue
+            if timer_step.reached():
+                break
+            if not step.save_img:
+                continue
+            if timer_save_img.reached():
+                continue
+            if step.save_max and save_image_count >= step.save_max:
+                continue
+            if timer_save_interval.reached():
+                timer_save_interval.reset()
+                save_image_count += 1
+                save_name = f't@{self.name}@{int(datetime.now().timestamp() * 1000)}_{save_image_count:03d}.png'
+                x_start, y_start = step.save_roi
+                img = self.device.image[y_start:y_start + 640, x_start:x_start + 640]
+                cache_image[save_name] = img
+                logger.info(f'Save image: {save_name}')
+                # cv2.imwrite(str(self.save_path / save_name), img)
+        if cache_image:
+            logger.info(f'Save image: {cache_image.keys()}')
+            for key, value in cache_image.items():
+                cv2.imwrite(str(self.save_path / key), value)
+
+    def run_town(self):
+        step_a = (641, 474)
+        step_b = (1165, 481)
+        step_c = (641, 556)
+        step_d = (1231, 567)
+        step_save_roi = (640, 80)
+        step_1 = Step('step_1', pos=step_b, time=2)
+        step_2 = Step('step_2', pos=step_a, time=2, save_img=True, save_roi=step_save_roi)
+        step_3 = Step('step_3', pos=step_b, time=2)
+        step_4 = Step('step_4', pos=step_c, time=2, save_img=True, save_roi=step_save_roi)
+        step_5 = Step('step_5', pos=step_d, time=2)
+        step_6 = Step('step_6', pos=step_a, time=2, save_img=True, save_roi=step_save_roi)
+        step_7 = Step('step_7', pos=step_d, time=2)
+        step_8 = Step('step_8', pos=step_c, time=2, save_img=True, save_roi=step_save_roi)
+        self.run_step(step_1)
+        self.run_step(step_2)
+        self.run_step(step_3)
+        self.run_step(step_4)
+        self.run_step(step_5)
+        self.run_step(step_6)
+        self.run_step(step_7)
+        self.run_step(step_8)
+
+    def exp_enter(self, layer: int = 25):
+        w = 188
+        h = 80
+        x_25, y_25 = 1052, 208
+        x_26, y_26 = 1052, 316
+        x_27, y_27 = 1052, 443
+        x_28, y_28 = 1052, 564
+        exp_click_25 = RuleClick(roi_front=(x_25, y_25, w, h), roi_back=(x_25, y_25, w, h), name="exp_click_25")
+        exp_click_26 = RuleClick(roi_front=(x_26, y_26, w, h), roi_back=(x_26, y_26, w, h), name="exp_click_26")
+        exp_click_27 = RuleClick(roi_front=(x_27, y_27, w, h), roi_back=(x_27, y_27, w, h), name="exp_click_27")
+        exp_click_28 = RuleClick(roi_front=(x_28, y_28, w, h), roi_back=(x_28, y_28, w, h), name="exp_click_28")
+        match layer:
+            case 25:
+                exp_click = exp_click_25
+            case 26:
+                exp_click = exp_click_26
+            case 27:
+                exp_click = exp_click_27
+            case 28:
+                exp_click = exp_click_28
+            case _:
+                exp_click = exp_click_28
+        self.ui_click(exp_click, self.I_E_EXPLORATION_CLICK)
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_E_AUTO_ROTATE_ON) or self.appear(self.I_E_AUTO_ROTATE_OFF):
+                break
+            if self.appear_then_click(self.I_E_EXPLORATION_CLICK, interval=1):
+                continue
+        from time import sleep
+        sleep(1)
+        logger.info(f'Enter exploration {layer}')
+
+    def exp_exit(self):
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_UI_BACK_RED):
+                break
+            if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                continue
+            if self.appear_then_click(self.I_UI_CONFIRM_SAMLL, interval=1):
+                continue
+            if self.appear_then_click(self.I_E_EXIT_CONFIRM, interval=1):
+                continue
+            if self.appear_then_click(self.I_UI_BACK_BLUE, interval=1.5):
+                continue
+        self.ui_click_until_disappear(self.I_UI_BACK_RED, interval=0.5)
+
+    def run_exp_25(self):
+        pos_right = 1270
+        pos_left = 260
+        pos_top = 390
+        pos_bottom = 500
+        pos_level = (pos_top + pos_bottom) / 2
+
+        step_1 = Step('step_1', pos=(pos_right, random.randint(pos_top, pos_bottom)), time=2.1)
+        step_2 = Step('step_2', pos=(pos_right, random.randint(pos_top, pos_bottom)), time=2.1)
+        step_3 = Step('step_3', pos=(pos_right, random.randint(pos_top, pos_bottom)), time=2.1)
+        step_4 = Step('step_4', pos=(pos_right, random.randint(pos_top, pos_bottom)), time=2.1)
+        step_5 = Step('step_5', pos=(pos_right, pos_bottom), time=2.1)
+
+        save_time = 1.6
+        back_1 = Step('back_1', pos=(pos_left, pos_bottom), time=1, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_2 = Step('back_2', pos=(pos_left, pos_top), time=2, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_3 = Step('back_3', pos=(pos_left, pos_top), time=2, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_4 = Step('back_4', pos=(pos_left, pos_bottom), time=2,  save_time=1.6, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_5 = Step('back_5', pos=(pos_left, pos_level), time=save_time, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+
+        self.run_step(step_1)
+        self.run_step(step_2)
+        self.run_step(step_3)
+        self.run_step(step_4)
+        self.run_step(step_5)
+        self.run_step(back_1)
+        self.run_step(back_2)
+        self.run_step(back_3)
+        self.run_step(back_4)
+        self.run_step(back_5)
+
+    def run_exp_26(self):
+        pos_right = 1270
+        pos_left = 260
+        pos_top = 454
+        pos_bottom = 620
+        pos_level = (pos_top + pos_bottom) / 2
+        step_1 = Step('step_1', pos=(pos_right, random.randint(pos_top, pos_bottom)), time=2.1)
+        step_2 = Step('step_2', pos=(pos_right, random.randint(pos_top, pos_bottom)), time=2.1)
+        step_3 = Step('step_3', pos=(pos_right, random.randint(pos_top, pos_bottom)), time=2.1)
+        step_4 = Step('step_4', pos=(pos_right, pos_bottom), time=2.1)
+        self.run_step(step_1)
+        self.run_step(step_2)
+        self.run_step(step_3)
+        self.run_step(step_4)
+
+        back_1 = Step('back_1', pos=(pos_left, pos_bottom), time=1, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_2 = Step('back_2', pos=(pos_left, pos_top), time=2, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_3 = Step('back_3', pos=(pos_left, pos_top), time=2, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_4 = Step('back_4', pos=(pos_left, pos_bottom), time=2, save_time=1.6, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_5 = Step('back_5', pos=(pos_left, pos_level), time=1.7, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+
+        self.run_step(back_1)
+        self.run_step(back_2)
+        self.run_step(back_3)
+        self.run_step(back_4)
+        self.run_step(back_5)
+
+    def run_exp_27(self):
+        pos_right = 1270
+        pos_left = 260
+        pos_top = 510
+        pos_bottom = 620
+        pos_level = (pos_top + pos_bottom) / 2
+        step_1 = Step('step_1', pos=(pos_right, random.randint(pos_top, pos_bottom)), time=2.1)
+        step_2 = Step('step_2', pos=(pos_right, random.randint(pos_top, pos_bottom)), time=2.3)
+        step_3 = Step('step_3', pos=(pos_right, random.randint(pos_top, pos_bottom)), time=2.5)
+        step_4 = Step('step_4', pos=(pos_right, pos_bottom), time=2.9)
+        self.run_step(step_1)
+        self.run_step(step_2)
+        self.run_step(step_3)
+        self.run_step(step_4)
+
+        back_1 = Step('back_1', pos=(pos_left, pos_bottom), time=1, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_2 = Step('back_2', pos=(pos_left, pos_top), time=2, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_3 = Step('back_3', pos=(pos_left, pos_top), time=2, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_4 = Step('back_4', pos=(pos_left, pos_bottom), time=2, save_time=1.6, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+        back_5 = Step('back_5', pos=(pos_left, pos_level), time=1.4, save_img=True,
+                      save_roi=(random.randint(100, 540), 80))
+
+        self.run_step(back_1)
+        self.run_step(back_2)
+        self.run_step(back_3)
+        self.run_step(back_4)
+        self.run_step(back_5)
+
+    def run_main(self):
+        from time import sleep
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+        sleep(1)
+
+        pos_right = 1270
+        pos_left = 540
+        pos_top = 540
+        pos_bottom = 660
+        step_1 = Step('step_1', pos=(pos_right, pos_top), time=2.1)
+        back_1 = Step('back_1', pos=(pos_left, pos_top), time=1.7, save_img=True, save_roi=(640, 80))
+        step_2 = step_1
+        step_2.name = 'step_2'
+        back_2 = Step('back_2', pos=(pos_left, pos_bottom), time=1.7, save_img=True, save_roi=(640, 80))
+
+        self.run_step(step_1)
+        self.run_step(back_1)
+        self.run_step(step_2)
+        self.run_step(back_2)
+
+    def back_main(self):
+        self.ui_get_current_page()
+        self.ui_goto(page_main)

+ 15 - 0
tasks/Hyakkiyakou/utils/fast_device.py

@@ -0,0 +1,15 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+
+
+from tasks.base_task import BaseTask
+from tasks.Script.config_device import ScreenshotMethod, ControlMethod
+
+class FastDevice(BaseTask):
+
+    def fast_screenshot(self):
+        if self.config.model.script.device.screenshot_method != ScreenshotMethod.WINDOW_BACKGROUND:
+            raise
+        self.device.image = self.device.screenshot_window_background()
+        return self.device.image

+ 89 - 14
tasks/Hyakkiyakou/generate.py → tasks/Hyakkiyakou/utils/generate.py

@@ -4,6 +4,7 @@
 import cv2
 from time import time, sleep
 from random import randint
+from pathlib import Path
 from cached_property import cached_property
 
 from module.daemon.benchmark import Benchmark
@@ -20,8 +21,11 @@ class ScriptTask(Benchmark, HyakkiyakouAssets):
                            roi_back=(667, 147, 461, 427),
                            mode="default",
                            name="Left Swipe")
+    hero_name = ''
 
     def run_simple(self, hero_name: str='test'):
+        self.screenshot_benchmark()
+        ScriptTask.hero_name = hero_name
         self.add_one_video(hero_name, index=0)
 
     def run(self, hero_name: str = 'test'):
@@ -29,13 +33,16 @@ class ScriptTask(Benchmark, HyakkiyakouAssets):
         :param hero_name: 你式神的名字
         :return:
         """
+        ScriptTask.hero_name = hero_name
         self.screenshot_benchmark()
         self.record_one(self.I_TPAGE_1, self.I_TCHECK_1, hero_name, index=1)
         self.record_one(self.I_TPAGE_2, self.I_TCHECK_2, hero_name, index=2)
         self.record_one(self.I_TPAGE_3, self.I_TCHECK_3, hero_name, index=3)
         self.record_one(self.I_TPAGE_4, self.I_TCHECK_4, hero_name, index=4)
-        self.record_one(self.I_TPAGE_5, self.I_TCHECK_5, hero_name, index=5)
         self.record_one(self.I_TPAGE_6, self.I_TCHECK_6, hero_name, index=6)
+        self.record_one(self.I_TPAGE_5, self.I_TCHECK_5, hero_name, index=5)
+
+        self.back_one()
 
     def screenshot_benchmark(self):
         self.config.model.script.device.screenshot_method = ScreenshotMethod.WINDOW_BACKGROUND
@@ -44,7 +51,9 @@ class ScriptTask(Benchmark, HyakkiyakouAssets):
 
     @classmethod
     def video(cls, name: str = 'test'):
-        return cv2.VideoWriter(f'./log/tmp/{name}_{int(time() * 1000)}.avi',
+        path = f'./log/tmp/{ScriptTask.hero_name}'
+        Path(path).mkdir(parents=True, exist_ok=True)
+        return cv2.VideoWriter(f'{path}/{name}@{int(time() * 1000)}.avi',
                                cv2.VideoWriter_fourcc(*'XVID'),
                                10,  # fps
                                (1280, 720),  # frame size
@@ -54,46 +63,112 @@ class ScriptTask(Benchmark, HyakkiyakouAssets):
         self.screenshot()
         video.write(self.device.image)
         # 竖直方向在240-480之间随机滑动
-        self.device.swipe(p1=(640, 240 + randint(0, 240)), p2=(640 - 64, 240 + randint(0, 240)),
+        self.device.swipe(p1=(640, 690 + randint(0, 28)), p2=(640 - 64, 690 + randint(0, 28)),
                           distance_check=False)
         # self.device.swipe(p1=(640, 360), p2=(640-64, 360))
-        sleep(0.5)
+        sleep(0.05)
 
     def add_one_video(self, name: str, index: int = 0):
-        video = ScriptTask.video(name=f'{name}_{index}')
+        video = ScriptTask.video(name=f'{name}@{index}')
         for _ in range(20):
             self.add_one_frame(video)
         video.release()
         cv2.destroyAllWindows()
 
     def record_one(self, tpage: RuleImage, tcheck: RuleImage, name: str, index: int = 0):
-        logger.info(f'开始录制第{index}个视频')
+        logger.hr(f'开始录制第{index}个视频')
+        skip_swipe_time = 2
         while 1:
             self.screenshot()
-            if self.appear(tpage):
-                self.ui_click(tpage, tcheck)
-                break
             self.appear_then_click(self.I_SWITCH_BACKGROUND, interval=4)
+            sleep(0.5)
+            if self.appear(tpage) or self.appear(tcheck):
+                # self.ui_click(tpage, tcheck)
+                click_count = 0
+                while 1:
+                    self.screenshot()
+                    if self.appear(tcheck):
+                        break
+                    if tcheck == self.I_TCHECK_2 and self.appear(self.I_TCHECK_22):
+                        logger.warning('I_TCHECK_22')
+                        break
+                    if tcheck == self.I_TCHECK_3 and self.appear(self.I_TCHECK_32):
+                        logger.warning('I_TCHECK_32')
+                        break
+                    if click_count > 5:
+                        logger.warning('已经点击背景五次了')
+                        break
+
+                    if self.appear_then_click(tpage, interval=2):
+                        click_count += 1
+                        continue
+                break
+
+            sleep(0.5)
+            if skip_swipe_time > 0:
+                skip_swipe_time -= 1
+                continue
+            self.swipe(self.S_TSWIPE, interval=1.5)
             sleep(1)
-            self.swipe(self.S_TSWIPE, interval=2.5)
         while 1:
             self.screenshot()
             if not self.appear(tpage):
                 break
             if self.appear_then_click(tcheck, interval=1.2):
                 continue
+            if self.click(self.C_CLICK, interval=4):
+                continue
+            if self.appear_then_click(self.I_TCHECK_22, interval=2):
+                continue
+            if self.appear_then_click(self.I_TCHECK_32, interval=2):
+                continue
 
         logger.info(f'已进入第{index}个背景')
+        sleep(0.5)
         self.add_one_video(name, index=index)
 
+    def back_one(self):
+        while 1:
+            self.screenshot()
+            if (self.appear(self.I_TPAGE_5)
+                    or self.appear(self.I_TPAGE_6)
+                    or self.appear(self.I_TCHECK_4)):
+                break
+            if self.appear_then_click(self.I_SWITCH_BACKGROUND, interval=1.2):
+                continue
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_TPAGE_1):
+                break
+            if self.swipe(self.S_TBACK, interval=2):
+                sleep(1.5)
+                continue
+        self.ui_click(self.I_TPAGE_1, self.I_TCHECK_1)
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_TPAGE_1):
+                break
+            if self.appear_then_click(self.I_TCHECK_1, interval=1.2):
+                continue
+
+
+
+
+
 
 if __name__ == '__main__':
     from module.config.config import Config
     from module.device.device import Device
 
-    c = Config('test')
+    c = Config('oas2')
     d = Device(c)
     t = ScriptTask(c, d)
-    HERO_NAME = 'test'
-    # t.run(HERO_NAME)
-    t.run_simple(HERO_NAME)
+    HERO_NAME = 'g_015'
+    # t.run_simple(HERO_NAME)
+    t.run(HERO_NAME)
+
+
+
+
+
+

+ 28 - 0
tasks/Hyakkiyakou/utils/utils.py

@@ -0,0 +1,28 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+
+
+from datetime import datetime
+
+from module.logger import logger
+
+
+class usage_time:
+    def __init__(self, name: str = None):
+        self.name = 'Timer' if name is None else name
+
+    def __enter__(self):
+        self.start_time = datetime.now()
+        return self
+
+    def __exit__(self, exc_type, exc_value, traceback):
+        self.end_time = datetime.now()
+        execution_time = self.end_time - self.start_time
+        logger.info(f'{str(self.name)}: {execution_time.total_seconds() * 1000 }ms')
+
+
+if __name__ == '__main__':
+    with usage_time('test'):
+        print('test1')
+    print('end')

+ 126 - 0
tasks/Hyakkiyakou/utils/video2images.py

@@ -0,0 +1,126 @@
+import cv2
+
+from datetime import datetime
+from pathlib import Path
+
+from module.logger import logger
+
+from tasks.base_task import BaseTask
+from tasks.Hyakkiyakou.assets import HyakkiyakouAssets
+
+
+class TransformVideo(HyakkiyakouAssets):
+    def __init__(self, change_channel: bool = False, interval: float = 2):
+        """
+
+        @param interval: 视频帧间隔,默认2
+        @param change_channel: 修改视频通道数,默认False
+        """
+        self.change_channel = change_channel
+        self.interval = interval
+
+    def run(self, video: str | Path, save_path: str | Path):
+        """
+
+        @param video: 视频的路径,可以是单个视频也可以是一个文件夹
+        @param save_path: 保存的路径
+        @return:
+        """
+        if isinstance(video, str):
+            video = Path(video)
+        if not isinstance(video, Path):
+            logger.error(f'{video} is not a valid path')
+            return
+        if isinstance(save_path, str):
+            save_path = Path(save_path)
+        if not isinstance(save_path, Path):
+            logger.error(f'{save_path} is not a valid path')
+            return
+        save_path.mkdir(parents=True, exist_ok=True)
+        if video.is_dir():
+            for video_file in video.iterdir():
+                self.parse_one(video_file, save_path)
+        else:
+            self.parse_one(video, save_path)
+
+    def parse_one(self, video: Path, save_path: Path = None, mode: int = 2):
+        """
+        单次解析一个视频
+        @param mode: 0:左边 1:右边 2: 两边
+        @param video:
+        @param save_path:
+        @return:
+        """
+        if isinstance(video, str):
+            video = Path(video)
+        if not save_path:
+            save_path = video.parent / f'images_{video.stem}'
+        if isinstance(save_path, str):
+            save_path = Path(save_path)
+        save_path.mkdir(parents=True, exist_ok=True)
+        # 获取时间戳的str形式,用来命名图片
+        datetime_now = datetime.now().strftime('%Y%m%dT%H%M%S')
+        logger.info(f'Start transform video {video}')
+
+        cap = cv2.VideoCapture(str(video))
+        if not cap.isOpened():
+            logger.error(f'{video} open failed')
+            return
+        fps = cap.get(cv2.CAP_PROP_FPS)
+        frame_skip = int(fps * self.interval)
+        count_frame = 0  # 抽帧用的
+        index_frame = 0  # 记录
+        while 1:
+            ret, frame = cap.read()
+            if not ret:
+                break
+
+                # 抽帧
+            count_frame += 1
+            if count_frame % frame_skip != 0:
+                continue
+
+            h, w, _ = frame.shape
+            if h == 720 and w == 1280:
+                pass
+            elif h == 720 and w != 1280:
+                frame = frame[:, 0:1280]
+            elif w != 1280 and h != 720:
+                frame = cv2.resize(frame, (1280, 720))
+            frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
+
+            # 检查是否是百鬼夜行中
+            # if not self.I_CHECK_RUN.match(frame, threshold=0.5):
+            #     continue
+            if not self.change_channel:
+                frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
+            index_frame += 1
+
+            h, w, _ = frame.shape
+
+            match mode:
+                case 0:
+                    img_a = frame[h-640:, 0:640]
+                    img_b = None
+                case 1:
+                    img_a = None
+                    img_b = frame[h-640:, 640:1280]
+                case 2:
+                    img_a = frame[h-640:, 0:640]
+                    img_b = frame[h-640:, 640:1280]
+                case _:
+                    raise ValueError('mode must be 0, 1, or 2')
+            if img_a is not None:
+                cv2.imwrite(str(save_path / f'{datetime_now}_{index_frame:05d}a.png'), img_a)
+            if img_b is not None:
+                cv2.imwrite(str(save_path / f'{datetime_now}_{index_frame:05d}b.png'), img_b)
+
+        cap.release()
+        logger.info(f'{video} done')
+
+
+if __name__ == '__main__':
+    VIDEO = r'C:\Users\Ryland\Downloads\202404031513.mp4'
+    # SAVE_PATH = 'D:/Project/Hyakkiyakou/OnmyojiAutoScript-hyakkiyakou/temp/sources_images'
+    t = TransformVideo(change_channel=True, interval=0.1)
+    t.parse_one(VIDEO, mode=2)

+ 2 - 2
tasks/KekkaiActivation/assets.py

@@ -88,9 +88,9 @@ class KekkaiActivationAssets:
 	# description 
 	I_CARDS_FISH_6 = RuleImage(roi_front=(193,183,87,91), roi_back=(178,169,110,474), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_fish_6.png")
 	# description 
-	I_CARDS_FISH_5 = RuleImage(roi_front=(192,358,88,21), roi_back=(176,155,105,492), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_fish_5.png")
+	I_CARDS_FISH_5 = RuleImage(roi_front=(192,329,88,90), roi_back=(176,155,116,492), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_fish_5.png")
 	# description 
-	I_CARDS_FISH_4 = RuleImage(roi_front=(192,409,87,21), roi_back=(176,175,118,473), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_fish_4.png")
+	I_CARDS_FISH_4 = RuleImage(roi_front=(192,409,87,21), roi_back=(176,175,118,473), threshold=0.7, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_fish_4.png")
 	# description 
 	I_CARDS_FISH_3 = RuleImage(roi_front=(193,314,86,64), roi_back=(188,164,100,482), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_fish_3.png")
 	# description 

BIN
tasks/KekkaiActivation/cards/cards_cards_fish_5.png


+ 4 - 4
tasks/KekkaiActivation/cards/image.json

@@ -47,10 +47,10 @@
   {
     "itemName": "cards_fish_5",
     "imageName": "cards_cards_fish_5.png",
-    "roiFront": "192,358,88,21",
-    "roiBack": "176,155,105,492",
+    "roiFront": "192,329,88,90",
+    "roiBack": "176,155,116,492",
     "method": "Template matching",
-    "threshold": 0.9,
+    "threshold": 0.8,
     "description": "description"
   },
   {
@@ -59,7 +59,7 @@
     "roiFront": "192,409,87,21",
     "roiBack": "176,175,118,473",
     "method": "Template matching",
-    "threshold": 0.9,
+    "threshold": 0.7,
     "description": "description"
   },
   {

+ 2 - 10
tasks/RichMan/mall/special.py

@@ -49,7 +49,7 @@ class Special(Buy, MallNavbar):
             if self.swipe(self.S_SP_DOWN, interval=2):
                 time.sleep(2)
 
-    def _special_totom(self, totem_pass:bool):
+    def _special_totom(self, totem_pass: bool):
         """
         购买御灵,要求必须下滑出现御灵
         :return:
@@ -108,7 +108,6 @@ class Special(Buy, MallNavbar):
             self.buy_more(self.I_SP_BUY_MEDIUM, buy_res_number)
             time.sleep(0.5)
 
-
     def _special_low(self, buy_number: int = 10):
         """
         购买低级盘,要求必须下滑出现低级盘
@@ -144,8 +143,6 @@ class Special(Buy, MallNavbar):
             self.buy_more(self.I_SP_BUY_LOW, buy_res_number)
             time.sleep(0.5)
 
-
-
     def _special_check_remain(self, target: RuleImage):
         """
         检查这个种类的剩余, 要求必须这个出现在当前的页面
@@ -155,7 +152,7 @@ class Special(Buy, MallNavbar):
         upper_midpoint = target.roi_front[0] + target.roi_front[2] // 2, target.roi_front[1]
         # 重设roi
         roi = self.O_SP_RES_NUMBER.roi
-        self.O_SP_RES_NUMBER.roi[0] = upper_midpoint[0] - roi[2]//2
+        self.O_SP_RES_NUMBER.roi[0] = upper_midpoint[0] - roi[2] // 2
         self.O_SP_RES_NUMBER.roi[1] = upper_midpoint[1] - roi[3]
         # logger.info(f'图片的ROI是: {target.roi_front}')
         # logger.info(f'上中点是:{upper_midpoint}')
@@ -184,8 +181,3 @@ if __name__ == '__main__':
     t = Special(c, d)
 
     t.execute_special()
-
-
-
-
-

+ 2 - 1
tasks/Script/config_device.py

@@ -9,8 +9,9 @@ from module.logger import logger
 class PackageName(str, Enum):
     AUTO = 'auto'
     NETEASE_ONMYOJI = 'com.netease.onmyoji.wyzymnqsd_cps'  # 网易自家的阴阳师
-    NETEASE_MI = 'com.netease.onmyoji.mi'
+    NETEASE_MI = 'com.netease.onmyoji.mi'  # 小米
     NETEASE = 'com.netease.onmyoji'
+    NETEASE_HUAWEI = 'com.netease.onmyoji.huawei'
 
 class ScreenshotMethod(str, Enum):
     AUTO = 'auto'

+ 4 - 0
tasks/base_task.py

@@ -40,6 +40,10 @@ class BaseTask(GlobalGameAssets, CostumeBase):
     current_count: int = None  # 当前运行的次数
 
     def __init__(self, config: Config, device: Device) -> None:
+        """
+
+        :rtype: object
+        """
         self.config = config
         self.device = device