Repository navigation
refactor(config): 解装模式取值语义化为 拆解全部/拆解舰种/保留舰种 #565
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -375,14 +375,18 @@ def relative_position_in_destroy(self) -> tuple[float, float]: | |
|
|
||
|
|
||
| class DestroyShipWorkMode(IntEnum): | ||
| """拆解工作模式。""" | ||
|
|
||
| disable = 0 | ||
| """不启用舰种分类""" | ||
| include = 1 | ||
| """只拆指定舰种""" | ||
| exclude = 2 | ||
| """拆除指定舰种以外的所有舰种""" | ||
| """解装范围: ``destroy_ship_types`` 列表的用途。""" | ||
|
|
||
| all = 0 | ||
| """拆解全部 (不按舰种分类, 走快速拆解路线)""" | ||
| destroy_only = 1 | ||
| """拆解舰种 (只拆列表内舰种)""" | ||
| keep_only = 2 | ||
| """保留舰种 (列表内舰种保留, 其余全拆)""" | ||
|
|
||
| disable = 0 # 旧成员名, 等价 all | ||
| include = 1 # 旧成员名, 等价 destroy_only | ||
| exclude = 2 # 旧成员名, 等价 keep_only | ||
|
|
||
|
|
||
| class DockFullAction(IntEnum): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该改动整体思路清晰,将原先含义模糊的 但存在一个潜在的兼容性问题需要关注:
如果该枚举仅以整数值形式参与配置和逻辑判断,那么本次改动没有问题;但若库的 API 承诺或外部用户可能使用 |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,10 +76,10 @@ repair_manually: false # 是否手动修理 | |
| bathroom_count: 2 # 浴室修理槽位数 (auto_bath_repair 空位调度用) | ||
|
|
||
| # ── 解装设置 ── | ||
| destroy_ship_work_mode: 不启用 # 不启用 / 黑名单 / 白名单 | ||
| # 不启用: 解装所有舰船 | ||
| # 黑名单: 解装列表中的舰种 | ||
| # 白名单: 解装不在列表中的舰种 | ||
| destroy_ship_work_mode: 拆解全部 # 拆解全部 / 拆解舰种 / 保留舰种 | ||
| # 拆解全部: 解装所有舰船 (不按舰种分类, 走快速拆解) | ||
| # 拆解舰种: 只解装列表中的舰种 | ||
| # 保留舰种: 解装不在列表中的舰种 | ||
| destroy_ship_types: [] # 指定舰种列表, 参照 ShipType 枚举使用中文 | ||
| # - 航母 | ||
| # - 潜艇 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该变更存在潜在兼容性问题,需要确认:
建议:仔细核对代码中对 |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,9 +231,46 @@ def test_destroy_ship_config(self, tmp_yaml: Callable[[str, str], Path]): | |
| """ | ||
| path = tmp_yaml('destroy.yaml', content) | ||
| cfg = UserConfig.from_yaml(path) | ||
| assert cfg.destroy_ship_work_mode == DestroyShipWorkMode.include | ||
| assert cfg.destroy_ship_work_mode == DestroyShipWorkMode.destroy_only | ||
| assert len(cfg.destroy_ship_types) == 2 | ||
|
|
||
| @pytest.mark.parametrize( | ||
| ('value', 'expected'), | ||
| [ | ||
| ('拆解全部', DestroyShipWorkMode.all), | ||
| ('拆解舰种', DestroyShipWorkMode.destroy_only), | ||
| ('保留舰种', DestroyShipWorkMode.keep_only), | ||
| ], | ||
| ) | ||
| def test_destroy_ship_chinese_alias( | ||
| self, | ||
| tmp_yaml: Callable[[str, str], Path], | ||
| value: str, | ||
| expected: DestroyShipWorkMode, | ||
| ): | ||
| """中文别名 拆解全部 / 拆解舰种 / 保留舰种 均映射到对应枚举。""" | ||
| content = f"""\ | ||
| emulator: | ||
| type: "雷电" | ||
| serial: "emulator-5554" | ||
| path: "C:/fake/dnplayer.exe" | ||
| destroy_ship_work_mode: {value} | ||
| """ | ||
| cfg = UserConfig.from_yaml(tmp_yaml('destroy_alias.yaml', content)) | ||
| assert cfg.destroy_ship_work_mode == expected | ||
|
|
||
| def test_destroy_ship_legacy_value_alias(self, tmp_yaml: Callable[[str, str], Path]): | ||
| """旧值别名 (不启用/黑名单/白名单、disable/include/exclude) 仍可用。""" | ||
| content = """\ | ||
| emulator: | ||
| type: "雷电" | ||
| serial: "emulator-5554" | ||
| path: "C:/fake/dnplayer.exe" | ||
| destroy_ship_work_mode: 白名单 | ||
| """ | ||
| cfg = UserConfig.from_yaml(tmp_yaml('destroy_legacy.yaml', content)) | ||
| assert cfg.destroy_ship_work_mode == DestroyShipWorkMode.keep_only | ||
|
|
||
|
|
||
| # ── FightConfig ── | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 以下是针对该代码变更片段的审核意见:
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.