소스 검색

!2 use animal skill

pcacc 5 달 전
부모
커밋
2e40bc8910
3개의 변경된 파일50개의 추가작업 그리고 6개의 파일을 삭제
  1. 31 4
      app_dongri.py
  2. 4 0
      dongri_pic.py
  3. 15 2
      dongri_task.py

+ 31 - 4
app_dongri.py

@@ -129,6 +129,11 @@ def handle_restart_game():
     python = sys.executable
     os.execl(python, python, *sys.argv, '--reset')
 
+@socketio.on('read_cfg')
+def handle_read_cfg():
+    cfg = read_cfg()
+    emit('processing_cfg', cfg)
+
 def restart_game():
     global isGameBegin
     isGameBegin = False
@@ -140,7 +145,8 @@ def restart_game():
             send_status("启动失败")
     isGameBegin = True
     send_status("结束")
-    auto_task(None)
+    config = read_cfg()
+    auto_task(config)
 
 def auto_participate():
     task_queue.appendleft(task_returnAllLine())
@@ -186,12 +192,15 @@ def add_auto_task(isMaxCollect, isSimple = False):
         task_queue.appendleft(task_train(False))
         if isSimple:
             task_queue.appendleft(check_buildOrResearch())
-        else:
-            task_queue.appendleft(task_collect(collectType, isSimple))
+        #else:
+        #    task_queue.appendleft(task_collect(collectType, isSimple))
         task_queue.appendleft(task_checkStoreRoom())
         if not isSimple:
             task_queue.appendleft(task_checkConfilits())
         task_queue.appendleft(task_checkDonata())
+        task_queue.appendleft(task_cure())
+        task_queue.appendleft(task_useAnnimalSkill())
+
         #task_queue.appendleft(task_waitTime())
         times += 1
         if times == 5:
@@ -208,10 +217,28 @@ def add_auto_task(isMaxCollect, isSimple = False):
     send_status(f'自动模式结束')
     event.clear()
         
-        
+
+def write_cfg(config):
+    with open('config.json', 'w') as config_file:
+        json.dump(config, config_file, indent=4)
+def read_cfg():
+    try:
+        with open('config.json', 'r') as config_file:
+            config = json.load(config_file)
+            return config
+    except FileNotFoundError:
+        print("配置文件不存在,请检查文件路径。")
+        return None
+    except PermissionError:
+        print("没有权限读取配置文件。")
+        return None
+    except json.JSONDecodeError:
+        print("配置文件格式错误,请检查文件内容是否为有效的 JSON。")
+        return None
 
 @socketio.on('begin_auto')
 def handle_auto(data):
+    write_cfg(data)
     auto_task(data)
 
 def auto_task(data):

+ 4 - 0
dongri_pic.py

@@ -100,6 +100,10 @@ class check_img:
     cure = R'dongri_img\check\cure.png'
     add_strength = R'dongri_img\check\add_strength.png'
     no_strength = R'dongri_img\check\no_strength.png'
+    annimal_skill = R'dongri_img\check\anninal_skill.png'
+    wolf_skill = R'dongri_img\check\wolf_skill.png'
+    use = R'dongri_img\check\use.png'
+
 
 class information_img:
     # = R'dongri_img\information\.png'

+ 15 - 2
dongri_task.py

@@ -264,7 +264,7 @@ class task_collect(dongri_task):
     def __init__(self, type = 0, isSimple = False):
         self.isSimple = isSimple
         if type == 0:
-            typeArr = [4,3,2,1]
+            typeArr = [4,3,3,2,1]
             type = typeArr[random.randint(0, len(typeArr) - 1)]
         elif type == 5:
             typeArr = [2,1]
@@ -596,6 +596,19 @@ class task_cure(dongri_task):
             return False
         return True
 
+class task_useAnnimalSkill(dongri_task):
+    def __init__(self):
+        super().__init__(f"使用动物技能")
+    def run(self):
+        basic_operate.go_outside()
+        if waitClickImg_noWait_withBool(check_img.annimal_skill, 2, 1) == False:
+            return False
+        
+        if waitClickImg_noWait_withBool(check_img.wolf_skill, 2, 1) == False:
+            return False
+        
+        if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
+            return False
 
 
 
@@ -616,4 +629,4 @@ if __name__ == '__main__':
     #task_collect(4).run()
     #task_returnAllLine().run()
     #task_paticipateInTeam().run()
-    task_train(True).run()
+    task_useAnnimalSkill().run()