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

Merge pull request #98 from runhey/master

Master to Dev
huangrunheng 3 лет назад
Родитель
Сommit
2ed407d3be

+ 70 - 0
.github/ISSUE_TEMPLATE/bug_report.yaml

@@ -0,0 +1,70 @@
+name: 🐛问题反馈
+title: '🐛'
+description: 在使用 oas 过程中遇到了错误
+labels: bug
+body:
+  - type: checkboxes
+    id: checks
+    attributes:
+      label: 在提问之前...
+      options:
+      - label: 我已经搜索了现有的 issues
+        required: true
+      - label: 我在提问题之前至少花费了 5 分钟来思考和准备
+        required: true
+      - label: 我已经阅读了文档中的 常见问题(FAQ)
+        required: true
+      - label: 这个问题出现了至少三次,不是偶发的
+        required: false
+  - type: textarea
+    id: describe
+    attributes:
+      label: 描述你的问题
+      description: 简要描述你的问题
+    validations:
+      required: true
+  - type: textarea
+    id: reproduce
+    attributes:
+      label: 如何复现
+      description: 重现该行为的步骤
+      value: |
+        1. 前往 '...'
+        2. 点击 '....'
+        3. 滑动到 '....'
+        4. 出现问题
+    validations:
+      required: false
+  - type: textarea
+    id: expected
+    attributes:
+      label: 预期行为
+      description: 简要描述你期望发生的事情
+    validations:
+      required: false
+  - type: textarea
+    id: logs
+    attributes:
+      label: 相关 Logs
+      description: 请复制并粘贴任何相关的日志输出。
+      render: Text
+    validations:
+      required: false
+  - type: textarea
+    id: screenshots
+    attributes:
+      label: 截图
+      description: |
+        如果有,添加屏幕截图以帮助解释你的问题。
+        提示: 可以通过点击这个区域,然后把文件拖进来添加图片或日志文件。
+    validations:
+      required: false
+  - type: textarea
+    id: others
+    attributes:
+      label: 还有别的吗?
+      description: |
+        相关的配置?链接?参考资料?
+        任何能让我们对你所遇到的问题有更多了解的东西。
+    validations:
+      required: false

+ 26 - 0
.github/ISSUE_TEMPLATE/feature-request.yaml

@@ -0,0 +1,26 @@
+name: ✨功能请求
+title: '✨'
+description: 为 oas 提出一个新的想法或建议
+labels: 'enhancement'
+body:
+  - type: textarea
+    id: describe
+    attributes:
+      label: 当前不足
+      description: 简单描述本项目当前存在的不足之处, 请标明是具体的哪儿 issue 如果这个建议同某个问题关联
+    validations:
+      required: false
+  - type: textarea
+    id: solution
+    attributes:
+      label: 解决方案
+      description: 描述你想要的解决方案
+    validations:
+      required: false
+  - type: textarea
+    id: additional
+    attributes:
+      label: 其他内容
+      description: 关于该功能请求的任何其他背景或屏幕截图。
+    validations:
+      required: false

+ 11 - 0
.github/ISSUE_TEMPLATE/others.yaml

@@ -0,0 +1,11 @@
+name: 🎈其他相关
+title: '🎈'
+description: 确定不是上面两种类型,同 oas 相关的一切
+labels: ['未来可期']
+body:
+  - type: textarea
+    id: additional
+    attributes:
+      label: 描述
+    validations:
+      required: false

+ 1 - 0
tasks/Orochi/assets.py

@@ -21,6 +21,7 @@ class OrochiAssets:
 	I_OROCHI_UNLOCK = RuleImage(roi_front=(575,558,26,29), roi_back=(560,553,56,40), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_unlock.png")
 	# 点击挑战 
 	I_OROCHI_FIRE = RuleImage(roi_front=(1095,577,131,124), roi_back=(1095,577,131,124), threshold=0.6, method="Template matching", file="./tasks/Orochi/o/o_orochi_fire.png")
+	I_OROCHI_WILD_FIRE = RuleImage(roi_front=(1179,602,81,87), roi_back=(1179,602,81,87), threshold=0.6, method="Template matching", file="./tasks/Orochi/o/o_orochi_wild_fire.png")
 	# 式神录 
 	I_SHI_RECORDS = RuleImage(roi_front=(821,638,48,45), roi_back=(821,638,48,45), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_shi_records.png")
 	# description 

BIN
tasks/Orochi/o/o_orochi_wild_fire.png


+ 92 - 8
tasks/Orochi/script_task.py

@@ -38,13 +38,14 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
         self.limit_count: int = limit_count
         self.limit_time: timedelta = timedelta(hours=limit_time.hour, minutes=limit_time.minute, seconds=limit_time.second)
 
-        self.ui_get_current_page()
-        self.ui_goto(page_main)
         config: Orochi = self.config.orochi
-        if config.orochi_config.soul_buff_enable:
-            self.open_buff()
-            self.soul(is_open=True)
-            self.close_buff()
+        if not self.is_in_battle(True):
+            self.ui_get_current_page()
+            self.ui_goto(page_main)
+            if config.orochi_config.soul_buff_enable:
+                self.open_buff()
+                self.soul(is_open=True)
+                self.close_buff()
 
         success = True
         match config.orochi_config.user_status:
@@ -328,8 +329,91 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
 
 
     def run_wild(self):
-        logger.error('Wild mode is not implemented')
-        pass
+        logger.info('Start run wild')
+
+        # 已经在战斗中不必初始化,保证已经组队开始战斗的情况下可以自动执行后续任务
+        if not self.is_in_battle(True):
+            self.ui_get_current_page()
+            self.ui_goto(page_soul_zones)
+            self.orochi_enter()
+            layer = self.config.orochi.orochi_config.layer
+            self.check_layer(layer)
+            self.check_lock(self.config.orochi.general_battle_config.lock_team_enable)
+            # 创建队伍
+            logger.info('Create team')
+            while 1:
+                self.screenshot()
+                if self.appear(self.I_OROCHI_MATCHING):
+                    break
+                if self.appear_then_click(self.I_FORM_TEAM, interval=1):
+                    continue
+            # 创建房间
+            self.create_room()
+            self.ensure_public()
+            self.create_ensure()
+
+        while 1:
+            self.screenshot()
+            # 无论胜利与否, 都会出现是否邀请一次队友
+            # 区别在于,失败的话不会出现那个勾选默认邀请的框
+            if self.check_and_invite(self.config.orochi.invite_config.default_invite):
+                continue
+
+            # 检查猫咪奖励
+            if self.appear_then_click(self.I_PET_PRESENT, action=self.C_WIN_3, interval=1):
+                continue
+
+            if self.current_count >= self.limit_count:
+                if self.is_in_room():
+                    logger.info('Orochi count limit out')
+                    break
+
+            if datetime.now() - self.start_time >= self.limit_time:
+                if self.is_in_room():
+                    logger.info('Orochi time limit out')
+                    break
+
+            if not self.is_in_room():
+                # 如果在探索界面或者是出现在组队界面,那就是可能房间死了,要结束任务
+                sleep(0.5)
+                if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+                    sleep(0.5)
+                    if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+                        logger.warning('Orochi task failed')
+                        success = False
+                        break
+                continue
+
+            # 点击挑战
+            logger.info('Wait for starting')
+            while 1:
+                self.screenshot()
+                # 在进入战斗前必然会出现挑战界面,因此点击失败必须重复点击,防止卡在挑战界面,
+                # 点击成功后如果网络卡顿,导致没有进入战斗,则无法进入 run_general_battle 流程,
+                # 所以如果判断是在战斗中,则执行通用战斗流程
+                if not (self.appear_then_click(self.I_OROCHI_WILD_FIRE, interval=0.5, threshold=0.8)
+                         or self.is_in_battle(False)):
+                    continue
+
+                self.screenshot()
+                if not self.appear(self.I_OROCHI_WILD_FIRE, threshold=0.8):
+                    self.run_general_battle(config=self.config.orochi.general_battle_config)
+                    break
+
+        # 当结束或者是失败退出循环的时候只有两个UI的可能,在房间或者是在组队界面
+        # 如果在房间就退出
+        if self.exit_room():
+            pass
+        # 如果在组队界面就退出
+        if self.exit_team():
+            pass
+
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+
+        if not success:
+            return False
+        return True