fix(fleet): support selector rules and disambiguate same-name ships#420
Merged
fix(fleet): support selector rules and disambiguate same-name ships#420
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull request overview
This PR adds backend support for slot-level fleet selector rules (candidates/search_name/level range) and improves fleet-changing + ship-choosing logic to handle same-name ships and selector-driven matching, then propagates the new fleet_rules field through server schemas/routes into normal/event fight preparation. It also bumps the package version.
Changes:
- Add
FleetRuleRequest+plan.fleet_rulesto task request schemas and route overrides. - Enhance fleet-change flow to be selector-aware (candidate reuse, one-to-one matching, refill/occupied-slot handling) and extend choose-ship flow with
search_name+ optional level filtering. - Update ship-list OCR utilities to support optional name de-duplication disabling and row-level keys for correlating name ↔ level OCR results.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
autowsgr/ui/utils/ship_list.py |
Extends row OCR helpers with optional de-dupe control and row keys to support same-name disambiguation + level correlation. |
autowsgr/ui/choose_ship_page.py |
Adds selector-aware choose-ship logic (search_name/candidates/min-max level) and returns the selected name. |
autowsgr/ui/battle/fleet_change/_change.py |
Updates fleet change algorithm to support selector rules, avoid same-name false matches, and handle refill/occupied-slot cases. |
autowsgr/server/schemas.py |
Introduces FleetRuleRequest and CombatPlanRequest.fleet_rules request schema support. |
autowsgr/server/routes/task.py |
Propagates fleet_rules overrides from requests into fight runners. |
autowsgr/ops/normal_fight.py |
Accepts/propagates fleet_rules into preparation flow and resolves ship names post-change. |
autowsgr/ops/event_fight.py |
Same as normal fight, for event fights. |
autowsgr/__init__.py |
Version bump to 2.1.9.post5. |
Comments suppressed due to low confidence (1)
autowsgr/ui/utils/ship_list.py:271
read_ship_levels()now optionally appendsrow_keyto each entry, but the debug log still unpacksfoundas(n, lv)pairs. Wheninclude_row_key=True(used byChooseShipPage._click_ship_in_listfor level filtering), this will raiseValueError: too many values to unpackand break ship selection. Update the debug formatting to index into the tuple (e.g.,entry[0],entry[1]) or branch on tuple length.
_log.debug(
'[选船列表] 等级识别: {}',
[(n, lv) for n, lv in found],
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Frontend now sends slot-level fleet selector rules (candidates/search_name). Without backend support, same-name ships can be treated as already matched and fail to replace, causing repeated fleet setup failures.
Validation