|
@@ -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):
|