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

Merge pull request #91 from runhey/dev

Dev
huangrunheng 3 лет назад
Родитель
Сommit
565dd352f4

+ 3 - 0
tasks/BondlingFairyland/script_task.py

@@ -484,6 +484,9 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
                 break
             if self.appear_then_click(self.I_BALL_FIRE, interval=1):
                 continue
+            # 某些活动的时候出现 “选择共鸣的阴阳师”
+            if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                continue
 
     def in_catch_ui(self, screenshot=False) -> bool:
         """

+ 1 - 1
tasks/CollectiveMissions/config.py

@@ -14,7 +14,7 @@ from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
 
 class MissionsConfig(BaseModel):
     # 契灵 > 觉醒二 > 觉醒一 > 御灵二 > 御灵一 > 御魂五 > 御魂四
-    missions_rule: MultiLine = Field(default='契灵 > 觉醒三 > 觉醒二 > 觉醒一 > 御灵二 > 御灵一 > 御魂二 > 御魂一',
+    missions_rule: MultiLine = Field(default='契灵 > 觉醒三 > 觉醒二 > 觉醒一 > 御灵三 > 御灵二 > 御灵一 > 御魂二 > 御魂一',
                                      description='missions_rule_help')
 
     @validator('missions_rule', pre=True, always=True)

+ 5 - 1
tasks/CollectiveMissions/script_task.py

@@ -25,6 +25,7 @@ class MC(str, Enum):
     AW3 = '觉醒三'
     GR1 = '御灵一'
     GR2 = '御灵二'
+    GR3 = '御灵三'
     SO1 = '御魂一'
     SO2 = '御魂二'
     FRIEND = '好友'
@@ -64,7 +65,8 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
         if mission == MC.BL:
             # 契灵单独处理
             self._bondling_fairyland(index)
-        elif mission == MC.AW1 or mission == MC.AW2 or mission == MC.AW3 or mission == MC.GR1 or mission == MC.GR2:
+        elif mission == MC.AW1 or mission == MC.AW2 or mission == MC.AW3 \
+                or mission == MC.GR1 or mission == MC.GR2 or mission == MC.GR3:
             # 其他就捐材料
             self._donate(index)
         elif mission == MC.SO1 or mission == MC.SO2:
@@ -114,6 +116,8 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
             return MC.GR1
         elif result_2 == '御灵二':
             return MC.GR2
+        elif result_2 == '御灵三':
+            return MC.GR3
         elif result_2 == '御魂一':
             return MC.SO1
         elif result_2 == '御魂二':

+ 2 - 2
tasks/Component/GeneralBattle/general_battle.py

@@ -153,7 +153,8 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
 
     def battle_wait(self, random_click_swipt_enable: bool) -> bool:
         """
-        等待战斗结束
+        等待战斗结束 !!!
+        很重要 这个函数是原先写的, 优化版本在tasks/Secret/script_task下。本着不改动原先的代码的原则,所以就不改了
         :param random_click_swipt_enable:
         :return:
         """
@@ -193,7 +194,6 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
             if random_click_swipt_enable:
                 self.random_click_swipt()
 
-
         # 再次确认战斗结果
         logger.info("Reconfirm the results of the battle")
         while 1:

+ 5 - 2
tasks/Component/Summon/summon.py

@@ -59,13 +59,16 @@ class Summon(BaseTask, SummonAssets):
         time.sleep(0.5)
         while 1:
             self.screenshot()
-            if self.appear(self.I_SM_CONFIRM):
+            if self.appear(self.I_SM_CONFIRM, interval=0.6):
                 self.ui_click_until_disappear(self.I_SM_CONFIRM)
                 break
-            if self.appear(self.I_SM_CONFIRM_2):
+            if self.appear(self.I_SM_CONFIRM_2, interval=0.6):
                 self.ui_click_until_disappear(self.I_SM_CONFIRM_2)
                 break
             if self.appear(self.I_ONE_TICKET, interval=1):
+                # 某些时候会点击到 “语言召唤”
+                if self.appear_then_click(self.I_UI_CANCEL, interval=0.8):
+                    continue
                 self.summon()
                 continue
         logger.info('Summon one success')

+ 5 - 1
tasks/Delegation/assets.py

@@ -42,6 +42,8 @@ class DelegationAssets:
 	I_D_SELECT_4 = RuleImage(roi_front=(632,595,42,40), roi_back=(579,584,111,57), threshold=0.7, method="Template matching", file="./tasks/Delegation/d/d_d_select_4.png")
 	# description 
 	I_D_SELECT_5 = RuleImage(roi_front=(767,593,41,40), roi_back=(721,582,103,60), threshold=0.7, method="Template matching", file="./tasks/Delegation/d/d_d_select_5.png")
+	# 返回 
+	I_D_BACK = RuleImage(roi_front=(940,415,138,51), roi_back=(940,415,138,51), threshold=0.8, method="Template matching", file="./tasks/Delegation/d/d_d_back.png")
 
 
 	# Ocr Rule Assets
@@ -61,7 +63,9 @@ class DelegationAssets:
 	# 差强人意 
 	I_REWARDS_FALSE = RuleImage(roi_front=(430,72,100,100), roi_back=(430,72,100,100), threshold=0.8, method="Template matching", file="./tasks/Delegation/rewards/rewards_rewards_false.png")
 	# description 
-	I_CHAT_1 = RuleImage(roi_front=(716,380,318,100), roi_back=(716,380,318,100), threshold=0.8, method="Template matching", file="./tasks/Delegation/rewards/rewards_chat_1.png")
+	I_CHAT_1 = RuleImage(roi_front=(735,350,318,100), roi_back=(651,161,601,391), threshold=0.8, method="Template matching", file="./tasks/Delegation/rewards/rewards_chat_1.png")
+	# description 
+	I_CHAT_2 = RuleImage(roi_front=(721,384,325,100), roi_back=(721,384,325,100), threshold=0.8, method="Template matching", file="./tasks/Delegation/rewards/rewards_chat_2.png")
 
 
 	# Ocr Rule Assets

BIN
tasks/Delegation/d/d_d_back.png


+ 9 - 0
tasks/Delegation/d/image.json

@@ -79,5 +79,14 @@
     "method": "Template matching",
     "threshold": 0.7,
     "description": "description"
+  },
+  {
+    "itemName": "d_back",
+    "imageName": "d_d_back.png",
+    "roiFront": "940,415,138,51",
+    "roiBack": "940,415,138,51",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "返回"
   }
 ]

+ 11 - 2
tasks/Delegation/rewards/image.json

@@ -47,8 +47,17 @@
   {
     "itemName": "chat_1",
     "imageName": "rewards_chat_1.png",
-    "roiFront": "716,380,318,100",
-    "roiBack": "716,380,318,100",
+    "roiFront": "735,350,318,100",
+    "roiBack": "651,161,601,391",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "chat_2",
+    "imageName": "rewards_chat_2.png",
+    "roiFront": "721,384,325,100",
+    "roiBack": "721,384,325,100",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

BIN
tasks/Delegation/rewards/rewards_chat_2.png


+ 11 - 1
tasks/Delegation/script_task.py

@@ -22,7 +22,7 @@ class ScriptTask(GameUi, DelegationAssets):
         self.check_reward()
         con: DelegationConfig = self.config.delegation.delegation_config
         if con.miyoshino_painting:
-            self.delegate_one('弥助')
+            self.delegate_one('画')
         if con.bird_feather:
             self.delegate_one('鸟羽')
         if con.find_earring:
@@ -61,6 +61,13 @@ class ScriptTask(GameUi, DelegationAssets):
             self.screenshot()
             if self.appear(self.I_D_START):
                 break
+            # 如果出现’召回‘ ’返回‘ 说明这个是现在委派中
+            # 需要退出
+            if self.appear(self.I_D_BACK):
+                logger.warning(f'Delegation: {name} is in delegation')
+                self.ui_click_until_disappear(self.I_D_BACK)
+                self.wait_until_appear(self.I_REWARDS_MIN)
+                return False
             if self.appear_then_click(self.I_D_SKIP, interval=0.8):
                 continue
             if self.appear_then_click(self.I_D_CONFIRM, interval=0.8):
@@ -100,6 +107,9 @@ class ScriptTask(GameUi, DelegationAssets):
             if self.appear_then_click(self.I_CHAT_1, interval=1):
                 check_timer.reset()
                 continue
+            if self.appear_then_click(self.I_CHAT_2, interval=1):
+                check_timer.reset()
+                continue
             if self.appear_then_click(self.I_REWARDS_DONE, interval=1):
                 check_timer.reset()
                 continue

+ 36 - 1
tasks/DemonEncounter/script_task.py

@@ -362,6 +362,40 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets):
         else:
             return True
 
+    def battle_wait(self, random_click_swipt_enable: bool) -> bool:
+        # 重写
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        self.device.click_record_clear()
+        # 战斗过程 随机点击和滑动 防封
+        logger.info("Start battle process")
+        check_timer = None
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_DE_WIN):
+                logger.info('Appear [demon encounter] win button')
+                self.ui_click_until_disappear(self.I_DE_WIN)
+                check_timer = Timer(3)
+                check_timer.start()
+                continue
+            if self.appear_then_click(self.I_WIN, interval=1):
+                logger.info('Appear win button')
+                check_timer = Timer(3)
+                check_timer.start()
+                continue
+            if self.appear(self.I_REWARD):
+                logger.info('Win battle')
+                self.ui_click_until_disappear(self.I_REWARD)
+                return True
+
+            # 失败的
+            if self.appear(self.I_FALSE):
+                logger.warning('False battle')
+                self.ui_click_until_disappear(self.I_FALSE)
+                return False
+            # 时间到
+            if check_timer and check_timer.reached():
+                logger.warning('Obtain battle timeout')
+                return True
 
 if __name__ == '__main__':
     from module.config.config import Config
@@ -372,4 +406,5 @@ if __name__ == '__main__':
     d = Device(c)
     t = ScriptTask(c, d)
 
-    t.run()
+    # t.run()
+    t.battle_wait(True)

+ 0 - 1
tasks/Secret/script_task.py

@@ -248,7 +248,6 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
         self.device.click_record_clear()
         # 战斗过程 随机点击和滑动 防封
         logger.info("Start battle process")
-        # win: bool = False
         while 1:
             self.screenshot()
             if self.appear(self.I_SE_BATTLE_WIN):

+ 3 - 0
tasks/SoulsTidy/script_task.py

@@ -128,6 +128,9 @@ class ScriptTask(GameUi, SoulsTidyAssets):
                 self.screenshot()
                 if self.appear_then_click(self.I_UI_CONFIRM, interval=0.5):
                     continue
+                # 如果奉纳少就不是神赐而是获得奖励
+                if self.ui_reward_appear_click():
+                    continue
                 # 出现神赐, 就点击然后消失,
                 if self.appear(self.I_ST_GOD_PRESENT):
                     sleep(0.5)

+ 4 - 2
tasks/TrueOrochi/script_task.py

@@ -117,14 +117,16 @@ class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
                         break
                     if self.appear_then_click(self.I_GREED_GHOST, interval=1):
                         continue
-                    # if self.appear_then_click(self.I_GREED_GHOST, action=self.C_REWARD_1, interval=1):
-                    #     continue
+                    if self.appear_then_click(self.I_ST_FRAME, interval=1):
+                        continue
                 break
             if self.appear_then_click(self.I_ST_FRAME, interval=1):
                 continue
             if check_timer.reached():
                 logger.warning('Battle timeout')
                 check_timer.reset()
+                self.device.stuck_record_clear()
+                self.device.stuck_record_add('BATTLE_STATUS_S')
             sleep(0.5)
 
         logger.info("Battle process end")

+ 5 - 0
tasks/WantedQuests/assets.py

@@ -10,6 +10,11 @@ from module.atom.list import RuleList
 class WantedQuestsAssets: 
 
 
+	# Click Rule Assets
+	# 秘闻的挑战对话 
+	C_SECRET_CHAT = RuleClick(roi_front=(597,296,59,100), roi_back=(597,296,59,100), name="secret_chat")
+
+
 	# Ocr Rule Assets
 	# 挑战券的数量 
 	O_WQ_NUMBER = RuleOcr(roi=(569,13,50,32), area=(569,13,50,32), mode="Digit", method="Default", keyword="", name="wq_number")

+ 8 - 0
tasks/WantedQuests/click.json

@@ -0,0 +1,8 @@
+[
+  {
+    "itemName": "secret_chat",
+    "roiFront": "597,296,59,100",
+    "roiBack": "597,296,59,100",
+    "description": "秘闻的挑战对话"
+  }
+]

+ 17 - 1
tasks/WantedQuests/script_task.py

@@ -202,7 +202,23 @@ class ScriptTask(SecretScriptTask, GeneralInvite, WantedQuestsAssets):
         self.ui_click(goto, self.I_WQSE_FIRE)
         for i in range(num):
             self.wait_until_appear(self.I_WQSE_FIRE)
-            self.ui_click_until_disappear(self.I_WQSE_FIRE)
+            # self.ui_click_until_disappear(self.I_WQSE_FIRE)
+            # 又臭又长的对话针的是服了这个网易
+            click_count = 0
+            while 1:
+                self.screenshot()
+                if not self.appear(self.I_UI_BACK_RED, threshold=0.7):
+                    break
+                if self.appear_then_click(self.I_WQSE_FIRE, interval=1):
+                    continue
+                if self.appear(self.I_UI_BACK_RED, threshold=0.7) and not self.appear(self.I_WQSE_FIRE):
+                    self.click(self.C_SECRET_CHAT, interval=0.8)
+                    click_count += 1
+                    if click_count >= 6:
+                        logger.warning('Secret mission chat too long, force to close')
+                        click_count = 0
+                        self.device.click_record_clear()
+                    continue
             success = self.run_general_battle(self.battle_config)
         while 1:
             self.screenshot()

+ 2 - 2
tasks/WeeklyTrifles/assets.py

@@ -57,9 +57,9 @@ class WeeklyTriflesAssets:
 	# 点击分享 
 	I_WT_COLLECT = RuleImage(roi_front=(1170,606,78,83), roi_back=(1170,606,78,83), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/collect/collect_wt_collect.png")
 	# 百鬼夜行图 
-	I_WT_SCROLL_1 = RuleImage(roi_front=(1186,28,28,121), roi_back=(1186,28,28,121), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/collect/collect_wt_scroll_1.png")
+	I_WT_SCROLL_1 = RuleImage(roi_front=(1180,27,28,121), roi_back=(1159,12,65,152), threshold=0.7, method="Template matching", file="./tasks/WeeklyTrifles/collect/collect_wt_scroll_1.png")
 	# 百妖风物鉴 
-	I_WT_SCROLL_2 = RuleImage(roi_front=(1186,26,24,122), roi_back=(1186,26,24,122), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/collect/collect_wt_scroll_2.png")
+	I_WT_SCROLL_2 = RuleImage(roi_front=(1182,24,24,122), roi_back=(1163,12,63,155), threshold=0.7, method="Template matching", file="./tasks/WeeklyTrifles/collect/collect_wt_scroll_2.png")
 	# 微信分享 
 	I_WT_COLLECT_WECHAT = RuleImage(roi_front=(640,617,70,63), roi_back=(640,617,70,63), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/collect/collect_wt_collect_wechat.png")
 	# 二维码 

+ 6 - 6
tasks/WeeklyTrifles/collect/image.json

@@ -29,19 +29,19 @@
   {
     "itemName": "wt_scroll_1",
     "imageName": "collect_wt_scroll_1.png",
-    "roiFront": "1186,28,28,121",
-    "roiBack": "1186,28,28,121",
+    "roiFront": "1180,27,28,121",
+    "roiBack": "1159,12,65,152",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "百鬼夜行图"
   },
   {
     "itemName": "wt_scroll_2",
     "imageName": "collect_wt_scroll_2.png",
-    "roiFront": "1186,26,24,122",
-    "roiBack": "1186,26,24,122",
+    "roiFront": "1182,24,24,122",
+    "roiBack": "1163,12,63,155",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "百妖风物鉴"
   },
   {

+ 1 - 1
tasks/WeeklyTrifles/script_task.py

@@ -267,6 +267,6 @@ if __name__ == '__main__':
     t = ScriptTask(c, d)
     t.screenshot()
 
-    t._broken_amulet(30)
+    t._share_collect()