Skip to content

Commit 165ceb3

Browse files
yltxgithub-actions[bot]huan-yp
authored
feat: 决战快修开关 + 舰船泡澡修理 API + 模拟器设备查询 API (#376)
* ci: 每30分钟自动同步上游仓库 * feat: 添加 POST /api/repair/ship 端点 — 按舰船名泡澡修理 添加 /api/repair/ship 路由,接受 ship_name 参数,调用已有的 repair_ship_by_name() 函数将指定舰船送入浴室修理。 返回修理时间(秒),浴场已满时返回错误。 此端点供 AutoWSGR-GUI 前端的泡澡修理系统使用。 * feat: 决战添加 use_quick_repair 开关 - DecisiveRequest schema 新增 use_quick_repair: bool = True - DecisiveConfig 新增 use_quick_repair 字段 - _start_decisive 传递 use_quick_repair 到 DecisiveConfig - handlers.py: use_quick_repair=False 时使用 RepairStrategy.NEVER - logic.py: should_repair() 尊重 use_quick_repair 配置 * feat: 添加 GET /api/system/emulator/devices 端点 通过 adb devices 查询已连接的模拟器设备列表, 用于前端检查模拟器运行状态。 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: huan-yp <85162020+huan-yp@users.noreply.github.com>
1 parent 16c85f3 commit 165ceb3

7 files changed

Lines changed: 33 additions & 2 deletions

File tree

autowsgr/infra/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ class DecisiveConfig:
474474
full_destroy: bool = False
475475
destroy_ship_types: list[ShipType] = field(default_factory=list)
476476
"""解装时指定的舰种列表。空列表 = 不过滤,全部解装。"""
477+
use_quick_repair: bool = True
478+
"""是否启用快修(桶修),关闭后不修理受损舰船。"""
477479

478480

479481
# ── ConfigManager ──

autowsgr/ops/decisive/handlers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ def _handle_prepare_combat(self) -> None:
251251
self._state.fleet = best_fleet
252252

253253
strategy = (
254-
RepairStrategy.MODERATE if self._config.repair_level <= 1 else RepairStrategy.SEVERE
254+
RepairStrategy.NEVER if not self._config.use_quick_repair
255+
else RepairStrategy.MODERATE if self._config.repair_level <= 1
256+
else RepairStrategy.SEVERE
255257
)
256258
page.apply_repair(strategy)
257259

autowsgr/ops/decisive/logic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ def should_retreat(self, fleet: list[str]) -> bool:
146146

147147
def should_repair(self) -> bool:
148148
"""根据修理等级判断是否需要修理。"""
149+
if not self.config.use_quick_repair:
150+
return False
149151
return any(
150152
status >= self.config.repair_level for status in self.state.ship_stats if status > 0
151153
)

autowsgr/server/routes/ops.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ async def repair_ship(request: RepairShipRequest):
220220
from autowsgr.ops.repair import repair_ship_by_name
221221

222222
try:
223-
repair_secs = await asyncio.to_thread(repair_ship_by_name, ctx, request.ship_name)
223+
repair_secs = await asyncio.to_thread(
224+
repair_ship_by_name, ctx, request.ship_name
225+
)
224226
if repair_secs < 0:
225227
return ApiResponse(
226228
success=False,

autowsgr/server/routes/system.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,21 @@ async def system_status():
7474
else None,
7575
},
7676
)
77+
78+
79+
@router.get('/emulator/devices', response_model=ApiResponse)
80+
async def emulator_devices():
81+
"""查询 ADB 设备列表,用于检查模拟器运行状态。"""
82+
import asyncio
83+
84+
try:
85+
from autowsgr.emulator.detector import list_adb_devices
86+
87+
devices = await asyncio.to_thread(list_adb_devices)
88+
return ApiResponse(
89+
success=True,
90+
data=[{'serial': s, 'status': st} for s, st in devices],
91+
)
92+
except Exception as e:
93+
_log.warning('[System] ADB 设备查询失败: {}', e)
94+
return ApiResponse(success=False, error=str(e))

autowsgr/server/routes/task.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ def executor(task_info: Any) -> list[dict[str, Any]]:
266266
level1=request.level1,
267267
level2=request.level2,
268268
flagship_priority=request.flagship_priority,
269+
use_quick_repair=request.use_quick_repair,
269270
)
270271

271272
controller = DecisiveController(ctx, config)

autowsgr/server/schemas.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ class DecisiveRequest(BaseModel):
176176
default_factory=lambda: ['U-1206'],
177177
description='旗舰优先级',
178178
)
179+
use_quick_repair: bool = Field(
180+
default=True,
181+
description='是否启用快修(桶修),关闭后不修理受损舰船',
182+
)
179183

180184
model_config = {'extra': 'forbid'}
181185

0 commit comments

Comments
 (0)