fix: keep automatic cultivation on one stable primary per species
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# 牧羊人之心牧场助手 · Web 2.0.6
|
||||
# 牧羊人之心牧场助手 · Web 2.0.7
|
||||
|
||||
## 产品约束
|
||||
|
||||
把现有桌面助手的功能和操作结构迁移至单管理员 Web 工作台。桌面版是页面顺序、信息密度、业务名称、保护条件与交互的依据,保留桌面兼容。本轮 Web 发布目标为 `2.0.6`,源码入口 `main`,游戏数据版本 `1.9.68`;桌面正式版保留 `1.2.0`。启动与配置见 [运行说明](README.md),Docker 与更新条件见 [部署说明](../deploy/web/README.md)。
|
||||
把现有桌面助手的功能和操作结构迁移至单管理员 Web 工作台。桌面版是页面顺序、信息密度、业务名称、保护条件与交互的依据,保留桌面兼容。本轮 Web 发布目标为 `2.0.7`,源码入口 `main`,游戏数据版本 `1.9.68`;桌面正式版保留 `1.2.0`。启动与配置见 [运行说明](README.md),Docker 与更新条件见 [部署说明](../deploy/web/README.md)。
|
||||
|
||||
使用者在 Windows 本机配置、验证,随后可在 Linux Docker 常驻运行。多个浏览器访问同一个管理员工作台;账号互相隔离,各账号串行执行,账号之间可以并行。
|
||||
|
||||
@@ -24,9 +24,13 @@
|
||||
- 数据分析用真实 DTO 绘制 SVG 条形图,保留来源筛选、体力效率、样本和不确定性说明。没有样本时明确说明。
|
||||
- 策略统一导入导出;收益 CSV/XLSX 导入与可用数据下载。错误展示具体原因,不把不支持的任务伪装成可执行任务。
|
||||
- 帮助可检查 GitHub 正式版本并提交受控更新请求。未配置部署器时明确显示原因,更新提交不表示更新成功。
|
||||
- 已在 2.0.1 完成私有仓库和 GHCR 认证的部署,可在 2.0.6 发布就绪后直接通过“帮助 → 检查版本更新…”升级,无需先安装 2.0.2、重复初始化或替换宿主机更新器;升级完成后刷新网页以加载新版界面,安装结果以宿主机健康检查为准。
|
||||
- 已在 2.0.1 完成私有仓库和 GHCR 认证的部署,可在 2.0.7 发布就绪后直接通过“帮助 → 检查版本更新…”升级,无需先安装 2.0.2、重复初始化或替换宿主机更新器;升级完成后刷新网页以加载新版界面,安装结果以宿主机健康检查为准。
|
||||
|
||||
## 2.0.6 表单布局
|
||||
## 2.0.7 主培养与资质备用
|
||||
|
||||
同种只自动培养已养成的高等级主培养;新资质更好的魔物只作为备用保留,不分配经验、礼物或潜能材料。已启用种类按主培养1只、更优备用最多1只整理,新备用严格更优才替换,同分保留已有备用。主培养到上限或冷却时等待,不向同种备用转移资源。硬保护保留,未勾选种类不扩大自动整理范围。
|
||||
|
||||
## 表单布局(2.0.6 起)
|
||||
|
||||
勾选框与右侧文字组成一组;数字、文本与下拉框采用标签在上、控件在下的布局。设置区限定合理宽度,并按可用空间排为多列,每日领取项目在单独分组中排列。界面尺寸变化不改变配置路径、自动保存或策略执行规则。
|
||||
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
# Web 2.0.6 运行说明
|
||||
# Web 2.0.7 运行说明
|
||||
|
||||
本轮 Web 发布目标 **2.0.6**,源码入口 `main`,游戏资料基线 **1.9.68**。桌面正式版保留 **1.2.0**,入口为 `python -m ranch_assistant`;Web 使用独立依赖与数据根。
|
||||
本轮 Web 发布目标 **2.0.7**,源码入口 `main`,游戏资料基线 **1.9.68**。桌面正式版保留 **1.2.0**,入口为 `python -m ranch_assistant`;Web 使用独立依赖与数据根。
|
||||
|
||||
Web 采用 FastAPI / Uvicorn 和原生 HTML/CSS/ES 模块,无 Node、npm 或前端编译步骤,不安装 PySide6。页面和策略能力沿用现有核心,详细业务范围与原有限制见 [桌面使用说明](../ranch_assistant/README.md)。多浏览器连接同一个管理员工作台;一个服务实例内,各账号独立线程并行,同一账号操作串行。
|
||||
|
||||
@@ -10,8 +10,8 @@ Web 采用 FastAPI / Uvicorn 和原生 HTML/CSS/ES 模块,无 Node、npm 或
|
||||
- [x] 保留账号页签、顶部数值与统一启停、可调日志;规则自动保存,配置与统计按账号/角色隔离,每次成功登录后自动执行已配置且已勾选的功能,可在顶部停止。
|
||||
- [x] Windows Python 启动与离线演示;Web 导入链和依赖不使用 Qt,无 Node 构建步骤。
|
||||
- [x] 提供 Linux Docker 与稳定 2.x 受控更新、停机备份及失败回滚脚本;历史 Linux Docker 部署、持久化权限、健康检查和定时更新检查烟测见下文。
|
||||
- [x] 本轮发布目标为 `2.0.6`,保留桌面兼容;战斗模拟为近似模型,特殊关卡并非全部支持,真实游戏 API 验收范围不因版本号变更而扩大。
|
||||
- 2.0.6 统一策略表单布局,勾选框贴近标签,普通字段标签置于控件上方,每日领取项目分组排列。详见 [本版发布说明](../analysis/RELEASE_2_0_6.md)。
|
||||
- [x] 本轮发布目标为 `2.0.7`,保留桌面兼容;战斗模拟为近似模型,特殊关卡并非全部支持,真实游戏 API 验收范围不因版本号变更而扩大。
|
||||
- 2.0.7 修复同种重复培养:主培养与资质备用分离,自动喂养、赠礼和潜能突破仅作用于主培养,启用种类固定主培养1只与更优备用最多1只。详见 [本版发布说明](../analysis/RELEASE_2_0_7.md)。
|
||||
- 2.0.3 修复 2.0.2 日志布局:所有页签复用原有底部日志区,按当前账号与功能筛选,默认收起;操作约定见 [产品说明](PRODUCT.md#203-底部分类日志),验收结果见 [发布说明](../analysis/RELEASE_2_0_3.md#验证)。
|
||||
|
||||
## Windows 本地运行
|
||||
@@ -97,13 +97,13 @@ sh start-web.sh --no-browser
|
||||
|
||||
Web 检查固定官方 GitHub Releases 的稳定 `v2.x.y`,跳过桌面 1.x、未来 3.x、草稿和预发布。开发版本 `2.0.0.dev1` 可升级至同数字的正式 `v2.0.0`;没有正式 Web 2 发布时明确显示暂无更新。Windows 默认仅检查;Web “更新”按钮仅在宿主机显式启用并有有效只读心跳时可提交 `pending` 请求,安装、备份和回滚由宿主机执行。默认定时检查只通知,自动安装需操作者 opt-in。
|
||||
|
||||
已在 **2.0.1** 完成私有仓库和 GHCR 认证的部署,可在 2.0.6 稳定 Release 和正式镜像就绪、宿主机心跳有效后,直接通过“帮助 → 检查版本更新…”升级 **2.0.6**,无需先安装 2.0.2、重复初始化或替换宿主机更新器。升级完成后刷新网页以加载新版界面,底部日志默认收起。安装结果以宿主机健康检查为准;首次配置仅供尚未初始化的宿主机参考。
|
||||
已在 **2.0.1** 完成私有仓库和 GHCR 认证的部署,可在 2.0.7 稳定 Release 和正式镜像就绪、宿主机心跳有效后,直接通过“帮助 → 检查版本更新…”升级 **2.0.7**,无需先安装 2.0.2、重复初始化或替换宿主机更新器。升级完成后刷新网页以加载新版界面,底部日志默认收起。安装结果以宿主机健康检查为准;首次配置仅供尚未初始化的宿主机参考。
|
||||
|
||||
## 离线验证
|
||||
|
||||
2.0.6 验证结果统一见 [发布说明](../analysis/RELEASE_2_0_6.md#验证),以下历史记录不计入本版验收。
|
||||
2.0.7 验证结果统一见 [发布说明](../analysis/RELEASE_2_0_7.md#验证),以下历史记录不计入本版验收。
|
||||
|
||||
### 历史验证记录(不计入 2.0.6)
|
||||
### 历史验证记录(不计入 2.0.7)
|
||||
|
||||
2.0.2 验证记录见 [历史发布说明](../analysis/RELEASE_2_0_2.md#验证)。
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Headless Web workspace for the ranch assistant."""
|
||||
|
||||
__version__ = "2.0.6"
|
||||
__version__ = "2.0.7"
|
||||
GAME_VERSION = "1.9.68"
|
||||
|
||||
__all__ = ["__version__", "GAME_VERSION"]
|
||||
|
||||
@@ -415,7 +415,7 @@ async function exportYields(account=current()) {
|
||||
async function command(name,account=current()) {
|
||||
try {
|
||||
if(name==='add-account'||name==='add-demo')return await addAccount(name==='add-demo');
|
||||
if(name==='about')return dialog('关于牧场助手',el('div',{},el('p',{text:`牧羊人之心牧场助手 Web ${state.meta?.version || '2.0.6'}`}),el('p',{text:`游戏数据版本 ${state.meta?.gameVersion || '1.9.68'}`})),{info:true});
|
||||
if(name==='about')return dialog('关于牧场助手',el('div',{},el('p',{text:`牧羊人之心牧场助手 Web ${state.meta?.version || '2.0.7'}`}),el('p',{text:`游戏数据版本 ${state.meta?.gameVersion || '1.9.68'}`})),{info:true});
|
||||
if(name==='updates')return await showUpdates();
|
||||
if(name==='admin-logout'){hideWorkbench();try{await api.logout();}finally{requireAuth();}return;}
|
||||
if(!account)throw new Error('请先新增或选择账号。');
|
||||
@@ -640,7 +640,7 @@ async function bootstrap() {
|
||||
$('#app').hidden=false;
|
||||
const [meta,schema]=await Promise.all([api.meta(),api.schema()]);state.meta=meta;state.schema=schema;
|
||||
if(state.redirecting)return;
|
||||
$('#app-version').textContent=meta.version || '2.0.6';$('#game-version').textContent=meta.gameVersion || '1.9.68';$('#access-mode').textContent=auth.access_mode==='local'||auth.access_mode==='loopback'?'本机工作台':auth.required?'管理工作台':'本机工作台';
|
||||
$('#app-version').textContent=meta.version || '2.0.7';$('#game-version').textContent=meta.gameVersion || '1.9.68';$('#access-mode').textContent=auth.access_mode==='local'||auth.access_mode==='loopback'?'本机工作台':auth.required?'管理工作台':'本机工作台';
|
||||
await syncAccounts();if(state.redirecting)return;state.ready=true;setStatus('工作台已连接');
|
||||
}catch(failure){if(failure.status===401||$('#app').hidden){requireAuth();return;}if(state.redirecting)return;setStatus(failure.message);$('#page-host').replaceChildren(el('div',{class:'initial-state'},el('p',{text:failure.message}),el('button',{text:'重新连接',onClick:bootstrap})));}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</div></details>
|
||||
<details class="menu"><summary accesskey="h">帮助<span class="access-key">(H)</span></summary><div class="menu-popup"><button data-command="updates">检查版本更新…</button><button data-command="debug">调试日志</button><button data-command="about">关于…</button></div></details>
|
||||
</nav>
|
||||
<span class="window-title">牧羊人之心牧场助手 <span id="app-version">2.0.6</span></span>
|
||||
<span class="window-title">牧羊人之心牧场助手 <span id="app-version">2.0.7</span></span>
|
||||
<span id="access-mode" class="muted"></span>
|
||||
</header>
|
||||
<div class="account-bar"><div id="account-tabs" class="account-tabs" role="tablist" aria-label="账号"></div><button id="add-account" class="compact" title="新增账号">+ 新增账号</button></div>
|
||||
|
||||
@@ -659,17 +659,20 @@ class ServiceTests(unittest.TestCase):
|
||||
worker.schedule.clock = lambda: clock[0]
|
||||
worker.engine.last_heartbeat = clock[0]
|
||||
monsters = list(worker.engine.snapshot.monsters)
|
||||
# Use the primary so the request reaches the uncertainty barrier.
|
||||
species = str(worker.engine.snapshot.monsters[monsters[0]]["typeId"])
|
||||
recipient = int(worker.engine.cultivation.select(worker.engine.snapshot)[species]["id"])
|
||||
if kind == "gift":
|
||||
# Engine overlays confirmed gift timestamps in seconds,
|
||||
# while an unchanged raw server snapshot uses milliseconds.
|
||||
mon = next(row for row in worker.engine.client.raw["monsters"] if row["id"] == monsters[0])
|
||||
mon = next(row for row in worker.engine.client.raw["monsters"] if row["id"] == recipient)
|
||||
mon["giftTime"] = 1_700_000_000_000
|
||||
worker.engine.gift_planner.confirmed[monsters[0]] = {
|
||||
worker.engine.gift_planner.confirmed[recipient] = {
|
||||
"owner": str(worker.engine.snapshot.raw["master"]["id"]),
|
||||
"type": str(mon["typeId"]), "feel": int(mon.get("feel") or 0),
|
||||
"giftTime": 1_700_000_060}
|
||||
action = Action(kind, "Unconfirmed gift", "monsterService/monsterSendGift",
|
||||
{"monsterId": monsters[0], "itemId": 1})
|
||||
{"monsterId": recipient, "itemId": 1})
|
||||
elif kind == "hatch":
|
||||
slot = worker.engine.client.raw["stacks"][0]
|
||||
slot["monsterId"] = -1
|
||||
@@ -678,7 +681,7 @@ class ServiceTests(unittest.TestCase):
|
||||
worker.engine.pending_hatches = [action]
|
||||
else:
|
||||
action = Action(kind, "Unconfirmed feed", "monsterService/monsterIntensify",
|
||||
{"targetId": monsters[0], "foods": [monsters[1]]})
|
||||
{"targetId": recipient, "foods": [monsters[1]]})
|
||||
before = len(FakeClient.calls)
|
||||
with patch.object(worker.engine, "plans", return_value=[action]):
|
||||
if kind == "hatch":
|
||||
|
||||
@@ -165,17 +165,38 @@ class TaskLogTests(unittest.TestCase):
|
||||
market = next(key for key, row in engine.catalog.data["markets"].items() if row.get("money", 0) > 0)
|
||||
engine.policy.daily_buy_money = 1000000
|
||||
engine.planner.notes = []
|
||||
primary = next(iter(engine.cultivation.select(engine.snapshot).values()))
|
||||
food = next(mon for mon in engine.snapshot.monsters.values()
|
||||
if mon.get("process") == 3 and mon.get("typeId") == primary["typeId"]
|
||||
and int(mon["id"]) != int(primary["id"]) and not mon.get("lock") and not mon.get("sysLock"))
|
||||
original_post = engine.client.http.post
|
||||
|
||||
def consume_feed(url, data, **kwargs):
|
||||
if url.endswith("monsterService/monsterIntensify"):
|
||||
payload = fixtures.decode(data, engine.client.session.key)
|
||||
foods = {int(mid) for mid in payload["foods"]}
|
||||
engine.client.raw["monsters"] = [mon for mon in engine.client.raw["monsters"] if int(mon["id"]) not in foods]
|
||||
return original_post(url, data, **kwargs)
|
||||
|
||||
actions = [
|
||||
Action("buy", "莉莉托斯市场十连抽蛋 ×10,花费100金币", "gachaService/gachaGetEggs", {"id": market, "num": 1}),
|
||||
Action("sell", "派遣 测试魔物 #1", "monsterService/monsterSell", {"monsterIds": [1]}),
|
||||
Action("feed", "喂养 测试魔物 ← 素材", "monsterService/monsterIntensify", {"targetId": 1, "foods": []}),
|
||||
Action("feed", "喂养 测试魔物 ← 素材", "monsterService/monsterIntensify",
|
||||
{"targetId": int(primary["id"]), "foods": [int(food["id"])]}),
|
||||
]
|
||||
for action in actions:
|
||||
with self.subTest(kind=action.kind):
|
||||
worker._running = True
|
||||
after = self.manager.logs(identifier, debug=True)["next"]
|
||||
with patch.object(engine, "plans", return_value=[action]):
|
||||
calls_before = len(fixtures.FakeClient.calls)
|
||||
with patch.object(engine, "plans", return_value=[action]), \
|
||||
patch.object(engine.client.http, "post", side_effect=consume_feed):
|
||||
self.tick(identifier, "poll")
|
||||
if action.kind == "feed":
|
||||
self.assertEqual([{key: payload[key] for key in action.payload}
|
||||
for _, url, payload in fixtures.FakeClient.calls[calls_before:]
|
||||
if url.endswith(action.path)], [action.payload])
|
||||
self.assertNotIn(int(food["id"]), engine.snapshot.monsters)
|
||||
entries = self.entries(identifier, after, debug=True)
|
||||
result = [row for row in entries if not row["debug"]]
|
||||
self.assertEqual({row["category"] for row in result}, {"hatching"})
|
||||
|
||||
@@ -82,6 +82,7 @@ import ranch_web.policies,ranch_web.views,ranch_web.actions
|
||||
fields = [field for page in value["pages"] for field in page["form"]]
|
||||
self.assertTrue(all(field["label"] and isinstance(field["path"], list) for field in fields))
|
||||
self.assertNotIn(["policy", "feed_target"], [field["path"] for field in fields])
|
||||
self.assertNotIn(["policy", "keep_better_quality"], [field["path"] for field in fields])
|
||||
self.assertNotIn(["progression_policy", "battle_mode"], [field["path"] for field in fields])
|
||||
self.assertEqual(dict(PAGES)["statistics"], "数据分析")
|
||||
self.assertEqual(dict(PAGES)["plans"], "执行计划")
|
||||
@@ -114,16 +115,19 @@ import ranch_web.policies,ranch_web.views,ranch_web.actions
|
||||
if code == 5:
|
||||
self.assertTrue(row["edits"]["enabled"]["disabled"])
|
||||
|
||||
def test_egg_keep_count_and_missing_stock_rule_bind_real_config(self):
|
||||
def test_fixed_retention_display_preserves_legacy_count_and_missing_stock_rule(self):
|
||||
config = deepcopy(self.worker.config)
|
||||
config["policy"]["egg_rules"]["1001010"] = {"enabled": True, "keep_count": 5, "priority": 1, "market_id": "sc_city1"}
|
||||
self.worker.save_config(config)
|
||||
dto = self.view("bag", {"category": "eggs"})
|
||||
row = next(row for row in dto["rows"] if row["id"] == "1001010")
|
||||
column = next(column for column in dto["columns"] if column["key"] == "keep_count")
|
||||
column = next(column for column in dto["columns"] if column["key"] == "retention_text")
|
||||
self.assertEqual(column["label"], "牧场保留")
|
||||
self.assertEqual(row["keep_count"], 5)
|
||||
self.assertEqual(column["edit"]["path"], ["policy", "egg_rules", "{id}", "keep_count"])
|
||||
self.assertEqual(row["retention_text"], "主培养1 + 更优备选≤1")
|
||||
self.assertNotIn("edit", column)
|
||||
self.assertNotIn("keep_count", [column["key"] for column in dto["columns"]])
|
||||
self.assertEqual(self.worker.config["policy"]["egg_rules"]["1001010"]["keep_count"], 5)
|
||||
self.assertTrue(row["edits"]["market_id"]["options"])
|
||||
|
||||
def test_add_rule_species_defaults_follow_current_market_and_desktop_fallback(self):
|
||||
|
||||
+41
-11
@@ -55,13 +55,12 @@ def _strategy_fields(catalog):
|
||||
hatch += [_policy_field("protect_star", "保留此星级及以上", "integer", min=1, max=6, group="牧场策略"),
|
||||
_policy_field("protect_quality", "资质保留条件", "select", group="牧场策略", options=_options([
|
||||
(4, "S及以上"), (3, "A及以上"), (2, "B及以上"), (1, "全部资质"), (5, "不按资质保留"), (6, "四项全S(4S)才保留")])),
|
||||
_policy_field("keep_better_quality", "保留资质高于牧场同种培养代表的新魔物", group="牧场策略"),
|
||||
_policy_field("room_id", "收取到牧场", "select", options=_options([(0, "自动选择有空位的牧场")]), group="牧场策略"),
|
||||
_policy_field("reserved_types", "额外保留魔物编号", "id_list", group="牧场策略"),
|
||||
_policy_field("reserved_eggs", "保留蛋数量", "id_counts", group="牧场策略"),
|
||||
_policy_field("feed", "按策略喂养选定目标(受当前突破上限限制)", group="喂养策略")]
|
||||
gift = [_policy_field(key, label) for key, label in (
|
||||
("gift_enabled", "启用自动赠礼"), ("gift_auto_representative", "每种魔物只培养一只,自动选择培养代表"),
|
||||
("gift_enabled", "启用自动赠礼"), ("gift_auto_representative", "自动选择各类主培养赠礼(关闭时按已勾选主培养)"),
|
||||
("gift_liked_only", "仅赠送目标喜欢的物品"))]
|
||||
quest = [_field(["quest_policy", key], label) for key, label in (
|
||||
("enabled", "启用委托自动接取 / 推进 / 领奖"), ("accept", "按氪金奖励优先接取(20 → 15 → 10)"), ("allow_items", "允许提交道具(遵守保留数量)"),
|
||||
@@ -234,8 +233,7 @@ def _egg_rows(dto, engine, config, query):
|
||||
dto["columns"] += [_column(k, label) for k, label in (
|
||||
("time_text", "培育时间"), ("sell_money", "派遣金币"), ("sell_exp", "基础经验"),
|
||||
("gold_per_hour", "金币/小时"), ("exp_per_hour", "经验/小时"), ("inventory_text", "物品ID"))]
|
||||
dto["columns"].append(_row_column("keep_count", "牧场保留", ["policy", "egg_rules"], min=0, max=1000,
|
||||
help="已启用规则跨牧场至少保留此数量;0不保留名额,硬保护仍有效"))
|
||||
dto["columns"].append(_column("retention_text", "牧场保留"))
|
||||
for key in dict.fromkeys([*groups, *rules]):
|
||||
info = catalog.monster(key)
|
||||
if not info or search and search not in (key + str(info.get("name", ""))).casefold():
|
||||
@@ -250,13 +248,14 @@ def _egg_rows(dto, engine, config, query):
|
||||
**groups.get(key, {"count": 0, "inventory_ids": []}), **rule, "time_total": total, "time_text": duration(total),
|
||||
"sell_money": money, "sell_exp": exp, "gold_per_hour": round(money * 3600 / total, 2), "exp_per_hour": round(exp * 3600 / total, 2),
|
||||
"inventory_text": ", ".join(map(str, groups.get(key, {}).get("inventory_ids", []))),
|
||||
"rule_defaults": defaults, "rule_path": ["policy", "egg_rules", key],
|
||||
"rule_defaults": defaults, "rule_path": ["policy", "egg_rules", key], "retention_text": "主培养1 + 更优备选≤1",
|
||||
"edits": {"market_id": _edit(["policy", "egg_rules", key, "market_id"], "select", options=options or _options([("", "金币市场无此蛋")]))}})
|
||||
dto["summary"] = f"{len(dto['rows'])} 种魔物蛋规则;已启用 {sum(row['enabled'] for row in dto['rows'])} 种"
|
||||
dto["summary"] = (f"{len(dto['rows'])} 种魔物蛋规则;已启用 {sum(row['enabled'] for row in dto['rows'])} 种;"
|
||||
"启用规则固定主培养1 + 更优备选≤1;锁定等硬保护仍有效")
|
||||
dto["form"].append(_field(["policy", "egg_rules"], "添加魔物蛋规则", "add_rule", value=None,
|
||||
options=_options([(key, row.get("name", key)) for key, row in catalog.monsters.items()]), defaults=asdict(EggRule()),
|
||||
defaults_by_id={key: _default_egg_rule(catalog, key, config["policy"]["market_id"]) for key in catalog.monsters},
|
||||
help="可配置背包当前没有的蛋;按孵化优先级、去向、补货和牧场保留规则自动执行"))
|
||||
help="可配置背包当前没有的蛋;启用规则固定主培养1 + 更优资质备选≤1,备选不接受自动喂养、赠礼或突破"))
|
||||
|
||||
|
||||
def _bag(dto, engine, config, query):
|
||||
@@ -300,6 +299,9 @@ def _bag(dto, engine, config, query):
|
||||
|
||||
def _ranch(dto, engine, config, query):
|
||||
snapshot, catalog = engine.snapshot, engine.catalog
|
||||
engine.plans() # Refresh pure planner statuses, including existing enabled-rule duplicates.
|
||||
primaries = engine.cultivation.select(snapshot)
|
||||
backups = engine.planner.backups
|
||||
grouped = _boolean(query.get("grouped"), False)
|
||||
try:
|
||||
room_id = int(query.get("room_id") or 0)
|
||||
@@ -315,6 +317,7 @@ def _ranch(dto, engine, config, query):
|
||||
"喂养目标", "喂养优先级", "潜能阶段", "参考攻击", "参考防御", "参考生命", "参考敏捷", "好感 / 当前上限", "喜欢的物品",
|
||||
"赠礼", "赠礼优先级", "自动突破目标", "突破优先级", "同种突破", "突破经验"]
|
||||
dto["columns"] = [_column(key, label) for key, label in zip(keys, labels)]
|
||||
dto["columns"].insert(8, _column("cultivation_role", "培养角色"))
|
||||
for prefix, mapping in (("feed", "feed_targets"), ("gift", "gift_targets"), ("breakthrough", "breakthrough_targets")):
|
||||
for column in dto["columns"]:
|
||||
if column["key"] == prefix + "_selected":
|
||||
@@ -343,24 +346,51 @@ def _ranch(dto, engine, config, query):
|
||||
key = str(int(mon["id"]))
|
||||
row = dict(zip(keys, values)) | {"id": key, "type_id": str(mon["typeId"]), "level": int(mon.get("level") or 1), "max_level": catalog.max_level(mon),
|
||||
"process": mon.get("process"), "room_id": int(mon.get("roomId") or 0), "group": "incubator" if mon.get("process") == 2 else f"room:{int(mon.get('roomId') or 0)}", "edits": {}}
|
||||
primary, backup = primaries.get(row["type_id"]), backups.get(row["type_id"])
|
||||
reason = engine.cultivation_target_reason(mon["id"], primaries=primaries)
|
||||
retained_primary = engine.planner.representatives.get(row["type_id"])
|
||||
if primary and int(primary["id"]) == int(mon["id"]):
|
||||
role, role_label = "primary", "主培养"
|
||||
elif backup and int(backup["id"]) == int(mon["id"]):
|
||||
role, role_label = "backup", "更优资质备选" + ("(待收取)" if mon.get("process") == 2 else "")
|
||||
elif mon.get("process") == 2:
|
||||
pending_primary = retained_primary and int(retained_primary["id"]) == int(mon["id"])
|
||||
role, role_label = ("primary_pending", "主培养待收取") if pending_primary else ("incubator", "培育中")
|
||||
else:
|
||||
role, role_label = ("duplicate", "同种重复") if primary else ("unconfirmed", "主培养待确认")
|
||||
row.update(cultivation_role=role_label,
|
||||
cultivation_role_key=role, primary_id=int(primary["id"]) if primary else None,
|
||||
automatic_eligible=not reason, automatic_reason=reason, tooltips={"cultivation_role": reason or "同种唯一自动培养对象"})
|
||||
rule_enabled = engine.policy.manual_eggs and config["policy"]["egg_rules"].get(row["type_id"], {}).get("enabled")
|
||||
status = engine.planner.statuses.get(int(mon["id"]), "")
|
||||
if rule_enabled or int(mon["id"]) in managed:
|
||||
row["scope"] = status or "启用规则管理"
|
||||
if not engine.policy.enabled:
|
||||
row["scope"] = "自动管理已关闭;" + row["scope"]
|
||||
elif role == "duplicate" and not engine.policy.dispatch:
|
||||
row["scope"] = "自动派遣已关闭;" + row["scope"]
|
||||
elif engine.policy.manual_eggs:
|
||||
row["scope"] = "规则未启用:不自动清理"
|
||||
for prefix, mapping in (("feed", "feed_targets"), ("gift", "gift_targets"), ("breakthrough", "breakthrough_targets")):
|
||||
targets = config["policy"][mapping]
|
||||
selected = key in targets
|
||||
row[prefix + "_selected"], row[prefix + "_priority"] = selected, targets.get(key, 100)
|
||||
row["edits"][prefix + "_selected"] = _edit(["policy", mapping, key], "target", default=100, unchecked="delete", disabled=mon.get("process") != 3)
|
||||
row["edits"][prefix + "_priority"] = _edit(["policy", mapping, key], "integer", min=1, max=999, optional=True, disabled=not selected or mon.get("process") != 3)
|
||||
row["edits"][prefix + "_selected"] = _edit(["policy", mapping, key], "target", default=100, unchecked="delete", disabled=bool(reason), reason=reason)
|
||||
row["edits"][prefix + "_priority"] = _edit(["policy", mapping, key], "integer", min=1, max=999, optional=True, disabled=not selected or bool(reason), reason=reason)
|
||||
dto["rows"].append(row)
|
||||
dto["details"][key] = {"name": row["name"], "species": catalog.monster(mon["typeId"]).get("name", "未知"), "id": int(mon["id"]),
|
||||
"level": row["level_text"], "quality": row["quality"], "reference_stats": catalog.reference_stats(mon),
|
||||
"growth": {name: mon.get("g" + name.capitalize()) for name in ("atk", "def", "hp", "dex")},
|
||||
"likes": row["likes"], "feel": row["feel_text"], "feed_exp": catalog.feed_exp(mon), "scope": row["scope"]}
|
||||
"likes": row["likes"], "feel": row["feel_text"], "feed_exp": catalog.feed_exp(mon), "scope": row["scope"],
|
||||
"培养角色": row["cultivation_role"], "主培养ID": row["primary_id"], "自动培养": reason or "同种唯一自动培养对象"}
|
||||
if grouped:
|
||||
known = {group["id"] for group in dto["groups"]}
|
||||
for row in dto["rows"]:
|
||||
if row["group"] not in known:
|
||||
known.add(row["group"])
|
||||
dto["groups"].append({"id": row["group"], "label": "培育室" if row["group"] == "incubator" else "未归属牧场", "count": counts[row["group"]], "collapsed": False})
|
||||
dto["summary"] = f"{len(snapshot.raw['rooms'])} 座牧场;显示 {len(dto['rows'])} 只魔物"
|
||||
dto["summary"] = (f"{len(snapshot.raw['rooms'])} 座牧场;显示 {len(dto['rows'])} 只魔物;"
|
||||
"自动喂养 / 赠礼 / 突破仅限各类主培养;备选 / 重复项原勾选保留但不执行")
|
||||
targets = [{"value": int(mon["id"]), "label": f"{catalog.monster_label(mon)} Lv.{mon.get('level', 1)}/{catalog.max_level(mon)}"}
|
||||
for mon in snapshot.raw["monsters"] if mon.get("process") == 3 and catalog.max_level(mon) is not None and int(mon.get("level", 1)) < catalog.max_level(mon)]
|
||||
dto["feed_targets"] = targets
|
||||
|
||||
Reference in New Issue
Block a user