Преглед изворни кода

Merge pull request #48 from runhey/dev

Dev
huangrunheng пре 3 година
родитељ
комит
aac3a8df1c
100 измењених фајлова са 1676 додато и 172 уклоњено
  1. 5 1
      module/config/config.py
  2. 1 0
      module/config/config_menu.py
  3. 24 0
      module/config/config_modify.py
  4. BIN
      module/config/i18n/zh_CN.qm
  5. 59 65
      module/config/i18n/zh_CN.ts
  6. 1 1
      module/device/handle.py
  7. 88 30
      module/device/method/window.py
  8. 16 2
      module/gui/context/process_manager.py
  9. 1 0
      module/gui/qml.qrc
  10. 191 0
      module/gui/qml/Content/TaskList.qml
  11. 10 0
      module/gui/qml/Page/ScriptView.qml
  12. 36 3
      script.py
  13. 1 1
      tasks/ActivityShikigami/assets.py
  14. 1 1
      tasks/AreaBoss/assets.py
  15. 1 1
      tasks/BondlingFairyland/assets.py
  16. 1 1
      tasks/Component/BaseActivity/assets.py
  17. 3 1
      tasks/Component/GeneralBattle/assets.py
  18. BIN
      tasks/Component/GeneralBattle/gb/gb_friends.png
  19. 9 0
      tasks/Component/GeneralBattle/gb/image.json
  20. 31 0
      tasks/Component/GeneralBattle/general_battle.py
  21. 1 1
      tasks/Component/GeneralBuff/assets.py
  22. 1 1
      tasks/Component/GeneralInvite/assets.py
  23. 4 2
      tasks/Component/GeneralInvite/general_invite.py
  24. 1 1
      tasks/Component/GeneralRoom/assets.py
  25. 6 1
      tasks/Component/ReplaceShikigami/assets.py
  26. 4 0
      tasks/Component/ReplaceShikigami/replace_shikigami.py
  27. 11 0
      tasks/Component/ReplaceShikigami/rs/supplement.json
  28. BIN
      tasks/Component/ReplaceShikigami/rs/utilize_u_confirm_small.png
  29. 1 1
      tasks/Component/SwitchSoul/assets.py
  30. 3 1
      tasks/Component/config_scheduler.py
  31. 1 1
      tasks/DemonEncounter/assets.py
  32. 1 1
      tasks/EternitySea/assets.py
  33. 1 1
      tasks/ExperienceYoukai/assets.py
  34. 1 1
      tasks/FallenSun/assets.py
  35. 7 2
      tasks/GameUi/assets.py
  36. 1 1
      tasks/GameUi/game_ui.py
  37. 5 0
      tasks/GameUi/page.py
  38. BIN
      tasks/GameUi/page/page_check_realm_raid.png
  39. 2 2
      tasks/GameUi/page/page_img.json
  40. 11 0
      tasks/GameUi/page/page_img_supplement_RyouToppa.json
  41. BIN
      tasks/GameUi/page/page_kekkai_toppa.png
  42. 1 1
      tasks/General/assets.py
  43. 1 1
      tasks/GlobalGame/assets.py
  44. 1 1
      tasks/GoldYoukai/assets.py
  45. 1 1
      tasks/GotoMain/assets.py
  46. 1 1
      tasks/Hunt/assets.py
  47. BIN
      tasks/KekkaiActivation/a/a_a_activate_gray.png
  48. BIN
      tasks/KekkaiActivation/a/a_a_activate_yellow.png
  49. BIN
      tasks/KekkaiActivation/a/a_a_auto_invite.png
  50. BIN
      tasks/KekkaiActivation/a/a_a_card_all.png
  51. BIN
      tasks/KekkaiActivation/a/a_a_card_fish.png
  52. BIN
      tasks/KekkaiActivation/a/a_a_card_kaiko.png
  53. BIN
      tasks/KekkaiActivation/a/a_a_card_moon.png
  54. BIN
      tasks/KekkaiActivation/a/a_a_card_other.png
  55. BIN
      tasks/KekkaiActivation/a/a_a_card_room.png
  56. BIN
      tasks/KekkaiActivation/a/a_a_check_card.png
  57. BIN
      tasks/KekkaiActivation/a/a_a_empty.png
  58. BIN
      tasks/KekkaiActivation/a/a_a_friend_1.png
  59. BIN
      tasks/KekkaiActivation/a/a_a_friend_2.png
  60. BIN
      tasks/KekkaiActivation/a/a_a_harvest_exp.png
  61. BIN
      tasks/KekkaiActivation/a/a_a_harvest_fish4.png
  62. BIN
      tasks/KekkaiActivation/a/a_a_invite.png
  63. 155 0
      tasks/KekkaiActivation/a/image.json
  64. 87 2
      tasks/KekkaiActivation/assets.py
  65. BIN
      tasks/KekkaiActivation/cards/cards_cards_fish_3.png
  66. BIN
      tasks/KekkaiActivation/cards/cards_cards_fish_4.png
  67. BIN
      tasks/KekkaiActivation/cards/cards_cards_fish_5.png
  68. BIN
      tasks/KekkaiActivation/cards/cards_cards_fish_6.png
  69. BIN
      tasks/KekkaiActivation/cards/cards_cards_kaiko_3.png
  70. BIN
      tasks/KekkaiActivation/cards/cards_cards_kaiko_4.png
  71. BIN
      tasks/KekkaiActivation/cards/cards_cards_kaiko_5.png
  72. BIN
      tasks/KekkaiActivation/cards/cards_cards_kaiko_6.png
  73. BIN
      tasks/KekkaiActivation/cards/cards_cards_moon_1.png
  74. BIN
      tasks/KekkaiActivation/cards/cards_cards_moon_2.png
  75. BIN
      tasks/KekkaiActivation/cards/cards_cards_moon_3.png
  76. BIN
      tasks/KekkaiActivation/cards/cards_cards_moon_4.png
  77. BIN
      tasks/KekkaiActivation/cards/cards_cards_moon_5.png
  78. BIN
      tasks/KekkaiActivation/cards/cards_cards_moon_6.png
  79. 128 0
      tasks/KekkaiActivation/cards/image.json
  80. 14 0
      tasks/KekkaiActivation/click.json
  81. 4 2
      tasks/KekkaiActivation/config.py
  82. 11 0
      tasks/KekkaiActivation/ocr.json
  83. 356 3
      tasks/KekkaiActivation/script_task.py
  84. 9 0
      tasks/KekkaiActivation/swipe.json
  85. 50 0
      tasks/KekkaiActivation/utils.py
  86. 25 7
      tasks/KekkaiUtilize/assets.py
  87. 1 0
      tasks/KekkaiUtilize/config.py
  88. 2 2
      tasks/KekkaiUtilize/ku/image.json
  89. BIN
      tasks/KekkaiUtilize/ku/ku_guild_assets_receive.png
  90. 4 4
      tasks/KekkaiUtilize/realm/image.json
  91. BIN
      tasks/KekkaiUtilize/realm/realm_box_exp.png
  92. 226 21
      tasks/KekkaiUtilize/script_task.py
  93. 2 2
      tasks/KekkaiUtilize/utilize/image.json
  94. 47 0
      tasks/KekkaiUtilize/utilize/image_2.json
  95. 9 0
      tasks/KekkaiUtilize/utilize/swipe.json
  96. BIN
      tasks/KekkaiUtilize/utilize/utilize_u_moon_2.png
  97. BIN
      tasks/KekkaiUtilize/utilize/utilize_u_moon_3.png
  98. BIN
      tasks/KekkaiUtilize/utilize/utilize_u_moon_4.png
  99. BIN
      tasks/KekkaiUtilize/utilize/utilize_u_moon_5.png
  100. BIN
      tasks/KekkaiUtilize/utilize/utilize_u_moon_6.png

+ 5 - 1
module/config/config.py

@@ -6,7 +6,7 @@ import datetime
 import operator
 import operator
 import threading
 import threading
 
 
-from datetime import datetime
+from datetime import datetime, timedelta
 from cached_property import cached_property
 from cached_property import cached_property
 
 
 from module.base.filter import Filter
 from module.base.filter import Filter
@@ -25,6 +25,8 @@ from module.logger import logger
 
 
 
 
 
 
+
+
 class Function:
 class Function:
     def __init__(self, key: str, data: dict):
     def __init__(self, key: str, data: dict):
         """
         """
@@ -276,6 +278,8 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
                 if success
                 if success
                 else scheduler.failure_interval
                 else scheduler.failure_interval
             )
             )
+            if isinstance(interval, str):
+                interval = timedelta(interval)
             run.append(start_time + interval)
             run.append(start_time + interval)
         # if server is not None:
         # if server is not None:
         #     if server:
         #     if server:

+ 1 - 0
module/config/config_menu.py

@@ -14,6 +14,7 @@ class ConfigMenu:
         self.menu = {}
         self.menu = {}
         # 总览
         # 总览
         self.menu["Overview"] = []
         self.menu["Overview"] = []
+        self.menu['TaskList'] = []
         # 脚本设置
         # 脚本设置
         self.menu['Script'] = ['Script', 'Restart', 'GlobalGame']
         self.menu['Script'] = ['Script', 'Restart', 'GlobalGame']
         # 刷御魂
         # 刷御魂

+ 24 - 0
module/config/config_modify.py

@@ -1,6 +1,9 @@
 # This Python file uses the following encoding: utf-8
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
+
+import json
+
 from module.config.config import Config
 from module.config.config import Config
 from module.config.utils import convert_to_underscore
 from module.config.utils import convert_to_underscore
 from module.config.config_model import ConfigModel
 from module.config.config_model import ConfigModel
@@ -66,3 +69,24 @@ class ConfigModify(Config):
         except ValidationError as e:
         except ValidationError as e:
             logger.error(e)
             logger.error(e)
             return False
             return False
+
+    def gui_task_list(self) -> str:
+        """
+        获取给gui显示的任务列表
+        :return:
+        """
+        result = {}
+        for key, value in self.model.dict().items():
+            if isinstance(value, str):
+                continue
+            if key == "restart":
+                continue
+            if "scheduler" not in value:
+                continue
+
+            scheduler = value["scheduler"]
+            item = {"enable": scheduler["enable"],
+                    "next_run": str(scheduler["next_run"])}
+            key = self.config.model.type(key)
+            result[key] = item
+        return json.dumps(result)

BIN
module/config/i18n/zh_CN.qm


+ 59 - 65
module/config/i18n/zh_CN.ts

@@ -118,18 +118,10 @@
 </context>
 </context>
 <context>
 <context>
     <name>FluTreeView</name>
     <name>FluTreeView</name>
-    <message>
-        <source>Home</source>
-        <translation>主页</translation>
-    </message>
-    <message>
-        <source>Update</source>
-        <translation>更新</translation>
-    </message>
-    <message>
-        <source>Overview</source>
-        <translation>总览</translation>
-    </message>
+    <message><source>Home</source><translation>主页</translation></message>
+    <message><source>Update</source><translation>更新</translation></message>
+    <message><source>Overview</source><translation>总览</translation></message>
+	<message><source>TaskList</source><translation>任务总览</translation></message>
     <message>
     <message>
         <source>Script</source>
         <source>Script</source>
         <translation>脚本</translation>
         <translation>脚本</translation>
@@ -166,54 +158,46 @@
         <source>Swipe Rule</source>
         <source>Swipe Rule</source>
         <translation>滑动规范</translation>
         <translation>滑动规范</translation>
     </message>
     </message>
-    <message>
-        <source>Daily Task</source>
-        <translation>日常任务</translation>
-    </message>
-    <message>
-        <source>AreaBoss</source>
-        <translation>地狱鬼王</translation>
-    </message>
-    <message>
-        <source>GoldYoukai</source>
-        <translation>金币妖怪</translation>
-    </message>
-    <message>
-        <source>ExperienceYoukai</source>
-        <translation>经验妖怪</translation>
-    </message>
-    <message>
-        <source>Nian</source>
-        <translation>年兽</translation>
-    </message>
-    <message>
-        <source>Soul Zones</source>
-        <translation>御魂副本</translation>
-    </message>
-    <message>
-        <source>Orochi</source>
-        <translation>八岐大蛇</translation>
-    </message>
-    <message>
-        <source>OrochiMoans</source>
-        <translation>御魂悲鸣</translation>
-    </message>
-    <message>
-        <source>OrochiJudgement</source>
-        <translation>御魂神罚</translation>
-    </message>
-    <message>
-        <source>Sougenbi</source>
-        <translation>业原火</translation>
-    </message>
-    <message>
-        <source>FallenSun</source>
-        <translation>日轮之城</translation>
-    </message>
-    <message>
-        <source>EternitySea</source>
-        <translation>永生之海</translation>
-    </message>
+    <message><source>Daily Task</source><translation>日常任务</translation></message>
+    <message><source>AreaBoss</source><translation>地狱鬼王</translation></message>
+    <message><source>GoldYoukai</source><translation>金币妖怪</translation></message>
+    <message><source>ExperienceYoukai</source><translation>经验妖怪</translation></message>
+    <message><source>Nian</source><translation>年兽</translation></message>
+    <message><source>Soul Zones</source><translation>御魂副本</translation></message>
+    <message><source>Orochi</source><translation>八岐大蛇</translation></message>
+	<message><source>OrochiMoans</source><translation>御魂悲鸣</translation></message>
+    <message><source>OrochiJudgement</source><translation>御魂神罚</translation></message>
+    <message><source>Sougenbi</source><translation>业原火</translation></message>
+    <message><source>FallenSun</source><translation>日轮之城</translation></message>
+    <message><source>EternitySea</source><translation>永生之海</translation></message>
+	<message><source>GlobalGame</source><translation>全局游戏设置</translation></message>
+	<message><source>RealmRaid</source><translation>个人突破</translation></message>
+	<message><source>RyouToppa</source><translation>寮突破</translation></message>
+	<message><source>List Rule</source><translation>列表规则</translation></message>
+	<message><source>Activity Task</source><translation>限时活动</translation></message>
+	<message><source>ActivityShikigami</source><translation>当期式神爬塔</translation></message>
+	<message><source>Liver Emperor Exclusive</source><translation>肝帝专属</translation></message>
+	<message><source>BondlingFairyland</source><translation>契灵之境</translation></message>
+	<message><source>Weekly Task</source><translation>每周任务</translation></message>
+	<message><source>TrueOrochi</source><translation>真·八岐大蛇</translation></message>
+	<message><source>KekkaiUtilize</source><translation>结界蹭卡</translation></message>
+	<message><source>KekkaiActivation</source><translation>结界挂卡</translation></message>
+	<message><source>DemonEncounter</source><translation>封魔之时</translation></message>
+</context>
+<context>
+    <name>TaskList</name>
+	    <message><source>Daily Task</source><translation>日常任务</translation></message>
+    <message><source>AreaBoss</source><translation>地狱鬼王</translation></message>
+    <message><source>GoldYoukai</source><translation>金币妖怪</translation></message>
+    <message><source>ExperienceYoukai</source><translation>经验妖怪</translation></message>
+    <message><source>Nian</source><translation>年兽</translation></message>
+    <message><source>Soul Zones</source><translation>御魂副本</translation></message>
+    <message><source>Orochi</source><translation>八岐大蛇</translation></message>
+	<message><source>OrochiMoans</source><translation>御魂悲鸣</translation></message>
+    <message><source>OrochiJudgement</source><translation>御魂神罚</translation></message>
+    <message><source>Sougenbi</source><translation>业原火</translation></message>
+    <message><source>FallenSun</source><translation>日轮之城</translation></message>
+    <message><source>EternitySea</source><translation>永生之海</translation></message>
 	<message><source>GlobalGame</source><translation>全局游戏设置</translation></message>
 	<message><source>GlobalGame</source><translation>全局游戏设置</translation></message>
 	<message><source>RealmRaid</source><translation>个人突破</translation></message>
 	<message><source>RealmRaid</source><translation>个人突破</translation></message>
 	<message><source>RyouToppa</source><translation>寮突破</translation></message>
 	<message><source>RyouToppa</source><translation>寮突破</translation></message>
@@ -222,6 +206,11 @@
 	<message><source>ActivityShikigami</source><translation>当期式神爬塔</translation></message>
 	<message><source>ActivityShikigami</source><translation>当期式神爬塔</translation></message>
 	<message><source>Liver Emperor Exclusive</source><translation>肝帝专属</translation></message>
 	<message><source>Liver Emperor Exclusive</source><translation>肝帝专属</translation></message>
 	<message><source>BondlingFairyland</source><translation>契灵之境</translation></message>
 	<message><source>BondlingFairyland</source><translation>契灵之境</translation></message>
+	<message><source>Weekly Task</source><translation>每周任务</translation></message>
+	<message><source>TrueOrochi</source><translation>真·八岐大蛇</translation></message>
+	<message><source>KekkaiUtilize</source><translation>结界蹭卡</translation></message>
+	<message><source>KekkaiActivation</source><translation>结界挂卡</translation></message>
+	<message><source>DemonEncounter</source><translation>封魔之时</translation></message>
 </context>
 </context>
 <context>
 <context>
     <name>Args</name>
     <name>Args</name>
@@ -457,21 +446,21 @@ mode_3策略是刷到五个契灵后开始结契,选择高级、中级盘来
 	<message><source>Enable Sign 999</source><translation>签到999天后的签到福袋</translation></message>
 	<message><source>Enable Sign 999</source><translation>签到999天后的签到福袋</translation></message>
 	<message><source>Enable Mail</source><translation>邮件</translation></message>
 	<message><source>Enable Mail</source><translation>邮件</translation></message>
 	<message><source>Enable Soul</source><translation>御魂或者觉醒加成</translation></message>
 	<message><source>Enable Soul</source><translation>御魂或者觉醒加成</translation></message>
+	<message><source>Enable Ap</source><translation>体力</translation></message>
 </context>	
 </context>	
 <context>
 <context>
     <name>Args</name>
     <name>Args</name>
 	<message><source>UtilizeScheduler</source><translation>任务调度</translation></message>
 	<message><source>UtilizeScheduler</source><translation>任务调度</translation></message>
 	<message><source>UtilizeConfig</source><translation>寄养</translation></message>
 	<message><source>UtilizeConfig</source><translation>寄养</translation></message>
-	<message><source>Utilize Rule</source><translation>寄养规则</translation></message>
+	<message><source>UtilizeRule</source><translation>寄养规则</translation></message>
 	<message><source>Auto Switch Sort</source><translation>切换好友列表以游戏刷新高星排序</translation></message>
 	<message><source>Auto Switch Sort</source><translation>切换好友列表以游戏刷新高星排序</translation></message>
-	<message><source>Shikigami Class</source><translation>寄养式神类型</translation></message>
+	<message><source>ShikigamiClass</source><translation>寄养式神类型</translation></message>
 	<message><source>Shikigami Order</source><translation>选中第几个式神寄养</translation></message>
 	<message><source>Shikigami Order</source><translation>选中第几个式神寄养</translation></message>
 	<message><source>Guild Ap Enable</source><translation>顺路收取寮补给</translation></message>
 	<message><source>Guild Ap Enable</source><translation>顺路收取寮补给</translation></message>
 	<message><source>Guild Assets Enable</source><translation>顺路收取寮资金</translation></message>
 	<message><source>Guild Assets Enable</source><translation>顺路收取寮资金</translation></message>
 	<message><source>Box Ap Enable</source><translation>顺路收取体力盒子</translation></message>
 	<message><source>Box Ap Enable</source><translation>顺路收取体力盒子</translation></message>
 	<message><source>Box Exp Enable</source><translation>顺路收取经验盒子</translation></message>
 	<message><source>Box Exp Enable</source><translation>顺路收取经验盒子</translation></message>
-	<message><source>utilize_rule_help</source><translation>挑选结界卡的规则,使用默认auto即可,当然你也可以使用过滤器自定义:
-以auto为例 "太鼓6>太鼓5>斗鱼6>斗鱼5>太鼓4>太鼓3>斗鱼4>斗鱼3"</translation></message>
+	<message><source>utilize_rule_help</source><translation>挑选结界卡的规则,使用默认default即可,具体规则看文档[任务列表],不可以选auto,已经弃置了。</translation></message>
 	<message><source>auto_switch_sort_help</source><translation>会自动寻找最优的坑位</translation></message>
 	<message><source>auto_switch_sort_help</source><translation>会自动寻找最优的坑位</translation></message>
 	<message><source>shikigami_class_help</source><translation>选择的式神类别(寄养默认选择N卡,且不建议选别的)</translation></message>
 	<message><source>shikigami_class_help</source><translation>选择的式神类别(寄养默认选择N卡,且不建议选别的)</translation></message>
 	<message><source>shikigami_order_help</source><translation>从左开始选第几个式神</translation></message>
 	<message><source>shikigami_order_help</source><translation>从左开始选第几个式神</translation></message>
@@ -479,6 +468,11 @@ mode_3策略是刷到五个契灵后开始结契,选择高级、中级盘来
 	<message><source>guild_assets_enable_help</source><translation>必选项</translation></message>
 	<message><source>guild_assets_enable_help</source><translation>必选项</translation></message>
 	<message><source>box_ap_enable_help</source><translation>必选项</translation></message>
 	<message><source>box_ap_enable_help</source><translation>必选项</translation></message>
 	<message><source>box_exp_enable_help</source><translation>必选项</translation></message>
 	<message><source>box_exp_enable_help</source><translation>必选项</translation></message>
+	<message><source>SelectFriendList</source><translation>选择同区还是跨区好友</translation></message>
+	<message><source>select_friend_list_help</source><translation>由于该死的游戏制作水准,无论任何方式都不可以稳定的对结界卡进行排序,需要从头到尾遍历一遍。
+且切换好友列表时候会丢失原先选定的好友卡,为此同时选择两个好友列表的最优解是会花费更多的时间,不打算支持</translation></message>
+	<message><source>Box Exp Waste</source><translation>从盒子提取经验时浪费一部分</translation></message>
+	<message><source>box_exp_waste_help</source><translation>某些时候寄养上存在满级的式神,收取经验盒子时会有提示,对于挂机玩家这点经验微不足道。如果不使能这一选项,将跳过收取经验盒子</translation></message>
 </context>	
 </context>	
 <context>
 <context>
     <name>Args</name>
     <name>Args</name>
@@ -487,7 +481,7 @@ mode_3策略是刷到五个契灵后开始结契,选择高级、中级盘来
 	<message><source>Card Rule</source><translation>放卡规则</translation></message>
 	<message><source>Card Rule</source><translation>放卡规则</translation></message>
 	<message><source>Exchange Max</source><translation>收取经验后更换下来满级的式神</translation></message>
 	<message><source>Exchange Max</source><translation>收取经验后更换下来满级的式神</translation></message>
 	<message><source>Exchange Before</source><translation>收取经验前更换下来满级的式神</translation></message>
 	<message><source>Exchange Before</source><translation>收取经验前更换下来满级的式神</translation></message>
-	<message><source>card_rule_help</source><translation>规则还没想好</translation></message>
+	<message><source>card_rule_help</source><translation>保持默认auto即可,具体的规则请翻阅文档[任务列表]</translation></message>
 	<message><source>exchange_before_help</source><translation>必选项</translation></message>
 	<message><source>exchange_before_help</source><translation>必选项</translation></message>
 	<message><source>exchange_max_help</source><translation>必选项</translation></message>
 	<message><source>exchange_max_help</source><translation>必选项</translation></message>
 </context>	
 </context>	

+ 1 - 1
module/device/handle.py

@@ -372,7 +372,7 @@ class Handle:
         scale_rate = window_scale_rate()
         scale_rate = window_scale_rate()
         width_before: int = winRect[2] - winRect[0]  # 右x-左x
         width_before: int = winRect[2] - winRect[0]  # 右x-左x
         height_before: int = winRect[3] - winRect[1]  # 下y - 上y 计算高度
         height_before: int = winRect[3] - winRect[1]  # 下y - 上y 计算高度
-        width, height = None, None
+        width, height = width_before, height_before
         if abs((width_before * scale_rate) - 1280) < 5:
         if abs((width_before * scale_rate) - 1280) < 5:
             width = 1280
             width = 1280
         if abs((height_before * scale_rate) - 720) < 5:
         if abs((height_before * scale_rate) - 720) < 5:

+ 88 - 30
module/device/method/window.py

@@ -11,10 +11,12 @@ from cached_property import cached_property
 from win32gui import (GetWindowText, EnumWindows, FindWindow, FindWindowEx,
 from win32gui import (GetWindowText, EnumWindows, FindWindow, FindWindowEx,
                       IsWindow, GetWindowRect, GetWindowDC, DeleteObject,
                       IsWindow, GetWindowRect, GetWindowDC, DeleteObject,
                       SetForegroundWindow, IsWindowVisible, GetDC, GetParent,
                       SetForegroundWindow, IsWindowVisible, GetDC, GetParent,
-                      EnumChildWindows)
+                      EnumChildWindows, SetForegroundWindow)
 from win32con import (SRCCOPY, DESKTOPHORZRES, DESKTOPVERTRES, WM_LBUTTONUP,
 from win32con import (SRCCOPY, DESKTOPHORZRES, DESKTOPVERTRES, WM_LBUTTONUP,
                       WM_LBUTTONDOWN, WM_ACTIVATE, WA_ACTIVE, MK_LBUTTON,
                       WM_LBUTTONDOWN, WM_ACTIVATE, WA_ACTIVE, MK_LBUTTON,
-                      WM_NCHITTEST, WM_SETCURSOR, HTCLIENT, WM_MOUSEMOVE)
+                      WM_NCHITTEST, WM_SETCURSOR, HTCLIENT, WM_MOUSEMOVE,
+                      WM_PARENTNOTIFY, WM_MOUSEACTIVATE, WM_MOUSEWHEEL,
+                      WM_SETFOCUS)
 from win32ui import CreateDCFromHandle, CreateBitmap
 from win32ui import CreateDCFromHandle, CreateBitmap
 from win32api import GetSystemMetrics, SendMessage, MAKELONG, PostMessage
 from win32api import GetSystemMetrics, SendMessage, MAKELONG, PostMessage
 from win32con import SRCCOPY
 from win32con import SRCCOPY
@@ -202,8 +204,8 @@ class Window(Handle):
         :return:
         :return:
         """
         """
         # 生成的坐标点列表
         # 生成的坐标点列表
-        interval: int = 8  # 每次移动的间隔时间
-        numberList: int = int(dist(startPos, endPos) / (1.5 * interval))  # 表示每毫秒移动1.5个像素点, 总的时间除以每个点10ms就得到总的点的个数
+        interval: int = 10  # 每次移动的间隔时间
+        numberList: int = int(dist(startPos, endPos) / (1 * interval))  # 表示每毫秒移动1.5个像素点, 总的时间除以每个点10ms就得到总的点的个数
         le = random.randint(2, 4)  #
         le = random.randint(2, 4)  #
         deviation = random.randint(20, 40)  # 幅度
         deviation = random.randint(20, 40)  # 幅度
         _type: int = 3
         _type: int = 3
@@ -218,38 +220,44 @@ class Window(Handle):
                                                   deviation=deviation, bias=0.5, type=_type, cbb=0, yhh=20)
                                                   deviation=deviation, bias=0.5, type=_type, cbb=0, yhh=20)
 
 
         # 使用生成的点列表进行拖拽
         # 使用生成的点列表进行拖拽
-        emulator_type = len(self.control_handle_list)
-        if emulator_type == 1:  # 雷电模拟器
-            handleNum = self.control_handle_list[0]
-        elif emulator_type == 2:  # mumu模拟器
+        handleNum = None
+        if self.emulator_family == EmulatorFamily.FAMILY_MUMU:  # mumu模拟器
             handleNum = self.control_handle_list[1]
             handleNum = self.control_handle_list[1]
-        elif emulator_type > 2:  # 夜神模拟器
+        elif self.emulator_family == EmulatorFamily.FAMILY_NOX:  # 夜神模拟器
             handleNum = self.control_handle_list[3]
             handleNum = self.control_handle_list[3]
-        # PostMessage(handleNum, WM_ACTIVATE, WA_ACTIVE, 0)  # 激活窗口
+        elif self.emulator_family == EmulatorFamily.FAMILY_LD:  # 雷电模拟器
+            handleNum = self.control_handle_list[0]
+
+        # 激活窗口
+        # SendMessage(self.control_handle_list[0], WM_PARENTNOTIFY, WM_LBUTTONDOWN, tmpPos)
+        # SendMessage(self.control_handle_list[0], WM_MOUSEACTIVATE, WM_LBUTTONDOWN, tmpPos)
+        # PostMessage(handleNum, WM_ACTIVATE, WA_ACTIVE, 0)
+
         # 先移动到第一个点
         # 先移动到第一个点
         tmpPos = MAKELONG(trace[0][0], trace[0][1])
         tmpPos = MAKELONG(trace[0][0], trace[0][1])
         SendMessage(handleNum, WM_NCHITTEST, 0, tmpPos)
         SendMessage(handleNum, WM_NCHITTEST, 0, tmpPos)
         SendMessage(handleNum, WM_SETCURSOR, handleNum, MAKELONG(HTCLIENT, WM_LBUTTONDOWN))
         SendMessage(handleNum, WM_SETCURSOR, handleNum, MAKELONG(HTCLIENT, WM_LBUTTONDOWN))
-        PostMessage(handleNum, WM_LBUTTONDOWN, MK_LBUTTON, tmpPos)
+        PostMessage(handleNum, WM_LBUTTONDOWN, 0, tmpPos)
+
         # 一点一点移动鼠标
         # 一点一点移动鼠标
-        for pos in trace[:-3]:
-            tmpPos = MAKELONG(pos[0], pos[1])
-            PostMessage(handleNum, WM_MOUSEMOVE, MK_LBUTTON, tmpPos)
-            time.sleep((interval + random.randint(-2, 2)) / 1000.0)
+        manual_control: int = 3  # 手动控制最后几个点的数量
+        total_len: int = len(trace)
+        for index, pos in enumerate(trace):
+            lparam = MAKELONG(pos[0], pos[1])
+            PostMessage(handleNum, WM_MOUSEMOVE, MK_LBUTTON, lparam)
+            if manual_control >= total_len - index:
+                time.sleep(0.08)
+            else:
+                time.sleep((interval + random.randint(-2, 2)) / 1000.0)
+
         # 最后释放鼠标
         # 最后释放鼠标
-        end_pos_3 = MAKELONG(trace[-3][0], trace[-3][1])
-        end_pos_2 = MAKELONG(trace[-2][0], trace[-2][1])
-        end_pos_1 = MAKELONG(trace[-1][0], trace[-1][1])
-        PostMessage(handleNum, WM_MOUSEMOVE, MK_LBUTTON, end_pos_3)
-        time.sleep(0.08)
-        PostMessage(handleNum, WM_MOUSEMOVE, MK_LBUTTON, end_pos_2)
-        time.sleep(0.08)
-        PostMessage(handleNum, WM_MOUSEMOVE, MK_LBUTTON, end_pos_1)
-        PostMessage(handleNum, WM_LBUTTONUP, 0, end_pos_1)
+        time.sleep(0.05)
+        end_lparam = MAKELONG(trace[-1][0], trace[-1][1])
+        PostMessage(handleNum, WM_LBUTTONUP, 0, end_lparam)
 
 
     def swipe_vector_window_message2(self, startPos: list, endPos: list) -> None:
     def swipe_vector_window_message2(self, startPos: list, endPos: list) -> None:
         """
         """
-        后台滑动
+        后台滑动, 直线滑动
         :param startPos:
         :param startPos:
         :param endPos:
         :param endPos:
         :return:
         :return:
@@ -298,10 +306,60 @@ class Window(Handle):
         tmpPos = MAKELONG(trace[-1][0], trace[-1][1])
         tmpPos = MAKELONG(trace[-1][0], trace[-1][1])
         PostMessage(handleNum, WM_LBUTTONUP, 0, tmpPos)
         PostMessage(handleNum, WM_LBUTTONUP, 0, tmpPos)
 
 
+    def scroll_window_message(self, x: int, y: int, delta: int=-120) -> None:
+        """
+        弃置
+        https://github.com/runhey/OnmyojiAutoScript/issues/43
+        :param x:
+        :param y:
+        :param delta:
+        :return:
+        """
+        wparam = MAKELONG(0, delta)
+        lparam = MAKELONG(x, y)
+        handle_num = None
+        if self.emulator_family == EmulatorFamily.FAMILY_MUMU:  # mumu模拟器
+            handle_num = self.control_handle_list[1]
+
+        elif self.emulator_family == EmulatorFamily.FAMILY_NOX:  # 夜神模拟器
+            handle_num = self.control_handle_list[3]
+        elif self.emulator_family == EmulatorFamily.FAMILY_LD:  # 雷电模拟器
+            handle_num = self.control_handle_list[0]
+
+        SetForegroundWindow(handle_num)
+        time.sleep(2)
+        # SendMessage(handle_num, WM_SETFOCUS, 0, 0)
+        # SendMessage(handle_num, WM_ACTIVATE, WA_ACTIVE, 0)
+        # SendMessage(handle_num, WM_MOUSEACTIVATE, WM_LBUTTONDOWN, lparam)
+
+
+        SendMessage(handle_num, WM_NCHITTEST, 0, lparam)
+        SendMessage(handle_num, WM_SETCURSOR, handle_num, lparam)
+        PostMessage(handle_num, WM_MOUSEMOVE, 0, lparam)
+        self.click_window_message(x, y)
+
+        for i in range(5):
+            PostMessage(handle_num, WM_SETCURSOR, handle_num, lparam)
+            PostMessage(handle_num, WM_MOUSEMOVE, 0, lparam)
+            PostMessage(handle_num, WM_MOUSEWHEEL, wparam, lparam)
+            time.sleep(0.5)
+        # 抄网上的
+        # SendMessage(handle_num, WM_NCHITTEST, 0, lparam)
+
+
+
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
-    w = Window(config='oas1')
-    img = w.screenshot_window_background()
-    logger.info(img.shape)
-    w.click_window_message(x=759, y=184)
-    # w.swipe_window_message(startPos=[200, 5], endPos=[300, 300])
+    # w = Window(config='oas1')
+    # img = w.screenshot_window_background()
+    # handle = 459852
+    # wparam = MAKELONG(0, -120)
+    # lparam = MAKELONG(300, 300)
+    # PostMessage(handle, WM_MOUSEWHEEL, wparam, lparam)
+
+    from pynput.mouse import Button, Controller
+    mouse = Controller()
+    mouse.position = (505, 505)
+    mouse.scroll(0, -3)
+
+

+ 16 - 2
module/gui/context/process_manager.py

@@ -289,7 +289,7 @@ class ProcessManager(QObject):
         """
         """
         if config in self.clients:
         if config in self.clients:
             logger.info(f'gui set value of {config} {task}')
             logger.info(f'gui set value of {config} {task}')
-            if self.clients[config].gui_set_task(task, group, arg, value):
+            if self.check_script(config).gui_set_task(task, group, arg, value):
                 return True
                 return True
             else:
             else:
                 return False
                 return False
@@ -310,7 +310,7 @@ class ProcessManager(QObject):
         """
         """
         if config in self.clients:
         if config in self.clients:
             logger.info(f'gui set value of {config} {task}')
             logger.info(f'gui set value of {config} {task}')
-            if self.clients[config].gui_set_task(task, group, arg, value):
+            if self.check_script(config).gui_set_task(task, group, arg, value):
                 return True
                 return True
             else:
             else:
                 return False
                 return False
@@ -347,6 +347,20 @@ class ProcessManager(QObject):
             logger.info(f'script {config} is not running')
             logger.info(f'script {config} is not running')
             return None
             return None
 
 
+
+
+    @Slot(str, result="QString")
+    def gui_task_list(self, config: str) -> str:
+        if config in self.clients:
+            logger.info(f'Gui get {config} task list')
+            return self.check_script(config).gui_task_list()
+        else:
+            logger.info(f'Script {config} is not running')
+            return None
+
+
+
+
     def start_log(self, config_name: str) -> Queue:
     def start_log(self, config_name: str) -> Queue:
         """
         """
         启动某个脚本实例config_name的log: 具体为创建一个queue信息队列,然后创建一个log线程,将queue传入log线程
         启动某个脚本实例config_name的log: 具体为创建一个queue信息队列,然后创建一个log线程,将queue传入log线程

+ 1 - 0
module/gui/qml.qrc

@@ -34,5 +34,6 @@
         <file>qml/Content/ListRule.qml</file>
         <file>qml/Content/ListRule.qml</file>
         <file>qml/Component/RuleFile2.qml</file>
         <file>qml/Component/RuleFile2.qml</file>
         <file>qml/Content/NotifyTest.qml</file>
         <file>qml/Content/NotifyTest.qml</file>
+        <file>qml/Content/TaskList.qml</file>
     </qresource>
     </qresource>
 </RCC>
 </RCC>

+ 191 - 0
module/gui/qml/Content/TaskList.qml

@@ -0,0 +1,191 @@
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import FluentUI
+import '../Global'
+
+
+Item{
+    id: taskList
+    signal click(string title)
+    onClick: {
+
+    }
+
+    FluScrollablePage{
+        id: contentScrollable
+        width: 800
+        height: parent.height
+        spacing: 12
+        anchors.horizontalCenter: parent.horizontalCenter
+    }
+
+    // 任务组
+    Component{
+        id: group_item
+        FluExpander{
+            id: expander
+            property string groupName: ""
+            property string groupTitle: ""
+            property var argumentValue: {""}
+            property alias model: groupModel
+            expand: true
+            headerText: qsTr(groupTitle)
+            width: contentScrollable.width
+            contentHeight: groupGridView.height + 20
+            ListModel{
+                id: groupModel
+            }
+
+            GridLayout{
+                id: groupGridView
+                clip: true
+                columns: 3
+                anchors{
+                    top: parent.top
+                    topMargin: 12
+                    left: parent.left
+                    leftMargin: 12
+                    right: parent.right
+                    rightMargin: 15
+                    bottomMargin: 12
+                }
+                Repeater {
+                    delegate: task_item
+                    model: groupModel
+                }
+            }
+        }
+    }
+
+    // 任务小项
+    Component{
+        id: task_item
+        FluArea{
+            id: task_root
+            width: 250
+            height: 50
+            visible: true
+            color: FluTheme.dark ? Window.active ?  Qt.rgba(38/255,44/255,54/255,1) : Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
+
+            property alias name: taskName.text
+            property alias nextRun: taskTime.text
+            property alias enable: taskEnable.selected
+
+
+            FluText{
+                id: taskName
+                anchors{
+                    left: parent.left
+                    leftMargin: 6
+                    top: parent.top
+                    topMargin: 6
+                }
+                text: qsTr( model.task)
+                font: FluTextStyle.BodyStrong
+            }
+            FluText{
+                id: taskTime
+                anchors{
+                    left: parent.left
+                    leftMargin: 6
+                    bottom: parent.bottom
+                    bottomMargin: 6
+                }
+                text: model.next_run
+                font: FluTextStyle.Caption
+            }
+            FluCheckBox{
+                id: taskEnable
+                anchors{
+                    right: settingButton.left
+                    rightMargin: 6
+                    verticalCenter: parent.verticalCenter
+                }
+                selected: model.enable
+//                onSelectedChanged: {
+//                    if(process_manager.gui_set_task_bool(MainEvent.scriptName, task_root.name, 'scheduler', 'enable', selected)){
+//                        showSuccess("Enable")
+//                        return true
+//                    }
+//                    showSuccess('Disenable')
+//                }
+                clickFunc: function click_func(){
+                    selected = !selected
+                    if(process_manager.gui_set_task_bool(MainEvent.scriptName, model.task, 'scheduler', 'enable', selected)){
+                        showSuccess("Enable")
+                        return true
+                    }
+                    showSuccess('Disenable')
+                }
+
+                text: ''
+            }
+
+            FluButton{
+                id: settingButton
+                anchors{
+                    right: parent.right
+                    rightMargin: 10
+                    verticalCenter: parent.verticalCenter
+                }
+                text:"setting"
+                onClicked: {
+                    showSuccess(name)
+                    taskList.click(name)
+                    taskList.parent.parent.title = model.task
+                }
+            }
+        }
+    }
+
+
+
+    Component.onCompleted:{
+
+        const data = JSON.parse(process_manager.gui_task_list(MainEvent.scriptName))
+        const menu = JSON.parse(process_manager.gui_menu())
+        for(const key in menu){
+            if(key === "Overview" || key === 'TaskList' || key === 'Script' || key === 'Tools'){
+                continue
+            }
+            const groupData = classify(menu[key], data)
+            create_group(key, groupData)
+        }
+
+    }
+
+    // 分类对每一个任务组,
+    // 第一个参数是这个菜单组的所有, 如["Script", "Restart", "GlobalGame"]
+    // 第二个参数是整个的数据
+    // 会提取data的数据 返回一个dict
+    function classify(group, data){
+        const result = {}
+        for(const item in data){
+            if(group.includes(item)){
+                result[item] = data[item]
+            }
+        }
+        return result
+    }
+    // 创建一个的任务组
+    function create_group(groupName, groupData){
+        const object = group_item.createObject(contentScrollable)
+        if(object === null){
+            console.error('Create group item failed!')
+        }
+        object.groupName = groupName
+        object.groupTitle = qsTr(groupName)
+        object.argumentValue = groupData
+        for(const key in groupData){
+            const item ={"task": key,
+                          "enable": groupData[key]["enable"],
+                         "next_run": groupData[key]["next_run"]}
+            object.model.append(item)
+
+        }
+
+        contentScrollable.content.push(object)
+
+    }
+}

+ 10 - 0
module/gui/qml/Page/ScriptView.qml

@@ -74,6 +74,16 @@ SplitPanel{
             }
             }
             setLoader(component)
             setLoader(component)
         }
         }
+        else if(title === "TaskList"){
+            const component = Qt.createComponent("../../qml/Content/TaskList.qml")
+            if(component.status !== Component.Ready){
+                console.error("TaskList component is not ready")
+                return
+            }
+            setLoader(component)
+        }
+
+
         //最后才是一般的参数页面
         //最后才是一般的参数页面
         else{
         else{
             const component = Qt.createComponent("../../qml/Component/Args.qml")
             const component = Qt.createComponent("../../qml/Component/Args.qml")

+ 36 - 3
script.py

@@ -11,6 +11,7 @@ import time
 import os
 import os
 import inflection
 import inflection
 import asyncio
 import asyncio
+import json
 
 
 from typing import Callable
 from typing import Callable
 from datetime import datetime, timedelta
 from datetime import datetime, timedelta
@@ -23,6 +24,7 @@ from threading import Thread
 
 
 from module.config.utils import convert_to_underscore
 from module.config.utils import convert_to_underscore
 from module.config.config import Config
 from module.config.config import Config
+from module.config.config_model import ConfigModel
 from module.device.device import Device
 from module.device.device import Device
 from module.base.utils import load_module
 from module.base.utils import load_module
 from module.base.decorator import del_cached_property
 from module.base.decorator import del_cached_property
@@ -227,6 +229,38 @@ class Script:
         if self.gui_update_task is not None:
         if self.gui_update_task is not None:
             self.gui_update_task(data)
             self.gui_update_task(data)
 
 
+
+    def gui_task_list(self) -> str:
+        """
+        获取给gui显示的任务列表
+        :return:
+        """
+        result = {}
+        for key, value in self.config.model.dict().items():
+            if isinstance(value, str):
+                continue
+            if key == "restart":
+                continue
+            if "scheduler" not in value:
+                continue
+
+            scheduler = value["scheduler"]
+            item = {"enable": scheduler["enable"],
+                    "next_run": str(scheduler["next_run"])}
+            key = self.config.model.type(key)
+            result[key] = item
+        return json.dumps(result)
+
+
+
+
+
+
+
+
+
+
+
     def wait_until(self, future):
     def wait_until(self, future):
         """
         """
         Wait until a specific time.
         Wait until a specific time.
@@ -444,6 +478,5 @@ class Script:
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
     script = Script("oas1")
     script = Script("oas1")
-    # print(script.get_next_task())
-    # script.run("ActivityShikigami")
-    script.run('AreaBoss')
+    print(script.gui_task_list())
+    print(script.config.gui_menu)

+ 1 - 1
tasks/ActivityShikigami/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class ActivityShikigamiAssets: 
 class ActivityShikigamiAssets: 
 
 

+ 1 - 1
tasks/AreaBoss/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class AreaBossAssets: 
 class AreaBossAssets: 
 
 

+ 1 - 1
tasks/BondlingFairyland/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class BondlingFairylandAssets: 
 class BondlingFairylandAssets: 
 
 

+ 1 - 1
tasks/Component/BaseActivity/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class BaseActivityAssets: 
 class BaseActivityAssets: 
 	pass
 	pass

+ 3 - 1
tasks/Component/GeneralBattle/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class GeneralBattleAssets: 
 class GeneralBattleAssets: 
 
 
@@ -101,6 +101,8 @@ class GeneralBattleAssets:
 	I_EXIT = RuleImage(roi_front=(14,12,43,41), roi_back=(14,12,43,41), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_exit.png")
 	I_EXIT = RuleImage(roi_front=(14,12,43,41), roi_back=(14,12,43,41), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_exit.png")
 	# 退出确认 
 	# 退出确认 
 	I_EXIT_ENSURE = RuleImage(roi_front=(674,388,135,63), roi_back=(674,388,135,63), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_exit_ensure.png")
 	I_EXIT_ENSURE = RuleImage(roi_front=(674,388,135,63), roi_back=(674,388,135,63), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_exit_ensure.png")
+	# 左上角好友图标 
+	I_FRIENDS = RuleImage(roi_front=(89,14,36,36), roi_back=(89,14,36,36), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_friends.png")
 
 
 
 
 	# Image Rule Assets
 	# Image Rule Assets

BIN
tasks/Component/GeneralBattle/gb/gb_friends.png


+ 9 - 0
tasks/Component/GeneralBattle/gb/image.json

@@ -160,5 +160,14 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "退出确认"
     "description": "退出确认"
+  },
+  {
+    "itemName": "friends",
+    "imageName": "gb_friends.png",
+    "roiFront": "89,14,36,36",
+    "roiBack": "89,14,36,36",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角好友图标"
   }
   }
 ]
 ]

+ 31 - 0
tasks/Component/GeneralBattle/general_battle.py

@@ -36,6 +36,20 @@ class GeneralBattle(BaseTask, GeneralBattleAssets):
             if self.current_count == 1:
             if self.current_count == 1:
                 self.switch_preset_team(config.preset_enable, config.preset_group, config.preset_team)
                 self.switch_preset_team(config.preset_enable, config.preset_group, config.preset_team)
 
 
+            # 检测是否已经在战斗中
+            if self.is_in_battle():
+                while 1:
+                    self.screenshot()
+                    if self.appear_then_click(self.I_PREPARE_HIGHLIGHT, interval=1.5):
+                        continue
+                    if not self.appear(self.I_BUFF):
+                        break
+                win = self.battle_wait(config.random_click_swipt_enable)
+                if win:
+                    return True
+                else:
+                    return False
+
             # 点击准备按钮
             # 点击准备按钮
             self.wait_until_appear(self.I_PREPARE_HIGHLIGHT)
             self.wait_until_appear(self.I_PREPARE_HIGHLIGHT)
             while 1:
             while 1:
@@ -334,6 +348,23 @@ class GeneralBattle(BaseTask, GeneralBattleAssets):
             # 重新设置为长战斗
             # 重新设置为长战斗
             self.device.stuck_record_add('BATTLE_STATUS_S')
             self.device.stuck_record_add('BATTLE_STATUS_S')
 
 
+    # 判断是否在战斗中
+    def is_in_battle(self, is_screenshot: bool = True) -> bool:
+        """
+        判断是否在战斗中
+        :return:
+        """
+        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):
+            return True
+        else:
+            return False
+
+
 
 
 
 
 
 

+ 1 - 1
tasks/Component/GeneralBuff/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class GeneralBuffAssets: 
 class GeneralBuffAssets: 
 
 

+ 1 - 1
tasks/Component/GeneralInvite/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class GeneralInviteAssets: 
 class GeneralInviteAssets: 
 
 

+ 4 - 2
tasks/Component/GeneralInvite/general_invite.py

@@ -197,11 +197,13 @@ class GeneralInvite(BaseTask, GeneralInviteAssets):
         logger.info('Exit room')
         logger.info('Exit room')
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
-            if not self.is_in_room():
+            if not self.is_in_room() and \
+                    not self.appear_then_click(self.I_GI_SURE, interval=0.5) and \
+                    not self.appear(self.I_BACK_YELLOW):
                 break
                 break
             if self.appear_then_click(self.I_GI_SURE, interval=0.5):
             if self.appear_then_click(self.I_GI_SURE, interval=0.5):
                 continue
                 continue
-            if self.appear_then_click(self.I_BACK_YELLOW, interval=0.5):
+            if not self.appear(self.I_GI_SURE) and self.appear_then_click(self.I_BACK_YELLOW, interval=0.5):
                 continue
                 continue
         return True
         return True
 
 

+ 1 - 1
tasks/Component/GeneralRoom/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class GeneralRoomAssets: 
 class GeneralRoomAssets: 
 
 

+ 6 - 1
tasks/Component/ReplaceShikigami/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class ReplaceShikigamiAssets: 
 class ReplaceShikigamiAssets: 
 
 
@@ -64,3 +64,8 @@ class ReplaceShikigamiAssets:
 	I_RS_LEVEL_MAX = RuleImage(roi_front=(487,248,23,21), roi_back=(52,238,1118,37), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/rs_rs_level_max.png")
 	I_RS_LEVEL_MAX = RuleImage(roi_front=(487,248,23,21), roi_back=(52,238,1118,37), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/rs_rs_level_max.png")
 
 
 
 
+	# Image Rule Assets
+	# 小一个尺寸的 确认按钮 
+	I_U_CONFIRM_SMALL = RuleImage(roi_front=(672,513,131,60), roi_back=(672,513,131,60), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/utilize_u_confirm_small.png")
+
+

+ 4 - 0
tasks/Component/ReplaceShikigami/replace_shikigami.py

@@ -90,6 +90,10 @@ class ReplaceShikigami(BaseTask, ReplaceShikigamiAssets):
 
 
             if not self.appear(stop_image):
             if not self.appear(stop_image):
                 break
                 break
+
+            if self.appear_then_click(self.I_U_CONFIRM_SMALL, interval=0.5):
+                continue
+
             if self.click(click_match, interval=1.5):
             if self.click(click_match, interval=1.5):
                 continue
                 continue
         logger.info('Set shikigami: %d' % shikigami_order)
         logger.info('Set shikigami: %d' % shikigami_order)

+ 11 - 0
tasks/Component/ReplaceShikigami/rs/supplement.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "u_confirm_small",
+    "imageName": "utilize_u_confirm_small.png",
+    "roiFront": "672,513,131,60",
+    "roiBack": "672,513,131,60",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "小一个尺寸的 确认按钮"
+  }
+]

BIN
tasks/Component/ReplaceShikigami/rs/utilize_u_confirm_small.png


+ 1 - 1
tasks/Component/SwitchSoul/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class SwitchSoulAssets: 
 class SwitchSoulAssets: 
 
 

+ 3 - 1
tasks/Component/config_scheduler.py

@@ -45,7 +45,9 @@ class Scheduler(ConfigBase):
 
 
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
-    s = Scheduler(success_interval='1 2:3:4')
+    s = Scheduler(success_interval='00 00:00:10')
+    if isinstance(s.success_interval, TimeDelta):
+        print(s.success_interval.seconds)
     print(s.json())
     print(s.json())
     print(s.dict())
     print(s.dict())
 
 

+ 1 - 1
tasks/DemonEncounter/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class DemonEncounterAssets: 
 class DemonEncounterAssets: 
 	pass
 	pass

+ 1 - 1
tasks/EternitySea/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class EternitySeaAssets: 
 class EternitySeaAssets: 
 	pass
 	pass

+ 1 - 1
tasks/ExperienceYoukai/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class ExperienceYoukaiAssets: 
 class ExperienceYoukaiAssets: 
 	pass
 	pass

+ 1 - 1
tasks/FallenSun/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class FallenSunAssets: 
 class FallenSunAssets: 
 	pass
 	pass

+ 7 - 2
tasks/GameUi/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class GameUiAssets: 
 class GameUiAssets: 
 
 
@@ -51,7 +51,7 @@ class GameUiAssets:
 	# description 
 	# description 
 	I_CHECK_SOUL_ZONES = RuleImage(roi_front=(49,105,298,405), roi_back=(49,105,298,405), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_soul_zones.png")
 	I_CHECK_SOUL_ZONES = RuleImage(roi_front=(49,105,298,405), roi_back=(49,105,298,405), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_soul_zones.png")
 	# description 
 	# description 
-	I_CHECK_REALM_RAID = RuleImage(roi_front=(123,632,57,55), roi_back=(123,632,57,55), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_realm_raid.png")
+	I_CHECK_REALM_RAID = RuleImage(roi_front=(507,72,261,46), roi_back=(507,72,261,46), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_realm_raid.png")
 	# description 
 	# description 
 	I_CHECK_GORYOU = RuleImage(roi_front=(881,17,30,39), roi_back=(881,17,30,39), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_goryou.png")
 	I_CHECK_GORYOU = RuleImage(roi_front=(881,17,30,39), roi_back=(881,17,30,39), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_goryou.png")
 	# description 
 	# description 
@@ -161,6 +161,11 @@ class GameUiAssets:
 	I_REALM_RAID_GOTO_EXPLORATION = RuleImage(roi_front=(1192,107,36,43), roi_back=(1192,107,36,43), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_realm_raid_goto_exploration.png")
 	I_REALM_RAID_GOTO_EXPLORATION = RuleImage(roi_front=(1192,107,36,43), roi_back=(1192,107,36,43), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_realm_raid_goto_exploration.png")
 
 
 
 
+	# Image Rule Assets
+	# 寮结界突破右上角 
+	I_KEKKAI_TOPPA = RuleImage(roi_front=(1065,3,203,61), roi_back=(1065,3,203,61), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_kekkai_toppa.png")
+
+
 	# Image Rule Assets
 	# Image Rule Assets
 	# 左上角蓝色的返回 
 	# 左上角蓝色的返回 
 	I_BACK_BL = RuleImage(roi_front=(32,31,50,53), roi_back=(1,2,139,120), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_back_blue.png")
 	I_BACK_BL = RuleImage(roi_front=(32,31,50,53), roi_back=(1,2,139,120), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_back_blue.png")

+ 1 - 1
tasks/GameUi/game_ui.py

@@ -20,7 +20,7 @@ class GameUi(BaseTask, GameUiAssets):
     ui_current: Page = None
     ui_current: Page = None
     ui_pages = [page_main, page_summon, page_exploration, page_town,
     ui_pages = [page_main, page_summon, page_exploration, page_town,
                 # 探索的
                 # 探索的
-                page_awake_zones, page_soul_zones, page_realm_raid, page_goryou_realm, page_delegation, page_secret_zones, page_area_boss, page_heian_kitan, page_six_gates, page_bondling_fairyland,
+                page_awake_zones, page_soul_zones, page_realm_raid, page_goryou_realm, page_delegation, page_secret_zones, page_area_boss, page_heian_kitan, page_six_gates, page_bondling_fairyland, page_kekkai_toppa,
                 # 町中的
                 # 町中的
                 page_duel, page_demon_encounter, page_hunt, page_draft_duel, page_hyakkisen,
                 page_duel, page_demon_encounter, page_hunt, page_draft_duel, page_hyakkisen,
                 # 庭院里面的
                 # 庭院里面的

+ 5 - 0
tasks/GameUi/page.py

@@ -1,6 +1,7 @@
 import traceback
 import traceback
 
 
 from tasks.GameUi.assets import GameUiAssets as G
 from tasks.GameUi.assets import GameUiAssets as G
+from tasks.RyouToppa.assets import RyouToppaAssets
 
 
 
 
 class Page:
 class Page:
@@ -59,6 +60,10 @@ page_exploration.link(button=G.I_EXPLORATION_GOTO_SOUL_ZONE, destination=page_so
 page_realm_raid = Page(G.I_CHECK_REALM_RAID)
 page_realm_raid = Page(G.I_CHECK_REALM_RAID)
 page_realm_raid.link(button=G.I_REALM_RAID_GOTO_EXPLORATION, destination=page_exploration)
 page_realm_raid.link(button=G.I_REALM_RAID_GOTO_EXPLORATION, destination=page_exploration)
 page_exploration.link(button=G.I_EXPLORATION_GOTO_REALM_RAID, destination=page_realm_raid)
 page_exploration.link(button=G.I_EXPLORATION_GOTO_REALM_RAID, destination=page_realm_raid)
+# 寮结界突破右上角 kekkai toppa
+page_kekkai_toppa = Page(G.I_KEKKAI_TOPPA)
+page_kekkai_toppa.link(button=G.I_REALM_RAID_GOTO_EXPLORATION, destination=page_exploration)
+page_realm_raid.link(button=RyouToppaAssets.I_RYOU_TOPPA, destination=page_kekkai_toppa)
 # 御灵 goryou realm
 # 御灵 goryou realm
 page_goryou_realm = Page(G.I_CHECK_GORYOU)
 page_goryou_realm = Page(G.I_CHECK_GORYOU)
 page_goryou_realm.link(button=G.I_BACK_BLUE, destination=page_exploration)
 page_goryou_realm.link(button=G.I_BACK_BLUE, destination=page_exploration)

BIN
tasks/GameUi/page/page_check_realm_raid.png


+ 2 - 2
tasks/GameUi/page/page_img.json

@@ -146,8 +146,8 @@
   {
   {
     "itemName": "check_realm_raid",
     "itemName": "check_realm_raid",
     "imageName": "page_check_realm_raid.png",
     "imageName": "page_check_realm_raid.png",
-    "roiFront": "123,632,57,55",
-    "roiBack": "123,632,57,55",
+    "roiFront": "507,72,261,46",
+    "roiBack": "507,72,261,46",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"

+ 11 - 0
tasks/GameUi/page/page_img_supplement_RyouToppa.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "kekkai_toppa",
+    "imageName": "page_kekkai_toppa.png",
+    "roiFront": "1065,3,203,61",
+    "roiBack": "1065,3,203,61",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "寮结界突破右上角"
+  }
+]

BIN
tasks/GameUi/page/page_kekkai_toppa.png


+ 1 - 1
tasks/General/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class GeneralAssets: 
 class GeneralAssets: 
 	pass
 	pass

+ 1 - 1
tasks/GlobalGame/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class GlobalGameAssets: 
 class GlobalGameAssets: 
 
 

+ 1 - 1
tasks/GoldYoukai/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class GoldYoukaiAssets: 
 class GoldYoukaiAssets: 
 	pass
 	pass

+ 1 - 1
tasks/GotoMain/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class GotoMainAssets: 
 class GotoMainAssets: 
 	pass
 	pass

+ 1 - 1
tasks/Hunt/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class HuntAssets: 
 class HuntAssets: 
 	pass
 	pass

BIN
tasks/KekkaiActivation/a/a_a_activate_gray.png


BIN
tasks/KekkaiActivation/a/a_a_activate_yellow.png


BIN
tasks/KekkaiActivation/a/a_a_auto_invite.png


BIN
tasks/KekkaiActivation/a/a_a_card_all.png


BIN
tasks/KekkaiActivation/a/a_a_card_fish.png


BIN
tasks/KekkaiActivation/a/a_a_card_kaiko.png


BIN
tasks/KekkaiActivation/a/a_a_card_moon.png


BIN
tasks/KekkaiActivation/a/a_a_card_other.png


BIN
tasks/KekkaiActivation/a/a_a_card_room.png


BIN
tasks/KekkaiActivation/a/a_a_check_card.png


BIN
tasks/KekkaiActivation/a/a_a_empty.png


BIN
tasks/KekkaiActivation/a/a_a_friend_1.png


BIN
tasks/KekkaiActivation/a/a_a_friend_2.png


BIN
tasks/KekkaiActivation/a/a_a_harvest_exp.png


BIN
tasks/KekkaiActivation/a/a_a_harvest_fish4.png


BIN
tasks/KekkaiActivation/a/a_a_invite.png


+ 155 - 0
tasks/KekkaiActivation/a/image.json

@@ -0,0 +1,155 @@
+[
+  {
+    "itemName": "a_harvest_fish4",
+    "imageName": "a_a_harvest_fish4.png",
+    "roiFront": "897,159,48,40",
+    "roiBack": "872,128,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "斗鱼收获奖励4星"
+  },
+  {
+    "itemName": "a_harvest_exp",
+    "imageName": "a_a_harvest_exp.png",
+    "roiFront": "891,153,49,43",
+    "roiBack": "865,121,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "一般的收获奖励"
+  },
+  {
+    "itemName": "a_cards_realm",
+    "imageName": "a_a_cards_realm.png",
+    "roiFront": "0,0,100,100",
+    "roiBack": "0,0,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "\"结界卡\""
+  },
+  {
+    "itemName": "a_card_all",
+    "imageName": "a_a_card_all.png",
+    "roiFront": "357,175,167,59",
+    "roiBack": "357,175,167,59",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "a_card_kaiko",
+    "imageName": "a_a_card_kaiko.png",
+    "roiFront": "355,237,169,62",
+    "roiBack": "355,237,169,62",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "a_card_fish",
+    "imageName": "a_a_card_fish.png",
+    "roiFront": "352,303,173,62",
+    "roiBack": "352,303,173,62",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "a_card_room",
+    "imageName": "a_a_card_room.png",
+    "roiFront": "355,370,167,59",
+    "roiBack": "355,370,167,59",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "a_card_moon",
+    "imageName": "a_a_card_moon.png",
+    "roiFront": "354,439,171,59",
+    "roiBack": "354,439,171,59",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "a_card_other",
+    "imageName": "a_a_card_other.png",
+    "roiFront": "353,502,173,61",
+    "roiBack": "353,502,173,61",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "其他变异"
+  },
+  {
+    "itemName": "a_invite",
+    "imageName": "a_a_invite.png",
+    "roiFront": "1040,552,100,100",
+    "roiBack": "1040,552,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "邀请"
+  },
+  {
+    "itemName": "a_auto_invite",
+    "imageName": "a_a_auto_invite.png",
+    "roiFront": "1071,456,53,51",
+    "roiBack": "1071,456,53,51",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "自动邀请"
+  },
+  {
+    "itemName": "a_friend_1",
+    "imageName": "a_a_friend_1.png",
+    "roiFront": "590,573,64,73",
+    "roiBack": "590,573,64,73",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "a_friend_2",
+    "imageName": "a_a_friend_2.png",
+    "roiFront": "741,572,70,69",
+    "roiBack": "741,572,70,69",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "位置2,空人的"
+  },
+  {
+    "itemName": "a_activate_yellow",
+    "imageName": "a_a_activate_yellow.png",
+    "roiFront": "1047,560,100,100",
+    "roiBack": "1047,560,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "激活, 黄色的可以激活"
+  },
+  {
+    "itemName": "a_activate_gray",
+    "imageName": "a_a_activate_gray.png",
+    "roiFront": "1046,556,100,100",
+    "roiBack": "1046,556,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "激活, 灰色不可激活"
+  },
+  {
+    "itemName": "a_empty",
+    "imageName": "a_a_empty.png",
+    "roiFront": "677,255,353,128",
+    "roiBack": "677,255,353,128",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "空着的表示没有卡在里面"
+  },
+  {
+    "itemName": "a_check_card",
+    "imageName": "a_a_check_card.png",
+    "roiFront": "513,32,260,49",
+    "roiBack": "513,32,260,49",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  }
+]

+ 87 - 2
tasks/KekkaiActivation/assets.py

@@ -5,8 +5,93 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class KekkaiActivationAssets: 
 class KekkaiActivationAssets: 
-	pass
+
+
+	# Click Rule Assets
+	# 切换卡的种类 
+	C_A_SELECT_CARD_LIST = RuleClick(roi_front=(352,99,172,53), roi_back=(352,99,172,53), name="a_select_card_list")
+	# description 
+	C_A_SELECT_AUTO = RuleClick(roi_front=(173,160,354,127), roi_back=(173,160,354,127), name="a_select_auto")
+
+
+	# Ocr Rule Assets
+	# 这张卡一共有多少小时 
+	O_CARD_ALL_TIME = RuleOcr(roi=(926,262,95,31), area=(926,262,95,31), mode="Single", method="Default", keyword="", name="card_all_time")
+
+
+	# Swipe Rule Assets
+	# description 
+	S_CARDS_SWIPE = RuleSwipe(roi_front=(178,401,23,23), roi_back=(176,168,29,24), mode="default", name="cards_swipe")
+
+
+	# Image Rule Assets
+	# 斗鱼收获奖励4星 
+	I_A_HARVEST_FISH4 = RuleImage(roi_front=(897,159,48,40), roi_back=(872,128,100,100), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_harvest_fish4.png")
+	# 一般的收获奖励 
+	I_A_HARVEST_EXP = RuleImage(roi_front=(891,153,49,43), roi_back=(865,121,100,100), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_harvest_exp.png")
+	# "结界卡" 
+	I_A_CARDS_REALM = RuleImage(roi_front=(0,0,100,100), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_cards_realm.png")
+	# description 
+	I_A_CARD_ALL = RuleImage(roi_front=(357,175,167,59), roi_back=(357,175,167,59), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_card_all.png")
+	# description 
+	I_A_CARD_KAIKO = RuleImage(roi_front=(355,237,169,62), roi_back=(355,237,169,62), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_card_kaiko.png")
+	# description 
+	I_A_CARD_FISH = RuleImage(roi_front=(352,303,173,62), roi_back=(352,303,173,62), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_card_fish.png")
+	# description 
+	I_A_CARD_ROOM = RuleImage(roi_front=(355,370,167,59), roi_back=(355,370,167,59), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_card_room.png")
+	# description 
+	I_A_CARD_MOON = RuleImage(roi_front=(354,439,171,59), roi_back=(354,439,171,59), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_card_moon.png")
+	# 其他变异 
+	I_A_CARD_OTHER = RuleImage(roi_front=(353,502,173,61), roi_back=(353,502,173,61), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_card_other.png")
+	# 邀请 
+	I_A_INVITE = RuleImage(roi_front=(1040,552,100,100), roi_back=(1040,552,100,100), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_invite.png")
+	# 自动邀请 
+	I_A_AUTO_INVITE = RuleImage(roi_front=(1071,456,53,51), roi_back=(1071,456,53,51), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_auto_invite.png")
+	# description 
+	I_A_FRIEND_1 = RuleImage(roi_front=(590,573,64,73), roi_back=(590,573,64,73), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_friend_1.png")
+	# 位置2,空人的 
+	I_A_FRIEND_2 = RuleImage(roi_front=(741,572,70,69), roi_back=(741,572,70,69), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_friend_2.png")
+	# 激活, 黄色的可以激活 
+	I_A_ACTIVATE_YELLOW = RuleImage(roi_front=(1047,560,100,100), roi_back=(1047,560,100,100), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_activate_yellow.png")
+	# 激活, 灰色不可激活 
+	I_A_ACTIVATE_GRAY = RuleImage(roi_front=(1046,556,100,100), roi_back=(1046,556,100,100), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_activate_gray.png")
+	# 空着的表示没有卡在里面 
+	I_A_EMPTY = RuleImage(roi_front=(677,255,353,128), roi_back=(677,255,353,128), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_empty.png")
+	# description 
+	I_A_CHECK_CARD = RuleImage(roi_front=(513,32,260,49), roi_back=(513,32,260,49), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/a/a_a_check_card.png")
+
+
+	# Image Rule Assets
+	# description 
+	I_CARDS_KAIKO_6 = RuleImage(roi_front=(191,216,89,73), roi_back=(169,148,130,501), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_kaiko_6.png")
+	# description 
+	I_CARDS_KAIKO_5 = RuleImage(roi_front=(192,255,88,22), roi_back=(172,162,126,488), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_kaiko_5.png")
+	# description 
+	I_CARDS_KAIKO_4 = RuleImage(roi_front=(191,248,90,22), roi_back=(179,165,116,482), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_kaiko_4.png")
+	# description 
+	I_CARDS_KAIKO_3 = RuleImage(roi_front=(191,370,89,66), roi_back=(183,169,109,474), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_kaiko_3.png")
+	# 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")
+	# 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")
+	# 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 
+	I_CARDS_MOON_6 = RuleImage(roi_front=(189,186,89,88), roi_back=(183,167,100,480), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_moon_6.png")
+	# description 
+	I_CARDS_MOON_5 = RuleImage(roi_front=(190,398,91,22), roi_back=(183,163,100,489), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_moon_5.png")
+	# description 
+	I_CARDS_MOON_4 = RuleImage(roi_front=(190,426,91,21), roi_back=(186,144,100,491), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_moon_4.png")
+	# description 
+	I_CARDS_MOON_3 = RuleImage(roi_front=(189,366,92,22), roi_back=(181,153,107,495), threshold=0.9, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_moon_3.png")
+	# description 
+	I_CARDS_MOON_2 = RuleImage(roi_front=(189,355,91,60), roi_back=(180,162,108,484), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_moon_2.png")
+	# description 
+	I_CARDS_MOON_1 = RuleImage(roi_front=(190,430,93,74), roi_back=(173,156,123,492), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_moon_1.png")
+
 
 

BIN
tasks/KekkaiActivation/cards/cards_cards_fish_3.png


BIN
tasks/KekkaiActivation/cards/cards_cards_fish_4.png


BIN
tasks/KekkaiActivation/cards/cards_cards_fish_5.png


BIN
tasks/KekkaiActivation/cards/cards_cards_fish_6.png


BIN
tasks/KekkaiActivation/cards/cards_cards_kaiko_3.png


BIN
tasks/KekkaiActivation/cards/cards_cards_kaiko_4.png


BIN
tasks/KekkaiActivation/cards/cards_cards_kaiko_5.png


BIN
tasks/KekkaiActivation/cards/cards_cards_kaiko_6.png


BIN
tasks/KekkaiActivation/cards/cards_cards_moon_1.png


BIN
tasks/KekkaiActivation/cards/cards_cards_moon_2.png


BIN
tasks/KekkaiActivation/cards/cards_cards_moon_3.png


BIN
tasks/KekkaiActivation/cards/cards_cards_moon_4.png


BIN
tasks/KekkaiActivation/cards/cards_cards_moon_5.png


BIN
tasks/KekkaiActivation/cards/cards_cards_moon_6.png


+ 128 - 0
tasks/KekkaiActivation/cards/image.json

@@ -0,0 +1,128 @@
+[
+  {
+    "itemName": "cards_kaiko_6",
+    "imageName": "cards_cards_kaiko_6.png",
+    "roiFront": "191,216,89,73",
+    "roiBack": "169,148,130,501",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_kaiko_5",
+    "imageName": "cards_cards_kaiko_5.png",
+    "roiFront": "192,255,88,22",
+    "roiBack": "172,162,126,488",
+    "method": "Template matching",
+    "threshold": 0.90,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_kaiko_4",
+    "imageName": "cards_cards_kaiko_4.png",
+    "roiFront": "191,248,90,22",
+    "roiBack": "179,165,116,482",
+    "method": "Template matching",
+    "threshold": 0.90,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_kaiko_3",
+    "imageName": "cards_cards_kaiko_3.png",
+    "roiFront": "191,370,89,66",
+    "roiBack": "183,169,109,474",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_fish_6",
+    "imageName": "cards_cards_fish_6.png",
+    "roiFront": "193,183,87,91",
+    "roiBack": "178,169,110,474",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_fish_5",
+    "imageName": "cards_cards_fish_5.png",
+    "roiFront": "192,358,88,21",
+    "roiBack": "176,155,105,492",
+    "method": "Template matching",
+    "threshold": 0.90,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_fish_4",
+    "imageName": "cards_cards_fish_4.png",
+    "roiFront": "192,409,87,21",
+    "roiBack": "176,175,118,473",
+    "method": "Template matching",
+    "threshold": 0.90,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_fish_3",
+    "imageName": "cards_cards_fish_3.png",
+    "roiFront": "193,314,86,64",
+    "roiBack": "188,164,100,482",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_moon_6",
+    "imageName": "cards_cards_moon_6.png",
+    "roiFront": "189,186,89,88",
+    "roiBack": "183,167,100,480",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_moon_5",
+    "imageName": "cards_cards_moon_5.png",
+    "roiFront": "190,398,91,22",
+    "roiBack": "183,163,100,489",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_moon_4",
+    "imageName": "cards_cards_moon_4.png",
+    "roiFront": "190,426,91,21",
+    "roiBack": "186,144,100,491",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_moon_3",
+    "imageName": "cards_cards_moon_3.png",
+    "roiFront": "189,366,92,22",
+    "roiBack": "181,153,107,495",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_moon_2",
+    "imageName": "cards_cards_moon_2.png",
+    "roiFront": "189,355,91,60",
+    "roiBack": "180,162,108,484",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "cards_moon_1",
+    "imageName": "cards_cards_moon_1.png",
+    "roiFront": "190,430,93,74",
+    "roiBack": "173,156,123,492",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  }
+]

+ 14 - 0
tasks/KekkaiActivation/click.json

@@ -0,0 +1,14 @@
+[
+  {
+    "itemName": "a_select_card_list",
+    "roiFront": "352,99,172,53",
+    "roiBack": "352,99,172,53",
+    "description": "切换卡的种类"
+  },
+  {
+    "itemName": "a_select_auto",
+    "roiFront": "173,160,354,127",
+    "roiBack": "173,160,354,127",
+    "description": "description"
+  }
+]

+ 4 - 2
tasks/KekkaiActivation/config.py

@@ -5,17 +5,19 @@ from pydantic import BaseModel, Field
 from enum import Enum
 from enum import Enum
 from datetime import datetime, time
 from datetime import datetime, time
 
 
+from tasks.Component.config_base import MultiLine
+
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_base import ConfigBase, TimeDelta
 from tasks.Component.config_base import ConfigBase, TimeDelta
 from tasks.Utils.config_enum import ShikigamiClass
 from tasks.Utils.config_enum import ShikigamiClass
 
 
 class ActivationScheduler(Scheduler):
 class ActivationScheduler(Scheduler):
     priority = Field(default=2, description='priority_help')
     priority = Field(default=2, description='priority_help')
-    success_interval: TimeDelta = Field(default=TimeDelta(hours=10), description='success_interval_help')
+    success_interval: TimeDelta = Field(default=TimeDelta(days=1), description='success_interval_help')
     failure_interval: TimeDelta = Field(default=TimeDelta(hours=10), description='failure_interval_help')
     failure_interval: TimeDelta = Field(default=TimeDelta(hours=10), description='failure_interval_help')
 
 
 class ActivationConfig(BaseModel):
 class ActivationConfig(BaseModel):
-    card_rule: str = Field(default='auto', description='card_rule_help')
+    card_rule: MultiLine = Field(default='auto', description='card_rule_help')
     exchange_before: bool = Field(default=True, description='exchange_before_help')
     exchange_before: bool = Field(default=True, description='exchange_before_help')
     exchange_max: bool = Field(default=True, description='exchange_max_help')
     exchange_max: bool = Field(default=True, description='exchange_max_help')
     shikigami_class: ShikigamiClass = Field(default=ShikigamiClass.N, description='shikigami_class_help')
     shikigami_class: ShikigamiClass = Field(default=ShikigamiClass.N, description='shikigami_class_help')

+ 11 - 0
tasks/KekkaiActivation/ocr.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "card_all_time",
+    "roiFront": "926,262,95,31",
+    "roiBack": "926,262,95,31",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "这张卡一共有多少小时"
+  }
+]

+ 356 - 3
tasks/KekkaiActivation/script_task.py

@@ -1,17 +1,370 @@
 # This Python file uses the following encoding: utf-8
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
+import time
 
 
+from cached_property import cached_property
+from datetime import datetime, timedelta
 
 
+from module.base.timer import Timer
+from module.atom.image_grid import ImageGrid
+from module.atom.image import RuleImage
 from module.logger import logger
 from module.logger import logger
 from module.exception import TaskEnd
 from module.exception import TaskEnd
 
 
-from tasks.GameUi.game_ui import GameUi
+from tasks.KekkaiUtilize.script_task import ScriptTask as KU
+from tasks.KekkaiUtilize.utils import CardClass
+from tasks.KekkaiActivation.assets import KekkaiActivationAssets
+from tasks.KekkaiActivation.utils import parse_rule
+from tasks.KekkaiActivation.config import ActivationConfig
+from tasks.Utils.config_enum import ShikigamiClass
+from tasks.GameUi.page import page_main, page_guild
 
 
 
 
-class ScriptTask(GameUi):
+class ScriptTask(KU, KekkaiActivationAssets):
 
 
     def run(self):
     def run(self):
-        pass
+        con = self.config.kekkai_activation.activation_config
+        self.ui_get_current_page()
+        self.ui_goto(page_guild)
+        # 进入寮结界
+        self.goto_realm()
+        if con.exchange_before:
+            self.check_max_lv(con.shikigami_class)
+        self.harvest_card()
 
 
+        self.run_activation(con)
+        while 1:
+            # 关闭到结界界面
+            self.screenshot()
+            if self.appear(self.I_REALM_SHIN):
+                break
+            if self.appear(self.I_SHI_GROWN):
+                break
+            if self.appear_then_click(self.I_UI_BACK_RED, interval=1):
+                continue
 
 
+        if con.exchange_max:
+            self.check_max_lv(con.shikigami_class)
+        self.back_guild()
+
+        raise TaskEnd('KekkaiActivation')
+
+    @cached_property
+    def dict_card_image(self) -> dict:
+        match_targets = {
+            CardClass.TAIKO6: self.I_CARDS_KAIKO_6,
+            CardClass.TAIKO5: self.I_CARDS_KAIKO_5,
+            CardClass.TAIKO4: self.I_CARDS_KAIKO_4,
+            CardClass.TAIKO3: self.I_CARDS_KAIKO_3,
+            CardClass.FISH6: self.I_CARDS_FISH_6,
+            CardClass.FISH5: self.I_CARDS_FISH_5,
+            CardClass.FISH4: self.I_CARDS_FISH_4,
+            CardClass.FISH3: self.I_CARDS_FISH_3,
+            CardClass.MOON6: self.I_CARDS_MOON_6,
+            CardClass.MOON5: self.I_CARDS_MOON_5,
+            CardClass.MOON4: self.I_CARDS_MOON_4,
+            CardClass.MOON3: self.I_CARDS_MOON_3,
+            CardClass.MOON2: self.I_CARDS_MOON_2,
+            CardClass.MOON1: self.I_CARDS_MOON_1
+        }
+        return match_targets
+
+    @cached_property
+    def dict_image_card(self) -> dict:
+        return {v: k for k, v in self.dict_card_image.items()}
+
+    @cached_property
+    def order_cards(self) -> list[CardClass]:
+        # 重写
+        config = self.config.kekkai_activation.activation_config.card_rule
+        return parse_rule(config)
+
+    @cached_property
+    def order_targets(self) -> ImageGrid:
+        # 重写
+        return ImageGrid([self.dict_card_image[card] for card in self.order_cards])
+
+    def run_activation(self, _config: ActivationConfig) -> bool:
+        """
+        执行挂卡,要求在结界的界面
+        顺便把下一次执行也设置了
+        :return: 挂卡成功()返回True,失败(时间没到提前来了)返回False
+        退出的时候还是在挂卡界面而不是结界界面
+        """
+        self.goto_cards()
+        # 太诡异了 为什么有这么长的动画, 那么长的动画先休息一会
+        logger.hr('Start activation')
+        time.sleep(0.5)
+        while 1:
+            self.screenshot()
+            card_status = self.check_card_status()
+            card_effect = self.check_card_effect()
+
+            # 不稳定太,等待动画结束
+            if not card_status and not card_effect:
+                # 黄色的 ”激活“
+                if self.appear(self.I_A_ACTIVATE_YELLOW, threshold=0.99):
+                    continue
+            # 如果这张卡生效着,在使用中
+            if card_status and card_effect:
+                logger.info('Card is using')
+                interval = self.ocr_time()
+                self.set_next_run("KekkaiActivation", success=False, finish=True, target=interval+datetime.now())
+                return False
+            # 如果已经选中这张卡了, 那就激活这张卡
+            if card_status and not card_effect:
+                logger.info('Card is selected but not using')
+                while 1:
+                    self.screenshot()
+                    if self.appear(self.I_A_INVITE):
+                        logger.info('Card is activated')
+                        break
+                    if self.appear_then_click(self.I_UI_CONFIRM, interval=0.6):
+                        continue
+                    if self.appear_then_click(self.I_A_ACTIVATE_YELLOW, interval=1):
+                        continue
+                interval = self.ocr_time(True)
+                self.set_next_run("KekkaiActivation", success=True, finish=True, target=interval + datetime.now())
+                return True
+            # 如果是什么都没有,那就是可以开始挂卡了
+            if not card_status and not card_effect:
+                logger.info('Card is not selected also not using')
+                self.screening_card(_config.card_rule)
+
+
+
+
+
+
+    def goto_cards(self):
+        """
+        寮结界,前往挂卡界面
+        :return:
+        """
+        while 1:
+            self.screenshot()
+
+            if self.appear(self.I_A_CHECK_CARD):
+                break
+            if self.appear(self.I_A_AUTO_INVITE):
+                break
+            if self.appear_then_click(self.I_SHI_CARD, interval=1):
+                continue
+        logger.info('Enter card page')
+
+    def check_card_status(self, screenshot=False) -> bool:
+        """
+        判断使用有挂卡在上面了, 判断依据就是如果没看就可以显示背景图
+        :param screenshot:
+        :return: 如果有卡在上面了返回True,否则返回False
+        """
+        if screenshot:
+            self.screenshot()
+        return not self.appear(self.I_A_EMPTY)
+
+    def check_card_effect(self, screenshot=False) -> bool:
+        """
+        检查这张卡是否生效了, 如果是出现的“邀请”那就是生效了, 如果是“激活”那就是还没生效
+        :param screenshot:
+        :return: 生效返回True
+        """
+        if screenshot:
+            self.screenshot()
+        if self.appear(self.I_A_INVITE, threshold=0.8):
+            return True
+        elif self.appear(self.I_A_ACTIVATE_YELLOW):
+            return False
+        logger.info('Unknown card effect')
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_A_INVITE, threshold=0.7):
+                return True
+            elif self.appear(self.I_A_ACTIVATE_YELLOW):
+                return False
+            elif self.appear(self.I_A_ACTIVATE_GRAY):
+                return False
+        return False
+
+    def ocr_time(self, screenshot=False) -> timedelta or None:
+        if screenshot:
+            self.screenshot()
+        delta = self.O_CARD_ALL_TIME.ocr_duration(self.device.image)
+        if not isinstance(delta, timedelta):
+            logger.warning('OCR error')
+            return None
+        return delta
+
+    def screening_card(self, rule: str):
+        """
+        开始挑选卡
+        :return:
+        """
+
+        def run_auto():
+            while 1:
+                self.screenshot()
+                if not self.appear(self.I_A_EMPTY) and self.appear(self.I_A_ACTIVATE_YELLOW, threshold=0.9):
+                    break
+                if self.click(self.C_A_SELECT_AUTO, interval=1):
+                    continue
+
+        if rule == "auto":
+            logger.info('Auto select card')
+            run_auto()
+            return
+
+        card_class = None
+        target_class = None
+        top_card = self.order_cards[0]
+        if top_card.startswith(CardClass.TAIKO):  # 太鼓
+            card_class = CardClass.TAIKO
+            target_class = self.I_A_CARD_KAIKO
+        elif top_card.startswith(CardClass.MOON):  # 太阴
+            card_class = CardClass.MOON
+            target_class = self.I_A_CARD_MOON
+        elif top_card.startswith(CardClass.FISH):  # 斗鱼
+            card_class = CardClass.FISH
+            target_class = self.I_A_CARD_FISH
+
+        if card_class is None:
+            logger.warning('Unknown card class')
+            run_auto()
+            return
+
+        while 1:
+            self.screenshot()
+
+            if self.appear(target_class):
+                time.sleep(0.3)
+                self.screenshot()
+                if self.appear(target_class):
+                    break
+            if self.click(self.C_A_SELECT_CARD_LIST, interval=1):
+                continue
+        logger.info('Appear card class: {}'.format(card_class))
+        while 1:
+            self.screenshot()
+            if not self.appear(target_class):
+                break
+            if self.appear_then_click(target_class, interval=1):
+                continue
+        logger.info('Selected card class: {}'.format(card_class))
+
+        # 得了开始一直往下滑动 找最优卡
+        card_best = None
+        swipe_count = 0
+        while 1:
+            self.screenshot()
+            current_best = self._current_select_best(card_best)
+            if current_best is None:
+                break
+
+            if current_best == self.order_cards[0]:
+                break
+            # 为什么找到第二个最优解也是会退出呢???
+            # 这个是因为一般是从高星到低星来找, 基本上第二个最优解就是最优解了
+            elif current_best == self.order_cards[1]:
+                break
+
+            # 超过十次就退出
+            if swipe_count > 20:
+                logger.warning('Swipe count is more than 10')
+                break
+            # 一直向下滑动
+            self.swipe(self.S_CARDS_SWIPE, interval=0.9)
+            swipe_count += 1
+            time.sleep(2)
+
+    def _image_convert_card(self, target: RuleImage) -> CardClass:
+        """
+        就是把一张图转化 到某个具体的类
+        :return:
+        """
+        try:
+            return self.dict_image_card[target]
+        except KeyError:
+            logger.warning(f'Unknown card class: {target}')
+            return CardClass.UNKNOWN
+
+    def _current_select_best(self, last_best: CardClass or None) -> CardClass | None:
+        self.screenshot()
+        target = self.order_targets.find_anyone(self.device.image)
+        if target is None:
+            logger.info('No target card found')
+            return None
+        current_card = self._image_convert_card(target)
+        if current_card == CardClass.UNKNOWN:
+            logger.info('Unknown card class')
+            return None
+        logger.info(f'Current best card class: {current_card}')
+
+        # 如果当前的最好的卡,不比上一次最好的卡,那就退出
+        if last_best is not None:
+            last_index = self.order_cards.index(last_best)
+            current_index = self.order_cards.index(current_card)
+            if current_index > last_index:
+                # 不比上一张卡好就退出不执行操作
+                logger.info('Current card is not better than last best card')
+                return last_best
+
+        # 否则就是比上一张卡好,那就执行操作 点击操作
+        logger.info('Current select card: %s', current_card)
+        # 如果一开始是没有选择中的,那就稳定点否则就是只管点击
+        self.screenshot()
+        if self.appear(self.I_A_EMPTY):
+            while 1:
+                self.screenshot()
+                if not self.appear(self.I_A_EMPTY):
+                    return current_card
+                if self.appear_then_click(target, interval=1):
+                    continue
+        self.appear_then_click(target, interval=0.5)
+        return current_card
+
+    def check_max_lv(self, shikigami_class: ShikigamiClass = ShikigamiClass.N):
+        """
+        在结界界面,进入式神育成,检查是否有满级的,如果有就换下一个
+        退出的时候还是结界界面
+        :return:
+        """
+        self.realm_goto_grown()
+        if self.appear(self.I_RS_LEVEL_MAX):
+            # 存在满级的式神
+            logger.info('Exist max level shikigami and replace it')
+            self.unset_shikigami_max_lv()
+            self.switch_shikigami_class(shikigami_class)
+            self.set_shikigami(shikigami_order=7, stop_image=self.I_RS_NO_ADD)
+        else:
+            logger.info('No max level shikigami')
+
+        # 回到结界界面
+        while 1:
+            self.screenshot()
+
+            if self.appear(self.I_REALM_SHIN):
+                break
+            if self.appear(self.I_SHI_GROWN):
+                break
+            if self.appear_then_click(self.I_UI_BACK_BLUE, interval=1):
+                continue
+
+    def harvest_card(self):
+        """
+        收卡的经验
+        :return:
+        """
+        self.appear_then_click(self.I_A_HARVEST_EXP)
+        self.appear_then_click(self.I_A_HARVEST_FISH4)  # 斗鱼的如果一直没有领的话
+
+if __name__ == "__main__":
+    from module.config.config import Config
+    from module.device.device import Device
+    import cv2
+
+    c = Config('oas1')
+    d = Device(c)
+
+    t = ScriptTask(c, d)
+    t.run()
+    # t.run_activation(t.config.kekkai_activation.activation_config)

+ 9 - 0
tasks/KekkaiActivation/swipe.json

@@ -0,0 +1,9 @@
+[
+  {
+    "itemName": "cards_swipe",
+    "roiFront": "178,401,23,23",
+    "roiBack": "176,168,29,24",
+    "mode": "default",
+    "description": "description"
+  }
+]

+ 50 - 0
tasks/KekkaiActivation/utils.py

@@ -0,0 +1,50 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+
+import re
+
+from tasks.KekkaiUtilize.utils import CardClass
+from module.atom.image_grid import ImageGrid
+
+
+def parse_rule(rule: str) -> list[CardClass]:
+    """
+    反正不管用的是第一个
+    :param rule:
+    :return:
+    """
+    values = ['太鼓6', '太鼓5', '太鼓4', '太鼓3', '斗鱼6', '斗鱼5', '斗鱼4', '斗鱼3', '太阴6', '太阴5', '太阴4', '太阴3',
+              '太阴2', '太阴1']
+    match = {
+        '太鼓6': CardClass.TAIKO6,
+        '太鼓5': CardClass.TAIKO5,
+        '太鼓4': CardClass.TAIKO4,
+        '太鼓3': CardClass.TAIKO3,
+        '斗鱼6': CardClass.FISH6,
+        '斗鱼5': CardClass.FISH5,
+        '斗鱼4': CardClass.FISH4,
+        '斗鱼3': CardClass.FISH3,
+        '太阴6': CardClass.MOON6,
+        '太阴5': CardClass.MOON5,
+        '太阴4': CardClass.MOON4,
+        '太阴3': CardClass.MOON3,
+        '太阴2': CardClass.MOON2,
+        '太阴1': CardClass.MOON1,
+    }
+    rule = rule.replace(' ', '').replace('\n', '')
+    # 正则表达式 分离 ">"
+    rule = re.split(r'>', rule)
+    rule = [item for item in rule if item in values]
+    result = [match[item] for item in rule]
+    return result
+
+# def parse_targets(cards: list[CardClass]) -> ImageGrid:
+#     """
+#     从卡片列表中解析出目标
+#     :param cards:
+#     :return:
+#     """
+#     pass
+
+# print(parse_rule("太鼓5 > 斗鱼5 > 太鼓4 > 斗鱼4 > 太鼓3 > 斗鱼3"))

+ 25 - 7
tasks/KekkaiUtilize/assets.py

@@ -5,7 +5,7 @@ from module.atom.swipe import RuleSwipe
 from module.atom.ocr import RuleOcr
 from module.atom.ocr import RuleOcr
 from module.atom.list import RuleList
 from module.atom.list import RuleList
 
 
-# This file was automatically generated by module/dev_tools/assets_extract.py.
+# This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 # Don't modify it manually.
 class KekkaiUtilizeAssets: 
 class KekkaiUtilizeAssets: 
 
 
@@ -20,9 +20,9 @@ class KekkaiUtilizeAssets:
 	# 神灶 
 	# 神灶 
 	I_GUILD_SHIRNE = RuleImage(roi_front=(872,624,60,62), roi_back=(872,624,60,62), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_shirne.png")
 	I_GUILD_SHIRNE = RuleImage(roi_front=(872,624,60,62), roi_back=(872,624,60,62), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_shirne.png")
 	# description 
 	# description 
-	I_GUILD_AP = RuleImage(roi_front=(483,314,22,22), roi_back=(297,232,229,132), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_ap.png")
+	I_GUILD_AP = RuleImage(roi_front=(483,314,22,22), roi_back=(225,224,301,167), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_ap.png")
 	# description 
 	# description 
-	I_GUILD_ASSETS = RuleImage(roi_front=(315,311,23,28), roi_back=(304,301,50,50), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_assets.png")
+	I_GUILD_ASSETS = RuleImage(roi_front=(315,311,23,28), roi_back=(227,262,354,136), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_assets.png")
 	# 领取寮资金 
 	# 领取寮资金 
 	I_GUILD_ASSETS_RECEIVE = RuleImage(roi_front=(565,426,144,63), roi_back=(565,426,144,63), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_assets_receive.png")
 	I_GUILD_ASSETS_RECEIVE = RuleImage(roi_front=(565,426,144,63), roi_back=(565,426,144,63), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_assets_receive.png")
 
 
@@ -37,11 +37,11 @@ class KekkaiUtilizeAssets:
 	# 收取经验(没有满的图) 
 	# 收取经验(没有满的图) 
 	I_CARD_EXP = RuleImage(roi_front=(889,151,57,54), roi_back=(863,118,124,121), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_card_exp.png")
 	I_CARD_EXP = RuleImage(roi_front=(889,151,57,54), roi_back=(863,118,124,121), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_card_exp.png")
 	# 收取体力(没有满) 
 	# 收取体力(没有满) 
-	I_BOX_AP = RuleImage(roi_front=(815,435,57,51), roi_back=(778,411,130,100), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_box_ap.png")
+	I_BOX_AP = RuleImage(roi_front=(815,435,57,51), roi_back=(778,411,130,100), threshold=0.7, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_box_ap.png")
 	# 收取盒子的经验(没有满) 
 	# 收取盒子的经验(没有满) 
-	I_BOX_EXP = RuleImage(roi_front=(894,433,50,55), roi_back=(866,407,100,100), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_box_exp.png")
+	I_BOX_EXP = RuleImage(roi_front=(893,440,42,45), roi_back=(866,407,100,100), threshold=0.7, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_box_exp.png")
 	# 结界皮肤 
 	# 结界皮肤 
-	I_REALM_SHIN = RuleImage(roi_front=(175,460,54,58), roi_back=(147,443,100,100), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_realm_shin.png")
+	I_REALM_SHIN = RuleImage(roi_front=(175,460,54,58), roi_back=(147,443,100,100), threshold=0.9, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_realm_shin.png")
 	# 寄养别人的经验 
 	# 寄养别人的经验 
 	I_UTILIZE_EXP = RuleImage(roi_front=(583,144,58,43), roi_back=(531,112,156,123), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_utilize_exp.png")
 	I_UTILIZE_EXP = RuleImage(roi_front=(583,144,58,43), roi_back=(531,112,156,123), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_utilize_exp.png")
 	# 取出 
 	# 取出 
@@ -64,7 +64,7 @@ class KekkaiUtilizeAssets:
 	# description 
 	# description 
 	I_U_TAIKO_5 = RuleImage(roi_front=(544,201,59,52), roi_back=(538,179,79,426), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_taiko_5.png")
 	I_U_TAIKO_5 = RuleImage(roi_front=(544,201,59,52), roi_back=(538,179,79,426), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_taiko_5.png")
 	# description 
 	# description 
-	I_U_TAIKO_6 = RuleImage(roi_front=(0,0,100,100), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_taiko_6.png")
+	I_U_TAIKO_6 = RuleImage(roi_front=(544,265,60,45), roi_back=(533,156,87,450), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_taiko_6.png")
 	# description 
 	# description 
 	I_U_FISH_3 = RuleImage(roi_front=(551,325,41,33), roi_back=(543,178,69,412), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_fish_3.png")
 	I_U_FISH_3 = RuleImage(roi_front=(551,325,41,33), roi_back=(543,178,69,412), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_fish_3.png")
 	# description 
 	# description 
@@ -91,8 +91,26 @@ class KekkaiUtilizeAssets:
 	I_U_CONFIRM_SMALL = RuleImage(roi_front=(672,513,131,60), roi_back=(672,513,131,60), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_confirm_small.png")
 	I_U_CONFIRM_SMALL = RuleImage(roi_front=(672,513,131,60), roi_back=(672,513,131,60), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_confirm_small.png")
 
 
 
 
+	# Image Rule Assets
+	# 太阴6 
+	I_U_MOON_6 = RuleImage(roi_front=(548,194,54,54), roi_back=(540,189,68,404), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_moon_6.png")
+	# description 
+	I_U_MOON_5 = RuleImage(roi_front=(548,205,48,46), roi_back=(540,196,66,407), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_moon_5.png")
+	# description 
+	I_U_MOON_4 = RuleImage(roi_front=(548,309,49,50), roi_back=(533,167,81,437), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_moon_4.png")
+	# description 
+	I_U_MOON_3 = RuleImage(roi_front=(549,305,53,53), roi_back=(535,173,77,430), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_moon_3.png")
+	# description 
+	I_U_MOON_2 = RuleImage(roi_front=(552,313,46,44), roi_back=(542,174,81,437), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/utilize/utilize_u_moon_2.png")
+
+
 	# Ocr Rule Assets
 	# Ocr Rule Assets
 	# 这个寄养的剩余时间 
 	# 这个寄养的剩余时间 
 	O_UTILIZE_RES_TIME = RuleOcr(roi=(1140,117,100,30), area=(1140,117,100,30), mode="Duration", method="Default", keyword="", name="utilize_res_time")
 	O_UTILIZE_RES_TIME = RuleOcr(roi=(1140,117,100,30), area=(1140,117,100,30), mode="Duration", method="Default", keyword="", name="utilize_res_time")
 
 
 
 
+	# Swipe Rule Assets
+	# 向下滑动 
+	S_U_UP = RuleSwipe(roi_front=(235,419,50,21), roi_back=(225,177,72,21), mode="default", name="u_up")
+
+

+ 1 - 0
tasks/KekkaiUtilize/config.py

@@ -35,6 +35,7 @@ class UtilizeConfig(BaseModel):
     guild_assets_enable: bool = Field(default=True, description='guild_assets_enable_help')
     guild_assets_enable: bool = Field(default=True, description='guild_assets_enable_help')
     box_ap_enable: bool = Field(default=True, description='box_ap_enable_help')
     box_ap_enable: bool = Field(default=True, description='box_ap_enable_help')
     box_exp_enable: bool = Field(default=True, description='box_exp_enable_help')
     box_exp_enable: bool = Field(default=True, description='box_exp_enable_help')
+    box_exp_waste: bool = Field(default=True, description='box_exp_waste_help')
 
 
 
 
 class KekkaiUtilize(ConfigBase):
 class KekkaiUtilize(ConfigBase):

+ 2 - 2
tasks/KekkaiUtilize/ku/image.json

@@ -39,7 +39,7 @@
     "itemName": "guild_ap",
     "itemName": "guild_ap",
     "imageName": "ku_guild_ap.png",
     "imageName": "ku_guild_ap.png",
     "roiFront": "483,314,22,22",
     "roiFront": "483,314,22,22",
-    "roiBack": "297,232,229,132",
+    "roiBack": "225,224,301,167",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
@@ -48,7 +48,7 @@
     "itemName": "guild_assets",
     "itemName": "guild_assets",
     "imageName": "ku_guild_assets.png",
     "imageName": "ku_guild_assets.png",
     "roiFront": "315,311,23,28",
     "roiFront": "315,311,23,28",
-    "roiBack": "304,301,50,50",
+    "roiBack": "227,262,354,136",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"

BIN
tasks/KekkaiUtilize/ku/ku_guild_assets_receive.png


+ 4 - 4
tasks/KekkaiUtilize/realm/image.json

@@ -41,16 +41,16 @@
     "roiFront": "815,435,57,51",
     "roiFront": "815,435,57,51",
     "roiBack": "778,411,130,100",
     "roiBack": "778,411,130,100",
     "method": "Template matching",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "收取体力(没有满)"
     "description": "收取体力(没有满)"
   },
   },
   {
   {
     "itemName": "box_exp",
     "itemName": "box_exp",
     "imageName": "realm_box_exp.png",
     "imageName": "realm_box_exp.png",
-    "roiFront": "894,433,50,55",
+    "roiFront": "893,440,42,45",
     "roiBack": "866,407,100,100",
     "roiBack": "866,407,100,100",
     "method": "Template matching",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "收取盒子的经验(没有满)"
     "description": "收取盒子的经验(没有满)"
   },
   },
   {
   {
@@ -59,7 +59,7 @@
     "roiFront": "175,460,54,58",
     "roiFront": "175,460,54,58",
     "roiBack": "147,443,100,100",
     "roiBack": "147,443,100,100",
     "method": "Template matching",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.9,
     "description": "结界皮肤"
     "description": "结界皮肤"
   },
   },
   {
   {

BIN
tasks/KekkaiUtilize/realm/realm_box_exp.png


+ 226 - 21
tasks/KekkaiUtilize/script_task.py

@@ -3,6 +3,7 @@
 # github https://github.com/runhey
 # github https://github.com/runhey
 import time
 import time
 from cached_property import cached_property
 from cached_property import cached_property
+from datetime import timedelta
 
 
 from module.base.timer import Timer
 from module.base.timer import Timer
 from module.atom.image_grid import ImageGrid
 from module.atom.image_grid import ImageGrid
@@ -13,13 +14,51 @@ from tasks.GameUi.game_ui import GameUi
 from tasks.Utils.config_enum import ShikigamiClass
 from tasks.Utils.config_enum import ShikigamiClass
 from tasks.KekkaiUtilize.assets import KekkaiUtilizeAssets
 from tasks.KekkaiUtilize.assets import KekkaiUtilizeAssets
 from tasks.KekkaiUtilize.config import UtilizeRule, SelectFriendList
 from tasks.KekkaiUtilize.config import UtilizeRule, SelectFriendList
+from tasks.KekkaiUtilize.utils import CardClass, target_to_card_class
 from tasks.Component.ReplaceShikigami.replace_shikigami import ReplaceShikigami
 from tasks.Component.ReplaceShikigami.replace_shikigami import ReplaceShikigami
+from tasks.GameUi.page import page_main, page_guild
 
 
 
 
 class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
 class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
 
 
     def run(self):
     def run(self):
-        pass
+        con = self.config.kekkai_utilize.utilize_config
+        self.ui_get_current_page()
+        self.ui_goto(page_guild)
+        # 收体力或者资金
+        # 进入寮主页会有一个动画,等一等
+        time.sleep(1)
+        self.check_guild_ap_or_assets(ap_enable=con.guild_ap_enable, assets_enable=con.guild_assets_enable)
+        # 进入寮结界
+        self.goto_realm()
+        # 顺带收体力盒子或者是经验盒子
+        time.sleep(0.5)
+        self.check_box_ap_or_exp(con.box_ap_enable, con.box_exp_enable, con.box_exp_waste)
+
+        # 收菜看看
+        self.check_utilize_harvest()
+        self.realm_goto_grown()
+        # 无论收不收到菜,都会进入看看至少看一眼时间还剩多少
+        self.screenshot()
+        if not self.appear(self.I_UTILIZE_ADD):
+            remaining_time = self.O_UTILIZE_RES_TIME.ocr(self.device.image)
+            if not isinstance(remaining_time, timedelta):
+                logger.warning('ocr remaining time error')
+            logger.info(f'Utilize remaining time: {remaining_time}')
+            # 执行失败,推出下一次执行为失败的时间间隔
+            logger.info('Utilize failed, exit')
+            self.back_guild()
+            self.set_next_run(task='KekkaiUtilize', success=False, finish=True)
+            raise TaskEnd
+        if not self.grown_goto_utilize():
+            logger.info('Utilize failed, exit')
+        self.run_utilize(con.select_friend_list, con.shikigami_class, con.shikigami_order)
+        self.back_guild()
+        self.set_next_run(task='KekkaiUtilize', success=True, finish=True)
+        raise TaskEnd
+
+
+
 
 
 
 
     def check_guild_ap_or_assets(self, ap_enable: bool=True, assets_enable: bool=True) -> bool:
     def check_guild_ap_or_assets(self, ap_enable: bool=True, assets_enable: bool=True) -> bool:
@@ -31,6 +70,7 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
         if ap_enable or assets_enable:
         if ap_enable or assets_enable:
             self.screenshot()
             self.screenshot()
             if not self.appear(self.I_GUILD_AP) and not self.appear(self.I_GUILD_ASSETS):
             if not self.appear(self.I_GUILD_AP) and not self.appear(self.I_GUILD_ASSETS):
+                logger.info('No ap or assets to collect')
                 return False
                 return False
         else:
         else:
             return False
             return False
@@ -44,23 +84,24 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
             # 获得奖励
             # 获得奖励
             if self.ui_reward_appear_click():
             if self.ui_reward_appear_click():
                 timer_check.reset()
                 timer_check.reset()
-                continue
+
             # 资金收取确认
             # 资金收取确认
             if self.appear_then_click(self.I_GUILD_ASSETS_RECEIVE, interval=0.5):
             if self.appear_then_click(self.I_GUILD_ASSETS_RECEIVE, interval=0.5):
                 timer_check.reset()
                 timer_check.reset()
                 continue
                 continue
 
 
             # 收体力
             # 收体力
-            if self.appear_then_click(self.I_GUILD_AP, interval=0.5):
+            if self.appear_then_click(self.I_GUILD_AP, interval=1.5):
                 timer_check.reset()
                 timer_check.reset()
                 continue
                 continue
             # 收资金
             # 收资金
-            if self.appear_then_click(self.I_GUILD_ASSETS, interval=0.5):
+            if self.appear_then_click(self.I_GUILD_ASSETS, interval=1.5, threshold=0.6):
                 timer_check.reset()
                 timer_check.reset()
                 continue
                 continue
 
 
             if timer_check.reached():
             if timer_check.reached():
                 break
                 break
+        logger.info('Collect ap or assets success')
         return True
         return True
 
 
     def goto_realm(self):
     def goto_realm(self):
@@ -78,7 +119,7 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
             if self.appear_then_click(self.I_GUILD_REALM, interval=1):
             if self.appear_then_click(self.I_GUILD_REALM, interval=1):
                 continue
                 continue
 
 
-    def check_box_ap_or_exp(self, ap_enable: bool=True, exp_enable: bool=True) -> bool:
+    def check_box_ap_or_exp(self, ap_enable: bool=True, exp_enable: bool=True, exp_waste: bool=True) -> bool:
         """
         """
         顺路检查盒子
         顺路检查盒子
         :param ap_enable:
         :param ap_enable:
@@ -97,14 +138,12 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
                     continue
                     continue
 
 
         # 先是体力盒子
         # 先是体力盒子
-        def _check_ap_box():
-            self.screenshot()
-            appear = False
-            if self.appear(self.I_BOX_AP):
-                appear = True
+        def _check_ap_box(appear: bool=False):
             if not appear:
             if not appear:
                 return False
                 return False
             # 点击盒子
             # 点击盒子
+            timer_ap = Timer(12)
+            timer_ap.start()
             while 1:
             while 1:
                 self.screenshot()
                 self.screenshot()
 
 
@@ -118,19 +157,20 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
                     continue
                     continue
                 if self.appear_then_click(self.I_AP_EXTRACT, interval=2):
                 if self.appear_then_click(self.I_AP_EXTRACT, interval=2):
                     continue
                     continue
+                if timer_ap.reached():
+                    logger.warning('Extract ap box timeout')
+                    break
             logger.info('Extract AP box finished')
             logger.info('Extract AP box finished')
             _exit_to_realm()
             _exit_to_realm()
 
 
-
         # 经验盒子
         # 经验盒子
-        def _check_exp_box():
-            self.screenshot()
-            appear = False
-            if self.appear(self.I_BOX_EXP):
-                appear = True
+        def _check_exp_box(appear: bool=False):
             if not appear:
             if not appear:
+                logger.info('No exp box')
                 return False
                 return False
 
 
+            time_exp = Timer(12)
+            time_exp.start()
             while 1:
             while 1:
                 self.screenshot()
                 self.screenshot()
 
 
@@ -142,12 +182,37 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
                 # 如果出现结界皮肤, 表示收取好了
                 # 如果出现结界皮肤, 表示收取好了
                 if self.appear(self.I_REALM_SHIN) and not self.appear(self.I_BOX_EXP):
                 if self.appear(self.I_REALM_SHIN) and not self.appear(self.I_BOX_EXP):
                     break
                     break
+
+                # 如果出现收取确认,表明进入到了有满级的
+                if self.appear(self.I_UI_CONFIRM):
+                    self.screenshot()
+                    if not self.appear(self.I_UI_CANCEL):
+                        logger.info('No cancel button')
+                        continue
+                    if exp_waste:
+                        check_button = self.I_UI_CONFIRM
+                    else:
+                        check_button = self.I_UI_CANCEL
+                    while 1:
+                        self.screenshot()
+                        if not self.appear(check_button):
+                            break
+                        if self.appear_then_click(check_button, interval=1):
+                            continue
+                    break
+
+                if time_exp.reached():
+                    logger.warning('Extract exp box timeout')
+                    break
             _exit_to_realm()
             _exit_to_realm()
 
 
+        self.screenshot()
+        box_ap = self.appear(self.I_BOX_AP)
+        box_exp = self.appear(self.I_BOX_EXP, threshold=0.6)
         if ap_enable:
         if ap_enable:
-            _check_ap_box()
+            _check_ap_box(box_ap)
         if exp_enable:
         if exp_enable:
-            _check_exp_box()
+            _check_exp_box(box_exp)
 
 
     def check_utilize_harvest(self) -> bool:
     def check_utilize_harvest(self) -> bool:
         """
         """
@@ -186,7 +251,7 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
         """
         """
         self.screenshot()
         self.screenshot()
         if not self.appear(self.I_UTILIZE_ADD):
         if not self.appear(self.I_UTILIZE_ADD):
-            logger.info('No utilize add')
+            logger.warning('No utilize add')
             return False
             return False
 
 
         while 1:
         while 1:
@@ -194,9 +259,10 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
 
 
             if self.appear(self.I_U_ENTER_REALM):
             if self.appear(self.I_U_ENTER_REALM):
                 break
                 break
-            if self.appear_then_click(self.I_UTILIZE_ADD, interval=1):
+            if self.appear_then_click(self.I_UTILIZE_ADD, interval=1.5):
                 continue
                 continue
         logger.info('Enter utilize')
         logger.info('Enter utilize')
+        return True
 
 
     def switch_friend_list(self, friend: SelectFriendList = SelectFriendList.SAME_SERVER) -> bool:
     def switch_friend_list(self, friend: SelectFriendList = SelectFriendList.SAME_SERVER) -> bool:
         """
         """
@@ -204,6 +270,7 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
         :param friend:
         :param friend:
         :return:
         :return:
         """
         """
+        logger.info('Switch friend list to %s', friend)
         if friend == SelectFriendList.SAME_SERVER:
         if friend == SelectFriendList.SAME_SERVER:
             check_image = self.I_UTILIZE_FRIEND_GROUP
             check_image = self.I_UTILIZE_FRIEND_GROUP
         else:
         else:
@@ -237,6 +304,143 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
             logger.error('Unknown utilize rule')
             logger.error('Unknown utilize rule')
             raise ValueError('Unknown utilize rule')
             raise ValueError('Unknown utilize rule')
 
 
+    @cached_property
+    def order_cards(self) -> list[CardClass]:
+        rule = self.config.kekkai_utilize.utilize_config.utilize_rule
+        result = []
+        if rule == UtilizeRule.DEFAULT:
+            result = [CardClass.TAIKO6, CardClass.FISH6, CardClass.TAIKO5, CardClass.FISH5,
+                      CardClass.TAIKO4, CardClass.FISH4, CardClass.TAIKO3, CardClass.FISH3]
+        elif rule == UtilizeRule.FISH:
+            result = [CardClass.FISH6, CardClass.FISH5, CardClass.FISH4, CardClass.FISH3,
+                      CardClass.TAIKO6, CardClass.TAIKO5, CardClass.TAIKO4, CardClass.TAIKO3]
+        elif rule == UtilizeRule.TAIKO:
+            result = [CardClass.TAIKO6, CardClass.TAIKO5, CardClass.TAIKO4, CardClass.TAIKO3,
+                      CardClass.FISH6, CardClass.FISH5, CardClass.FISH4, CardClass.FISH3]
+        else:
+            logger.error('Unknown utilize rule')
+            raise ValueError('Unknown utilize rule')
+        return result
+
+    def run_utilize(self, friend: SelectFriendList = SelectFriendList.SAME_SERVER,
+                    shikigami_class: ShikigamiClass = ShikigamiClass.N,
+                    shikigami_order: int = 7):
+        """
+        执行寄养
+        :param shikigami_class:
+        :param friend:
+        :param rule:
+        :return:
+        """
+        def _current_select_best(last_best: CardClass or None) -> CardClass | None:
+            """
+            当前选中的最好的卡,(会自动和记录的最好的比较)
+            包括点击这种卡
+            :return: 返回当前选中的最好的卡, 如果什么的都没有,返回None
+            """
+            self.screenshot()
+            target = self.order_targets.find_anyone(self.device.image)
+            if target is None:
+                logger.info('No target card found')
+                return None
+            card_class = target_to_card_class(target)
+            logger.info('Current find best card: %s', target)
+            # 如果当前的卡比记录的最好的卡还要好,那么就更新最好的卡
+            if last_best is not None:
+                last_index = self.order_cards.index(last_best)
+                current_index = self.order_cards.index(card_class)
+                if current_index > last_index:
+                    # 不比上一张卡好就退出不执行操作
+                    logger.info('Current card is not better than last best card')
+                    return last_best
+            logger.info('Current select card: %s', card_class)
+
+            self.appear_then_click(target, interval=0.3)
+            # 验证这张卡 的等级是否一致
+            # while 1:
+            #     self.screenshot()
+            return card_class
+
+        logger.hr('Start utilize')
+        self.switch_friend_list(friend)
+        card_best = None
+        swipe_count = 0
+        while 1:
+            self.screenshot()
+            current_card = _current_select_best(card_best)
+
+            if current_card is None:
+                break
+            else:
+                card_best = current_card
+
+            # 超过十次就退出
+            if swipe_count > 10:
+                logger.warning('Swipe count is more than 10')
+                break
+
+            # 一直向下滑动
+            self.swipe(self.S_U_UP, interval=0.9)
+            swipe_count += 1
+            time.sleep(3)
+        # 最好的结界卡
+        logger.info('End best card is %s', card_best)
+
+        # 进入结界
+        self.screenshot()
+        if not self.appear(self.I_U_ENTER_REALM):
+            logger.warning('Cannot find enter realm button')
+            # 可能是滑动的时候出错
+            logger.warning('The best reason is that the swipe is wrong')
+            return
+        while 1:
+            self.screenshot()
+
+            if not self.appear(self.I_U_ENTER_REALM):
+                # 用不显示原按键来判断是否进入是很蠢的
+                time.sleep(0.5)
+                break
+
+            if self.appear_then_click(self.I_U_ENTER_REALM, interval=1):
+                continue
+        logger.info('Enter friend realm')
+
+        # 切换式神的类型
+        self.switch_shikigami_class(shikigami_class)
+        # 判断好友的有两个位置还是一个坑位
+        stop_image = None
+        self.screenshot()
+        if self.appear(self.I_U_ADD_1):  # 右侧第一个有(无论左侧有没有)
+            stop_image = self.I_U_ADD_1
+        elif self.appear(self.I_U_ADD_2) and not self.appear(self.I_U_ADD_1):  # 右侧第二个有 但是最左边的没有,这表示只留有一个坑位
+            stop_image = self.I_U_ADD_2
+        if not stop_image:
+            # 没有坑位可能是其他人的手速太快了抢占了
+            logger.warning('Cannot find stop image')
+            logger.warning('Maybe other people is faster than you')
+            return
+
+        self.set_shikigami(shikigami_order, stop_image)
+
+
+    def back_guild(self):
+        """
+        回到寮的界面
+        :return:
+        """
+        while 1:
+            self.screenshot()
+
+            if self.appear(self.I_GUILD_INFO):
+                break
+            if self.appear(self.I_GUILD_REALM):
+                break
+
+            if self.appear_then_click(self.I_UI_BACK_RED, interval=1):
+                continue
+            if self.appear_then_click(self.I_UI_BACK_BLUE, interval=1):
+                continue
+
 if __name__ == "__main__":
 if __name__ == "__main__":
     from module.config.config import Config
     from module.config.config import Config
     from module.device.device import Device
     from module.device.device import Device
@@ -245,6 +449,7 @@ if __name__ == "__main__":
     d = Device(c)
     d = Device(c)
     t = ScriptTask(c, d)
     t = ScriptTask(c, d)
 
 
-    t.switch_friend_list(SelectFriendList.DIFFERENT_SERVER)
+    t.run()
+
 
 
 
 

+ 2 - 2
tasks/KekkaiUtilize/utilize/image.json

@@ -56,8 +56,8 @@
   {
   {
     "itemName": "u_taiko_6",
     "itemName": "u_taiko_6",
     "imageName": "utilize_u_taiko_6.png",
     "imageName": "utilize_u_taiko_6.png",
-    "roiFront": "0,0,100,100",
-    "roiBack": "0,0,100,100",
+    "roiFront": "544,265,60,45",
+    "roiBack": "533,156,87,450",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"

+ 47 - 0
tasks/KekkaiUtilize/utilize/image_2.json

@@ -0,0 +1,47 @@
+[
+  {
+    "itemName": "u_moon_6",
+    "imageName": "utilize_u_moon_6.png",
+    "roiFront": "548,194,54,54",
+    "roiBack": "540,189,68,404",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "太阴6"
+  },
+  {
+    "itemName": "u_moon_5",
+    "imageName": "utilize_u_moon_5.png",
+    "roiFront": "548,205,48,46",
+    "roiBack": "540,196,66,407",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "u_moon_4",
+    "imageName": "utilize_u_moon_4.png",
+    "roiFront": "548,309,49,50",
+    "roiBack": "533,167,81,437",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "u_moon_3",
+    "imageName": "utilize_u_moon_3.png",
+    "roiFront": "549,305,53,53",
+    "roiBack": "535,173,77,430",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "u_moon_2",
+    "imageName": "utilize_u_moon_2.png",
+    "roiFront": "552,313,46,44",
+    "roiBack": "542,174,81,437",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  }
+]

+ 9 - 0
tasks/KekkaiUtilize/utilize/swipe.json

@@ -0,0 +1,9 @@
+[
+  {
+    "itemName": "u_up",
+    "roiFront": "235,419,50,21",
+    "roiBack": "225,177,72,21",
+    "mode": "default",
+    "description": "向下滑动"
+  }
+]

BIN
tasks/KekkaiUtilize/utilize/utilize_u_moon_2.png


BIN
tasks/KekkaiUtilize/utilize/utilize_u_moon_3.png


BIN
tasks/KekkaiUtilize/utilize/utilize_u_moon_4.png


BIN
tasks/KekkaiUtilize/utilize/utilize_u_moon_5.png


BIN
tasks/KekkaiUtilize/utilize/utilize_u_moon_6.png


Неке датотеке нису приказане због велике количине промена