Browse Source

!2 listbox replace checkbox

pcacc 5 months ago
parent
commit
8325cdd9fb
4 changed files with 72 additions and 36 deletions
  1. 17 14
      app_dongri.py
  2. 9 4
      dongri_task.py
  3. 2 2
      scriptBase/comon.py
  4. 44 16
      templates/index_dongri.html

+ 17 - 14
app_dongri.py

@@ -174,10 +174,9 @@ def auto_participate():
 
 
 
-def add_auto_task(isMaxCollect, isJina, isSimple = False):
-    collectType = 0
-    if isMaxCollect:
-        collectType = 5
+def add_auto_task(isMaxCollect, isJina, isSimple = False, isAddStrengh = False):
+    collectArr = [int(x) for x in isMaxCollect.split(",")]
+    print("collectArr", collectArr)
     times = 0
     while not event.is_set():
         if not isSimple:
@@ -193,18 +192,20 @@ def add_auto_task(isMaxCollect, isJina, isSimple = False):
         if not isSimple:
             task_queue.appendleft(task_checkConfilits())
         if not isSimple:
-            if isJina:
-                task_queue.appendleft(task_fight_jina(True))
-            else:
-                task_queue.appendleft(task_fightMonster(False, True, isSimple))
-        task_queue.appendleft(task_collect(collectType, isSimple))
+            if isJina == 'jina':
+                task_queue.appendleft(task_fight_jina(isAddStrengh))
+            elif isJina == 'monster':
+                task_queue.appendleft(task_fightMonster(isAddStrengh, False, isSimple))
+            elif isJina == 'big_monster':
+                task_queue.appendleft(task_fightMonster(isAddStrengh, True, isSimple))
+        task_queue.appendleft(task_collect(collectArr, isSimple))
         task_queue.appendleft(task_train(False))
-        task_queue.appendleft(task_collect(collectType, isSimple))
+        task_queue.appendleft(task_collect(collectArr, isSimple))
         task_queue.appendleft(task_train(False))
         if isSimple:
             task_queue.appendleft(check_buildOrResearch())
         else:
-            task_queue.appendleft(task_collect(collectType, isSimple))
+            task_queue.appendleft(task_collect(collectArr, isSimple))
         
         task_queue.appendleft(task_cure())
         
@@ -254,15 +255,17 @@ def handle_auto(data):
 def auto_task(data):
     global autoTask
     if data == None:
-        isMaxCollect = False
+        isMaxCollect = '4,3,2,1'
         isSimple = False
-        isJina = False
+        isJina = 'jina'
+        isAddStrengh = False
     else:
         isMaxCollect = data['maxCollect']
         isSimple = data['simple']
         isJina = data['jina']
+        isAddStrengh = data['add_strength']
     send_status(f'开始自动模式')
-    executor.submit(add_auto_task, isMaxCollect, isJina, isSimple)
+    executor.submit(add_auto_task, isMaxCollect, isJina, isSimple, isAddStrengh)
 
 
 @socketio.on('begin_auto_participate')

+ 9 - 4
dongri_task.py

@@ -257,13 +257,14 @@ class task_fight_jina(dongri_task):
 
 class task_fightMonster(dongri_task):
     def __init__(self, add_strengh, fight_bigMonster, isSimple):
-        super().__init__(f"战斗怪物")
         self.add_strengh = add_strengh
         self.isSimple = isSimple
         if fight_bigMonster == True:
+            super().__init__(f"战斗大怪物")
             self.monster = monster_img.bigMonster
             self.attack = monster_img.muti_team
         else:
+            super().__init__(f"战斗小怪物")
             self.monster = monster_img.wolf
             self.attack = monster_img.attack
 
@@ -313,7 +314,10 @@ class task_fightMonster(dongri_task):
 class task_collect(dongri_task):
     def __init__(self, type = 0, isSimple = False):
         self.isSimple = isSimple
-        if type == 0:
+        if isinstance(type, (list, tuple)):
+            typeArr = type
+            type = typeArr[random.randint(0, len(typeArr) - 1)]
+        elif type == 0:
             typeArr = [4,4,3,3,3,2,2,2,1,1]
             type = typeArr[random.randint(0, len(typeArr) - 1)]
         elif type == 5:
@@ -419,6 +423,7 @@ class task_checkStoreRoom(dongri_task):
         
         myTimeSleep_big()
         yys_dragAuto(check_img.move_down)
+        myTimeSleep_big()
         if waitClickImg_noWait_withBool((train_img.train_success, check_img.needgo), 2, 1) == False:
             return False
         myTimeSleep_big()
@@ -668,7 +673,7 @@ if __name__ == '__main__':
     #task_fightMonster(False, True).run()
     #task_checkHelp().run()
     #task_checkStoreRoom().run()
-    #task_collect().run()
+    task_collect([4,3,2,1]).run()
     #task_train().run()
     #task_information().run()
     #check_buildOrResearch().run()
@@ -679,4 +684,4 @@ if __name__ == '__main__':
     #task_collect(4).run()
     #task_returnAllLine().run()
     #task_paticipateInTeam().run()
-    task_fight_jina(True).run()
+    #task_fight_jina(True).run()

+ 2 - 2
scriptBase/comon.py

@@ -173,11 +173,11 @@ def waitClickImg_withBool(imgPath, waitTime, preWaitTime):
 def myTimeSleep(curTime , FunStatus=None):
     tmpTime = curTime * 1000
     randomTime = random.randint(int(tmpTime - tmpTime / 9), int(tmpTime + tmpTime / 9)) / 1000
-    randomTime = round(randomTime, 2)
+    randomTime = round(randomTime)
     while randomTime > 10:
         time.sleep(10)
         randomTime -= 10
-        showStr = f'剩余等待时间{randomTime}'
+        showStr = f'下一轮{randomTime}s'
         if FunStatus is not None:
             FunStatus(showStr)
         print(showStr)

+ 44 - 16
templates/index_dongri.html

@@ -42,9 +42,21 @@
         <h3>任务列表:</h3>
         <div id="hint_message"></div>
         <div class="checkbox-container">
-            <label><input type="checkbox" id="maxCollectCheckbox"> 是否最大收集</label>
-            <label><input type="checkbox" id="JiNaCheckbox"> 是否吉娜</label>
+            <label>
+                是否最大收集:
+                <input type="text" id="maxCollectCheckbox" value="4,4,3,3,3,2,2,2,1,1">
+            </label>
+            <label>
+                打怪:
+                <select id="JiNaCheckbox">
+                    <option value="None">None</option>
+                    <option value="monster">monster</option>
+                    <option value="big_monster">big_monster</option>
+                    <option value="jina" selected>jina</option>
+                </select>
+            </label>
             <label><input type="checkbox" id="SimpleCheckbox"> 是否小号</label>
+            <label><input type="checkbox" id="AddStrenghCheckbox"> 是否添加体力</label>
         </div>
         <button class="custom-button" id="atuo_btn" onclick="begin_paticipate()">自动集结</button>
         <button class="custom-button" id="resetScript_btn" onclick="reset_script()">重置脚本</button>
@@ -80,16 +92,24 @@
             messageBox.innerHTML = msg;
         });
         socket.on('processing_cfg', (msg) => {
-            console.log(msg)
-            const isMaxCollect = document.getElementById('maxCollectCheckbox');
-            const isJiNa = document.getElementById('JiNaCheckbox');
-            const isSimple = document.getElementById('SimpleCheckbox');
-            isMaxCollect.checked = msg['maxCollect']
-            isJiNa.checked = msg['jina']
-            isSimple.checked = msg['simple']
-
-            //var messageBox = document.getElementById('title_message');
-            //messageBox.innerHTML = msg;
+            console.log(msg);
+
+            // 获取元素
+            const maxCollectInput = document.getElementById('maxCollectCheckbox'); // 文本输入框
+            const jiNaSelect = document.getElementById('JiNaCheckbox'); // 下拉列表
+            const simpleCheckbox = document.getElementById('SimpleCheckbox'); // 复选框
+            const AddStrenghCheckbox = document.getElementById('AddStrenghCheckbox'); // 复选框
+
+            // 设置值
+            maxCollectInput.value = msg['maxCollect']; // 设置文本输入框的值
+            jiNaSelect.value = msg['jina']; // 设置下拉列表的值
+            simpleCheckbox.checked = msg['simple']; // 设置复选框的状态
+            AddStrenghCheckbox.checked = msg['add_strength']; // 设置复选框的状态
+
+
+            // 如果需要显示消息,可以取消注释以下代码
+            // var messageBox = document.getElementById('title_message');
+            // messageBox.innerHTML = msg;
         });
 
 
@@ -126,10 +146,18 @@
         }
 
         function begin_auto() {
-            const isMaxCollect = document.getElementById('maxCollectCheckbox').checked;
-            const isJiNa = document.getElementById('JiNaCheckbox').checked;
-            const isSimple = document.getElementById('SimpleCheckbox').checked;
-            socket.emit('begin_auto', { maxCollect: isMaxCollect, jina: isJiNa, simple: isSimple });
+            const maxCollectValue = document.getElementById('maxCollectCheckbox').value; // 获取文本输入框的值
+            const jiNaValue = document.getElementById('JiNaCheckbox').value; // 获取下拉列表的值
+            const isSimple = document.getElementById('SimpleCheckbox').checked; // 获取复选框的状态
+            const isAddStrengh = document.getElementById('AddStrenghCheckbox').checked; // 获取复选框的状态
+
+            // 发出数据
+            socket.emit('begin_auto', {
+                maxCollect: maxCollectValue, // 发送文本输入框的值
+                jina: jiNaValue, // 发送下拉列表的值
+                simple: isSimple // 发送复选框的状态
+                ,add_strength:isAddStrengh
+            });
         }
 
         function begin_paticipate(){