Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在小助手中选择模拟宇宙的命途和难度 #223

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/setting_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,23 @@ def __initCard(self):
"",
"universe_enable"
)
fates = {}
for a in ["存护", "记忆", "虚无", "丰饶", "巡猎", "毁灭", "欢愉", "繁育", "智识"]:
fates[a] = a
self.universeFateCard = ComboBoxSettingCard2(
"universe_fate",
FIF.PIE_SINGLE,
self.tr('命途'),
'',
texts=fates
)
self.universeDifficultyCard = RangeSettingCard1(
"universe_difficulty",
[1, 5],
FIF.HISTORY,
self.tr("难度"),
self.tr(""),
)
self.universeOperationModeCard = ComboBoxSettingCard2(
"universe_operation_mode",
FIF.COMMAND_PROMPT,
Expand Down Expand Up @@ -579,6 +596,8 @@ def __initLayout(self):
self.FightGroup.addSettingCard(self.FightRunTimeCard)

self.UniverseGroup.addSettingCard(self.universeEnableCard)
self.UniverseGroup.addSettingCard(self.universeFateCard)
self.UniverseGroup.addSettingCard(self.universeDifficultyCard)
self.UniverseGroup.addSettingCard(self.universeOperationModeCard)
self.UniverseGroup.addSettingCard(self.universeTimeoutCard)
self.UniverseGroup.addSettingCard(self.universeBonusEnableCard)
Expand Down
2 changes: 2 additions & 0 deletions assets/config/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ universe_path: .\3rdparty\Auto_Simulated_Universe # 模拟宇宙路径,指向
universe_timeout: 20 # 模拟宇宙超时时间(单位:小时),设置脚本或程序的最长运行时间。
universe_requirements: false # 是否已安装模拟宇宙依赖。true 表示已安装,false 表示未安装或需要重新安装。
universe_timestamp: 0 # 上次运行模拟宇宙的时间戳,用于记录和控制运行频率。
universe_fate: '巡猎' # 模拟宇宙使用的命途
universe_difficulty: 4 # 模拟宇宙使用的难度

# 忘却之庭配置
forgottenhall_enable: false # 是否启用混沌回忆功能。true 开启,false 关闭。
Expand Down
30 changes: 30 additions & 0 deletions module/config/asu_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os
import shutil

import yaml
from module.config import cfg


def auto_config():
if not os.path.exists(os.path.join(cfg.universe_path, "info.yml")):
shutil.copyfile(os.path.join(cfg.universe_path, "info_example.yml"), os.path.join(
cfg.universe_path, "info.yml"))
with open(os.path.join(cfg.universe_path, "info.yml"), 'r', encoding='utf-8') as f:
info = yaml.safe_load(f)
if info['config']['fate'] != cfg.universe_fate or info['config']['difficulty'] != cfg.universe_difficulty:
info['config']['fate'] = cfg.universe_fate
info['config']['difficulty'] = cfg.universe_difficulty
with open(os.path.join(cfg.universe_path, "info.yml"), 'w', encoding='utf-8') as f:
yaml.dump(info, f, default_flow_style=False,
allow_unicode=True)


def reload_config_from_asu():
file = os.path.join(cfg.universe_path, "info.yml")
if not os.path.exists(file):
return None
with open(file, 'r', encoding='utf-8') as f:
info = yaml.safe_load(f)
if info['config']['fate'] != cfg.universe_fate:
pass
# todo: save cfg memory/file and reload gui
4 changes: 4 additions & 0 deletions tasks/weekly/universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import time
import sys
import os
from module.config import asu_config


class Universe:
Expand Down Expand Up @@ -152,6 +153,8 @@ def start(nums=cfg.universe_count, save=True):
# 进入黑塔办公室
screen.change_to('main')

asu_config.auto_config()

if Universe.start_calibration() and Universe.start_simulation(nums, save):
return True

Expand Down Expand Up @@ -182,6 +185,7 @@ def get_reward():
def gui():
if Universe.before_start():
if subprocess.run(["start", "gui.exe"], shell=True, check=True, cwd=cfg.universe_path, env=cfg.env):
asu_config.reload_config_from_asu()
return True
return False

Expand Down
Loading