Add region stage selection, eligible sweeps and daily rewards

This commit is contained in:
AttilaNet
2026-11-07 22:41:55 +08:00
parent 657f5f33b5
commit 42edc111d1
13 changed files with 1071 additions and 94 deletions
+50 -65
View File
@@ -18,7 +18,9 @@ from .management import expansion_quote, manual_monster_actions
from .native_widgets import IntegerInput, use_native_scrollbars
from .login import PasswordLogin, device_id, server_labels
from .quests import QuestPolicy
from .maps import stages
from .daily import DailyPolicy
from .sweeping import SweepPolicy
from .activity_gui import ActivityPages
from .capture import PAGES, load_buttons, read_profile, saved_profiles, save_page
from .credentials import CredentialStore
from .debug import TraceLog
@@ -154,7 +156,7 @@ def fill_table(widget, rows, sorting=True):
widget.setSortingEnabled(sorting)
class Window(W.QMainWindow):
class Window(ActivityPages, W.QMainWindow):
network_event = C.Signal(object)
profile_changed = C.Signal(str)
@@ -307,6 +309,7 @@ class Window(W.QMainWindow):
self.yield_tab()
self.quests_tab()
self.maps_tab()
self.daily_tab()
self.farm_tab()
self.capture_tab()
self.plans = table(["操作", "下一步计划(每轮只执行一项,并重新读取状态)"])
@@ -548,11 +551,12 @@ class Window(W.QMainWindow):
def start_workflow(self):
try:
policy = self.read_policy()
if not (policy.enabled and any((policy.buy, policy.fill, policy.dispatch, policy.collect, policy.feed))) and not self.quest_enabled.isChecked():
other = self.quest_enabled.isChecked() or self.daily_enabled.isChecked() or self.map_enabled.isChecked()
if not (policy.enabled and any((policy.buy, policy.fill, policy.dispatch, policy.collect, policy.feed))) and not other:
self.report("请先勾选至少一项功能,并启用对应策略")
return
self.read_quest_policy()
if policy.enabled and not any(rule["enabled"] for rule in policy.egg_rules.values()) and not self.quest_enabled.isChecked():
if policy.enabled and not any(rule["enabled"] for rule in policy.egg_rules.values()) and not other:
self.report("请先在“背包魔物蛋”勾选要孵化的蛋,并设置优先级和孵出后的去向")
self.tabs.setCurrentWidget(self.egg_page)
return
@@ -588,6 +592,8 @@ class Window(W.QMainWindow):
try:
self.engine.policy = self.read_policy()
self.engine.quest_policy = self.read_quest_policy()
self.engine.daily_policy = self.read_daily_policy()
self.engine.sweep_policy = self.read_sweep_policy()
except ValueError:
self.report("请先修正孵蛋规则中的编号和保留数量")
return
@@ -722,58 +728,6 @@ class Window(W.QMainWindow):
layout.addWidget(self.quests_table)
self.tabs.addTab(tab, "自动委托")
def maps_tab(self):
tab, layout = W.QWidget(), W.QVBoxLayout()
tab.setLayout(layout)
line = W.QHBoxLayout()
self.map_search = W.QLineEdit()
self.map_search.setPlaceholderText("地图名称或关卡编号")
self.map_search.textChanged.connect(self.render_maps)
self.only_unlocked = W.QCheckBox("只看账号已解锁")
self.only_unlocked.setChecked(True)
self.only_unlocked.toggled.connect(self.render_maps)
choose = W.QPushButton("设为自动战斗目标")
choose.clicked.connect(self.choose_map)
line.addWidget(self.map_search)
line.addWidget(self.only_unlocked)
line.addWidget(choose)
layout.addLayout(line)
self.maps_summary = W.QLabel("登录后显示账号实际解锁状态")
layout.addWidget(self.maps_summary)
self.maps_table = table(["城市", "关卡编号", "名称", "难度", "已解锁", "已通关", "当前开放", "体力", "入场道具"])
layout.addWidget(self.maps_table)
note = W.QLabel("当前客户端未发现独立扫荡接口。此处可查看关卡和设置正常自动战斗目标;纯接口即时结算尚未实现。")
note.setWordWrap(True)
layout.addWidget(note)
self.tabs.addTab(tab, "地图关卡")
def render_maps(self, *args):
if not hasattr(self, "maps_table") or self.engine.snapshot is None:
return
all_rows = stages(self.catalog, self.engine.snapshot)
query = self.map_search.text().strip()
visible = [s for s in all_rows if (not self.only_unlocked.isChecked() or s.unlocked) and (not query or query in s.name or query in s.stage_id)]
fill_table(self.maps_table, [[s.city, s.stage_id, s.name, int(s.level), "是" if s.unlocked else "否", "是" if s.passed else "否", "是" if s.open else "否", s.stamina, s.tickets] for s in visible])
self.maps_summary.setText(f"账号已解锁 {sum(s.unlocked for s in all_rows)} 个关卡难度;当前显示 {len(visible)} 项")
def choose_map(self):
row = self.maps_table.currentRow()
if row < 0:
return
stage_id = self.maps_table.item(row, 1).text()
level = self.maps_table.item(row, 3).text()
if self.maps_table.item(row, 4).text() != "是" or self.maps_table.item(row, 6).text() != "是":
self.report("所选关卡未解锁或当前未开放")
return
index = self.stage.findData(stage_id)
if index < 0:
self.stage.addItem(self.maps_table.item(row, 2).text() + " " + stage_id, stage_id)
index = self.stage.count() - 1
self.stage.setCurrentIndex(index)
self.stage_level.setCurrentIndex(self.stage_level.findData(level))
self.tabs.setCurrentWidget(self.screen.parentWidget())
self.report("已设置自动战斗目标;手机需打开相应关卡准备页")
def farm_tab(self):
tab, horizontal = W.QWidget(), W.QHBoxLayout()
tab.setLayout(horizontal)
@@ -794,8 +748,8 @@ class Window(W.QMainWindow):
self.template = combo([("进入关卡按钮(必需)", "entry"), ("胜利结算按钮(必需)", "victory"),
("关卡名称区域(必需,仅识别)", "stage"), ("触摸开始倒计时", "countdown"), ("自动战斗未开启图标", "auto_off"), ("结算下一步按钮", "continue"), ("失败标识(只检测不点击)", "defeat")])
form.addRow("框选的按钮类型", self.template)
guide = W.QPushButton("打开页面截图配置(推荐,无需框选)")
guide.clicked.connect(lambda: self.tabs.setCurrentWidget(self.capture_rows.parentWidget()))
guide = W.QPushButton("打开ADB实战截图配置(扫荡无需截图)")
guide.clicked.connect(lambda: self.tabs.setCurrentWidget(self.capture_scroll))
form.addRow(guide)
capture = W.QPushButton("手工标定(可选):截图并在右侧框选")
capture.clicked.connect(self.capture)
@@ -820,7 +774,13 @@ class Window(W.QMainWindow):
def capture_tab(self):
tab, layout = W.QWidget(), W.QVBoxLayout()
tab.setLayout(layout)
note = W.QLabel("按下列页面截图即可,不需要手工框选。先在“体力刷图”选择设备、关卡和难度。\n你玩到对应页面时点击该行截图;截图过程中不会自动点击或切换手机页面。")
self.capture_page_widget = tab
scroll = W.QScrollArea()
scroll.setWidgetResizable(True)
scroll.setWidget(tab)
self.capture_scroll = scroll
layout.setSizeConstraint(W.QLayout.SizeConstraint.SetMinimumSize)
note = W.QLabel("此页仅用于ADB手机实战;地图接口扫荡和每日事务不需要截图。\n先在“体力刷图”选择设备、关卡和难度。你玩到对应页面时点击该行截图,无需手工框选;截图不会自动点击或切换手机页面。")
note.setWordWrap(True)
layout.addWidget(note)
self.capture_target = W.QLabel()
@@ -830,8 +790,7 @@ class Window(W.QMainWindow):
self.capture_profiles.currentIndexChanged.connect(self.select_capture_profile)
layout.addWidget(self.capture_profiles)
self.capture_rows = W.QTableWidget(len(PAGES), 4)
self.capture_rows.setMinimumHeight(200)
self.capture_rows.verticalHeader().setDefaultSectionSize(22)
self.capture_rows.verticalHeader().setDefaultSectionSize(max(28, self.fontMetrics().height() + 12))
self.capture_rows.setHorizontalHeaderLabels(["页面", "截图需要包含", "操作", "状态"])
self.capture_rows.setEditTriggers(W.QAbstractItemView.EditTrigger.NoEditTriggers)
self.capture_rows.cellClicked.connect(self.preview_capture)
@@ -844,6 +803,9 @@ class Window(W.QMainWindow):
button.clicked.connect(lambda checked=False, page=key: self.capture_page(page))
self.capture_rows.setCellWidget(index, 2, button)
self.capture_rows.setItem(index, 3, W.QTableWidgetItem("未截图"))
self.capture_rows.setRowHeight(index, max(28, button.sizeHint().height() + 4))
height = self.capture_rows.horizontalHeader().sizeHint().height() + sum(self.capture_rows.rowHeight(i) for i in range(len(PAGES))) + 30
self.capture_rows.setFixedHeight(height)
layout.addWidget(self.capture_rows)
line = W.QHBoxLayout()
refresh = W.QPushButton("检查已保存截图")
@@ -862,7 +824,8 @@ class Window(W.QMainWindow):
self.capture_preview = Screen(selectable=False)
self.capture_preview.setMinimumHeight(140)
layout.addWidget(self.capture_preview, 1)
self.tabs.addTab(tab, "页面截图配置")
self.tabs.addTab(scroll, "页面截图配置")
self.tabs.setTabToolTip(self.tabs.indexOf(scroll), "仅用于ADB手机实战;接口扫荡和每日事务无需截图")
self.stage.currentIndexChanged.connect(self.refresh_capture_profiles)
self.stage_level.currentIndexChanged.connect(self.refresh_capture_profiles)
self.serial.editingFinished.connect(self.refresh_capture_profiles)
@@ -1160,7 +1123,7 @@ class Window(W.QMainWindow):
if tab is self.yields.parentWidget():
self.render_catalog()
self.report("收益资料已从本地表刷新")
elif tab is self.capture_rows.parentWidget():
elif tab is self.capture_scroll:
self.refresh_capture_profiles()
else:
self.refresh()
@@ -1270,7 +1233,7 @@ class Window(W.QMainWindow):
self.error("显示数据时出错:" + str(error))
def apply_result(self, kind, value):
if kind in ("poll", "monster_lock", "manual_monsters", "expansion", "growth_sync"):
if kind in ("poll", "monster_lock", "manual_monsters", "expansion", "growth_sync", "daily_claim"):
snapshot, plans, message = value
self.render(snapshot, plans)
self.report(message)
@@ -1333,6 +1296,8 @@ class Window(W.QMainWindow):
try:
self.engine.policy = self.read_policy()
self.engine.quest_policy = self.read_quest_policy()
self.engine.daily_policy = self.read_daily_policy()
self.engine.sweep_policy = self.read_sweep_policy()
fill_table(self.plans, [[action.kind, action.description] for action in self.engine.plans()])
except (ValueError, TypeError, KeyError, AttributeError) as error:
self.report("状态已显示;策略暂不可用:" + str(error))
@@ -1423,6 +1388,8 @@ class Window(W.QMainWindow):
try:
self.engine.policy = self.read_policy()
self.engine.quest_policy = self.read_quest_policy()
self.engine.daily_policy = self.read_daily_policy()
self.engine.sweep_policy = self.read_sweep_policy()
self.engine.auto = self.execute.isChecked() and automated and self.monitoring
self.next_poll = time.monotonic() + self.interval.currentData()
self.submit("poll", self.engine.poll)
@@ -1534,6 +1501,7 @@ class Window(W.QMainWindow):
self.catalog.data["task_info"][key].get("reward", {}).get("money", 0),
self.catalog.data["task_info"][key].get("reward", {}).get("ke", 0), text] for key, name, status, text, _ in quest_rows])
self.render_maps()
self.render_daily()
except (ValueError, TypeError, KeyError, AttributeError) as error:
self.report("基础数据已显示;委托或地图暂不可用:" + str(error))
left = snapshot.raw.get("history", {}).get("loopTaskNum", "未知")
@@ -1732,6 +1700,10 @@ class Window(W.QMainWindow):
self.farm.stop()
self.start_farm.setText("开始布丁牧场刷图")
return
if self.map_enabled.isChecked() and self.execute.isChecked():
self.start_farm.setChecked(False)
self.report("请先停止地图页的接口扫荡,再开始手机实战")
return
if self.busy or self.engine.demo or self.engine.snapshot is None:
self.start_farm.setChecked(False)
self.report("请先连接真实手机会话,等待刷新完成后再开始刷图")
@@ -1757,7 +1729,9 @@ class Window(W.QMainWindow):
def config_value(self):
self.update_farm_config()
return {"policy": asdict(self.read_policy()), "quest_policy": asdict(self.read_quest_policy()), "farm": asdict(self.farm.config), "overrides": copy.deepcopy(self.catalog.overrides),
return {"policy": asdict(self.read_policy()), "quest_policy": asdict(self.read_quest_policy()),
"daily_policy": asdict(self.read_daily_policy()), "sweep_policy": asdict(self.read_sweep_policy()),
"farm": asdict(self.farm.config), "overrides": copy.deepcopy(self.catalog.overrides),
"log_visible": self.show_log.isChecked(), "log_sizes": self.log_splitter.sizes() if self.show_log.isChecked() else self.log_sizes,
"yield_stars": [star for star, check in self.yield_stars.items() if check.isChecked()],
"adb_path": self.adb_path.text(), "serial": self.serial.text().strip(), "interval": self.interval.currentData(),
@@ -1792,6 +1766,15 @@ class Window(W.QMainWindow):
self.log.setVisible(self.show_log.isChecked())
self.show_log.setText("隐藏日志" if self.show_log.isChecked() else "显示日志")
policy = Policy(**value.get("policy", {}))
daily = DailyPolicy(**value.get("daily_policy", {}))
self.daily_enabled.setChecked(daily.enabled)
for key, check in self.daily_checks.items():
check.setChecked(key in daily.selected)
sweep = SweepPolicy(**value.get("sweep_policy", {}))
self.map_rules = copy.deepcopy(sweep.rules)
self.map_enabled.setChecked(sweep.enabled)
self.map_keep_ti.setValue(sweep.keep_stamina)
self.map_team.setCurrentIndex(max(0, self.map_team.findData(sweep.team)))
self.egg_rules = copy.deepcopy(policy.egg_rules)
self.feed_targets = copy.deepcopy(policy.feed_targets)
for widget, data in ((self.strategy, policy.strategy), (self.protect_quality, policy.protect_quality), (self.egg_order, policy.egg_order), (self.interval, value.get("interval", 10)),
@@ -1846,6 +1829,8 @@ class Window(W.QMainWindow):
def closeEvent(self, event):
self.closed = True
self.timer.stop()
if hasattr(self, "activity_save_timer"):
self.activity_save_timer.stop()
self.pending_refresh = None
self.engine.auto = False
self.monitoring = False