|
@@ -31,6 +31,7 @@ g_times = 0
|
|
|
g_cureNum = 500
|
|
|
g_switch = False
|
|
|
g_isRestart = True
|
|
|
+last_change_time = time.time()
|
|
|
|
|
|
@app.after_request
|
|
|
def add_no_cache_header(response):
|
|
@@ -254,6 +255,7 @@ def auto_palace():
|
|
|
start_time = time.time() # 记录开始时间
|
|
|
read_cfg()
|
|
|
while not event.is_set():
|
|
|
+ g_times += 1
|
|
|
if len(task_queue) < 4:
|
|
|
task_queue.appendleft(task_cure(True, g_cureNum))
|
|
|
task_queue.appendleft(task_cure(True, g_cureNum))
|
|
@@ -410,7 +412,7 @@ def add_auto_task(isMaxCollect, isJina, isSimple = False, isAddStrengh = False,
|
|
|
restart_times = 7
|
|
|
if g_switch:
|
|
|
restart_times = 4
|
|
|
- if g_times == restart_times:
|
|
|
+ if g_times % restart_times == 0 and g_times != 0:
|
|
|
if g_isRestart:
|
|
|
handle_end_game()
|
|
|
if g_switch == False:
|
|
@@ -620,6 +622,25 @@ def handle_auto_palace():
|
|
|
send_status(f'开始自动王城')
|
|
|
executor.submit(auto_palace)
|
|
|
|
|
|
+def monitor_game_runtime():
|
|
|
+ global g_times, last_change_time
|
|
|
+ last_value = g_times
|
|
|
+
|
|
|
+ while True:
|
|
|
+ current_value = g_times
|
|
|
+ if current_value != last_value:
|
|
|
+ last_value = current_value
|
|
|
+ last_change_time = time.time()
|
|
|
+ print(f"g_times changed to {current_value}")
|
|
|
+
|
|
|
+ # 检查是否超过60分钟没有变化
|
|
|
+ if time.time() - last_change_time > 3600: # 3600秒=60分钟
|
|
|
+ print("g_times hasn't changed for 60 minutes!")
|
|
|
+ handle_restart_game()
|
|
|
+
|
|
|
+ time.sleep(10)
|
|
|
+
|
|
|
+
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
init()
|
|
@@ -630,5 +651,8 @@ if __name__ == '__main__':
|
|
|
runTask = threading.Thread(target=thread_runTask)#启动线程往里面添加任务
|
|
|
runTask.daemon = True
|
|
|
runTask.start()
|
|
|
+
|
|
|
+ monitor_thread = threading.Thread(target=monitor_game_runtime, daemon=True)
|
|
|
+ monitor_thread.start()
|
|
|
|
|
|
socketio.run(app, host= '0.0.0.0', debug=True)
|