Fix incubator dispatch 997 by using active monsterIds contract
This commit is contained in:
@@ -33,11 +33,11 @@
|
||||
|
||||
- 看培育槽/背包:`masterQueryDetail`;刷新成长:`stackCheckProcess`;放蛋:`stackAddMonster`。
|
||||
- 收取到牧场:`stackTransferMonster`,`datas` 内具体结构需结合调用者;派遣:`monsterSell`。
|
||||
- 注意 `NetStack.sellMonsters` 发送 `monsterId` 数组,`NetMonster.sellMonsters` 发送 `monsterIds` 数组,不能混用包装层。
|
||||
- 派遣统一使用 `monsterIds` 数组:`MonsterCenter.sellAllStackMonsters` 的培育室路径也调用 `NetMonster.sellMonsters`。`NetStack.sellMonsters` 的单数 `monsterId` 是未找到调用点的旧包装;用户日志中它返回997,复数请求成功。
|
||||
- 喂养升级:`monsterIntensify`,目标 `targetId`,素材数组 `foods`。
|
||||
- 委托:`taskLoopFlush` → `taskLoopReceive` → `taskCompleteStep` → `taskComplete`。
|
||||
- 普通冒险:`stageStart` → 客户端实际战斗 → `battleEnd`。后者提交 `battleData`,包含伤害、击杀、时间、阵容等。
|
||||
- 本次范围未发现独立扫荡路径;战斗结算不是只发成功标志。服务端如何验证仍未知。
|
||||
- 客户端 `StageStartPanel.startSaodang/doSaodangBattle` 复用上述接口;普通关卡三个难度全部通关后开放。详见 `STAGES_DAILY.md`。服务端如何验证仍未知。
|
||||
|
||||
## 游戏接口(按功能)
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ writes stop with a persisted pending record; no automatic replay occurs.
|
||||
VIP daily gifts and mail attachment claims. Refreshes remain read-only; explicit
|
||||
selection and execution are required. Null VIPs, millisecond/second timestamps,
|
||||
JSON mail rewards and stale reads are handled. New policy and budget files remain
|
||||
role-isolated. Full local suite: 100 tests passed. Live reward/sweep use is still
|
||||
role-isolated. Full local suite: 101 tests passed. Live reward/sweep use is still
|
||||
unverified; no real account or phone was operated during this work.
|
||||
|
||||
The screenshot page remains necessary for ADB real battles such as special
|
||||
@@ -153,8 +153,14 @@ is enlarged. See `STAGES_DAILY.md` for source evidence and endpoint details.
|
||||
|
||||
## Artifact evidence
|
||||
|
||||
- `NetStack.as`, `NetMonster.as`: incubation, growth settlement, transfer,
|
||||
dispatch and feeding payloads, including singular/plural dispatch differences.
|
||||
- `NetStack.as`, `NetMonster.as`: incubation, growth settlement, transfer and
|
||||
feeding payloads. Dispatch always follows `MonsterCenter.sellMonsters` to
|
||||
`NetMonster` with plural `monsterIds`, including mature incubator monsters.
|
||||
The unused `NetStack.sellMonsters` singular field is not the live contract:
|
||||
user logs show five 997 responses for that field and earlier successes for
|
||||
plural requests. The previous helper incorrectly selected it by process=2.
|
||||
Automatic and manual dispatch now use the active plural field; the encrypted
|
||||
loopback regression reproduced 997 before the fix and passes after it.
|
||||
- `MasterCenter.as`, `MonsterCenter.as`, `StackCenter.as`, `MonsterVo.as`,
|
||||
`GameMath.as`: snapshot data, maturity, room/VIP limits, growth grades,
|
||||
sale values and feeding experience formula.
|
||||
@@ -193,7 +199,7 @@ method informs the configurable strategy; numeric values come from the APK.
|
||||
|
||||
## Validation and remaining inputs
|
||||
|
||||
100 unit/integration tests pass: eligible-stage sweep and daily claim workflows,
|
||||
101 unit/integration tests pass: mature incubator dispatch contract, eligible-stage sweep and daily claim workflows,
|
||||
pending writes and role/day budgets, stage tree/rule restoration and scroll
|
||||
geometry, plus local encrypted HTTP and inventory actions,
|
||||
SDK password form/headers -> two Android regions -> selected region entry ->
|
||||
|
||||
@@ -174,6 +174,9 @@
|
||||
培育室的“同步孵化 / 成长”可单独更新这些状态,本次不执行派遣或喂养。
|
||||
“仅监控”不会结算或派遣;需点“开始执行勾选功能”才能自动处理。
|
||||
保留原因会显示在培育室建议和日志中,例如达到保留星级、综合资质A/S、锁定或未启用派遣。
|
||||
培育室与牧场派遣都使用 `monsterService/monsterSell` 的 `monsterIds` 数组参数,
|
||||
不需要先收取到牧场。旧版培育室误用了遗留包装的 `monsterId` 字段,会触发服务端997
|
||||
“网络错误”;现已统一修正自动派遣和右键手动派遣。
|
||||
培育室魔物的 `roomId=null` 已兼容,统计牧场容量时不会再因空字段中断整轮策略。
|
||||
|
||||
- 魔物表可多选,使用按钮或右键锁定/解锁。派遣、指定喂养会列出将消耗的魔物并要求确认;
|
||||
@@ -232,7 +235,7 @@
|
||||
- 自定义表:`typeId, sell_money, sell_exp, time_total`(秒),可只提供部分
|
||||
覆盖列;中文列名“编号、派遣金币、强化经验、孵化秒数”也支持。
|
||||
- 测试:`python -m unittest discover -s ranch_assistant/tests -v`。
|
||||
- 100 项测试通过,覆盖难度列表解析、扫荡条件/请求顺序/异常暂停/跨角色每日额度、
|
||||
- 101 项测试通过,包含培育室派遣997的加密HTTP复现与修复回归;覆盖难度列表解析、扫荡条件/请求顺序/异常暂停/跨角色每日额度、
|
||||
签到与邮件JSON/空VIP/时间单位/失败不重试、树形规则恢复和截图页不重叠;以及
|
||||
加密HTTP十连→实际赠蛋→负数空坑孵化→成长结算→派遣→余额刷新、逐种优先级和补货、
|
||||
多目标喂养优先级、锁定/手动派遣/喂养、开坑与建牧场的费用复核和取消确认、金币/库存/每日额度限制、
|
||||
|
||||
@@ -82,9 +82,4 @@ def manual_monster_actions(catalog, snapshot, kind, monster_ids, target_id=0):
|
||||
return [Action("feed", f"将 {len(ids)} 只素材喂给 #{target_id}", "monsterService/monsterIntensify", {"targetId": int(target_id), "foods": ids})]
|
||||
if kind != "sell":
|
||||
raise ValueError("未知魔物操作")
|
||||
actions = []
|
||||
for process, field in ((2, "monsterId"), (3, "monsterIds")):
|
||||
group = [int(m["id"]) for m in monsters if m.get("process") == process]
|
||||
if group:
|
||||
actions.append(Action("sell", f"派遣 {len(group)} 只魔物", "monsterService/monsterSell", {field: group}))
|
||||
return actions
|
||||
return [Action("sell", f"派遣 {len(ids)} 只魔物", "monsterService/monsterSell", {"monsterIds": ids})]
|
||||
|
||||
@@ -458,8 +458,9 @@ class Planner:
|
||||
disposition = "keep"
|
||||
self.statuses[mid] = "保留:" + reason if disposition == "keep" else "待派遣" if disposition == "sell" else "待喂养"
|
||||
if disposition == "sell":
|
||||
key = "monsterId" if mon.get("process") == 2 else "monsterIds"
|
||||
actions.append(Action("sell", f"派遣 {name} #{mid}", "monsterService/monsterSell", {key: [mid]}))
|
||||
# MonsterCenter also routes mature incubator monsters through
|
||||
# NetMonster.sellMonsters, whose active parameter is plural.
|
||||
actions.append(Action("sell", f"派遣 {name} #{mid}", "monsterService/monsterSell", {"monsterIds": [mid]}))
|
||||
elif mon.get("process") == 2 and policy.collect:
|
||||
room = snapshot.room_available(self.catalog, policy.room_id)
|
||||
if room is not None:
|
||||
|
||||
@@ -254,7 +254,7 @@ class AutomationTests(unittest.TestCase):
|
||||
elif name == "stackCheckProcess":
|
||||
state["monsters"][0]["mode"] = 2
|
||||
elif name == "monsterSell":
|
||||
assert body["monsterId"] == [101]
|
||||
assert body["monsterIds"] == [101]
|
||||
state["monsters"] = []
|
||||
state["stacks"][0]["monsterId"] = -1
|
||||
state["master"]["money"] += 150
|
||||
|
||||
@@ -222,7 +222,7 @@ class WireIntegrationTests(unittest.TestCase):
|
||||
if mon.get("process") == 2: mon["mode"] = 2
|
||||
response = {"resCode": 0}
|
||||
elif self.path.endswith("monsterSell"):
|
||||
mid = body["monsterId"][0]
|
||||
mid = body["monsterIds"][0]
|
||||
state["monsters"] = [m for m in state["monsters"] if m["id"] != mid]
|
||||
for slot in state["stacks"]:
|
||||
if slot["monsterId"] == mid: slot["monsterId"] = 0
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
"""The live 997 trace: mature incubator dispatch used an obsolete parameter."""
|
||||
import copy
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
import threading
|
||||
import unittest
|
||||
|
||||
from ranch_assistant.api import Client, DEFAULT_KEY, Session, decode, encode
|
||||
from ranch_assistant.engine import Engine, demo_snapshot
|
||||
from ranch_assistant.model import Catalog, Policy
|
||||
|
||||
|
||||
class DispatchWireTests(unittest.TestCase):
|
||||
def test_auto_dispatch_from_incubator_uses_active_client_contract(self):
|
||||
catalog = Catalog()
|
||||
state = copy.deepcopy(demo_snapshot(catalog).raw)
|
||||
mon = state["monsters"][0]
|
||||
mon.update(process=2, mode=2, roomId=None)
|
||||
state["monsters"] = [mon]
|
||||
state["stacks"] = [{"id": 1, "position": 0, "monsterId": mon["id"]}]
|
||||
state["items"] = []
|
||||
calls = []
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
def do_POST(self):
|
||||
body = decode(self.rfile.read(int(self.headers["Content-Length"])), DEFAULT_KEY)
|
||||
calls.append((self.path, body))
|
||||
if self.path.endswith("monsterSell"):
|
||||
# NetMonster.sellMonsters and the successful live trace use
|
||||
# monsterIds. NetStack's unused singular field gets 997.
|
||||
if body.get("monsterIds") != [mon["id"]] or "monsterId" in body:
|
||||
response = {"resCode": 997, "resMsg": "网络错误!"}
|
||||
else:
|
||||
state["monsters"] = []
|
||||
state["stacks"][0]["monsterId"] = -1
|
||||
state["master"]["money"] += 150
|
||||
response = {"resCode": 0, "money": 150}
|
||||
else:
|
||||
response = state | {"resCode": 0}
|
||||
data = encode(response, DEFAULT_KEY)
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Length", str(len(data)))
|
||||
self.end_headers()
|
||||
self.wfile.write(data)
|
||||
|
||||
server = ThreadingHTTPServer(("127.0.0.1", 0), Handler)
|
||||
thread = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
thread.start()
|
||||
client = Client(Session(f"http://127.0.0.1:{server.server_port}/", "synthetic-token"))
|
||||
try:
|
||||
engine = Engine(catalog, client)
|
||||
engine.policy = Policy(strategy="gold", protect_star=6, protect_quality=5, fill=False, buy=False)
|
||||
engine.auto = True
|
||||
snapshot, _, message = engine.poll()
|
||||
self.assertNotIn(mon["id"], snapshot.monsters)
|
||||
self.assertEqual(snapshot.raw["stacks"][0]["monsterId"], -1)
|
||||
self.assertIn("派遣", message)
|
||||
sells = [body for path, body in calls if path.endswith("monsterSell")]
|
||||
self.assertEqual(len(sells), 1)
|
||||
self.assertEqual(sells[0]["monsterIds"], [mon["id"]])
|
||||
finally:
|
||||
client.close()
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
thread.join(2)
|
||||
@@ -98,7 +98,7 @@ class GrowthTests(unittest.TestCase):
|
||||
client = GrowthClient(self.catalog, age=610)
|
||||
engine = self.engine(client)
|
||||
snapshot, _, _ = engine.poll()
|
||||
self.assertEqual([body for name, body in client.calls if name == "monsterService/monsterSell"], [{"monsterId": [501]}])
|
||||
self.assertEqual([body for name, body in client.calls if name == "monsterService/monsterSell"], [{"monsterIds": [501]}])
|
||||
self.assertNotIn(501, snapshot.monsters)
|
||||
self.assertLess([name for name, _ in client.calls].index("growth"), [name for name, _ in client.calls].index("monsterService/monsterSell"))
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class ManagementTests(unittest.TestCase):
|
||||
def test_manual_dispatch_payloads_and_feed_guards(self):
|
||||
self.snapshot.monsters[102]["process"] = 3
|
||||
actions = manual_monster_actions(self.catalog, self.snapshot, "sell", [101, 102])
|
||||
self.assertEqual([a.payload for a in actions], [{"monsterId": [101]}, {"monsterIds": [102]}])
|
||||
self.assertEqual([a.payload for a in actions], [{"monsterIds": [101, 102]}])
|
||||
action = manual_monster_actions(self.catalog, self.snapshot, "feed", [102], 900)[0]
|
||||
self.assertEqual(action.payload, {"targetId": 900, "foods": [102]})
|
||||
self.snapshot.monsters[900].update(level=20, potentialLevel=2)
|
||||
|
||||
@@ -233,11 +233,11 @@ def main():
|
||||
"调试窗口已记录进入解析器之前的解密响应,文件为 `local_state/ranch_helper/network_debug.jsonl`。", "",
|
||||
"## 培育室和冒险的关键组合", "", "- 看培育槽/背包:`masterQueryDetail`;刷新成长:`stackCheckProcess`;放蛋:`stackAddMonster`。",
|
||||
"- 收取到牧场:`stackTransferMonster`,`datas` 内具体结构需结合调用者;派遣:`monsterSell`。",
|
||||
"- 注意 `NetStack.sellMonsters` 发送 `monsterId` 数组,`NetMonster.sellMonsters` 发送 `monsterIds` 数组,不能混用包装层。",
|
||||
"- 派遣统一使用 `monsterIds` 数组:`MonsterCenter.sellAllStackMonsters` 的培育室路径也调用 `NetMonster.sellMonsters`。`NetStack.sellMonsters` 的单数 `monsterId` 是未找到调用点的旧包装;用户日志中它返回997,复数请求成功。",
|
||||
"- 喂养升级:`monsterIntensify`,目标 `targetId`,素材数组 `foods`。",
|
||||
"- 委托:`taskLoopFlush` → `taskLoopReceive` → `taskCompleteStep` → `taskComplete`。",
|
||||
"- 普通冒险:`stageStart` → 客户端实际战斗 → `battleEnd`。后者提交 `battleData`,包含伤害、击杀、时间、阵容等。",
|
||||
"- 本次范围未发现独立扫荡路径;战斗结算不是只发成功标志。服务端如何验证仍未知。", "", "## 游戏接口(按功能)", ""]
|
||||
"- 客户端 `StageStartPanel.startSaodang/doSaodangBattle` 复用上述接口;普通关卡三个难度全部通关后开放。详见 `STAGES_DAILY.md`。服务端如何验证仍未知。", "", "## 游戏接口(按功能)", ""]
|
||||
csv_rows = []
|
||||
for cls, group in GROUPS.items():
|
||||
selected = [(row, call) for row in rows for call in (row["calls"] or row["declarations"]) if call["class"] == cls]
|
||||
|
||||
Reference in New Issue
Block a user